#define STRICT
#define ORBITER_MODULE
#include "orbitersdk.h"
class LBS: public VESSEL2 {
public:
LBS (OBJHANDLE hVessel, int flightmodel)
: VESSEL2 (hVessel, flightmodel) {}
void clbkSetClassCaps (FILEHANDLE cfg);
void LBS::clbkSetClassCaps (FILEHANDLE cfg)
{
SetSize (10);
SetEmptyMass (5000);
SetCW (0.09, 1.0, 1.8, 1.8);
SetWingAspect (0);
SetWingEffectiveness (0);
SetCrossSections (_V(81.55,81.56,26.20));
SetRotDrag (_V(0.6,0.6,0.35));
SetPMI (_V(15.43,15.43,4.86));
SetTrimScale (0.05);
SetCameraOffset (_V(0,0.0,0.0))
SetTouchdownPoints (_V(0,-2.9,-5), _V(0,-2.9,0), _V(0,-2.9,5));
//Animation
enum anim_status { CLOSED, OPEN, CLOSING, OPENING }
void LBS::DefineAnimations()
{
static UINT ret1 = {Retainer1}
static UNIT ret2 = {Retainer2}
static UNIT ret3 = {Retainer3}
static UNIT nose = {NoseCone}
static MGROUP_ROTATE nose {
0,
nose, 1
_V(0,2.9,6.7),
_V(1,0,0),
(float)(-120*RAD)
}
static MGROUP_ROTATE ret1 {
0,
ret1, 1
_V(2.8,0,4.08)
_V(0,1,0),
(float)(80*RAD)
}
static MGROUP_ROTATE ret2 {
0,
ret2, 1
_V(0,-2.8,4.23)
_V(1,0,0),
(float)(80*RAD)
}
static MGROUP_ROTATE ret3 {
0,
ret3, 1
_V(-2.8,0,4.08)
_V(0,1,0),
(float)(-80*RAD)
}
anim = CreateAnimation (0)
AddAnimationComponent (anim, 0, 1, &nose);
AddAnimationComponent (anim, 0.1, 0.9, &ret1);
AddAnimationComponent (anim, 0.1, 0.9, &ret2);
AddAnimationComponent (anim, 0.1, 0.9, &ret3);
void LBS::Timestep (double simt)
{
if (anim_status == CLOSING || ganim_status == OPENING) {
double da = oapiGetSimStep() * anim_speed;
if (anim_status == CLOSING) {
if (anim_proc > 0.0)
anim_proc = max (0.0, anim_proc-da);
else
anim_status = CLOSED;
} else { // door opening
if (anim_proc < 1.0)
anim_proc = min (1.0, anim_proc+da);
else
anim_status = OPEN;
}
SetAnimation (anim, anim_proc);
}
}
const double FUELMASS = 29000;
const double ISP = 7e3;
const double MAXMAINTH = 1001000;
const double MAXRCSTH = 1e5;
PROPELLANT_HANDLE tank;
tank = CreatePropellantResource (FUELMASS);
THRUSTER_HANDLE th_main, th_rcs[14], th_group[4];
th_main = CreateThruster (_V(0,0,-7.6), _V(0,0,1), MAXMAINTH, tank,ISP);
CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
AddExhaust (th_main, 8, 1, _V(0,0,-7.6), _V(0,0,-1));
th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0,1,0), MAXRCSTH, tank , ISP);
th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), MAXRCSTH, tank, ISP);
th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0,1,0), MAXRCSTH,tank, ISP);
th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), MAXRCSTH, tank, ISP);
th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0,1,0), MAXRCSTH, tank, ISP);
th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), MAXRCSTH, tank, ISP);
th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0,1,0), MAXRCSTH, tank, ISP);
th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), MAXRCSTH,tank , ISP);
th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), MAXRCSTH, tank, ISP);
th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V(1,0,0), MAXRCSTH, tank, ISP);
th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), MAXRCSTH, tank, ISP);
th_rcs[11] = CreateThruster (_V(-1,0,-3), _V(1,0,0), MAXRCSTH, tank, ISP);
th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0,1), MAXRCSTH, tank, ISP);
th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), MAXRCSTH, tank, 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);
AddMesh ("LBS");
}
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new LBS (hvessel, flightmodel);
}
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (LBS*)vessel;
}