See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: [UCGO]Tests avec le ShuttlePB  (Read 2876 times)

0 Members and 1 Guest are viewing this topic.

Offline SolarLiner

  • Global Moderator
  • Legend
  • *****
  • Posts: 2769
  • Country: France fr
  • Karma: 55
  • a été remercié par Le Créateur
02 August 2012, 18:40:50
Salut !
En vue d'une éventuelle adaptation du Shuttle PB Mk2 vers UCGO, je m'entraine avec le Shuttle PB normal. Pour tester le code, j'ai ajouté 2-3 effets, comme les AOA Vapors ou la "fumée" crée lors du passage Max Q. Tout marche trèèèsss bien. Alors je décide d'implémenter UCGO. Je crée toutes les fonctions nécésaires (clbkConsumeBufferedKey et d'autres). Une fois arrivé au paragraphe "Votre add-on est maintenant compatible avec UCGO", je build. Pas d'erreurs. (Juste un warning qui m'annonce une conversion double->float causée par l'affichage de données dans oapiDeugString)

J'ouvre mon scénario de test, censé avoir mon ShuttlePB sur le pad 1 de Canaveral et ho ! Surprise ! Je me retrouve à 376M de km ... du Soleil ! Je remarque alors que je n'ai pas de fuel, aucun moteur disponible ... et pas de mesh visible ! Après un regard au Orbiter.log, rien ne m'attire l'oeil ... Même pas de mesh manquant ou quoi que ce soit ! Alors j'implore votre aide ... Qui est la bienvenue !
Voici le contenu de mon projet (c'est à dire ShuttlePB.cpp, unique fichier à part le header et la library de UCGO):
Code: [Select]
// ==============================================================
//                 ORBITER MODULE: ShuttlePB
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//                   All rights reserved
//
// ShuttlePB.cpp
// Control module for ShuttlePB vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================

#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"
#include "UCGOCargoSDK.h"

// ==============================================================
// Some vessel parameters
// ==============================================================
const double  PB_SIZE       = 3.5;             // mean radius [m]
const VECTOR3 PB_CS         = {10.5,15.0,5.8}; // x,y,z cross sections [m^2]
const VECTOR3 PB_PMI        = {2.28,2.31,0.79};// principal moments of inertia (mass-normalised) [m^2]
const VECTOR3 PB_RD         = {0.025,0.025,0.02};//{0.05,0.1,0.05};  // rotation drag coefficients
const double  PB_EMPTYMASS  = 400.0;           // empty vessel mass [kg]
const double  PB_FUELMASS   = 1200.0;           // max fuel mass [kg]
const double  PB_ISP        = 5e5;             // fuel-specific impulse [m/s]
const VECTOR3 PB_TDP[3]     = {{0,-1.5,2},{-1,-1.5,-1.5},{1,-1.5,-1.5}}; // touchdown points [m]
const VECTOR3 PB_COP        = {0,0,0};//{0,0,-0.1};      // centre of pressure for airfoils [m]
const double  PB_VLIFT_C    = 2.0;             // chord length [m]
const double  PB_VLIFT_S    = 2.0;             // wing area [m^2]
const double  PB_VLIFT_A    = 2.5;             // wing aspect ratio
const double  PB_HLIFT_C    = 2.0;             // chord length [m]
const double  PB_HLIFT_S    = 1.5;             // wing area [m^2]
const double  PB_HLIFT_A    = 2.0;             // wing aspect ratio

const double  PB_MAXMAINTH  = 4.5e4;            
const double  PB_MAXHOVERTH = 2.1e4;
const double  PB_MAXRCSTH   = 2.1e2;

const VECTOR3 PB_DOCK_POS   = {0,1.3,-1};      // docking port location [m]
const VECTOR3 PB_DOCK_DIR   = {0,1,0};         // docking port approach direction
const VECTOR3 PB_DOCK_ROT   = {0,0,-1};        // docking port alignment direction

double STREAMlvl = 0.0;       // Level for Particle Stream vent
bool StreamAct = FALSE;   // Used for Paticle vent Effect to trigger vent

double BOOMlvl = 0.0;   // Sonic Boom effect
double AOAlvl = 0.0;   // AOA level effect

// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function
double LiftCoeff (double aoa)
{
int i;
const int nlift = 9;
static const double AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
static const double CL[nlift]  = {       0,      0,   -0.1,     0,   0.2,  0.25,   0.2,     0,      0};
static const double SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
                             (CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
 (CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
 (CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
for (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
return CL[i] + (aoa-AOA[i])*SCL[i];
}

// ==============================================================
// Shuttle-PB class interface
// ==============================================================

class ShuttlePB: public VESSEL3 {
public:
ShuttlePB (OBJHANDLE hVessel, int flightmodel);
~ShuttlePB ();
void clbkSetClassCaps (FILEHANDLE cfg);
virtual int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);
void clbkPreStep (double simt, double simdt, double mjd);
void clbkSaveScenario (FILEHANDLE scn);
void clbkLoadStateEx(FILEHANDLE scn, void *vs);
bool clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp);
void clbkVisualCreated (VISHANDLE vis, int refcount);

// UCGO 2.0 CLASS HANDLE FUNCTION AND VARIABLES
UCGO hUcgo; // Cargo class handle
char *SendCargHudMessage(void); // Cargo hud display function
char cCargoHudDisplay[255]; // Cargo hud display char variable
double dCargHudMessageDelay; // Cargo hud display delay
int iSelectedCargo; // for the selection of cargos -1 by default

private:
static void vlift (VESSEL *v, double aoa, double M, double Re,
void *context, double *cl, double *cm, double *cd);
static void hlift (VESSEL *v, double aoa, double M, double Re,
void *context, double *cl, double *cm, double *cd);

// transformations for control surface animations
static MGROUP_ROTATE trans_Laileron, trans_Raileron;
static MGROUP_ROTATE trans_Lelevator, trans_Relevator;
};

ShuttlePB::ShuttlePB (OBJHANDLE hVessel, int flightmodel)
: VESSEL3 (hVessel, flightmodel)
{
}

ShuttlePB::~ShuttlePB ()
{
}

// animation transformation definitions
static UINT GRP_LWING = 2;
static UINT GRP_RWING = 3;
static VECTOR3 LWING_REF  = {-1.3,-0.725,-1.5};
static VECTOR3 LWING_AXIS = {-0.9619,-0.2735,0};
static VECTOR3 RWING_REF  = {1.3,-0.725,-1.5};
static VECTOR3 RWING_AXIS = {0.9619,-0.2735,0};
static float AILERON_RANGE = (float)(20.0*RAD);
static float ELEVATOR_RANGE = (float)(30.0*RAD);
MGROUP_ROTATE ShuttlePB::trans_Laileron (0, &GRP_LWING, 1, LWING_REF, LWING_AXIS, AILERON_RANGE);
MGROUP_ROTATE ShuttlePB::trans_Raileron (0, &GRP_RWING, 1, RWING_REF, RWING_AXIS, AILERON_RANGE);
MGROUP_ROTATE ShuttlePB::trans_Lelevator (0, &GRP_LWING, 1, LWING_REF, LWING_AXIS, -ELEVATOR_RANGE);
MGROUP_ROTATE ShuttlePB::trans_Relevator (0, &GRP_RWING, 1, RWING_REF, RWING_AXIS, ELEVATOR_RANGE);


// ==============================================================
// Overloaded callback functions
// ==============================================================

// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void ShuttlePB::clbkSetClassCaps (FILEHANDLE cfg)
{
THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];

//UCGO 2.0 Initialisation, cargo slot pos, rot declaration

hUcgo.Init(GetHandle());
hUcgo.DeclareCargoSlot(0,_V(-1.14,0.01,-1.59),_V(0,0,75)); // slot 0
hUcgo.DeclareCargoSlot(1,_V(-1.17,0.01,-0.31),_V(0,0,75)); // slot 1
//         Parameters settings
hUcgo.SetReleaseSpeedInSpace(0.10f); // release speed of cargo in space in m/s
hUcgo.SetMaxCargoMassAcceptable(5000.0); // max cargo mass in kg that your vessel can carry
hUcgo.SetGrappleDistance(50); // grapple distance radius in meter from center of ship
hUcgo.SetGlobalGroundReleasePos(_V(0,0,4)); // global release position on ground
//         Variables initialisation
cCargoHudDisplay[0]=0; // Cargo hud display char variable
dCargHudMessageDelay=0; // Cargo hud display delay
iSelectedCargo=-1; // for the selection of cargos (-1 mean "default" see header)
//         Welcome message with keys for users
strcpy(SendCargHudMessage(),"Cargo key: C/SHF+C = grapple/release, 9/SHF+9 = add cargo from disk, 8=infos on cargos");

//Physical vessel parameters
SetSize (PB_SIZE);
SetEmptyMass (PB_EMPTYMASS);
SetPMI (PB_PMI);
SetCrossSections (PB_CS);
SetRotDrag (PB_RD);
SetTouchdownPoints (PB_TDP[0], PB_TDP[1], PB_TDP[2]);

// docking port definitions
SetDockParams (PB_DOCK_POS, PB_DOCK_DIR, PB_DOCK_ROT);

// airfoil definitions
CreateAirfoil3 (LIFT_VERTICAL,   PB_COP, vlift, NULL, PB_VLIFT_C, PB_VLIFT_S, PB_VLIFT_A);
CreateAirfoil3 (LIFT_HORIZONTAL, PB_COP, hlift, NULL, PB_HLIFT_C, PB_HLIFT_S, PB_HLIFT_A);

// control surface animations
UINT anim_Laileron = CreateAnimation (0.5);
UINT anim_Raileron = CreateAnimation (0.5);
UINT anim_elevator = CreateAnimation (0.5);
AddAnimationComponent (anim_Laileron, 0, 1, &trans_Laileron);
AddAnimationComponent (anim_Raileron, 0, 1, &trans_Raileron);
AddAnimationComponent (anim_elevator, 0, 1, &trans_Lelevator);
AddAnimationComponent (anim_elevator, 0, 1, &trans_Relevator);

// aerodynamic control surface defintions
CreateControlSurface (AIRCTRL_ELEVATOR, 1.5, 0.7, _V( 0,0,-2.5), AIRCTRL_AXIS_XPOS, anim_elevator);
CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V( 1,0,-2.5), AIRCTRL_AXIS_XPOS, anim_Laileron);
CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V(-1,0,-2.5), AIRCTRL_AXIS_XNEG, anim_Raileron);

// propellant resources
PROPELLANT_HANDLE mpr = CreatePropellantResource (PB_FUELMASS);
PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS/1.5);
PROPELLANT_HANDLE rpr = CreatePropellantResource (PB_FUELMASS/2);

// main engine
th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, mpr, PB_ISP);
CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1));

