Apokliptico
New member
Hi everyone!!! Well, i've finnaly finished my mars.dll module, that features a complex human friendly atmosphere. I couldn't have done it without the help from many users in this forum, so I decided to post the source code, so if anyone wants to create a new planet, or modify an existing one, it won't be such a tedious work.
Notice that I haven't made the complex ephemeris calculations, so I especified them in the .cfg file.
Thanks to everyone!
APOKLIPTICO
Code:
#define ORBITER_MODULE
#include "OrbiterAPI.h"
#include "CelbodyAPI.h"
#pragma comment(lib, "Orbitersdk.lib")
#pragma comment(lib, "orbiter.lib")
class MyPlanet: public CELBODY {
public:
MyPlanet();
void clbkInit (FILEHANDLE cfg);
virtual bool clbkAtmParam (double alt, ATMPARAM *prm);
};
MyPlanet::MyPlanet():CELBODY()
{
// add constructor code here
}
bool MyPlanet::clbkAtmParam (double alt, ATMPARAM *prm)
{
if(alt < 340000.0)
{
if(alt < 40000.0) prm->T = 292 - (70 / 40000.0 * alt);
else if(alt < 80000.0) prm->T = 222 + (20 / 40000.0 * (alt - 40000));
else if(alt < 120000.0) prm->T = 242 - (50 / 40000.0 * (alt - 80000));
else if(alt < 200000.0) prm->T = 192 - (20 / 80000.0 * (alt - 120000));
else if(alt < 300000.0) prm->T = 172 - (140 / 100000.0 * (alt - 200000));
else prm->T = 32 - (31 / 40000.0 * (alt - 300000));
prm->p = 85390 * exp((-3.7279 * 28.9644 * alt) / (8314.32 * prm->T));
prm->rho = (1.293 / 85390) * prm->p;
return true;
}
else return false;
}
void MyPlanet::clbkInit (FILEHANDLE cfg)
{
// read parameters from config file (e.g. tolerance limits, etc)
// perform any required initialisation (e.g. read perturbation terms from data files)
}
DLLCLBK void InitModule (HINSTANCE hModule)
{
// module initialisation
}
DLLCLBK void ExitModule (HINSTANCE hModule)
{
// module cleanup
}
DLLCLBK CELBODY *InitInstance (OBJHANDLE hBody)
{
// instance initialisation
return new MyPlanet;
}
DLLCLBK void ExitInstance (CELBODY *body)
{
// instance cleanup
delete (MyPlanet*)body;
}
Notice that I haven't made the complex ephemeris calculations, so I especified them in the .cfg file.
Thanks to everyone!
APOKLIPTICO