#define STRICT
#define ORBITER_MODULE
#include "orbitersdk.h"
#include "ScnEditorAPI.h"
// ==============================================================
// Some vessel parameters
// ==============================================================
const double UNITY_FUELMASS = 7000.0;
const double UNITY_ISP = 3840;
const double UNITY_MAXMAINTH = 12000; //N
const double UNITY_MAXRCSTH = 9000;
// 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)
{
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 (int i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
return CL[i] + (aoa-AOA[i])*SCL[i];
}
// ==============================================================
// Unity class interface
// ==============================================================
class Unity: public VESSEL2 {
public:
Unity (OBJHANDLE hVessel, int flightmodel)
: VESSEL2 (hVessel, flightmodel) {}
void clbkSetClassCaps (FILEHANDLE cfg);
};
// ==============================================================
// Overloaded callback functions
// ==============================================================
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void Unity::clbkSetClassCaps (FILEHANDLE cfg)
{
THRUSTER_HANDLE th_main[4], th_rcs[16], th_group[4]; //no hover engines, 4 MEs
// physical specs
SetSize (4); //radius ~4m, not visually, but for aerodynamics purposes
SetEmptyMass (14000); //14000 kg without fuel
//AddMesh (oapiLoadMeshGlobal ("Unity.msh")); PB module not the same syntax as documentation, mesh defined below
SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (0.5); //assuming that the fixed ballute provides some degree of lift
SetWingEffectiveness (1.5); //see above note
SetCrossSections (_V(10.5,15.0,5.8));
SetRotDrag (_V(0.6,0.6,0.35));
SetPMI (_V(2.28,2.31,0.79));
SetTrimScale (0.0); //no trim available
SetCameraOffset (_V(0,0.8,0));
SetLiftCoeffFunc (LiftCoeff);
SetDockParams (_V(0,0,-3.037422), _V(0,1,0), _V(0,0,-1)); //docking port is at the rear
SetTouchdownPoints (_V(0.0,-0.5759583,1.291359), _V(-0.515331,0.5880836,1.291359), _V(0.5274567,0.5759581,1.291359)); //touchdown points are directly on the nose (splashdown face-forward)
// propellant resources
PROPELLANT_HANDLE hpr = CreatePropellantResource (UNITY_FUELMASS);