PARTICLESTREAMSPEC contrail_main = {
0, 2.5, 16, 280, 0.15, 3, 15, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
AddExhaustStream (th_main, _V(0,0.3, -5), &exhaust_main);

// hover engine
th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));

PARTICLESTREAMSPEC contrail_hover = {
0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_hover = {
0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};

AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);

// RCS engines
th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, rpr, PB_ISP);
th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, rpr, PB_ISP);

th_group[0] = th_rcs[0];
th_group[1] = th_rcs[2];
th_group[2] = th_rcs[5];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);

th_group[0] = th_rcs[1];
th_group[1] = th_rcs[3];
th_group[2] = th_rcs[4];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHDOWN);

th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKLEFT);

th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKRIGHT);

th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_UP);

th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_DOWN);

th_group[0] = th_rcs[8];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);

th_group[0] = th_rcs[9];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);

th_group[0] = th_rcs[8];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_LEFT);

th_group[0] = th_rcs[9];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_RIGHT);

CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);

// vent Particle Stream
PARTICLESTREAMSPEC vent = {
0, 0.01, 100, 10, 0, 0.8, 2, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
AddParticleStream( &vent, _V(1, 1.2, -1.9), _V(0, 0.5, -0.5), &STREAMlvl);

// Boom Particle Stream
PARTICLESTREAMSPEC boom = {
0, 0.5, 150, 0, 0.2, 0.2, 10, 1.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PLIN, 0, 0.05,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1};
AddParticleStream(&boom, _V(0,-0.8,3), _V(0,0.5,0), &BOOMlvl);

//AOA vapor effect
PARTICLESTREAMSPEC aoa = {
0, 0.8, 100, 0, 0.5, 0.15, 5, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_PLIN, 0, 0.01,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1};
AddParticleStream(&aoa, _V(-1.5,-0.7,-1.6), _V(0,0.5,0), &AOAlvl);
AddParticleStream(&aoa, _V( 1.5,-0.7,-1.6), _V(0,0.5,0), &AOAlvl);

// camera parameters
SetCameraOffset (_V(0,0.8,0));

// associate a mesh for the visual
AddMesh ("ShuttlePB");
}

