[Add] Make orbital starports in system generation.
This commit is contained in:
parent
b5175d562e
commit
cb7d734e74
BIN
icons/object_orbital_starport.png
Normal file
BIN
icons/object_orbital_starport.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
@ -24,7 +24,7 @@ static GLUtesselator* tobj;
|
|||||||
static inline double fac(int n) {
|
static inline double fac(int n) {
|
||||||
double r = 1.0;
|
double r = 1.0;
|
||||||
|
|
||||||
for(int i = 2; i < n; i++) {
|
for(int i = 2; i <= n; i++) {
|
||||||
r *= (double)i;
|
r *= (double)i;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
@ -361,7 +361,7 @@ FontFace::FontFace(const char* filename_ttf) {
|
|||||||
temppts.clear();
|
temppts.clear();
|
||||||
GenContourPoints(chr, outline, contour, BEZIER_STEPS, &temppts);
|
GenContourPoints(chr, outline, contour, BEZIER_STEPS, &temppts);
|
||||||
for(size_t i = 0; i < temppts.size(); i++) pts.push_back(temppts[i]);
|
for(size_t i = 0; i < temppts.size(); i++) pts.push_back(temppts[i]);
|
||||||
for(size_t i = 0; i < temppts.size(); i+=4, nv++)
|
for(size_t i = 0; i < temppts.size(); i+=3, nv++)
|
||||||
gluTessVertex(tobj, &pts[nv*3], &g_index[nv]);
|
gluTessVertex(tobj, &pts[nv*3], &g_index[nv]);
|
||||||
gluTessEndContour(tobj);
|
gluTessEndContour(tobj);
|
||||||
}
|
}
|
||||||
|
@ -638,48 +638,48 @@ Model ship2model = { 1.0f, 35.0f, 98, ship2vtx1, 120, 1, ship2vtx2, 10,
|
|||||||
{ { 0, ship2data, 0, 14, ship2thruster } } };
|
{ { 0, ship2data, 0, 14, ship2thruster } } };
|
||||||
|
|
||||||
static PlainVertex station1vtx1[] = {
|
static PlainVertex station1vtx1[] = {
|
||||||
{ VTYPE_PLAIN, { -15.0f, 30.0f, 20.0f } }, /* 6, front octagon. */
|
{ VTYPE_PLAIN, { -15.0f, -20.0f, 30.0f } }, /* 6, front octagon. */
|
||||||
{ VTYPE_PLAIN, { 15.0f, 30.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 15.0f, -20.0f, 30.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, 15.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 30.0f, -20.0f, 15.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, -15.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 30.0f, -20.0f, -15.0f } },
|
||||||
{ VTYPE_PLAIN, { 15.0f, -30.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 15.0f, -20.0f, -30.0f } },
|
||||||
{ VTYPE_PLAIN, { -15.0f, -30.0f, 20.0f } },
|
{ VTYPE_PLAIN, { -15.0f, -20.0f, -30.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { -15.0f, 30.0f, -20.0f } }, /* 12, back octagon. */
|
{ VTYPE_PLAIN, { -15.0f, 20.0f, 30.0f } }, /* 12, back octagon. */
|
||||||
{ VTYPE_PLAIN, { 15.0f, 30.0f, -20.0f } },
|
{ VTYPE_PLAIN, { 15.0f, 20.0f, 30.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, 15.0f, -20.0f } },
|
{ VTYPE_PLAIN, { 30.0f, 20.0f, 15.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, -15.0f, -20.0f } },
|
{ VTYPE_PLAIN, { 30.0f, 20.0f, -15.0f } },
|
||||||
{ VTYPE_PLAIN, { 15.0f, -30.0f, -20.0f } },
|
{ VTYPE_PLAIN, { 15.0f, 20.0f, -30.0f } },
|
||||||
{ VTYPE_PLAIN, { -15.0f, -30.0f, -20.0f } },
|
{ VTYPE_PLAIN, { -15.0f, 20.0f, -30.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { -10.0f, 5.0f, 20.0f } }, /* 18, inlet front. */
|
{ VTYPE_PLAIN, { -10.0f, -20.0f, 5.0f } }, /* 18, inlet front. */
|
||||||
{ VTYPE_PLAIN, { 10.0f, 5.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 10.0f, -20.0f, 5.0f } },
|
||||||
{ VTYPE_PLAIN, { 10.0f, -5.0f, 20.0f } },
|
{ VTYPE_PLAIN, { 10.0f, -20.0f, -5.0f } },
|
||||||
{ VTYPE_PLAIN, { -10.0f, -5.0f, 20.0f } },
|
{ VTYPE_PLAIN, { -10.0f, -20.0f, -5.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { -10.0f, 5.0f, 0.0f } }, /* 22, inlet rear. */
|
{ VTYPE_PLAIN, { -10.0f, 0.0f, 5.0f } }, /* 22, inlet rear. */
|
||||||
{ VTYPE_PLAIN, { 10.0f, 5.0f, 0.0f } },
|
{ VTYPE_PLAIN, { 10.0f, 0.0f, 5.0f } },
|
||||||
{ VTYPE_PLAIN, { 10.0f, -5.0f, 0.0f } },
|
{ VTYPE_PLAIN, { 10.0f, 0.0f, -5.0f } },
|
||||||
{ VTYPE_PLAIN, { -10.0f, -5.0f, 0.0f } },
|
{ VTYPE_PLAIN, { -10.0f, 0.0f, -5.0f } },
|
||||||
|
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { 30.0f, 10.0f, 10.0f } }, /* 26, strut inner. */
|
{ VTYPE_PLAIN, { 30.0f, -10.0f, 10.0f } }, /* 26, strut inner. */
|
||||||
{ VTYPE_PLAIN, { 30.0f, -10.0f, 10.0f } },
|
{ VTYPE_PLAIN, { 30.0f, -10.0f, 10.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, -10.0f, -10.0f } },
|
{ VTYPE_PLAIN, { 30.0f, -10.0f, -10.0f } },
|
||||||
{ VTYPE_PLAIN, { 30.0f, 10.0f, -10.0f } },
|
{ VTYPE_PLAIN, { 30.0f, 10.0f, 10.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { 100.0f, 10.0f, 10.0f } }, /* 30, strut outer. */
|
{ VTYPE_PLAIN, { 100.0f, -10.0f, 10.0f } }, /* 30, strut outer. */
|
||||||
{ VTYPE_PLAIN, { 100.0f, -10.0f, 10.0f } },
|
|
||||||
{ VTYPE_PLAIN, { 100.0f, -10.0f, -10.0f } },
|
{ VTYPE_PLAIN, { 100.0f, -10.0f, -10.0f } },
|
||||||
{ VTYPE_PLAIN, { 100.0f, 10.0f, -10.0f } },
|
{ VTYPE_PLAIN, { 100.0f, 10.0f, -10.0f } },
|
||||||
|
{ VTYPE_PLAIN, { 100.0f, 10.0f, 10.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { 0.0f, 0.0f, 25.0f } }, /* 34, ring start, end. */
|
{ VTYPE_PLAIN, { 0.0f, -25.0f, 0.0f } }, /* 34, ring start, end. */
|
||||||
{ VTYPE_PLAIN, { 0.0f, 0.0f, -25.0f } },
|
{ VTYPE_PLAIN, { 0.0f, 25.0f, 0.0f } },
|
||||||
|
|
||||||
{ VTYPE_PLAIN, { -9.0f, 4.5f, 10.0f } },
|
{ VTYPE_PLAIN, { -9.0f, -10.0f, 4.5f } },
|
||||||
{ VTYPE_PLAIN, { 9.0f, 4.5f, 10.0f } }, /* 36, inlet middle (for docking). */
|
{ VTYPE_PLAIN, { 9.0f, -10.0f, 4.5f } }, /* 36, inlet middle (for docking). */
|
||||||
{ VTYPE_PLAIN, { 9.0f, -4.5f, 10.0f } },
|
{ VTYPE_PLAIN, { 9.0f, -10.0f, -4.5f } },
|
||||||
{ VTYPE_PLAIN, { -9.0f, -4.5f, 10.0f } },
|
{ VTYPE_PLAIN, { -9.0f, -10.0f, -4.5f } },
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{ VTYPE_PLAIN, { 0.0f, 120.0f, 15.0f } }, /* 34, ring top. */
|
{ VTYPE_PLAIN, { 0.0f, 120.0f, 15.0f } }, /* 34, ring top. */
|
||||||
@ -774,7 +774,7 @@ static uint16 station1data[] = {
|
|||||||
PTYPE_QUADFLAT | RFLAG_XREF, 28, 29, 33, 32,
|
PTYPE_QUADFLAT | RFLAG_XREF, 28, 29, 33, 32,
|
||||||
PTYPE_QUADFLAT | RFLAG_XREF, 29, 26, 30, 33,
|
PTYPE_QUADFLAT | RFLAG_XREF, 29, 26, 30, 33,
|
||||||
|
|
||||||
PTYPE_TUBE | RFLAG_XREF, 0, 38, 34, 35, 1, 11500, 10000,
|
PTYPE_TUBE | RFLAG_XREF, 0, 38, 34, 35, 2, 11500, 10000,
|
||||||
|
|
||||||
PTYPE_SETCFLAG, 0x10,
|
PTYPE_SETCFLAG, 0x10,
|
||||||
PTYPE_QUADFLAT | RFLAG_INVISIBLE, 39, 38, 37, 36,
|
PTYPE_QUADFLAT | RFLAG_INVISIBLE, 39, 38, 37, 36,
|
||||||
|
@ -53,7 +53,7 @@ Model* const ppModel[] = {
|
|||||||
/* 80. */
|
/* 80. */
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/* 90, other people's ships. */
|
/* 90, other people's ships. */
|
||||||
&starport1model, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
&starport1model, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
/* 100, more sub-objects. */
|
/* 100, more sub-objects. */
|
||||||
&metalFrameTowerModel
|
&metalFrameTowerModel
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "l3d.h"
|
#include "l3d.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "star_system.h"
|
#include "star_system.h"
|
||||||
|
#include "space_station.h"
|
||||||
#include "sbre/sbre.h"
|
#include "sbre/sbre.h"
|
||||||
|
|
||||||
dWorldID Space::world;
|
dWorldID Space::world;
|
||||||
@ -97,7 +98,7 @@ static Frame* MakeFrameFor(StarSystem::SBody* sbody, Body* b, Frame* f) {
|
|||||||
rotFrame->m_astroBody = b;
|
rotFrame->m_astroBody = b;
|
||||||
b->SetFrame(rotFrame);
|
b->SetFrame(rotFrame);
|
||||||
return orbFrame;
|
return orbFrame;
|
||||||
} else {
|
} else if(supertype == StarSystem::SUPERTYPE_STAR) {
|
||||||
/* Stars want a single small non-rotating frame. */
|
/* Stars want a single small non-rotating frame. */
|
||||||
orbFrame = new Frame(f, sbody->name.c_str());
|
orbFrame = new Frame(f, sbody->name.c_str());
|
||||||
orbFrame->m_sbody = sbody;
|
orbFrame->m_sbody = sbody;
|
||||||
@ -105,6 +106,24 @@ static Frame* MakeFrameFor(StarSystem::SBody* sbody, Body* b, Frame* f) {
|
|||||||
orbFrame->SetRadius(sbody->GetMaxChildOrbitalDistance()*1.1);
|
orbFrame->SetRadius(sbody->GetMaxChildOrbitalDistance()*1.1);
|
||||||
b->SetFrame(orbFrame);
|
b->SetFrame(orbFrame);
|
||||||
return orbFrame;
|
return orbFrame;
|
||||||
|
} else if(supertype == StarSystem::SUPERTYPE_STARPORT) {
|
||||||
|
/*
|
||||||
|
* Space stations want non-rotating frame to some distance
|
||||||
|
* and a much closer rotating frame.
|
||||||
|
*/
|
||||||
|
frameRadius = 1000000.0; /* XXX No idea. */
|
||||||
|
orbFrame = new Frame(f, sbody->name.c_str());
|
||||||
|
orbFrame->m_sbody = sbody;
|
||||||
|
orbFrame->SetRadius(frameRadius ? frameRadius : 10*sbody->GetRadius());
|
||||||
|
|
||||||
|
assert(sbody->GetRotationPeriod() != 0);
|
||||||
|
rotFrame = new Frame(orbFrame, sbody->name.c_str());
|
||||||
|
rotFrame->SetRadius(5000.0);
|
||||||
|
rotFrame->SetAngVelocity(vector3d(0,2*M_PI/sbody->GetRotationPeriod(), 0));
|
||||||
|
b->SetFrame(rotFrame);
|
||||||
|
return orbFrame;
|
||||||
|
} else {
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +134,9 @@ void Space::GenBody(StarSystem::SBody* sbody, Frame* f) {
|
|||||||
if(sbody->GetSuperType() == StarSystem::SUPERTYPE_STAR) {
|
if(sbody->GetSuperType() == StarSystem::SUPERTYPE_STAR) {
|
||||||
Star* star = new Star(sbody);
|
Star* star = new Star(sbody);
|
||||||
b = star;
|
b = star;
|
||||||
|
} else if(sbody->type == StarSystem::TYPE_STARPORT_ORBITAL) {
|
||||||
|
SpaceStation* ss = new SpaceStation(SpaceStation::JJHOOP);
|
||||||
|
b = ss;
|
||||||
} else {
|
} else {
|
||||||
Planet* planet = new Planet(sbody);
|
Planet* planet = new Planet(sbody);
|
||||||
b = planet;
|
b = planet;
|
||||||
|
@ -145,6 +145,15 @@ static const struct SBodySubTypeInfo {
|
|||||||
StarSystem::SUPERTYPE_ROCKY_PLANET,
|
StarSystem::SUPERTYPE_ROCKY_PLANET,
|
||||||
{}, 100, "World with indigenous life and an oxygen atmosphere",
|
{}, 100, "World with indigenous life and an oxygen atmosphere",
|
||||||
"icons/object_planet_life.png"
|
"icons/object_planet_life.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StarSystem::SUPERTYPE_STARPORT,
|
||||||
|
{}, 0, "Orbital starport",
|
||||||
|
"icons/object_orbital_starport.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
StarSystem::SUPERTYPE_STARPORT,
|
||||||
|
{}, 0, "Starport",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -561,6 +570,13 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
/* Decide how infested the place is. */
|
||||||
|
const int dist = 1+MAX(abs(sector_x), abs(sector_y));
|
||||||
|
m_humanInfested = (fixed(1,2)+fixed(1,2)*rand.Fixed()) / dist;
|
||||||
|
printf("Infested %f\n", m_humanInfested.ToDouble());
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < m_numStars; i++) MakePlanetsAround(star[i]);
|
for(int i = 0; i < m_numStars; i++) MakePlanetsAround(star[i]);
|
||||||
|
|
||||||
if(m_numStars > 1) MakePlanetsAround(centGrav1);
|
if(m_numStars > 1) MakePlanetsAround(centGrav1);
|
||||||
@ -631,7 +647,7 @@ void StarSystem::MakePlanetsAround(SBody* primary) {
|
|||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
(*i)->name = primary->name+buf;
|
(*i)->name = primary->name+buf;
|
||||||
fixed d = ((*i)->orbMin + (*i)->orbMax) >> 1;
|
fixed d = ((*i)->orbMin + (*i)->orbMax) >> 1;
|
||||||
(*i)->PickPlanetType(primary, d, rand, true);
|
(*i)->PickPlanetType(this, primary, d, rand, true);
|
||||||
|
|
||||||
#ifdef DEBUG_DUMP
|
#ifdef DEBUG_DUMP
|
||||||
/*printf("%s: mass %f, semi-major axis %fAU, ecc %f\n",
|
/*printf("%s: mass %f, semi-major axis %fAU, ecc %f\n",
|
||||||
@ -641,7 +657,7 @@ void StarSystem::MakePlanetsAround(SBody* primary) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StarSystem::SBody::PickPlanetType(SBody* star, const fixed distToPrimary, MTRand& rand, bool genMoons) {
|
void StarSystem::SBody::PickPlanetType(StarSystem* system, SBody* star, const fixed distToPrimary, MTRand& rand, bool genMoons) {
|
||||||
fixed albedo = rand.Fixed() * fixed(1,2);
|
fixed albedo = rand.Fixed() * fixed(1,2);
|
||||||
fixed globalwarming = rand.Fixed() * fixed(9,10);
|
fixed globalwarming = rand.Fixed() * fixed(9,10);
|
||||||
/* Light planets have like.. no atmosphere. */
|
/* Light planets have like.. no atmosphere. */
|
||||||
@ -766,9 +782,30 @@ void StarSystem::SBody::PickPlanetType(SBody* star, const fixed distToPrimary, M
|
|||||||
buf[0] = '1'+(idx++);
|
buf[0] = '1'+(idx++);
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
(*i)->name = name+buf;
|
(*i)->name = name+buf;
|
||||||
(*i)->PickPlanetType(star, distToPrimary, rand, false);
|
(*i)->PickPlanetType(system, star, distToPrimary, rand, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Starports. */
|
||||||
|
if((averageTemp < CELSIUS+100) && (averageTemp > 100) &&
|
||||||
|
(rand.Fixed() < system->m_humanInfested)) {
|
||||||
|
SBody* sp = new SBody;
|
||||||
|
sp->type = TYPE_STARPORT_ORBITAL;
|
||||||
|
sp->seed = rand.Int32();
|
||||||
|
sp->tmp = 0;
|
||||||
|
sp->parent = this;
|
||||||
|
sp->rotationPeriod = fixed(1, 3600);
|
||||||
|
sp->averageTemp = this->averageTemp;
|
||||||
|
sp->mass = 0;
|
||||||
|
sp->name = "Starport";
|
||||||
|
fixed semiMajorAxis = fixed(1, 2000);
|
||||||
|
sp->orbit.eccentricity = 0;
|
||||||
|
sp->orbit.semiMajorAxis = semiMajorAxis.ToDouble()*AU;
|
||||||
|
sp->orbit.period = calc_orbital_period(sp->orbit.semiMajorAxis, this->mass.ToDouble()*EARTH_MASS);
|
||||||
|
sp->orbit.rotMatrix = matrix4x4d::Identity();
|
||||||
|
this->children.push_back(sp);
|
||||||
|
sp->orbMin = semiMajorAxis;
|
||||||
|
sp->orbMax = semiMajorAxis;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StarSystem::~StarSystem(void) {
|
StarSystem::~StarSystem(void) {
|
||||||
|
@ -64,6 +64,8 @@ public:
|
|||||||
TYPE_PLANET_METHANE_THICK_ATMOS,
|
TYPE_PLANET_METHANE_THICK_ATMOS,
|
||||||
TYPE_PLANET_HIGHLY_VOLCANIC,
|
TYPE_PLANET_HIGHLY_VOLCANIC,
|
||||||
TYPE_PLANET_INDIGENOUS_LIFE,
|
TYPE_PLANET_INDIGENOUS_LIFE,
|
||||||
|
TYPE_STARPORT_ORBITAL,
|
||||||
|
TYPE_STARPORT_SURFACE,
|
||||||
TYPE_MAX,
|
TYPE_MAX,
|
||||||
TYPE_STAR_MIN = TYPE_STAR_M,
|
TYPE_STAR_MIN = TYPE_STAR_M,
|
||||||
TYPE_STAR_MAX = TYPE_WHITE_DWARF
|
TYPE_STAR_MAX = TYPE_WHITE_DWARF
|
||||||
@ -71,7 +73,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum BodySuperType {
|
enum BodySuperType {
|
||||||
SUPERTYPE_NONE, SUPERTYPE_STAR, SUPERTYPE_ROCKY_PLANET, SUPERTYPE_GAS_GIANT
|
SUPERTYPE_NONE, SUPERTYPE_STAR, SUPERTYPE_ROCKY_PLANET, SUPERTYPE_GAS_GIANT, SUPERTYPE_STARPORT
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BodyStats {
|
struct BodyStats {
|
||||||
@ -83,6 +85,7 @@ public:
|
|||||||
friend class StarSystem;
|
friend class StarSystem;
|
||||||
~SBody(void);
|
~SBody(void);
|
||||||
void EliminateBadChildren(void); /* :D */
|
void EliminateBadChildren(void); /* :D */
|
||||||
|
void PickPlanetType(StarSystem*, SBody*, fixed distToPrimary, MTRand& drand, bool genMoons);
|
||||||
void PickPlanetType(SBody*, fixed distToPrimary, MTRand& drand, bool genMoons);
|
void PickPlanetType(SBody*, fixed distToPrimary, MTRand& drand, bool genMoons);
|
||||||
SBody* parent;
|
SBody* parent;
|
||||||
std::vector<SBody*> children;
|
std::vector<SBody*> children;
|
||||||
@ -127,6 +130,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
SBody* rootBody;
|
SBody* rootBody;
|
||||||
|
fixed m_humanInfested; /* 0 to 1 */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakePlanetsAround(SBody* primary);
|
void MakePlanetsAround(SBody* primary);
|
||||||
|
Loading…
Reference in New Issue
Block a user