Commit bb4838be authored by u's avatar u

added creation of different planets (earthlike, earthlike with no water, gas)

parent 681a07c1
......@@ -47,7 +47,7 @@ public:
Geometry playerIconGeometry;
std::map<Entity::Id, Entity> minimapItems;
Entity addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool generateAtmosphereLookups = false);
Entity addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool isEarthlike, bool hasWater, bool hasMoon, bool generateAtmosphereLookups = false);
bool startup() override;
void shutdown() override;
......
......@@ -532,7 +532,7 @@ void precomputeAtmosphereLookupTextures(double molecularNumberDensity,
}
// Mass is in solar masses!
Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool generateAtmosphereLookups) {
Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool isEarthlike, bool hasWater, bool hasMoon, bool generateAtmosphereLookups) {
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
auto planetEntity = m_scene->create();
......@@ -552,7 +552,11 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
planetTransform->scale = glm::dvec3(solarToWorld(r), solarToWorld(r), solarToWorld(r));
planetTransform->position = pos;
planetEntity.assign<Drawable>(defaultGeom, earthMat, 2, m_renderer->getRenderPassId("Main"_sh));
if (isEarthlike) {
planetEntity.assign<Drawable>(defaultGeom, earthMat, 2, m_renderer->getRenderPassId("Main"_sh));
} else {
planetEntity.assign<Drawable>(defaultGeom, jupiterMat, 2, m_renderer->getRenderPassId("Main"_sh));
}
// Add an atmosphere to the planet
......@@ -577,28 +581,31 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
atmosphere.assign<Drawable>(defaultGeom, atmosphereMat, 0, m_renderer->getRenderPassId("Main"_sh));
atmosphereTransform->scale = planetTransform->scale * 1.05;
// Add simple water as well
auto water = m_scene->create();
auto waterTransform = water.assign<Transform>();
waterTransform->parent = planetTransform;
water.assign<Drawable>(defaultGeom, waterMat, 1, 1);
waterTransform->scale = planetTransform->scale * 1.0;
// Let's add a moon!
auto moon = m_scene->create();
auto moonTransform = moon.assign<Transform>();
moonTransform->parent = planetTransform;
moon.assign<Drawable>(defaultGeom, moonMat, 0, m_renderer->getRenderPassId("Main"_sh));
auto moonComponent = moon.assign<Planet>("Moon", 0.000000036939686, 0.003505316091954, 0.205633, 0.08, 0.0898041713, 5.4583095414, 1.671072474, 0 );
// change starting point
//float t = static_cast <float> (rand()) / static_cast <float> (RAND_MAX / 10.0f);
glm::dvec3 moonPos = applyKepler(moonComponent, 0);
moonPos = glm::dvec3(AUToWorld(moonPos.x), AUToWorld(moonPos.y), AUToWorld(moonPos.z));
moonTransform->position = moonPos;
moonTransform->scale = glm::dvec3(solarToWorld(r*0.5f), solarToWorld(r*0.5f), solarToWorld(r*0.5f));
if (isEarthlike && hasWater) {
// Add simple water as well
auto water = m_scene->create();
auto waterTransform = water.assign<Transform>();
waterTransform->parent = planetTransform;
water.assign<Drawable>(defaultGeom, waterMat, 1, 1);
waterTransform->scale = planetTransform->scale * 1.0;
}
if (hasMoon) {
// Let's add a moon!
auto moon = m_scene->create();
auto moonTransform = moon.assign<Transform>();
moonTransform->parent = planetTransform;
moon.assign<Drawable>(defaultGeom, moonMat, 0, m_renderer->getRenderPassId("Main"_sh));
auto moonComponent = moon.assign<Planet>("Moon", 0.000000036939686, 0.003505316091954, 0.205633, 0.08, 0.0898041713, 5.4583095414, 1.671072474, 0 );
// change starting point
//float t = static_cast <float> (rand()) / static_cast <float> (RAND_MAX / 10.0f);
glm::dvec3 moonPos = applyKepler(moonComponent, 0);
moonPos = glm::dvec3(AUToWorld(moonPos.x), AUToWorld(moonPos.y), AUToWorld(moonPos.z));
moonTransform->position = moonPos;
moonTransform->scale = glm::dvec3(solarToWorld(r*0.5f), solarToWorld(r*0.5f), solarToWorld(r*0.5f));
}
// Add the transformation matrixes to calculate the trajectory from a standard circle:
double b = a*sqrt(1 - e*e);
......
......@@ -264,14 +264,14 @@ void AtmosphereTestScene::switchToMainScene() {
// mass radius
//e
// a i N w
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, false);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0);
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, true, false, true);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0, true, false, true);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, true, true, true, false);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, true, true, true);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, false, false, true);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, false, false, true);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, false, false, true);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, false, false, true);
m_player->attachToParent(earth);
double r = earth.component<Transform>()->scale.x;
......
......@@ -91,14 +91,14 @@ bool OrbitsScene::startup() {
// Mass in solar masses, Radius in solar radii, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
// mass radius e a i N w
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0);
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, true, true, true);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0, true, true, true);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, true, true, true);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, true, true, true);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, true, true, true);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, true, true, true);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, true, true, true);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, true, true, true);
// Load a sound and enable 3D positioning for it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment