HELP!!! The eagle 3 is fine is space. But in air it is horrible. Not sure how to make it more aerodynamic?
i looked at the new eagle sources and it has no flight dynamics. So what I'm missing?
Code:
void VLiftCoeff (double aoa, double M, double Re, double *cl, double *cm, double *cd)
{
const int nabsc = 9;
static const double AOA[nabsc] = {-180*RAD,-60*RAD,-30*RAD,-2*RAD, 15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
static const double CL[nabsc] = { 0, 0, -0.4, 0, 0.7, 1, 0.8, 0, 0};
static const double CM[nabsc] = { 0, 0, 0.014, 0.004,-0.0074,-0.094,-0.012, 0, 0};
int i;
for (i = 0; i < nabsc-1 && AOA[i+1] < aoa; i++);
double f = (aoa-AOA[i]) / (AOA[i+1]-AOA[i]);
*cl = CL[i] + (CL[i+1]-CL[i]) * f;
*cm = CM[i] + (CM[i+1]-CM[i]) * f;
double saoa = sin(aoa);
double pd = 0.015 + 0.4*saoa*saoa;
*cd = pd + oapiGetInducedDrag (*cl, 1.5, 0.7) + oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);
}
void HLiftCoeff (double beta, double M, double Re, double *cl, double *cm, double *cd)
{
const int nabsc = 8;
static const double BETA[nabsc] = {-180*RAD,-135*RAD,-90*RAD,-45*RAD,45*RAD,90*RAD,135*RAD,180*RAD};
static const double CL[nabsc] = { 0, +0.3, 0, -0.3, +0.3, 0, -0.3, 0};
int i;
for (i = 0; i < nabsc-1 && BETA[i+1] < beta; i++);
*cl = CL[i] + (CL[i+1]-CL[i]) * (beta-BETA[i]) / (BETA[i+1]-BETA[i]);
*cm = 0.0;
*cd = 0.015 + oapiGetInducedDrag (*cl, 1.5, 0.6) + oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);
}
Code:
void EAGLE3::clbkSetClassCaps (FILEHANDLE cfg)
{
// physical specs
SetSize (32);
SetEmptyMass (8000.0);
SetCW (0.9, 0.9, 2, 1.4);
SetWingAspect (0.1);
SetWingEffectiveness (0.1);
SetCrossSections (_V(85.24,163.99,40.59));
SetRotDrag (_V(0.1,0.1,0.1));
if (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(15.5,22.1,7.7));
SetTrimScale (0.05);
//SetCameraOffset (_V(-1.362,1.633,11.752));
SetCameraOffset (_V(-2.18532,2.9,13));
SetClipRadius(0.1);
SetTouchdownPoints (_V(0,-3.124,8.7), _V(-5.45,-3.124,-9.6), _V(5.45,-3.124,-9.6));;
...
th_main = CreateThruster (_V(0,0,-4.3), _V(0,0,1), MAXMAINTH, TANK, ISP);
CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
AddExhaust (th_main, 12, 2, _V(2.45,0.57,-15.9), _V(0,0,-1),tex_main);
AddExhaust (th_main, 12, 2, _V(-2.41,0.57,-15.9), _V(0,0,-1),tex_main);
AddExhaust (th_main, 12, 2, _V(0,-0.76,-15.9), _V(0,0,-1),tex_main);
AddExhaust (th_main, 12, 2, _V(0,1.89,-15.9), _V(0,0,-1),tex_main);
AddExhaustStream (th_main, _V(2.45,0.57,-15.9), &contrail_main);
AddExhaustStream (th_main, _V(-2.45,0.57,-15.9), &contrail_main);
AddExhaustStream (th_main, _V(0,-0.76,-15.9), &contrail_main);
AddExhaustStream (th_main, _V(0,1.89,-15.9), &contrail_main);
PARTICLESTREAMSPEC contrail_hover = {
0,1, 3, 33, .3, 1, 4, 3, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_hover = {
0,.5, 25, 50, .1, .05, 7, 1, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
th_hover = CreateThruster (_V(0,0,0), _V(0,1,0), MAXHOVERTH, TANK, ISP);
CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
AddExhaust (th_hover, 6, 1, _V(0.64,-1.5,9.378), _V(0,-1,0),tex_hover);
AddExhaust (th_hover, 6, 1, _V(-0.64,-1.5,9.378), _V(0,-1,0),tex_hover);
AddExhaust (th_hover, 6, 1, _V(-0.64,-1.5,-9.399), _V(0,-1,0),tex_hover);
AddExhaust (th_hover, 6, 1, _V(0.64,-1.5,-9.399), _V(0,-1,0),tex_hover);
AddExhaustStream (th_hover, _V(0.64,-1.5,9.378), &contrail_hover);
AddExhaustStream (th_hover, _V(0.64,-1.5,9.378), &contrail_hover);
AddExhaustStream (th_hover, _V(0.64,-1.5,-9.399), &contrail_hover);
AddExhaustStream (th_hover, _V(0.64,-1.5,-9.399), &contrail_hover);
th_retro = CreateThruster (_V(0,0,4.3), _V(0,0,-1), MAXRETROTH, TANK, ISP);
CreateThrusterGroup (&th_retro, 1, THGROUP_RETRO);
AddExhaust (th_retro, 1, .1, _V(6.234,-0.34,7.375), _V(0,0,1),tex_retro);
AddExhaust (th_retro, 1, .1, _V(-6.234,-0.34,7.375), _V(0,0,1),tex_retro);
AddExhaust (th_retro, 1, .1, _V(6.234,-0.34,-8.45), _V(0,0,1),tex_retro);
AddExhaust (th_retro, 1, .1, _V(-6.234,-0.34,-8.45), _V(0,0,1),tex_retro);
i looked at the new eagle sources and it has no flight dynamics. So what I'm missing?
Code:
// Class NewEagle
// Archivo de código NewEagle.cpp
// By Hispaorbiter; February, 2004
// =================================
#include "NewEagle.h"
// Banderas booleanas de estado de la nave
bool bPodSeparate=false;
bool bModuleSeparate=false;
// Por defecto, la vista es exterior
int bExtInt=1;
//Características de las partículas de humo
static PARTICLESTREAMSPEC contrail_main = {
0, 8.0, 5, 150, 0.3, 4.0, 4, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
static PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 150, 0.1, 0.2, 16, 2.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
static PARTICLESTREAMSPEC exhaust_hover = {
0, 1.0, 5, 50, 0.3, 2.0, 3, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, -0.1, 0.1
};
// Constructor
NewEagle::NewEagle (OBJHANDLE hObj, int fmodel) : VESSEL (hObj, fmodel)
{
// Banderas booleanas de estado de la nave
bPodSeparate = false;
bModuleSeparate = false;
bVistaInt = 1;
stage=0;
// Localización de los motores principales
MainEngineOfs[0]=_V( 0,-0.75,-15.5);
MainEngineOfs[1]=_V( 0, 1.91,-15.5);
MainEngineOfs[2]=_V( 2.45, 0.59,-15.5);
MainEngineOfs[3]=_V(-2.45, 0.59,-15.5);
//Motores elevadores
// Los de la estructura principal
HoverEngineOfs[0]=_V( 0.63,-2.83,12);
HoverEngineOfs[1]=_V(-0.63,-2.83,12);
HoverEngineOfs[2]=_V(-0.63,-2.83,-6.71);
HoverEngineOfs[3]=_V( 0.63,-2.83,-6.71);
// Los del módulo de carga
HoverEngineOfs[4]=_V( 1.00,-3.15, 6.56);
HoverEngineOfs[5]=_V(-1.00,-3.15, 6.56);
HoverEngineOfs[6]=_V(-1.00,-3.15,-1.32);
HoverEngineOfs[7]=_V( 1.00,-3.15,-1.32);
// Impulsores de control de posición del cuerpo principal
RCSTransporterOfs[0]=_V(6.224432,-0.3,10.238448);
RCSTransporterOfs[1]=_V(-6.224432,-0.3,10.238448);
RCSTransporterOfs[2]=_V(6.224432,-0.3,-5.573767);
RCSTransporterOfs[3]=_V(-6.224432,-0.3,-5.573767);
// Creación del tanque de combustible
ph_main=CreatePropellantResource(MAX_FUEL);
}
// Destructor
NewEagle::~NewEagle ()
{
}
bool NewEagle::PasarLosHumos(bool humo)
{
int NumHover, i;
double level, alt;
level=GetThrusterGroupLevel(THGROUP_HOVER);
alt=GetAltitude();
// If stage=1 only 4 hovers, here's no cargo module
if (stage == 1)
NumHover=4;
else
NumHover=8;
// Conditions to add smoke to hovers:
// 1: Altitude below 10m
// 2: Here's no previous defined smoke for hovers (humo flag in false condition)
if ((alt <10) && (!humo))
{
for (i=0; i<NumHover; i++)
hover_humo[i]=AddExhaustStream (th_hover[i], _V(HoverEngineOfs[i].x,HoverEngineOfs[i].y-7.5,HoverEngineOfs[i].z), &exhaust_hover);
return true;
};
// Conditions to delete smoke to hovers:
// 1: Altitude above 10m
// 2: Previosly defined smoke for hovers (humo flag in true condition)
if ((alt>10) && (humo))
{
SetThrusterGroupLevel(THGROUP_HOVER,0.0);
for (i=0; i<NumHover; i++)
DelExhaustStream (hover_humo[i]);
SetThrusterGroupLevel(THGROUP_HOVER,level);
return false;
}
return humo;
}
void NewEagle::UbicarVista(int i)
{
switch (i)
{
case 1:
SetCameraOffset(_V(0,0,20));
break;
case 2:
SetCameraOffset(CAMERA_OFFSET_PILOT);
break;
case 3:
SetCameraOffset(CAMERA_OFFSET_COPILOT);
break;
};
bVistaInt=i;
}
// Ubicar los motores y las salidas de gases para el cuerpo principal según el estado de la nave
void NewEagle::AddTransporterExhaust()
{
int i,NumHover;
//Se crean los motores principales y sus escapes con humo
for (i=0; i<4; i++)
{
th_main[i] = CreateThruster (_V(0,0,0), _V(0,0,1), MAX_MAIN_THRUST, ph_main, ISP_FUS);
AddExhaust (th_main[i],2,0.5,_V(MainEngineOfs[i].x,MainEngineOfs[i].y,MainEngineOfs[i].z+2.3),_V(0,0,-1));
AddExhaustStream (th_main[i], MainEngineOfs[i], &exhaust_main);
};
AddExhaustStream (th_main[1],_V(0,0,-24),&contrail_main);
// Se crea el grupo motor principal
thg_main = CreateThrusterGroup (th_main, 4, THGROUP_MAIN);
//Motores elevadores
if (stage ==1)
{
SetEngineLevel(ENGINE_HOVER,0.0);
for (i=3; i<8; i++)
DelThruster (th_hover[i]);
NumHover=4;
}
else
NumHover=8;
for (i=0; i<NumHover; i++)
{
th_hover[i] = CreateThruster (_V(0,0,0), _V(0,1,0), MAX_HOVER_THRUST, ph_main, ISP_QUI);
AddExhaust (th_hover[i], 0.3, 0.5,_V(HoverEngineOfs[i].x,HoverEngineOfs[i].y+1.3,HoverEngineOfs[i].z),_V(0,-1,1));
}
// Se crea el grupo motor elevador
thg_hover = CreateThrusterGroup (th_hover, NumHover, THGROUP_HOVER);
// Impulsores de control de posición
// Para mejorar la navegabilidad, los motores están ubicados en posiciones diferentes a los escapes
// Grupo delantero derecho
// Delantero derecho superior
th_rcs[0]=CreateThruster(_V(6,0,10),_V(0,-1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[0],1,0.1,RCSTransporterOfs[0],_V(0,1,0));
// Delantero derecho inferior
th_rcs[1]=CreateThruster(_V(6,0,10),_V(0,1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[1],1,0.1,RCSTransporterOfs[0],_V(0,-1,0));
// Delantero derecho proa
th_rcs[2]=CreateThruster(_V(6,0,10),_V(0,0,-1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[2],1,0.1,RCSTransporterOfs[0],_V(0,0,1));
// Delantero derecho popa
th_rcs[3]=CreateThruster(_V(6,0,10),_V(0,0,1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[3],1,0.1,RCSTransporterOfs[0],_V(0,0,-1));
// Delantero derecho exterior
th_rcs[4]=CreateThruster(_V(6,0,10),_V(-1,0,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[4],1,0.1,RCSTransporterOfs[0],_V(1,0,0));
// Grupo delantero izquierdo
// Delantero izquierdo superior
th_rcs[5]=CreateThruster(_V(-6,0,10),_V(0,-1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[5],1,0.1,RCSTransporterOfs[1],_V(0,1,0));
// Delantero izquierdo inferior
th_rcs[6]=CreateThruster(_V(-6,0,10),_V(0,1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[6],1,0.1,RCSTransporterOfs[1],_V(0,-1,0));
// Delantero izquierdo proa
th_rcs[7]=CreateThruster(_V(-6,0,10),_V(0,0,-1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[7],1,0.1,RCSTransporterOfs[1],_V(0,0,1));
// Delantero izquierdo popa
th_rcs[8]=CreateThruster(_V(-6,0,10),_V(0,0,1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[8],1,0.1,RCSTransporterOfs[1],_V(0,0,-1));
// Delantero izquierdo exterior
th_rcs[9]=CreateThruster(_V(-6,0,10),_V(1,0,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[9],1,0.1,RCSTransporterOfs[1],_V(-1,0,0));
// Grupo trasero derecho
// Trasero derecho superior
th_rcs[10]=CreateThruster(_V(6,0,-10),_V(0,-1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[10],1,0.1,RCSTransporterOfs[2],_V(0,1,0));
// Trasero derecho inferior
th_rcs[11]=CreateThruster(_V(6,0,-10),_V(0,1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[11],1,0.1,RCSTransporterOfs[2],_V(0,-1,0));
// Trasero derecho proa
th_rcs[12]=CreateThruster(_V(6,0,-10),_V(0,0,-1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[12],1,0.1,RCSTransporterOfs[2],_V(0,0,1));
// Trasero derecho popa
th_rcs[13]=CreateThruster(_V(6,0,-10),_V(0,0,1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[13],1,0.1,RCSTransporterOfs[2],_V(0,0,-1));
// Trasero derecho exterior
th_rcs[14]=CreateThruster(_V(6,0,-10),_V(-1,0,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[14],1,0.1,RCSTransporterOfs[2],_V(1,0,0));
// Grupo trasero izquierdo
// Trasero izquierdo superior
th_rcs[15]=CreateThruster(_V(-6,0,-10),_V(0,-1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[15],1,0.1,RCSTransporterOfs[3],_V(0,1,0));
// Trasero izquierdo inferior
th_rcs[16]=CreateThruster(_V(-6,0,-10),_V(0,1,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[16],1,0.1,RCSTransporterOfs[3],_V(0,-1,0));
// Trasero izquierdo proa
th_rcs[17]=CreateThruster(_V(-6,0,-10),_V(0,0,-1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[17],1,0.1,RCSTransporterOfs[3],_V(0,0,1));
// Trasero izquierdo popa
th_rcs[18]=CreateThruster(_V(-6,0,-10),_V(0,0,1),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[18],1,0.1,RCSTransporterOfs[3],_V(0,0,-1));
// Trasero izquierdo exterior
th_rcs[19]=CreateThruster(_V(-6,0,-10),_V(1,0,0),MAX_RCS_THRUST,ph_main,ISP_QUI);
AddExhaust (th_rcs[19],1,0.1,RCSTransporterOfs[3],_V(-1,0,0));
// Se crean los grupos motores para los diferentes movimientos de la nave
// 1-Movimientos rotacionales
// Grupo motor de cabeceo hacia arriba "PITCH-UP"
th_group[0]=th_rcs[1];
th_group[1]=th_rcs[6];
th_group[2]=th_rcs[10];
th_group[3]=th_rcs[15];
CreateThrusterGroup(th_group,4,THGROUP_ATT_PITCHUP);
// Grupo motor de cabeceo hacia abajo "PITCH-DOWN"
th_group[0]=th_rcs[0];
th_group[1]=th_rcs[5];
th_group[2]=th_rcs[11];
th_group[3]=th_rcs[16];
CreateThrusterGroup(th_group,4,THGROUP_ATT_PITCHDOWN);
// Grupo motor de balanceo izquierda "YAW-RIGHT"
th_group[0]=th_rcs[8];
th_group[1]=th_rcs[18];
th_group[2]=th_rcs[2];
th_group[3]=th_rcs[12];
CreateThrusterGroup(th_group,4,THGROUP_ATT_YAWRIGHT);
// Grupo motor de balanceo derecha "YAW-LEFT"
th_group[0]=th_rcs[3];
th_group[1]=th_rcs[13];
th_group[2]=th_rcs[7];
th_group[3]=th_rcs[17];
CreateThrusterGroup(th_group,4,THGROUP_ATT_YAWLEFT);
// Grupo motor de alabeo derecho "BANK-RIGHT"
th_group[0]=th_rcs[0];
th_group[1]=th_rcs[6];
th_group[2]=th_rcs[10];
th_group[3]=th_rcs[16];
CreateThrusterGroup(th_group,4,THGROUP_ATT_BANKRIGHT);
// Grupo motor de alabeo izquierdo "BANK-LEFT"
th_group[0]=th_rcs[1];
th_group[1]=th_rcs[5];
th_group[2]=th_rcs[11];
th_group[3]=th_rcs[15];
CreateThrusterGroup(th_group,4,THGROUP_ATT_BANKLEFT);
// 2-Movimientos traslacionales
// Grupo motor de traslación derecha "RIGHT"
// Este grupo lo podían formar los impulsores izquierdos delantero de proa y trasero de popa
th_group[0]=th_rcs[9];
th_group[1]=th_rcs[19];
CreateThrusterGroup(th_group,2,THGROUP_ATT_RIGHT);
// Grupo motor de traslación izquierda "LEFT"
// Este grupo lo podían formar los impulsores derechos delantero de proa y trasero de popa
th_group[0]=th_rcs[4];
th_group[1]=th_rcs[14];
CreateThrusterGroup(th_group,2,THGROUP_ATT_LEFT);
// Grupo motor de traslación arriba "DOWN"
th_group[0]=th_rcs[0];
th_group[1]=th_rcs[5];
th_group[2]=th_rcs[10];
th_group[3]=th_rcs[15];
CreateThrusterGroup(th_group,4,THGROUP_ATT_DOWN);
// Grupo motor de traslación abajo "UP"
th_group[0]=th_rcs[1];
th_group[1]=th_rcs[6];
th_group[2]=th_rcs[11];
th_group[3]=th_rcs[16];
CreateThrusterGroup(th_group,4,THGROUP_ATT_UP);
// Grupo motor de traslación adelante "FORWARD"
th_group[0]=th_rcs[3];
th_group[1]=th_rcs[8];
th_group[2]=th_rcs[13];
th_group[3]=th_rcs[18];
CreateThrusterGroup(th_group,4,THGROUP_ATT_FORWARD);
// Grupo motor de traslación atrás "BACK"
th_group[0]=th_rcs[2];
th_group[1]=th_rcs[7];
th_group[2]=th_rcs[12];
th_group[3]=th_rcs[17];
CreateThrusterGroup(th_group,4,THGROUP_ATT_BACK);
}
void NewEagle::SetRetros(bool ban)
{
int i;
double MAX_RETRO_THRUST;
if (ban)
MAX_RETRO_THRUST=160000.0;
else
MAX_RETRO_THRUST=0.0;
//Se crean los motores retropropulsores
for (i=0; i<4; i++)
{
th_retro[i]=CreateThruster(_V(0,0,0),_V(0,0,-1), MAX_RETRO_THRUST, ph_main, ISP_QUI);
AddExhaust (th_retro[i],2,0.1,RCSTransporterOfs[i],_V(0,0,1));
}
// Se crea el grupo motor retropropulsor
thg_retro=CreateThrusterGroup(th_retro,4,THGROUP_RETRO);
}
// Inicialización del Eagle completo
void NewEagle::SetTransporter()
{
int i;
SetSize(EAGLE_SIZE);
SetPMI (PMI);
SetCrossSections (CROSS_SECTION);
SetCW (0.2, 0.2, 1.5, 1.5);
SetRotDrag (ROT_DRAG);
SetPitchMomentScale(PITCH_MOMENT_SCALE);
SetBankMomentScale (BANK_MOMENT_SCALE);
SetDockParams(MODULE_DOCK_OFS,_V(1,0,0),_V(0,1,0));
SetTouchdownPoints(TP1,TP2,TP3);
ClearMeshes();
ClearExhaustRefs();
AddMesh ("eagle1y", &OFS_TRANSPORTER);
i=AddMesh ("eagle1p", &OFS_POD);
SetMeshVisibilityMode(i,MESHVIS_ALWAYS);
AddTransporterExhaust();
// Llamada a PasarLosHumos forzando la situación de los humos según la altura
if (GetAltitude()<10)
// Esta llamada fuerza los humos a activos
HoverSmoke=PasarLosHumos(false);
else
// En caso contrario, se fuerzan los humos a inactivos
HoverSmoke=PasarLosHumos(true);
}
// Lectura de estado del escenario
void NewEagle::LoadState(FILEHANDLE scn, void *vs)
{
char *line;
stage=0; // Transporter completo por defecto
bVistaInt=1; // Vista exterior por defecto
MODULE_MASS=0; // Masa del módulo por defecto, también por si las moscas
while (oapiReadScenario_nextline (scn, line))
{
// Lectura de STAGE (con o sin modulo)
if (!strnicmp (line, "STAGE", 5))
sscanf (line+5, "%d%lf", &stage);
// Lectura de modo vista de cabina
else if (!strnicmp (line, "INTVIEW", 7))
sscanf (line+7, "%d%lf", &bVistaInt);
// Lectura del mesh del módulo
else if (!strnicmp (line, "MODULE", 6))
sscanf (line+6, "%s", module);
// Masa del modulo
else if (!strnicmp (line, "MASSMODULE", 10))
sscanf (line+10, "%d%lf", &MODULE_MASS);
// Lectura del estado de los retros
else if (!strnicmp (line, "RETRO", 5))
sscanf (line+5, "%s", retro);
else
{
// Si la opción no es reconocida, pasarsela al orbiter para que la analice
ParseScenarioLineEx (line, vs);
}
}
SetTransporter();
// Y poner los retros (o no)
if (retro == "OFF")
SetRetros(false);
else
SetRetros(true);
if (stage == 0)
{
AddMesh(module,&OFS_MODULE);
SetEmptyMass(EAGLE_EMPTY_MASS+MODULE_MASS+POD_MASS);
}
else
SetEmptyMass(EAGLE_EMPTY_MASS+POD_MASS);
UbicarVista(bVistaInt);
}
// Grabación de estado en el escenario
void NewEagle::SaveState(FILEHANDLE scn)
{
SaveDefaultState(scn);
oapiWriteScenario_int (scn, "STAGE", stage);
oapiWriteScenario_int (scn, "INTVIEW", bVistaInt);
if (stage == 0)
{
oapiWriteScenario_string (scn,"MODULE", module);
oapiWriteScenario_int (scn, "MASSMODULE", MODULE_MASS);
}
oapiWriteScenario_string (scn,"RETRO", retro);
}
// Gestión del estado de la nave
void NewEagle::Estado()
{
HoverSmoke=PasarLosHumos(HoverSmoke);
}
// ==============================================================
// API interface
// ==============================================================
// Inicialización
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new NewEagle (hvessel, flightmodel);
}
// Destrucción
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (NewEagle*)vessel;
}
// Gestión de entradas por teclado
DLLCLBK int ovcConsumeKey (VESSEL *vessel, const char *keystate)
{
// OBJHANDLE hvessel;
if (KEYMOD_SHIFT (keystate))
{
return 0; // shift combinations are reserved
}
else if (KEYMOD_CONTROL (keystate))
{
// insert ctrl key combinations here
}
else
{ // unmodified keys
if (KEYDOWN (keystate, OAPI_KEY_1)) { // Cambio a vista externa
if (oapiAcceptDelayedKey (OAPI_KEY_1, 1.0))
((NewEagle*)vessel)->UbicarVista(1);
}
if (KEYDOWN (keystate, OAPI_KEY_2)) { // Cambio a vista piloto
if (oapiAcceptDelayedKey (OAPI_KEY_2, 1.0))
((NewEagle*)vessel)->UbicarVista(2);
}
if (KEYDOWN (keystate, OAPI_KEY_3)) { // Cambio a vista copiloto
if (oapiAcceptDelayedKey (OAPI_KEY_3, 1.0))
((NewEagle*)vessel)->UbicarVista(3);
}
}
return 0;
}
// Inicialización del Eagle completo
DLLCLBK void ovcSetClassCaps (VESSEL *vessel, FILEHANDLE cfg)
{
((NewEagle*)vessel)->SetTransporter();
}
// Llamada a la gestión de la nane en función de la situación actual
DLLCLBK void ovcTimestep (VESSEL *vessel, double simt)
{
((NewEagle*)vessel)->Estado();
}
// Lee el estado de la nave desde el archivo de escenario
DLLCLBK void ovcLoadStateEx (VESSEL *vessel, FILEHANDLE scn, void *vs)
{
((NewEagle*)vessel)->LoadState (scn, vs);
}
// Graba el estado de la nave en el archivo de escenario
DLLCLBK void ovcSaveState (VESSEL *vessel, FILEHANDLE scn)
{
((NewEagle*)vessel)->SaveState (scn);
}