// Copyright (c) Martin Schweiger
// Licensed under the MIT License
// ==============================================================
// ORBITER MODULE: ShuttlePB
// Part of the ORBITER SDK
//
// 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"
// ==============================================================
// 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 = 500.0; // empty vessel mass [kg]
const double PB_FUELMASS = 750.0; // max fuel mass [kg]
...
// --------------------------------------------------------------
// 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 (tdvtx, ntdvtx);
// 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);
...
// camera parameters
SetCameraOffset (_V(0,0.8,0));
// associate a mesh for the visual
AddMesh ("ShuttlePB");
}