// ==============================================================
//O'Neill Colony Source Code
//Taken from the Shuttle PB - I didn't want to mess with anything I didn't have to, so there's
//a lot of meaningless data left over, but hopefully it won't be an issue.
// ==============================================================
#define STRICT
#define ORBITER_MODULE
#include "orbitersdk.h"
// ==============================================================
// Some vessel parameters
// ==============================================================
// 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])};
int i;
for (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
return CL[i] + (aoa-AOA[i])*SCL[i];
}
// ==============================================================
// O'Neill class interface
// ==============================================================
class oneill: public VESSEL2
{
public:
oneill (OBJHANDLE hVessel, int flightmodel)
: VESSEL2 (hVessel, flightmodel), rotation_angle(0.0) {};
void clbkSetClassCaps (FILEHANDLE cfg);
void clbkPreStep (double SimT, double SimDT, double mjd);
void DefineAnimations ();
UINT anim_grav;
double rotation_angle;
};
const double rotation_speed = 3.2 / 360.0;
const double cloud_speed = 1.6 / 360.0;
void oneill::DefineAnimations ()
{
static UINT grav_groups[8] = {1,2,3,4,5,6,7,8};
static MGROUP_ROTATE grav (
0,//WTF is a Mesh Index? Google won't tell me. Maybe the problem lies here.
grav_groups, 8,
_V(0,0,0),
_V(0,0,1),
(float)(2.0*PI)
);
anim_grav = CreateAnimation (0);
AddAnimationComponent (anim_grav, 0, 1, &grav);
}
void oneill::clbkPreStep (double SimT, double SimDT, double mjd)
{
double da = SimDT * rotation_speed; // Delta angle
rotation_angle += da;
// Next line changed from ring_angle -= 1.0 to deal with problems
// associated with high time acceleration.
if (rotation_angle > 1.0) rotation_angle -= floor(rotation_angle);
SetAnimation (anim_grav, rotation_angle);
}
//^^^^Why doesn't this work?
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void oneill::clbkSetClassCaps (FILEHANDLE cfg)
{
// physical specs, etc. below
SetSize (10000);//Not technically correct, but having it smaller solves the clipping issue, at least close up.
SetAlbedoRGB (_V(1.0,1.0,1.0));
SetVisibilityLimit (1.0e-3, 1.0e-9); //Why doesn't this work, either? I want my white dot!
SetEmptyMass (3.9e12);
SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (0.7);
SetWingEffectiveness (2.5);
SetCrossSections (_V(3.0e8,3.0e8,3.0e7));
SetRotDrag (_V(3.0e8,3.0e8,3.0e7));
if (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(3.0e8,3.0e8,3.0e7));
SetTrimScale (0.0);
SetCameraOffset (_V(0,0,0));
SetLiftCoeffFunc (LiftCoeff);
SetTouchdownPoints (_V(-1000,-3000,-20000), _V(1000,-3000,-20000), _V(0,-3000,20000));
//Docks
CreateDock (_V(81.64,189.16,21710.12),_V(0,0,1),_V(0,1,0));
CreateDock (_V(-277.8,-161.5,21655.64),_V(0,0,1),_V(0,1,0));
CreateDock (_V(323.983,72.23,21455.67),_V(0,0,1),_V(0,1,0));
CreateDock (_V(323.8,-161.75,21455.67),_V(0,0,1),_V(0,1,0));
CreateDock (_V(-277.8,189.16,21456.98),_V(0,0,1),_V(0,1,0));
// visual specs
AddMesh ("oneill");
}
// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new oneill (hvessel, flightmodel);
}
// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (oneill*)vessel;
}