void ShuttlePB::clbkPreStep (double simt, double simdt, double mjd)
{
float cmn = ShuttlePB::GetMachNumber();
float aoa = ShuttlePB::GetAOA()*DEG;
if(cmn >= 0.97 && cmn <= 1.05)
BOOMlvl = 1.0;
else
BOOMlvl = 0.0;

if(aoa < 50 && aoa > 36)
AOAlvl = 1.0;
else
AOAlvl = 0.0;

sprintf(oapiDebugString(), "Mach Number=%f | AOA=%f", cmn, aoa);
hUcgo.WarnUserUCGONotInstalled("New ShuttlePB");
}
// ==============================================================
// Airfoil lift/drag functions
// ==============================================================

void ShuttlePB::vlift (VESSEL *v, double aoa, double M, double Re,
void *context, double *cl, double *cm, double *cd)
{
static const double clp[] = {  // lift coefficient from -pi to pi in 10deg steps
-0.1,-0.5,-0.4,-0.1,0,0,0,0,0,0,0,0,0,0,-0.2,-0.6,-0.6,-0.4,0.2,0.5,0.9,0.8,0.2,0,0,0,0,0,0,0,0,0,0.1,0.4,0.5,0.3,-0.1,-0.5
};
static const double aoa_step = 10.0*RAD;
double a, fidx, saoa = sin(aoa);
a = modf((aoa+PI)/aoa_step, &fidx);
int idx = (int)(fidx+0.5);
*cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
*cm = 0.0; //-0.03*sin(aoa-0.1);
*cd = 0.03 + 0.4*saoa*saoa;                // profile drag
*cd += oapiGetInducedDrag (*cl, 1.0, 0.5); // induced drag
*cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
}

