All pastes #2045307 Raw Edit

lss0.3

public cpp v1 · immutable
#2045307 ·published 2011-04-12 01:34 UTC
rendered paste body
//Commented lines cause strange effects when included. Vessel works fine (other than incomplete RCS exhausts) as-is.#define STRICT#define ORBITER_MODULE#include "orbitersdk.h"//TODO: move constants and class interface to LSS.hconst double V_SIZE        = 18;const VECTOR3 CS             = {122.1,122.1,71};const VECTOR3 PMI            = {10,10,5};const VECTOR3 RD             = {0.5,0.5,0.5};const double EMPTYMASS       = 3084.4;const double FUELMASS        = 18000;const double RCSFUELMASS     = 8000;const double MAIN_ISP        = 600;const double HOVER_ISP       = 460;const double RCS_ISP         = 306;const VECTOR3 TDP [3]        = {{0,-3.098563,5.306288},{-2.865911,-3.098563,-5.235881},{2.865911,-3.098563,-5.235881}};const double MAXMAINTH       = 25000;const double MAXRETROTH      = 25000;const double MAXHOVERTH      = 50000;const double MAXRCSTH        = 3870;const VECTOR3 FORE_DOCK_POS  = {0,0,9.408442};const VECTOR3 FORE_DOCK_DIR  = {0,0,1};const VECTOR3 FORE_DOCK_ROT  = {0,1,0};class LSS: public VESSEL3 {public:	LSS (OBJHANDLE hVessel, int flightmodel);	~LSS ();	void clbkSetClassCaps (FILEHANDLE cfg);//	void clbkPostStep (double simt, double simdt, double mjd);//	int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);//	bool bManualSeparate;	ATTACHMENTHANDLE payload;};LSS::LSS (OBJHANDLE hVessel, int flightmodel) : VESSEL3 (hVessel, flightmodel) {}LSS::~LSS () {}void LSS::clbkSetClassCaps (FILEHANDLE cfg){	THRUSTER_HANDLE th_main, th_retro, th_hover, th_rcs[14], th_group[4];		SetSize (V_SIZE);	SetEmptyMass (EMPTYMASS);	SetPMI (PMI);	SetCrossSections (CS);	SetTouchdownPoints (TDP[0],TDP[1],TDP[2]);		SetDockParams (FORE_DOCK_POS, FORE_DOCK_DIR, FORE_DOCK_ROT);		payload = CreateAttachment (false, _V(0,-0.4,-1), _V(0,1,0), _V(0,0,1), "XS");		PROPELLANT_HANDLE prm = CreatePropellantResource (FUELMASS);	PROPELLANT_HANDLE rcs = CreatePropellantResource (RCSFUELMASS);		SURFHANDLE hovertex = oapiRegisterExhaustTexture ("Exhaust_atrcs");		th_main = CreateThruster (_V(0,0,-2.06406), _V(0,0,1), MAXMAINTH, prm, MAIN_ISP);	CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);	AddExhaust (th_main, 1.5, 0.1, _V(-4.480906,-0.24288,-2.06406), _V(0,0,-1), hovertex);	AddExhaust (th_main, 1.5, 0.1, _V(4.480906,-0.24288,-2.06406), _V(0,0,-1), hovertex);		th_retro = CreateThruster (_V(0,0,2.06406), _V(0,0,-1), MAXRETROTH, prm, MAIN_ISP);	CreateThrusterGroup (&th_retro, 1, THGROUP_RETRO);	AddExhaust (th_retro, 1.5, 0.1, _V(-4.480906,-0.24288,2.06406), _V(0,0,1));	AddExhaust (th_retro, 1.5, 0.1, _V(4.480906,-0.24288,2.06406), _V(0,0,1));		PARTICLESTREAMSPEC oms_ex = {		0, 0.2, 26, 10, 0.08, 0.08, 1.2, 0,		PARTICLESTREAMSPEC::EMISSIVE,		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,		PARTICLESTREAMSPEC::ATM_FLAT, 1,	};	AddExhaustStream (th_main, _V(-4.480906,-0.24288,-2.06406), &oms_ex);	AddExhaustStream (th_main, _V(4.480906,-0.24288,-2.06406), &oms_ex);	AddExhaustStream (th_retro, _V(-4.480906,-0.24288,2.06406), &oms_ex);	AddExhaustStream (th_retro, _V(4.480906,-0.24288,2.06406), &oms_ex);		th_hover = CreateThruster (_V(0,-1.062284,0), _V(0,1,0), MAXHOVERTH, prm, HOVER_ISP);	CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);	AddExhaust (th_hover, 8, 1, _V(-4.532407,-1.062284,0.8303303), _V(0,-1,0), hovertex);	AddExhaust (th_hover, 8, 1, _V(4.532407,-1.062284,0.8303303), _V(0,-1,0), hovertex);	AddExhaust (th_hover, 8, 1, _V(-4.532407,-1.062284,-0.7899902), _V(0,-1,0), hovertex);	AddExhaust (th_hover, 8, 1, _V(4.532407,-1.062284,-0.7899902), _V(0,-1,0), hovertex);		PARTICLESTREAMSPEC hover_ex = {		0, 1, 20, 20, 0.4, 0.2, 8, 0,		PARTICLESTREAMSPEC::EMISSIVE,		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,		PARTICLESTREAMSPEC::ATM_FLAT, 1,	};	AddExhaustStream (th_hover, _V(-4.532407,-2.062284,0.8303303), &hover_ex);	AddExhaustStream (th_hover, _V(4.532407,-2.062284,0.8303303), &hover_ex);	AddExhaustStream (th_hover, _V(-4.532407,-2.062284,-0.7899902), &hover_ex);	AddExhaustStream (th_hover, _V(4.532407,-2.062284,-0.7899902), &hover_ex);	        //TODO: Many, many things...	th_rcs[ 0] = CreateThruster (_V( 1,0, 7.3), _V(0, 1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 1] = CreateThruster (_V( 1,0, 7.3), _V(0,-1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 2] = CreateThruster (_V(-1,0, 7.3), _V(0, 1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 3] = CreateThruster (_V(-1,0, 7.3), _V(0,-1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 4] = CreateThruster (_V( 1,0,-7.3), _V(0, 1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 5] = CreateThruster (_V( 1,0,-7.3), _V(0,-1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 6] = CreateThruster (_V(-1,0,-7.3), _V(0, 1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 7] = CreateThruster (_V(-1,0,-7.3), _V(0,-1,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 8] = CreateThruster (_V( 1,0, 7.3), _V(-1,0,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[ 9] = CreateThruster (_V(-1,0, 7.3), _V( 1,0,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[10] = CreateThruster (_V( 1,0,-7.3), _V(-1,0,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[11] = CreateThruster (_V(-1,0,-7.3), _V( 1,0,0), MAXRCSTH, rcs, RCS_ISP);	th_rcs[12] = CreateThruster (_V( 0,0,-7.3), _V(0,0, 1), MAXRCSTH, rcs, RCS_ISP);	th_rcs[13] = CreateThruster (_V( 0,0, 7.3), _V(0,0,-1), MAXRCSTH, rcs, RCS_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);		//RCS exhaust...what a headache! (Not done)	AddExhaust (th_rcs[0], 2, 0.05, _V(-3.213465,0,7.349519), _V(-1,0,0));	AddExhaust (th_rcs[0], 2, 0.05, _V(3.213465,0,7.349519), _V(1,0,0));	AddExhaust (th_rcs[1], 2, 0.05, _V(-3.216827,0,-7.206742), _V(-1,0,0));	AddExhaust (th_rcs[1], 2, 0.05, _V(3.216827,0,-7.206742), _V(1,0,0));			SetCameraOffset (_V(0.895,1.365,8.67728));		SetMeshVisibilityMode (AddMesh ("LSS_Seneca"), MESHVIS_ALWAYS);}/*void LSS::clbkPostStep (double simt, double simdt, double mjd){	if (bManualSeparate && GetAttachmentStatus (payload)) {			DetachChild (payload, 0.1);			bManualSeparate = false;		}}int LSS::clbkConsumeBufferedKey (DWORD key, bool down, char *kstate){	if (!down) return 0;	switch (key)	{		case OAPI_KEY_J:  // "Jettison"			{			bManualSeparate = true;			}		return 1;	}}*/DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel){		return new LSS (hvessel, flightmodel);}DLLCLBK void ovcExit (VESSEL *vessel){	if (vessel) delete (LSS*)vessel;}