make orbital starports in system generation

git-svn-id: https://pioneer.svn.sourceforge.net/svnroot/pioneer/trunk@123 e632f14b-6550-0410-b89e-a82653faca30
master
tompox 2008-09-10 21:28:48 +00:00
parent a1a3dd1f86
commit a7c017aa8c
5 changed files with 97 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -9,6 +9,7 @@
#include "Pi.h"
#include "Player.h"
#include "StarSystem.h"
#include "SpaceStation.h"
#include "sbre/sbre.h"
dWorldID Space::world;
@ -98,7 +99,7 @@ static Frame *MakeFrameFor(StarSystem::SBody *sbody, Body *b, Frame *f)
b->SetFrame(rotFrame);
return orbFrame;
}
else /*if (supertype == StarSystem::SUPERTYPE_STAR)*/ {
else if (supertype == StarSystem::SUPERTYPE_STAR) {
// stars want a single small non-rotating frame
orbFrame = new Frame(f, sbody->name.c_str());
orbFrame->m_sbody = sbody;
@ -106,7 +107,24 @@ static Frame *MakeFrameFor(StarSystem::SBody *sbody, Body *b, Frame *f)
orbFrame->SetRadius(sbody->GetMaxChildOrbitalDistance()*1.1);
b->SetFrame(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 NFI!
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);//(1.1*sbody->GetRadius());
rotFrame->SetAngVelocity(vector3d(0,2*M_PI/sbody->GetRotationPeriod(),0));
b->SetFrame(rotFrame);
return orbFrame;
} else {
assert(0);
}
}
void Space::GenBody(StarSystem::SBody *sbody, Frame *f)
@ -117,6 +135,9 @@ void Space::GenBody(StarSystem::SBody *sbody, Frame *f)
if (sbody->GetSuperType() == StarSystem::SUPERTYPE_STAR) {
Star *star = new Star(sbody);
b = star;
} else if (sbody->type == StarSystem::TYPE_STARPORT_ORBITAL) {
SpaceStation *ss = new SpaceStation(SpaceStation::JJHOOP);
b = ss;
} else {
Planet *planet = new Planet(sbody);
b = planet;

View File

@ -128,6 +128,13 @@ static const struct SBodySubTypeInfo {
StarSystem::SUPERTYPE_ROCKY_PLANET,
{}, 100, "World with indigenous life and an oxygen atmosphere",
"icons/object_planet_life.png"
}, {
StarSystem::SUPERTYPE_STARPORT,
{}, 0, "Orbital starport",
"icons/object_orbital_starport.png"
}, {
StarSystem::SUPERTYPE_STARPORT,
{}, 0, "Starport",
}
};
@ -576,6 +583,12 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx)
}
}
{ /* decide how infested the joint 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]);
if (m_numStars > 1) MakePlanetsAround(centGrav1);
@ -648,7 +661,7 @@ void StarSystem::MakePlanetsAround(SBody *primary)
buf[2] = 0;
(*i)->name = primary->name+buf;
fixed d = ((*i)->orbMin + (*i)->orbMax) >> 1;
(*i)->PickPlanetType(primary, d, rand, true);
(*i)->PickPlanetType(this, primary, d, rand, true);
#ifdef DEBUG_DUMP
// printf("%s: mass %f, semi-major axis %fAU, ecc %f\n", (*i)->name.c_str(), (*i)->mass.ToDouble(), (*i)->orbit.semiMajorAxis/AU, (*i)->orbit.eccentricity);
@ -657,7 +670,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 globalwarming = rand.Fixed() * fixed(9,10);
@ -783,9 +796,31 @@ void StarSystem::SBody::PickPlanetType(SBody *star, const fixed distToPrimary, M
buf[0] = '1'+(idx++);
buf[1] = 0;
(*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()

View File

@ -67,6 +67,8 @@ public:
TYPE_PLANET_METHANE_THICK_ATMOS,
TYPE_PLANET_HIGHLY_VOLCANIC,
TYPE_PLANET_INDIGENOUS_LIFE,
TYPE_STARPORT_ORBITAL,
TYPE_STARPORT_SURFACE,
TYPE_MAX,
TYPE_STAR_MIN = TYPE_STAR_M,
TYPE_STAR_MAX = TYPE_WHITE_DWARF
@ -74,7 +76,7 @@ public:
};
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 {
@ -87,7 +89,7 @@ public:
~SBody();
void EliminateBadChildren();
void PickPlanetType(SBody *, fixed distToPrimary, MTRand &drand, bool genMoons);
void PickPlanetType(StarSystem *, SBody *, fixed distToPrimary, MTRand &drand, bool genMoons);
SBody *parent;
std::vector<SBody*> children;
@ -127,6 +129,7 @@ public:
};
SBody *rootBody;
fixed m_humanInfested; // 0 to 1
private:
void MakePlanetsAround(SBody *primary);
void MakeRandomStar(SBody *sbody, MTRand &rand);

View File

@ -618,48 +618,48 @@ Model ship2model = { 1.0f, 35.0f, 98, ship2vtx1, 120, 1, ship2vtx2, 10,
static PlainVertex station1vtx1[] = {
{ VTYPE_PLAIN, { -15.0f, 30.0f, 20.0f } }, // 6, front octagon
{ VTYPE_PLAIN, { 15.0f, 30.0f, 20.0f } },
{ VTYPE_PLAIN, { 30.0f, 15.0f, 20.0f } },
{ VTYPE_PLAIN, { 30.0f, -15.0f, 20.0f } },
{ VTYPE_PLAIN, { 15.0f, -30.0f, 20.0f } },
{ VTYPE_PLAIN, { -15.0f, -30.0f, 20.0f } },
{ VTYPE_PLAIN, { -15.0f, -20.0f, 30.0f } }, // 6, front octagon
{ VTYPE_PLAIN, { 15.0f, -20.0f, 30.0f } },
{ VTYPE_PLAIN, { 30.0f, -20.0f, 15.0f } },
{ VTYPE_PLAIN, { 30.0f, -20.0f, -15.0f } },
{ VTYPE_PLAIN, { 15.0f, -20.0f, -30.0f } },
{ VTYPE_PLAIN, { -15.0f, -20.0f, -30.0f } },
{ VTYPE_PLAIN, { -15.0f, 30.0f, -20.0f } }, // 12, back octagon
{ VTYPE_PLAIN, { 15.0f, 30.0f, -20.0f } },
{ VTYPE_PLAIN, { 30.0f, 15.0f, -20.0f } },
{ VTYPE_PLAIN, { 30.0f, -15.0f, -20.0f } },
{ VTYPE_PLAIN, { 15.0f, -30.0f, -20.0f } },
{ VTYPE_PLAIN, { -15.0f, -30.0f, -20.0f } },
{ VTYPE_PLAIN, { -15.0f, 20.0f, 30.0f } }, // 12, back octagon
{ VTYPE_PLAIN, { 15.0f, 20.0f, 30.0f } },
{ VTYPE_PLAIN, { 30.0f, 20.0f, 15.0f } },
{ VTYPE_PLAIN, { 30.0f, 20.0f, -15.0f } },
{ VTYPE_PLAIN, { 15.0f, 20.0f, -30.0f } },
{ VTYPE_PLAIN, { -15.0f, 20.0f, -30.0f } },
{ VTYPE_PLAIN, { -10.0f, 5.0f, 20.0f } }, // 18, inlet front
{ VTYPE_PLAIN, { 10.0f, 5.0f, 20.0f } },
{ VTYPE_PLAIN, { 10.0f, -5.0f, 20.0f } },
{ VTYPE_PLAIN, { -10.0f, -5.0f, 20.0f } },
{ VTYPE_PLAIN, { -10.0f, -20.0f, 5.0f } }, // 18, inlet front
{ VTYPE_PLAIN, { 10.0f, -20.0f, 5.0f } },
{ VTYPE_PLAIN, { 10.0f, -20.0f, -5.0f } },
{ VTYPE_PLAIN, { -10.0f, -20.0f, -5.0f } },
{ VTYPE_PLAIN, { -10.0f, 5.0f, 0.0f } }, // 22, inlet rear
{ VTYPE_PLAIN, { 10.0f, 5.0f, 0.0f } },
{ VTYPE_PLAIN, { 10.0f, -5.0f, 0.0f } },
{ VTYPE_PLAIN, { -10.0f, -5.0f, 0.0f } },
{ VTYPE_PLAIN, { -10.0f, 0.0f, 5.0f } }, // 22, inlet rear
{ VTYPE_PLAIN, { 10.0f, 0.0f, 5.0f } },
{ VTYPE_PLAIN, { 10.0f, 0.0f, -5.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 } },
{ 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, { 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 } }, // 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, { 0.0f, 0.0f, 25.0f } }, // 34, ring start, end
{ VTYPE_PLAIN, { 0.0f, 0.0f, -25.0f } },
{ VTYPE_PLAIN, { 0.0f, -25.0f, 0.0f } }, // 34, ring start, end
{ VTYPE_PLAIN, { 0.0f, 25.0f, 0.0f } },
{ VTYPE_PLAIN, { -9.0f, 4.5f, 10.0f } }, // 36, inlet middle (for docking)
{ VTYPE_PLAIN, { 9.0f, 4.5f, 10.0f } },
{ VTYPE_PLAIN, { 9.0f, -4.5f, 10.0f } },
{ VTYPE_PLAIN, { -9.0f, -4.5f, 10.0f } },
{ VTYPE_PLAIN, { -9.0f, -10.0f, 4.5f } }, // 36, inlet middle (for docking)
{ VTYPE_PLAIN, { 9.0f, -10.0f, 4.5f } },
{ VTYPE_PLAIN, { 9.0f, -10.0f, -4.5f } },
{ VTYPE_PLAIN, { -9.0f, -10.0f, -4.5f } },
/* { VTYPE_PLAIN, { 0.0f, 120.0f, 15.0f } }, // 34, ring top
@ -753,7 +753,7 @@ static uint16 station1data[] = {
PTYPE_QUADFLAT | RFLAG_XREF, 28, 29, 33, 32,
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_QUADFLAT | RFLAG_INVISIBLE, 39, 38, 37, 36,