void ShuttlePB::hlift (VESSEL *v, double aoa, double M, double Re,
void *context, double *cl, double *cm, double *cd)
{
static const double clp[] = {  // lift coefficient from -pi to pi in 45deg steps
0,0.4,0,-0.4,0,0.4,0,-0.4,0,0.4
};
static const double aoa_step = 45.0*RAD;
double a, fidx;
a = modf((aoa+PI)/aoa_step, &fidx);
int idx = (int)(fidx+0.5);
*cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
*cm = 0.0;
*cd = 0.03;
*cd += oapiGetInducedDrag (*cl, 1.5, 0.6); // induced drag
*cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
}

int ShuttlePB::clbkConsumeBufferedKey(DWORD key, bool down, char *kstate)
{
if(!down) return 0;

if(key==OAPI_KEY_V)
{
if(KEYMOD_LSHIFT(kstate)||KEYMOD_RSHIFT(kstate))
{
if(!StreamAct)
{
STREAMlvl = 1.0;
StreamAct = TRUE;
}
else
{
STREAMlvl = 0.0;
StreamAct = FALSE;
}
}
}
// 9 key "select" one cargo on disk (cycle)
if(key==OAPI_KEY_9&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate))
{
sprintf(SendCargHudMessage(),"%s - selected",hUcgo.ScnEditor_SelectNextCargoAvailableOnDisk());
return 1;
}
// SHIFT+9 key "add last cargo selected by key 9"
// If iSelectedCargo=-1 (default) add to the first free slot found
if(key==OAPI_KEY_9&&KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate))
{
if(hUcgo.ScnEditor_AddLastSelectedCargoToSlot(iSelectedCargo)==TRUE)
{
strcpy(SendCargHudMessage(),"Cargo added to ship");
}
else
{
if(iSelectedCargo<0)
{
strcpy(SendCargHudMessage(),"Cargo not added (ship full or weight excess ?)");
}
else
{
strcpy(SendCargHudMessage(),"Cargo not added (slot full ship full or weight excess ?)");
}
}
return 1;
}
// "C" grapple cargo. If iSelectedCargo=-1 (default) add to the first free slot found
if(key==OAPI_KEY_C&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate))
{
int ReturnedCode=hUcgo.GrappleOneCargo(iSelectedCargo);
// for return code list see function "GrappleOneCargo" in the header
switch(ReturnedCode)
{
case 1:
strcpy(SendCargHudMessage(),"Cargo grappled");
break;
case 0:
strcpy(SendCargHudMessage(),"No cargo in range");
break;
case -1:
strcpy(SendCargHudMessage(),"cargo exceed maximum mass");
break;
case -2:
strcpy(SendCargHudMessage(),"bad config, mesh not found or slot not declared");
break;
case -3:
strcpy(SendCargHudMessage(),"Can't grapple cargo, slot not empty");
break;
case -4:
strcpy(SendCargHudMessage(),"Can't grapple cargo,doors closed ");
break;
case -5:
strcpy(SendCargHudMessage(),"Can't grapple cargo,Ship full");
break;
default:
strcpy(SendCargHudMessage(),"Misc error Unable to grapple cargo");
}
return 1;
}
// SHIFT+C release cargo. If iSelectedCargo=-1 (default) release the first free slot found
if(key==OAPI_KEY_C&&KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate))
{
if(hUcgo.ReleaseOneCargo(iSelectedCargo)!=FALSE)
{
strcpy(SendCargHudMessage(),"Cargo released");
}
else
{
strcpy(SendCargHudMessage(),"Cargo not released (empty slot, no cargo aboard?)");
}
return 1;
}
// "8" show some info on cargo
if(key==OAPI_KEY_8&&!KEYMOD_SHIFT(kstate)&&!KEYMOD_CONTROL (kstate))
{
sprintf(SendCargHudMessage(),"%i cargos aboard. "
"Total cargos weight: %.0fkg",hUcgo.GetNbrCargoLoaded(),hUcgo.GetCargoTotalMass());
return 1;
}
return 0;
}

