Example #1
0
// Set SRB class specs
void Atlantis_SRB::clbkSetClassCaps (FILEHANDLE cfg)
{
	extern PARTICLESTREAMSPEC srb_contrail, srb_exhaust;
	PARTICLESTREAMSPEC srb_bolt = {
		0, 8.0, 20, 0.0, 0.1, 0.3, 16, 3.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_LIN, 0, 1,
		PARTICLESTREAMSPEC::ATM_FLAT, 1, 1
	};

	SetEnableFocus (false);
	// SRB cannot receive input focus

	// *********************** physical parameters *********************************

	SetSize (23.0);
	SetEmptyMass (SRB_EMPTY_MASS);
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetCrossSections (_V(162.1,162.1,26.6));
	SetRotDrag (_V(0.7,0.7,0.1));
	SetPMI (_V(154.3,154.3,1.83));
	//SetGravityGradientDamping (10.0);
	SetTouchdownPoints (tdvtx, ntdvtx);
	SetLiftCoeffFunc (0);

	// ************************* docking port **************************************

	CreateDock (_V(1.95,0,5),_V(1,0,0),_V(0,0,1)); // ET attachment

	// ************************* propellant specs **********************************

	ph_main = CreatePropellantResource (SRB_MAX_PROPELLANT_MASS);

	// *********************** thruster definitions ********************************

	// main engine
	th_main = CreateThruster (_V(0,0,-21), THRUSTGIMBAL_LAUNCH, SRB_THRUST_MAX, ph_main, SRB_ISP0, SRB_ISP1);
	SURFHANDLE tex = oapiRegisterExhaustTexture ("Exhaust2");
	srb_exhaust.tex = oapiRegisterParticleTexture ("Contrail2");
	AddExhaust (th_main, 16.0, 2.0, tex);
	AddExhaustStream (th_main, _V(0,0,-30), &srb_contrail);
	AddExhaustStream (th_main, _V(0,0,-25), &srb_exhaust);

	// separation bolts
	th_bolt = CreateThruster (_V(0,0,3.0), _V(-1,0,0), 3e6, ph_main, 1e7);
	// for simplicity, the separation bolts directly use SRB propellant. We give
	// them an insanely high ISP to avoid significant propellant drainage

	AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,-8), _V(-1,0,0));
	AddExhaust (th_bolt, 0.7, 0.1, _V(2.1,0,11), _V(-1,0,0));
	AddExhaustStream (th_bolt, _V(2.1,0,0), &srb_bolt);

	// ************************ visual parameters **********************************

	AddMesh (hSRBMesh);

	bMainEngine = false;
	bSeparationEngine = false;
	bGimbalCmd = false;
	srbpos = SRB_UNDEFINED;
}
// Set vessel class parameters
void Dragonfly::SetClassCaps (FILEHANDLE cfg)
{
	
	int i;

	SetSize (4.0);
	SetEmptyMass (EMPTY_MASS);
	SetCrossSections (_V(23.7,22.5,17.3));
	SetPMI (_V(5.4,5.4,2.5));
	SetCameraOffset (_V(0,1.5,0));

	// ************************* propellant specs **********************************

	ph_main = CreatePropellantResource (MAX_MAIN_FUEL);

	// *********************** thruster definitions ********************************

	// thrusters in left pod
	th_lp[0] = CreateThruster (_V(-3.5,0,0), _V(1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP);
	th_lp[1] = CreateThruster (_V(-2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[2] = CreateThruster (_V(-2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[3] = CreateThruster (_V(-2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_lp[4] = CreateThruster (_V(-2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// thrusters in right pod
	th_rp[0] = CreateThruster (_V(3.5,0,0), _V(-1,0,0), 2*MAX_RCS_THRUST, ph_main, ISP);
	th_rp[1] = CreateThruster (_V(2.98,0,-0.8), _V(0,0,1), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[2] = CreateThruster (_V(2.98,0,0.8), _V(0,0,-1), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[3] = CreateThruster (_V(2.98,-0.8,0), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_rp[4] = CreateThruster (_V(2.98,0.8,0), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// thrusters in aft pod (rotational RCS)
	th_ap[0] = CreateThruster (_V(-0.8,0,-11.1), _V(1,0,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[1] = CreateThruster (_V(0.8,0,-11.1), _V(-1,0,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[2] = CreateThruster (_V(0,-0.8,-11.1), _V(0,1,0), MAX_RCS_THRUST, ph_main, ISP);
	th_ap[3] = CreateThruster (_V(0,0.8,-11.1), _V(0,-1,0), MAX_RCS_THRUST, ph_main, ISP);

	// exhaust definitions for left pod
	AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,0.18,-0.18), _V(-1,0,0));
	AddExhaust (th_lp[0], 1, 0.15, _V(-3.5,-0.18,0.18), _V(-1,0,0));
	for (i = 1; i < 5; i++) AddExhaust (th_lp[i], 1, 0.15);

	// exhaust definitions for right pod
	AddExhaust (th_rp[0], 1, 0.15, _V(3.5,-0.18,-0.18), _V(1,0,0));
	AddExhaust (th_rp[0], 1, 0.15, _V(3.5,0.18,0.18), _V(1,0,0));
	for (i = 1; i < 5; i++) AddExhaust (th_rp[i], 1, 0.15);

	// exhaust definitions for aft pod
	for (i = 0; i < 4; i++) AddExhaust (th_ap[i], 1, 0.15);
	//thruster definitions. Both manual and "automatic" RCS
	SetManualRCS();
	SetNormalRCS();//
	
	// *************************** docking port ************************************

	SetDockParams (_V(0,0,3.2), _V(0,0,1), _V(0,1,0));
    
	// ******************************** mesh ***************************************

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

	// 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 hpr = CreatePropellantResource (PB_FUELMASS);

	// main engine
	th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, 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, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		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, hpr, PB_ISP);
	th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP);
	th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, 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);

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

	// associate a mesh for the visual
	AddMesh ("ShuttlePB");
}
Example #4
0
void LEM::SetLmAscentHoverStage()

{
	ClearThrusterDefinitions();
	agc.SetVesselStats(APS_ISP, APS_THRUST, true);
	ShiftCentreOfMass(_V(0.0,3.0,0.0));
	SetSize (5);
	SetCOG_elev (5);
	SetEmptyMass (1920.0);
	SetPMI(_V(2.8, 2.29, 2.37));
	SetCrossSections (_V(21,23,17));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,0.7));
	SetPitchMomentScale (0);
	SetBankMomentScale (0);
	SetLiftCoeffFunc (0); 
	ClearMeshes();
	ClearExhaustRefs();
	ClearAttExhaustRefs();

	double tdph = -5.8;
	SetTouchdownPoints (_V(0, tdph, 5), _V(-5, tdph, -5), _V(5, tdph, -5));
	VSSetTouchdownPoints(GetHandle(), _V(0, tdph, 5), _V(-5, tdph, -5), _V(5, tdph, -5));

	VECTOR3 mesh_dir=_V(-0.191,-0.02,+0.383);	
	UINT meshidx = AddMesh (hLMAscent, &mesh_dir);
	SetMeshVisibilityMode (meshidx, MESHVIS_VCEXTERNAL);

    if (!ph_Asc)  
		ph_Asc  = CreatePropellantResource(AscentFuelMassKg);	// 2nd stage Propellant
	SetDefaultPropellantResource (ph_Asc);			// Display 2nd stage propellant level in generic HUD
	// orbiter main thrusters
    th_hover[0] = CreateThruster (_V( 0.0,  -2.5, 0.0), _V( 0,1,0), APS_THRUST, ph_Asc, APS_ISP);
	th_hover[1] = CreateThruster (_V( 0.01, -2.0, 0.0), _V( 0,1,0), 0,          ph_Asc, 0);		// this is a "virtual engine",no thrust and no fuel
																								// needed for visual gimbaling for corrected engine flames
    DelThrusterGroup(THGROUP_HOVER,true);
	thg_hover = CreateThrusterGroup (th_hover, 2, THGROUP_HOVER);
	AddExhaust (th_hover[1], 6.0, 0.8, exhaustTex);
	
	SetCameraOffset (_V(-1,1.0,0.0));
	status = 2;
	stage = 2;
	SetEngineLevel(ENGINE_HOVER,0);
	AddRCS_LMH2(-1.86);
	bModeHover=true;

	if(ph_Dsc){
		DelPropellantResource(ph_Dsc);
		ph_Dsc = 0;
	}
	
	VECTOR3 dockpos = {0.0 ,0.58, 0.0};
	VECTOR3 dockdir = {0,1,0};

	VECTOR3 dockrot = { -0.8660254, 0, 0.5 };
	SetDockParams(dockpos, dockdir, dockrot);
	hattDROGUE = CreateAttachment(true, dockpos, dockdir, dockrot, "PADROGUE");
	InitNavRadios (4);
	LDGswitch=false;
	AFEED1switch=true;
	AFEED2switch=true;
	AFEED3switch=true;
	AFEED4switch=true;

	// Descent stage detached.
	agc.SetInputChannelBit(030, DescendStageAttached, false);

	CheckRCS();
}
Example #5
0
void LEM::SetLmVesselHoverStage()
{
	ClearThrusterDefinitions();
	agc.SetVesselStats(DPS_ISP, DPS_THRUST, true);

	SetEmptyMass(AscentFuelMassKg + 4374.0);

	SetSize (7);
	SetPMI (_V(3.26,2.22,3.26)); 
	SetCrossSections (_V(24.53,21.92,24.40));
	// SetPMI (_V(2.8,2.29,2.37));
	// SetCrossSections (_V(21,23,17));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,0.7));
	SetPitchMomentScale (0);
	SetBankMomentScale (0);
	SetLiftCoeffFunc (0); 
	ClearMeshes();
	ClearExhaustRefs();
	ClearAttExhaustRefs();

	SetTouchdownPoints (_V(0, -3.86, 5), _V(-5, -3.86, -5), _V(5, -3.86, -5));
	VSSetTouchdownPoints(GetHandle(), _V(0, -3.86, 5), _V(-5, -3.86, -5), _V(5, -3.86, -5));

	VECTOR3 mesh_dir=_V(-0.003,-0.03,0.004);	
	UINT meshidx;
	if (Landed) {
		meshidx = AddMesh (hLMLanded, &mesh_dir);
	}else{
		UINT probeidx;
		meshidx = AddMesh (hLMLanded, &mesh_dir);
		probeidx = AddMesh (hLemProbes, &mesh_dir);
		SetMeshVisibilityMode (probeidx, MESHVIS_VCEXTERNAL);
	}
	SetMeshVisibilityMode (meshidx, MESHVIS_VCEXTERNAL);
    
	if (!ph_Dsc){  
		ph_Dsc  = CreatePropellantResource(DescentFuelMassKg); //2nd stage Propellant
	}

	SetDefaultPropellantResource (ph_Dsc); // display 2nd stage propellant level in generic HUD

	if (!ph_RCSA){
		ph_RCSA = CreatePropellantResource(133.084001);
	}
	if (!ph_RCSB){
		ph_RCSB = CreatePropellantResource(133.084001);
	}
	
	// orbiter main thrusters
	th_hover[0] = CreateThruster (_V(0.0  , -2.0,  0.0),   _V(0,1,0), 46706.3, ph_Dsc, 3107);
	th_hover[1] = CreateThruster (_V(0.013, -2.8, -0.034), _V(0,1,0),     0, ph_Dsc, 0);	//this is a "virtual engine",no thrust and no fuel
																							//needed for visual gimbaling for corrected engine flames
    DelThrusterGroup(THGROUP_HOVER,true);
	thg_hover = CreateThrusterGroup(th_hover, 2, THGROUP_HOVER);
	AddExhaust (th_hover[1], 10.0, 1.5, exhaustTex);
		
	SetCameraOffset (_V(-1,1.0,0.0));
	status = 1;
	stage = 1;
	SetEngineLevel(ENGINE_HOVER,0);
	AddRCS_LMH(-1.85);
	bModeHover=true;

	VECTOR3 dockpos = {0.0 ,2.6, 0.0};	
	VECTOR3 dockdir = {0,1,0};
	VECTOR3 dockrot = { -0.8660254, 0, 0.5 };
	SetDockParams(dockpos, dockdir, dockrot);
	hattDROGUE = CreateAttachment(true, dockpos, dockdir, dockrot, "PADROGUE");
	InitNavRadios (4);

	LDGswitch=true;
	ATT2switch=true;
	ATT3switch=true;
	ATT1switch=true;
	AFEED1switch=false;
	AFEED2switch=false;
	AFEED3switch=false;
	AFEED4switch=false;

	// Descent stage attached.
	agc.SetInputChannelBit(030, DescendStageAttached, true);

	CheckRCS();
}
Example #6
0
void LEM::SetLmVesselDockStage()

{	
	double fuelmass;
	int mnumber;
	ClearThrusterDefinitions();
	agc.SetVesselStats(DPS_ISP, DPS_THRUST, true);
	//
	// Changed to reflect mission-specific empty and fuel mass
	//
	// From "Apollo by the Numbers"
	//
	mnumber=agc.GetApolloNo();
	if(mnumber < 15) {
		SetEmptyMass(6565);		
		fuelmass=8375.;
	} else {
		SetEmptyMass(7334);
		fuelmass=8891.;
	}
	SetSize (6);
	// SetPMI (_V(2.8,2.29,2.37));
	SetPMI(_V(2.5428, 2.2871, 2.7566));
	// SetCrossSections (_V(21,23,17));
	//SetPMI(_V(3.26, 2.22, 3.26));
	SetCrossSections (_V(24.53,21.92,24.40));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,0.7));
	SetPitchMomentScale (0);
	SetBankMomentScale (0);
	SetLiftCoeffFunc (0); 
	ClearMeshes();
	ClearExhaustRefs();
	ClearAttExhaustRefs();
	SetTouchdownPoints (_V(0,0,10), _V(-1,0,-10), _V(1,0,-10));
    VECTOR3 mesh_dir=_V(0.0,-0.2,0.03);

	UINT meshidx = AddMesh (hLMPKD, &mesh_dir);	
	SetMeshVisibilityMode (meshidx, MESHVIS_VCEXTERNAL);
    if (!ph_Dsc)  
		ph_Dsc  = CreatePropellantResource(fuelmass); //2nd stage Propellant
	SetDefaultPropellantResource (ph_Dsc); // display 2nd stage propellant level in generic HUD

	// 133.084001 kg is 293.4 pounds, which is the fuel + oxidizer capacity of one RCS tank.
	if (!ph_RCSA) {
		ph_RCSA = CreatePropellantResource(133.084001);
	}
	if (!ph_RCSB) {
		ph_RCSB = CreatePropellantResource(133.084001);
	}

	// orbiter main thrusters
	th_hover[0] = CreateThruster (_V(0.0  , -3.3,  0.0),  _V(0,1,0), 46706.3, ph_Dsc, 3107);
	th_hover[1] = CreateThruster (_V(0.013, -3.0, -0.03), _V(0,1,0),     0, ph_Dsc, 0);		//this is a "virtual engine",no thrust and no fuel
																							//needed for visual gimbaling for corrected engine flames
	DelThrusterGroup(THGROUP_HOVER,true);
	thg_hover = CreateThrusterGroup(th_hover, 2, THGROUP_HOVER);
	AddExhaust(th_hover[1], 10.0, 1.2, exhaustTex);

	SetCameraOffset (_V(-1,1.0,0.0));
	SetEngineLevel(ENGINE_HOVER,0);
	AddRCS_LMH(-1.85);
	status = 0;
	stage = 0;
	bModeDocked=true;

	VECTOR3 dockpos = {0.0 ,2.6, 0.0};
    VECTOR3 dockdir = {0,1,0};
	VECTOR3 dockrot = { -0.8660254, 0, 0.5 };
	SetDockParams(dockpos, dockdir, dockrot);
	hattDROGUE = CreateAttachment(true, dockpos, dockdir, dockrot, "PADROGUE");
	InitNavRadios (4);
    LDGswitch=false;
	ATT2switch=true;
	ATT3switch=true;
	ATT1switch=true;
	AFEED1switch=false;
	AFEED2switch=false;
	AFEED3switch=false;
	AFEED4switch=false;

	// Descent stage attached.
	agc.SetInputChannelBit(030, DescendStageAttached, true);

	CheckRCS();
}
void InterplanetarySC::createSubSystems()
{
	/*
	Erstellung der Treibstofftanks.
	Es wurde hier bewusst darauf verzichtet die Treibstofftanks direkt in den
	Subsystemen zu erstellen, da Orbiter ohnehin nicht zwischen propellant und oxidant
	unterscheidet. Dennoch wird mitgerechnet mit einer stöchiometrischen Verbrennung,
	das heißt dass es je 2 Tanks mit propellant und oxidant gibt, einmal für das
	Haupttriebwerk und einmal für die Raktionsdüsen.
	*/
	double mainPropMass = 800000.0;
	double rcsPropMass = 6000.0;
	double stoechioMainHydro = mainPropMass * 2/10;
	double stoechioMainOxy = mainPropMass * 8/10;
	double stoechioRCSHydro = rcsPropMass * 2/10;
	double stoechioRCSOxy = rcsPropMass * 8/10;
	PROPELLANT_HANDLE orbiterMainTank = CreatePropellantResource(mainPropMass);
	PROPELLANT_HANDLE orbiterRCSTank = CreatePropellantResource(rcsPropMass);

	HydrogenTank *hydroMain = new HydrogenTank(this,"Wasserstoff Haupt",simTimePtr_,stoechioMainHydro,stoechioMainHydro);
	OxygenTank *oxyMain = new OxygenTank(this,"Sauerstoff Haupt",simTimePtr_,stoechioMainOxy,stoechioMainOxy);
	HydrogenTank *hydroRCS = new HydrogenTank(this,"WasserstoffTank1",simTimePtr_,stoechioMainHydro,stoechioMainHydro);
	OxygenTank *oxyRCS = new OxygenTank(this,"SauerstoffTank1",simTimePtr_,stoechioMainOxy,stoechioMainOxy);

	/*
	Erstellung der Main Engine
	*/
	THGROUP_TYPE mainEngineType[] = {THGROUP_ATT_FORWARD};
	Thruster *mainEngine = new Thruster(this,"Main Engine",simTimePtr_,_V(0,0,-290),_V(0,0,1),350000,orbiterMainTank,8300,mainEngineType,1,200,10);
	/*
	Erstellung der RCS Thruster
	*/
	double rcsTh = 50;
	double rcsTh1 = 150;
	double rcsIsp = 20000;
	double rcsL = 20;
	double rcsW = 1;
	THGROUP_TYPE rcsGroup1[] = {THGROUP_ATT_PITCHUP};
	THGROUP_TYPE rcsGroup2[] = {THGROUP_ATT_YAWRIGHT,THGROUP_ATT_BANKLEFT};
	THGROUP_TYPE rcsGroup3[] = {THGROUP_ATT_YAWLEFT,THGROUP_ATT_BANKRIGHT};
	THGROUP_TYPE rcsGroup4[] = {THGROUP_ATT_YAWLEFT,THGROUP_ATT_PITCHDOWN};
	THGROUP_TYPE rcsGroup5[] = {THGROUP_ATT_YAWLEFT,THGROUP_ATT_PITCHUP,THGROUP_ATT_BANKLEFT};
	THGROUP_TYPE rcsGroup6[] = {THGROUP_ATT_PITCHDOWN,THGROUP_ATT_BANKRIGHT};
	THGROUP_TYPE rcsGroup7[] = {THGROUP_ATT_YAWRIGHT,THGROUP_ATT_PITCHDOWN};
	THGROUP_TYPE rcsGroup8[] = {THGROUP_ATT_YAWRIGHT,THGROUP_ATT_PITCHUP,THGROUP_ATT_BANKRIGHT};
	THGROUP_TYPE rcsGroup9[] = {THGROUP_ATT_PITCHDOWN,THGROUP_ATT_BANKLEFT};
	THGROUP_TYPE rcsGroup10[] = {THGROUP_ATT_PITCHUP};
	THGROUP_TYPE rcsGroup11[] = {THGROUP_ATT_YAWRIGHT,THGROUP_ATT_PITCHUP};
	THGROUP_TYPE rcsGroup12[] = {THGROUP_ATT_YAWLEFT,THGROUP_ATT_PITCHUP};
	THGROUP_TYPE rcsGroup13[] = {THGROUP_ATT_FORWARD};
	THGROUP_TYPE rcsGroup14[] = {THGROUP_ATT_BACK};
	THGROUP_TYPE rcsGroup15[] = {THGROUP_ATT_FORWARD};
	THGROUP_TYPE rcsGroup16[] = {THGROUP_ATT_BACK};
	THGROUP_TYPE rcsGroup17[] = {THGROUP_ATT_FORWARD};
	THGROUP_TYPE rcsGroup18[] = {THGROUP_ATT_BACK};
	
	Thruster *rcs1 = new Thruster(this,"RCS 1",simTimePtr_,_V(0,-30.9,52.9),_V(0,1,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup1,1,rcsL,rcsW);
	Thruster *rcs2 = new Thruster(this,"RCS 2",simTimePtr_,_V(-0.5,-30.5,52.9),_V(1,0,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup2,2,rcsL,rcsW);
	Thruster *rcs3 = new Thruster(this,"RCS 3",simTimePtr_,_V(0.5,-30.5,52.9),_V(-1,0,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup3,2,rcsL,rcsW);
	Thruster *rcs4 = new Thruster(this,"RCS 4",simTimePtr_,_V(26.7,15.4,52.9),_V(-0.86,-0.5,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup4,2,rcsL,rcsW);
	Thruster *rcs5 = new Thruster(this,"RCS 5",simTimePtr_,_V(26.7,14.8,52.9),_V(-0.5,0.86,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup5,3,rcsL,rcsW);
	Thruster *rcs6 = new Thruster(this,"RCS 6",simTimePtr_,_V(26.1,15.7,52.9),_V(0.5,-0.86,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup6,2,rcsL,rcsW);
	Thruster *rcs7 = new Thruster(this,"RCS 7",simTimePtr_,_V(-26.7,15.4,52.9),_V(0.86,-0.5,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup7,2,rcsL,rcsW);
	Thruster *rcs8 = new Thruster(this,"RCS 8",simTimePtr_,_V(-26.7,14.8,52.9),_V(0.5,0.86,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup8,3,rcsL,rcsW);
	Thruster *rcs9 = new Thruster(this,"RCS 9",simTimePtr_,_V(-26.1,15.7,52.9),_V(-0.5,-0.86,0),rcsTh,orbiterRCSTank,rcsIsp,rcsGroup9,2,rcsL,rcsW);
	Thruster *rcs10 = new Thruster(this,"RCS 10",simTimePtr_,_V(0,-1.5,-232.7),_V(0,-1,0),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup10,1,rcsL,rcsW);
	Thruster *rcs11 = new Thruster(this,"RCS 11",simTimePtr_,_V(1.3,0.7,-232.6),_V(-0.86,-0.5,0),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup11,2,rcsL,rcsW);
	Thruster *rcs12 = new Thruster(this,"RCS 12",simTimePtr_,_V(-1.3,0.7,-232.6),_V(0.86,-0.5,0),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup12,2,rcsL,rcsW);
	Thruster *rcs13 = new Thruster(this,"RCS 13",simTimePtr_,_V(0,-30.5,52.3),_V(0,0,1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup13,1,rcsL,rcsW);
	Thruster *rcs14 = new Thruster(this,"RCS 14",simTimePtr_,_V(0,-30.5,53.4),_V(0,0,-1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup14,1,rcsL,rcsW);
	Thruster *rcs15 = new Thruster(this,"RCS 15",simTimePtr_,_V(26.4,15.3,52.3),_V(0,0,1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup15,1,rcsL,rcsW);
	Thruster *rcs16 = new Thruster(this,"RCS 16",simTimePtr_,_V(26.4,15.3,53.4),_V(0,0,-1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup16,1,rcsL,rcsW);
	Thruster *rcs17 = new Thruster(this,"RCS 17",simTimePtr_,_V(-26.4,15.3,52.3),_V(0,0,1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup17,1,rcsL,rcsW);
	Thruster *rcs18 = new Thruster(this,"RCS 18",simTimePtr_,_V(-26.4,15.3,53.4),_V(0,0,-1),rcsTh1,orbiterRCSTank,rcsIsp,rcsGroup18,1,rcsL,rcsW);

	WaterTank *water1 = new WaterTank(this,"WasserTank1",simTimePtr_,4000,50000);
	
	

	FuelCell *fc1 = new FuelCell(this,"Brennstoffzelle1",simTimePtr_,0.4,4,3000);
	fc1->deactivate();
	hydroMain->setStatus(STATUS_ACTIVE_WARNING);
	Battery *bat1 = new Battery(this,"Batterie1",simTimePtr_,50000,900000,1000,10000,0.9,0.9,300,270,320,5000,400,5);
	Radiator *radiator1 = new Radiator(this,"Radiator1",simTimePtr_,5000,1000000,100);
	Heater *heater1 = new Heater(this,"Heater1",simTimePtr_,5000000,0.8,0.8);

	subsys_.push_back(water1);
	subsys_.push_back(oxyMain);
	subsys_.push_back(hydroMain);
	subsys_.push_back(oxyRCS);
	subsys_.push_back(hydroRCS);
	subsys_.push_back(mainEngine);
	subsys_.push_back(fc1);
	subsys_.push_back(bat1);
	subsys_.push_back(radiator1);
	subsys_.push_back(heater1);

	// Diese zuweisungen sind auskommentiert, um die Visualisierung übersichtlicher zu machen
	//subsys_.push_back(rcs1);
	//subsys_.push_back(rcs2);
	//subsys_.push_back(rcs3);
	//subsys_.push_back(rcs4);
	//subsys_.push_back(rcs5);
	//subsys_.push_back(rcs6);
	//subsys_.push_back(rcs7);
	//subsys_.push_back(rcs8);
	//subsys_.push_back(rcs9);
	//subsys_.push_back(rcs10);
	//subsys_.push_back(rcs11);
	//subsys_.push_back(rcs12);
	//subsys_.push_back(rcs13);
	//subsys_.push_back(rcs14);
	//subsys_.push_back(rcs15);
	//subsys_.push_back(rcs16);
	//subsys_.push_back(rcs17);
	//subsys_.push_back(rcs18);

	//Links instanzieren
	Link *h2a = new Link("H2");
	Link *h2b = new Link("H2");
	Link *o2a = new Link("O2");
	Link *o2b = new Link("O2");
	Link *h2oa = new Link("H2O");
	Link *h2ob = new Link("H2O");
	Link *power1 = new Link("Energy[J]");
	Link *power2 = new Link("Energy[J]");
	Link *heat1 = new Link("Heat[J]");
	Link *heat2 = new Link("Heat[J]");
	Link *heat3 = new Link("Heat[J]");


	links_.push_back(h2a);
	links_.push_back(h2b);
	links_.push_back(o2a);
	links_.push_back(o2b);
	links_.push_back(h2oa);
	links_.push_back(h2ob);
	links_.push_back(heat1);
	links_.push_back(power1);
	links_.push_back(power2);
	links_.push_back(heat2);
	links_.push_back(heat3);

	//Ports verbinden
	hydroMain->connectPortToOutput(h2a->getPort());
	hydroMain->connectPortToOutput(h2b->getPort());
	oxyMain->connectPortToOutput(o2a->getPort());
	oxyMain->connectPortToOutput(o2b->getPort());
	water1->connectPortToOutput(h2oa->getPort());
	water1->connectPortToInput(h2ob->getPort());
	mainEngine->connectPortToInput(h2a->getPort());
	mainEngine->connectPortToInput(o2a->getPort());
	//rcs1->connectPortToInput(h2a->getPort());
	//rcs1->connectPortToInput(o2a->getPort());
	//rcs2->connectPortToInput(h2a->getPort());
	//rcs2->connectPortToInput(o2a->getPort());
	//rcs3->connectPortToInput(h2a->getPort());
	//rcs3->connectPortToInput(o2a->getPort());
	//rcs4->connectPortToInput(h2a->getPort());
	//rcs4->connectPortToInput(o2a->getPort());
	//rcs5->connectPortToInput(h2a->getPort());
	//rcs5->connectPortToInput(o2a->getPort());
	//rcs6->connectPortToInput(h2a->getPort());
	//rcs6->connectPortToInput(o2a->getPort());
	//rcs7->connectPortToInput(h2a->getPort());
	//rcs7->connectPortToInput(o2a->getPort());
	//rcs8->connectPortToInput(h2a->getPort());
	//rcs8->connectPortToInput(o2a->getPort());
	//rcs9->connectPortToInput(h2a->getPort());
	//rcs9->connectPortToInput(o2a->getPort());
	//rcs10->connectPortToInput(h2a->getPort());
	//rcs10->connectPortToInput(o2a->getPort());
	//rcs11->connectPortToInput(h2a->getPort());
	//rcs11->connectPortToInput(o2a->getPort());
	//rcs12->connectPortToInput(h2a->getPort());
	//rcs12->connectPortToInput(o2a->getPort());
	//rcs13->connectPortToInput(h2a->getPort());
	//rcs13->connectPortToInput(o2a->getPort());
	//rcs14->connectPortToInput(h2a->getPort());
	//rcs14->connectPortToInput(o2a->getPort());
	//rcs15->connectPortToInput(h2a->getPort());
	//rcs15->connectPortToInput(o2a->getPort());
	//rcs16->connectPortToInput(h2a->getPort());
	//rcs16->connectPortToInput(o2a->getPort());
	//rcs17->connectPortToInput(h2a->getPort());
	//rcs17->connectPortToInput(o2a->getPort());
	//rcs18->connectPortToInput(h2a->getPort());
	//rcs18->connectPortToInput(o2a->getPort());

	fc1->connectPortToInput(h2b->getPort());
	fc1->connectPortToInput(o2b->getPort());
	fc1->connectPortToInput(h2oa->getPort());
	fc1->connectPortToOutput(h2ob->getPort());
	fc1->connectPortToOutput(power1->getPort());
	fc1->connectPortToOutput(heat1->getPort());
	fc1->connectPortToOutput(power2->getPort());

	bat1->connectPortToInput(power1->getPort());
	bat1->connectPortToInput(heat2->getPort());
	bat1->connectPortToOutput(heat3->getPort());
	heater1->connectPortToInput(power2->getPort());
	heater1->connectPortToOutput(heat2->getPort());
	radiator1->connectPortToInput(heat1->getPort());
	radiator1->connectPortToInput(heat3->getPort());

}