132 lines
3.3 KiB
C++
132 lines
3.3 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include <string>
|
|
#include "libs.h"
|
|
|
|
#define EARTH_RADIUS 6378135.0
|
|
#define EARTH_MASS 5.9742e24
|
|
#define JUPITER_MASS 317.8*EARTH_MASS
|
|
/* Brown dwarfs above 13 jupiter masses fuse deuterium. */
|
|
#define MIN_BROWN_DWARF (13.0*JUPITER_MASS)
|
|
#define SOL_RADIUS 6.955e8
|
|
#define SOL_MASS 1.98892e30
|
|
#define AU 149598000000.0
|
|
#define G 6.67428e-11
|
|
|
|
struct systemloc_t {
|
|
int secX, secY, sysIdx;
|
|
};
|
|
|
|
struct CustomSBody;
|
|
|
|
/* Doubles: All masses are in Kg, all lengths in meters. */
|
|
class StarSystem {
|
|
public:
|
|
StarSystem(void) { rootBody = 0; }
|
|
StarSystem(int sector_x, int sector_y, int system_idx);
|
|
~StarSystem(void);
|
|
bool IsSystem(int sector_x, int sector_y, int system_idx);
|
|
void GetPos(systemloc_t* l) { *l = loc; };
|
|
void GetPos(int* sec_x, int* sec_y, int* sys_idx) {
|
|
*sec_x = loc.secX; *sec_y = loc.secY, *sys_idx = loc.sysIdx;
|
|
}
|
|
|
|
static float starColors[][3];
|
|
|
|
struct Orbit {
|
|
void KeplerPosAtTime(double t, double* dist, double* ang);
|
|
vector3d CartesianPosAtTime(double t);
|
|
double eccentricity;
|
|
double semiMajorAxis;
|
|
double period; /* Seconds. */
|
|
matrix4x4d rotMatrix;
|
|
};
|
|
|
|
enum BodyType {
|
|
TYPE_GRAVPOINT,
|
|
TYPE_STAR_M,
|
|
TYPE_STAR_K,
|
|
TYPE_STAR_G,
|
|
TYPE_STAR_F,
|
|
TYPE_STAR_A,
|
|
TYPE_STAR_B,
|
|
TYPE_STAR_O,
|
|
TYPE_BROWN_DWARF,
|
|
TYPE_PLANET_SMALL_GAS_GIANT,
|
|
TYPE_PLANET_MEDIUM_GAS_GIANT,
|
|
TYPE_PLANET_LARGE_GAS_GIANT,
|
|
TYPE_PLANET_VERY_LARGE_GAS_GIANT,
|
|
TYPE_PLANET_DWARF,
|
|
TYPE_PLANET_SMALL,
|
|
TYPE_PLANET_WATER,
|
|
TYPE_PLANET_CO2,
|
|
TYPE_PLANET_METHANE,
|
|
TYPE_PLANET_WATER_THICK_ATMOS,
|
|
TYPE_PLANET_CO2_THICK_ATMOS,
|
|
TYPE_PLANET_METHANE_THICK_ATMOS,
|
|
TYPE_PLANET_HIGHLY_VOLCANIC,
|
|
TYPE_PLANET_INDIGENOUS_LIFE,
|
|
TYPE_MAX
|
|
/* TODO: Need larger atmosphereless thing. */
|
|
};
|
|
|
|
enum BodySuperType {
|
|
SUPERTYPE_NONE, SUPERTYPE_STAR, SUPERTYPE_ROCKY_PLANET, SUPERTYPE_GAS_GIANT
|
|
};
|
|
|
|
struct BodyStats {
|
|
|
|
};
|
|
|
|
struct SBody {
|
|
~SBody(void);
|
|
void EliminateBadChildren(void); /* :D */
|
|
void PickPlanetType(SBody*, fixed distToPrimary, MTRand& drand, bool genMoons);
|
|
SBody* parent;
|
|
std::vector<SBody*> children;
|
|
|
|
const char* GetAstroDescription(void);
|
|
const char* GetIcon(void);
|
|
BodySuperType GetSuperType() const;
|
|
double GetRadius(void) const {
|
|
if(GetSuperType() == SUPERTYPE_STAR)
|
|
return radius.ToDouble() * SOL_RADIUS;
|
|
else
|
|
return radius.ToDouble() * EARTH_RADIUS;
|
|
}
|
|
double GetMass(void) const {
|
|
if(GetSuperType() == SUPERTYPE_STAR)
|
|
return mass.ToDouble() * SOL_MASS;
|
|
else
|
|
return mass.ToDouble() * EARTH_MASS;
|
|
}
|
|
/* Returned in seconds. */
|
|
double GetRotationPeriod(void) const {
|
|
return rotationPeriod.ToDouble()*60*60*24;
|
|
}
|
|
|
|
int tmp;
|
|
Orbit orbit;
|
|
int seed; /* planet.cpp can use to generate terrain. */
|
|
std::string name;
|
|
fixed radius;
|
|
fixed mass; /* Earth masses if planet, solar masses if star. */
|
|
fixed radMin, radMax; /* In AU's. */
|
|
fixed rotationPeriod; /* In days. */
|
|
int averageTemp;
|
|
|
|
BodySuperType supertype;
|
|
BodyType type;
|
|
};
|
|
|
|
SBody* rootBody;
|
|
|
|
private:
|
|
void CustomGetChildOf(SBody* parent, const CustomSBody* customDef, const int parentIdx);
|
|
void GenerateFromCustom(const CustomSBody*);
|
|
systemloc_t loc;
|
|
|
|
MTRand rand;
|
|
};
|
|
|