void ShuttlePB::clbkLoadStateEx(FILEHANDLE scn, void *vs)
{
char *line;
while (oapiReadScenario_nextline (scn, line))
{
if(hUcgo.LoadCargoFromScenario(line)==TRUE) // UCGO load cargo
continue;
}
}

void ShuttlePB::clbkSaveScenario (FILEHANDLE scn)
{
char cbuf[256];
// default vessel parameters
VESSEL3::clbkSaveState (scn);

// Save UCGO 2.0 cargo in scenario
hUcgo.SaveCargoToScenario(scn);
}

////////////////////////////////////////////////////////
// SendCargHudMessage
////////////////////////////////////////////////////////
char *ShuttlePB::SendCargHudMessage(void)
{
dCargHudMessageDelay=15; // 15 seconds display delay for msg
return cCargoHudDisplay;
}

bool ShuttlePB::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
// draw the default HUD
VESSEL3::clbkDrawHUD(mode, hps, skp);
// UCGO display messages
if(dCargHudMessageDelay>0)
{
TextOut(skp->GetDC(),5,hps->H/60*12,cCargoHudDisplay,strlen(cCargoHudDisplay));
dCargHudMessageDelay-=oapiGetSimStep();
if(dCargHudMessageDelay<0)
dCargHudMessageDelay=0;
}

return true;
}

void ShuttlePB::clbkVisualCreated (VISHANDLE vis, int refcount)
{
hUcgo.SetUcgoVisual(vis); // must be called in clbkVisualCreated.
}
// ==============================================================
// API callback interface
// ==============================================================

// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new ShuttlePB (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (ShuttlePB*)vessel;
}

Et Orbiter.log:
Code: [Select]
**** Orbiter.log
Build Aug 30 2010 [v.100830]
Timer precision: 3.8489e-007 sec
Found 0 joystick(s)
Devices enumerated: 4
Devices accepted: 3
==> RGB Emulation
==> Direct3D HAL
==> Direct3D HAL (Intel(R) HD Graphics)
Module AtlantisConfig.dll .... [Build 100830, API 100830]
Module AtmConfig.dll ......... [Build 100830, API 100830]
Module DGConfigurator.dll .... [Build 100830, API 100830]
Module ScnEditor.dll ......... [Build 100830, API 100830]
Module Rcontrol.dll .......... [Build 100830, API 100830]
Module Framerate.dll ......... [Build 100830, API 100830]
Module FlightData.dll ........ [Build 100830, API 100830]
Module ExtMFD.dll ............ [Build 100830, API 100830]
Module LuaConsole.dll ........ [Build 100830, API 100830]
Module ScriptMFD.dll ......... [Build 100830, API 100830]
Error loading module Modules\Plugin\STSGuidanceMFD.dll (code 126)
Module OrbiterSound.dll ...... [Build 120328, API 100830]
---------------------------------------------------------------
>>> WARNING: Obsolete API function used: oapiRegisterMFDMode
At least one active module is accessing an obsolete interface function.
Addons which rely on obsolete functions may not be compatible with
future versions of Orbiter.
---------------------------------------------------------------
Error loading module Modules\Plugin\msvcr80.dll (code 126)
Error loading module Modules\Plugin\msvcp80.dll (code 126)
Error loading module Modules\Plugin\msvcm80.dll (code 126)
Error loading module Modules\Plugin\LunarTransferMFD.dll (code 126)
Error loading module Modules\Plugin\LolaMFD.dll (code 126)
Error loading module Modules\Plugin\Load.dll (code 126)
Error loading module Modules\Plugin\LightingMFD.dll (code 126)
Error loading module Modules\Plugin\LaunchMFD.dll (code 126)
Error loading module Modules\Plugin\LandMFD.dll (code 126)
Error loading module Modules\Plugin\InterMFD54.dll (code 126)
Error loading module Modules\Plugin\HoverMFD.dll (code 126)
Error loading module Modules\Plugin\ClockMFD.dll (code 126)
Error loading module Modules\Plugin\CamShake.dll (code 126)
Error loading module Modules\Plugin\CameraMFD.dll (code 126)
Error loading module Modules\Plugin\BaseSyncMFD.dll (code 126)
Error loading module Modules\Plugin\baseland.dll (code 126)
Error loading module Modules\Plugin\AutopilotMFD.dll (code 126)
Error loading module Modules\Plugin\AutoFCS.dll (code 126)
Error loading module Modules\Plugin\AttitudeMFD.dll (code 126)
Error loading module Modules\Plugin\AeroBrakeMFD.dll (code 126)
Error loading module Modules\Plugin\AAMissile.dll (code 126)

Module transx.dll ............ [Build 100824, API 100823]
Module LuaMFD.dll ............ [Build 100830, API 100830]
Module CustomMFD.dll ......... [Build 100830, API 100830]
Module TrackIR.dll ........... [Build 100830, API 100830]
TrackIR module not found.
Module Meshdebug.dll ......... [Build 100830, API 100830]

Error loading module Modules\Plugin\flightinstruments.dll (code 126)
Error loading module Modules\Plugin\SensorMFD.dll (code 126)
Error loading module Modules\Plugin\uap.dll (code 126)
Error loading module Modules\Plugin\UnivPTG.dll (code 126)
Error loading module Modules\Plugin\RPOP.dll (code 126)
Error loading module Modules\Plugin\RealTime.dll (code 126)
Error loading module Modules\Plugin\GPCMFD.dll (code 126)
Error loading module Modules\Plugin\GE Tracker 2.dll (code 126)
Error loading module Modules\Plugin\ITSArrayMFD.dll (code 126)
Error loading module Modules\Plugin\RWarpMFD.dll (code 126)
Error loading module Modules\Plugin\vel_hud.dll (code 126)
Error loading module Modules\Plugin\WarpDriveMFD-Mk2.dll (code 126)
Error loading module Modules\Plugin\Bump.dll (code 126)
Error loading module Modules\Plugin\videnie.dll (code 126)
Error loading module Modules\Plugin\BurnTimeCalculator.dll (code 126)
Error loading module Modules\Plugin\CamControl.dll (code 126)
Error loading module Modules\Plugin\WebMFD.dll (code 126)
Error loading module Modules\Plugin\launchrecorder.dll (code 126)
Error loading module Modules\Plugin\ReFuelMFD.dll (code 126)
Error loading module Modules\Plugin\WeatherMFD.dll (code 126)
Error loading module Modules\Plugin\VNCMFD.dll (code 126)
Error loading module Modules\Plugin\ThrustControlMFD.dll (code 126)
Error loading module Modules\Plugin\FuelQuantityMFD.dll (code 126)
Error loading module Modules\Plugin\enc.dll (code 126)
Error loading module Modules\Plugin\waypointMFD.dll (code 126)


