Commit eab912f1 authored by Dario Seyb's avatar Dario Seyb

merged terrain

parents 7fad2e2f bb4838be
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
Geometry playerIconGeometry; Geometry playerIconGeometry;
std::map<Entity::Id, Entity> minimapItems; 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 hasAtmosphere = false);
bool startup() override; bool startup() override;
void shutdown() override; void shutdown() override;
......
...@@ -589,7 +589,7 @@ void precomputeAtmosphereLookupTextures(double molecularNumberDensity, ...@@ -589,7 +589,7 @@ void precomputeAtmosphereLookupTextures(double molecularNumberDensity,
} }
// Mass is in solar masses! // 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 hasAtmosphere) {
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion // Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
auto planetEntity = m_scene->create(); auto planetEntity = m_scene->create();
...@@ -609,7 +609,11 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, ...@@ -609,7 +609,11 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
planetTransform->scale = glm::dvec3(solarToWorld(r), solarToWorld(r), solarToWorld(r)); planetTransform->scale = glm::dvec3(solarToWorld(r), solarToWorld(r), solarToWorld(r));
planetTransform->position = pos; 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 // Add an atmosphere to the planet
...@@ -625,40 +629,45 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, ...@@ -625,40 +629,45 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
6360000, 6420000, 8000, 0.76, transmittance, inscattering); 6360000, 6420000, 8000, 0.76, transmittance, inscattering);
} }
atmosphereMat.mainTexture = transmittance; if (hasAtmosphere) {
atmosphereMat.specularSmoothnessTexture = inscattering; atmosphereMat.mainTexture = transmittance;
atmosphereMat.emissiveColor = { Rg - 10, Rt + 80, 0, 0 }; atmosphereMat.specularSmoothnessTexture = inscattering;
atmosphereMat.emissiveColor = { Rg - 10, Rt + 120, 0, 0 };
auto atmosphere = m_scene->create(); auto atmosphere = m_scene->create();
auto atmosphereTransform = atmosphere.assign<Transform>(); auto atmosphereTransform = atmosphere.assign<Transform>();
atmosphereTransform->parent = planetTransform; atmosphereTransform->parent = planetTransform;
atmosphere.assign<Drawable>(atmosphereGeom, atmosphereMat, 0, m_renderer->getRenderPassId("Main"_sh));
atmosphereTransform->scale = glm::dvec3(Rt);
// Add simple water as well atmosphere.assign<Drawable>(atmosphereGeom, atmosphereMat, 0, m_renderer->getRenderPassId("Main"_sh));
auto water = m_scene->create(); atmosphereTransform->scale = glm::dvec3(Rt);
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; if (isEarthlike && hasWater) {
moonTransform->scale = glm::dvec3(solarToWorld(r*0.5f), solarToWorld(r*0.5f), solarToWorld(r*0.5f)); // 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: // Add the transformation matrixes to calculate the trajectory from a standard circle:
double b = a*sqrt(1 - e*e); double b = a*sqrt(1 - e*e);
......
...@@ -264,14 +264,16 @@ void AtmosphereTestScene::switchToMainScene() { ...@@ -264,14 +264,16 @@ void AtmosphereTestScene::switchToMainScene() {
// mass radius // mass radius
//e //e
// a i N w // 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); mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, true, false, true, true);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, 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, true);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0); earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, true, true, true, true);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0); mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, true, true, true, true);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0); jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, false, false, true, false);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0); saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, false, false, true, false);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0); uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, false, false, true, false);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, false, false, true, false);
m_player->attachToParent(earth); m_player->attachToParent(earth);
double r = earth.component<Transform>()->scale.x; double r = earth.component<Transform>()->scale.x;
......
...@@ -91,14 +91,14 @@ bool OrbitsScene::startup() { ...@@ -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 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 // 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); 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); 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); 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); 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); 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); 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); 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); 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 // 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