**** Creating simulation session
DirectDraw interface OK
Direct3D interface OK
Graphics: Viewport: Window 1274 x 692 x 32
Graphics: Hardware T&L capability: No
Graphics: Z-buffer depth: 32 bit
Graphics: Active lights supported: -1
Loading 15382 records from star database
Module Sun.dll ............... [Build 100830, API 100830]
VSOP87(E) Sun: Precision 1e-006, Terms 554/6634
Module Mercury.dll ........... [Build 100830, API 100830]
VSOP87(B) Mercury: Precision 1e-005, Terms 167/7123
Module Venus.dll ............. [Build 100830, API 100830]
Module VenusAtm2006.dll ...... [Build 100830, API 100830]
VSOP87(B) Venus: Precision 1e-005, Terms 79/1710
Module Earth.dll ............. [Build 100830, API 100830]
Module EarthAtm2006.dll ...... [Build 100830, API 100830]
VSOP87(B) Earth: Precision 1e-008, Terms 2564/2564
Module Moon.dll .............. [Build 100830, API 100830]
ELP82: Precision 1e-005, Terms 116/829
Module Mars.dll .............. [Build 100830, API 100830]
Module MarsAtm2006.dll ....... [Build 100830, API 100830]
VSOP87(B) Mars: Precision 1e-005, Terms 405/6400
Module Phobos.dll ............ [Build ******, API 060425]
Module Deimos.dll ............ [Build ******, API 060425]
Module Galsat.dll ............ [Build 100217, API 100215]
Module Jupiter.dll ........... [Build 100830, API 100830]
VSOP87(B) Jupiter: Precision 1e-006, Terms 1624/3625
Module Io.dll ................ [Build 100217, API 100215]
Module Europa.dll ............ [Build 100217, API 100215]
Module Ganymede.dll .......... [Build 100217, API 100215]
Module Callisto.dll .......... [Build 100217, API 100215]
Module Satsat.dll ............ [Build 100215, API 100212]
Module Saturn.dll ............ [Build 100830, API 100830]
VSOP87(B) Saturn: Precision 1e-006, Terms 2904/6365
Module Mimas.dll ............. [Build 100215, API 100212]
SATSAT Mimas: Terms 113
Module Enceladus.dll ......... [Build 100215, API 100212]
SATSAT Enceladus: Terms 33
Module Tethys.dll ............ [Build 100215, API 100212]
SATSAT Tethys: Terms 101
Module Dione.dll ............. [Build 100215, API 100212]
SATSAT Dione: Terms 59
Module Rhea.dll .............. [Build 100215, API 100212]
SATSAT Rhea: Terms 68
Module Titan.dll ............. [Build 100215, API 100212]
SATSAT Titan: Terms 100
Module Iapetus.dll ........... [Build 100215, API 100212]
SATSAT Iapetus: Terms 605
Module Uranus.dll ............ [Build 100830, API 100830]
VSOP87(B) Uranus: Precision 1e-006, Terms 1827/5269
Module Miranda.dll ........... [Build ******, API 060425]
Module Ariel.dll ............. [Build ******, API 060425]
Module Umbriel.dll ........... [Build ******, API 060425]
Module Titania.dll ........... [Build ******, API 060425]
Module Oberon.dll ............ [Build ******, API 060425]
Module Neptune.dll ........... [Build 100830, API 100830]
VSOP87(B) Neptune: Precision 1e-006, Terms 391/2024
Finished initialising world
Module ShuttlePB.dll ......... [Build 120802, API 100830]
Finished initialising status
Finished initialising camera
Finished initialising panels
Finished setting up render state
---------------------------------------------------------------
>>> WARNING: Obsolete API function used: oapiGetStationCount
At least one active module is accessing an obsolete interface function.
Addons which rely on obsolete functions may not be compatible with
future versions of Orbiter.
---------------------------------------------------------------
**** Respawning Orbiter process

En rouge: Ne pas prendre en compte, j'utilise JSGME, normal qui me trouve pas les modules -> Pas d'incidence.



Message modifié ( 02-08-2012 18:46 )


Offline SolarLiner

  • Global Moderator
  • Legend
  • *****
  • Posts: 2769
  • Country: France fr
  • Karma: 55
  • a été remercié par Le Créateur
Reply #1 - 02 August 2012, 21:49:41
EDIT: J'ai trouvé le problème: clbkLoadStateEx. Dès que je le commente tout remarhe correctement. Le tout est de savoir: Pourquoi ?


« Last Edit: 03 August 2012, 00:04:05 by SolarLiner »

Offline ea76620

  • Sr. Member
  • ****
  • Posts: 393
  • Country: France fr
  • Karma: 15
Reply #2 - 02 August 2012, 21:59:54
Bonjour,

Quote
Dès que je le commente tout remarhe correctement.

Tu as ajouté ça?

Code: [Select]
// --------------------------------------------------------------
// Read status from scenario file
// --------------------------------------------------------------

Bizarre, pourtant ce n'est que des commentaires.

A+



Message modifié ( 02-08-2012 22:00 )

« Last Edit: 03 August 2012, 00:04:05 by ea76620 »

Offline SolarLiner

  • Global Moderator
  • Legend
  • *****
  • Posts: 2769
  • Country: France fr
  • Karma: 55
  • a été remercié par Le Créateur
Reply #3 - 02 August 2012, 22:09:09
Je veux dire dès que je commente la section clbkLoadStateEx (pour l'omettre de la build). Sinon je me retrouve tout près du Soleil !


« Last Edit: 03 August 2012, 00:04:05 by SolarLiner »

Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #4 - 02 August 2012, 23:04:40
Parce qu'il manque la ligne de chargement par défaut "ParseScenarioLineEx "

Code: [Select]
void ShuttlePB::clbkLoadStateEx(FILEHANDLE scn, void *vs)
{
char *line;
while (oapiReadScenario_nextline (scn, line))
{
if(hUcgo.LoadCargoFromScenario(line)==TRUE) // UCGO load cargo
continue;
// ORBITER, unrecognised option - pass to Orbiter's generic parser
ParseScenarioLineEx (line, status);
}
}



Message modifié ( 02-08-2012 23:05 )

« Last Edit: 03 August 2012, 00:04:05 by DanSteph »

Offline SolarLiner

  • Global Moderator
  • Legend
  • *****
  • Posts: 2769
  • Country: France fr
  • Karma: 55
  • a été remercié par Le Créateur
Reply #5 - 02 August 2012, 23:08:41
Oops ... Quelle erreur basique ! Je me sens un peu con là ...
En tout cas, merci ! Je vais pouvoir continuer ...


« Last Edit: 03 August 2012, 00:04:05 by SolarLiner »

Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #6 - 02 August 2012, 23:43:25
Quote
SolarLiner a écrit:
Oops ... Quelle erreur basique ! Je me sens un peu con là ...

Ceux qui auraient envie de rire n'ont probablement jamais programmé parce que le genre
"ooops" après trois heures à s’arracher les cheveux... ;)

Dan

« Last Edit: 03 August 2012, 00:04:05 by DanSteph »

Offline SolarLiner

  • Global Moderator
  • Legend
  • *****
  • Posts: 2769
  • Country: France fr
  • Karma: 55
  • a été remercié par Le Créateur
Reply #7 - 03 August 2012, 00:04:05
Quote
DanSteph wrote:
Quote
SolarLiner a écrit:
Oops ... Quelle erreur basique ! Je me sens un peu con là ...

Ceux qui auraient envie de rire n'ont probablement jamais programmé parce que le genre
"ooops" après trois heures à s’arracher les cheveux... ;)

Dan
Et en plus j'ai eu encore à chercher un peu car "status" n'était pas déclaré ... Une fois remplaçé pas "vs" j'ai pu continuer.
Donc au final j'ai réussi mon objectif: Shutte PB compatible UCGO ET UMmu.


« Last Edit: 03 August 2012, 00:04:05 by SolarLiner »