Commit 118bfc52 authored by Dario Seyb's avatar Dario Seyb

merged linux fixes

parent 9bbb31e2
......@@ -12,7 +12,7 @@ if(MSVC)
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-long-long -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wno-long-long -Wno-reorder -pedantic")
endif()
......
#pragma once
#include <unordered_map>
#include <map>
#include <vector>
#include <engine/core/Context.hpp>
......@@ -27,7 +28,7 @@ private:
typedef std::function<void(const void*)> EventCallback;
typedef std::unordered_map< EventSubscriberId, std::shared_ptr<EventCallbackWrapperBase> > EventMap;
typedef std::map< EventSubscriberId, std::shared_ptr<EventCallbackWrapperBase> > EventMap;
std::unordered_map< BaseEvent::EventId, EventMap> m_registeredCallbacks;
......@@ -36,10 +37,10 @@ public:
CONSTRUCT_SYSTEM(EventSystem), m_nextId(0) { }
template<typename E, typename Callback>
inline EventSubscriberId subscribe(Callback callback) {
inline EventSubscriberId subscribe(Callback callback, int priorityOffset = 0) {
auto eventId = Event<E>::id();
auto callbacksIt = m_registeredCallbacks.find(eventId);
EventSubscriberId resultId = m_nextId++;
EventSubscriberId resultId = m_nextId++ + priorityOffset*10;
if (callbacksIt == m_registeredCallbacks.end()) {
m_registeredCallbacks[eventId] = EventMap();
}
......@@ -49,8 +50,8 @@ public:
}
template<StringHash hash, typename Callback>
inline EventSubscriberId subscribe(Callback callback) {
return subscribe<SEvent<hash>>([callback](const SEvent<hash>& /*e*/) { callback(); });
inline EventSubscriberId subscribe(Callback callback, int priorityOffset = 0) {
return subscribe<SEvent<hash>>([callback](const SEvent<hash>& /*e*/) { callback(); }, priorityOffset);
}
template<typename E>
......@@ -88,4 +89,4 @@ public:
bool startup() override;
void shutdown() override;
};
\ No newline at end of file
};
......@@ -22,9 +22,9 @@ using namespace ACGL::Utils;
const glm::vec2 SHADOW_MAP_RESOLUTION = {512, 512};
glm::mat4 interpolate(TransformData a, TransformData b, double t, glm::dvec3 camPos) {
a.pos = a.pos - camPos;
b.pos = b.pos - camPos;
glm::vec3 pos = a.pos + (b.pos - a.pos) * t;
a.pos = a.pos - camPos;
b.pos = b.pos - camPos;
glm::vec3 pos = a.pos + (b.pos - a.pos) * t;
glm::quat rot = glm::slerp(a.rot, b.rot, static_cast<float>(t));
glm::vec3 s = a.scale + (b.scale - a.scale) * t;
......@@ -80,50 +80,50 @@ bool RendererSystem::startup() {
m_txaaHistoryBuffer->validate();
// Create two VABs to store transform feedback vertices. Size is a bit tricky because nobody knows how much
// vertices the tessellation shader creates.
// First Buffer
m_transformFeedbackVAO = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO->attachAllAttributes(m_transformFeedbackBuffer);
// Create two VABs to store transform feedback vertices. Size is a bit tricky because nobody knows how much
// vertices the tessellation shader creates.
// First Buffer
m_transformFeedbackVAO = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO->attachAllAttributes(m_transformFeedbackBuffer);
m_transformFeedbackBuffer->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 *3*3*2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO->bind();
m_transformFeedbackBuffer->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 *3*3*2, NULL, GL_DYNAMIC_COPY);
// Second buffer
m_transformFeedbackVAO2 = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer2 = SharedArrayBuffer(new ArrayBuffer());
// Second buffer
m_transformFeedbackVAO2 = SharedVertexArrayObject(new VertexArrayObject(GL_TRIANGLES));
m_transformFeedbackBuffer2 = SharedArrayBuffer(new ArrayBuffer());
m_transformFeedbackBuffer2->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackBuffer2->defineAttribute("gNormal", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gPosition", GL_FLOAT, 3);
m_transformFeedbackBuffer2->defineAttribute("gTexCoord", GL_FLOAT, 2);
m_transformFeedbackVAO2->attachAllAttributes(m_transformFeedbackBuffer2);
m_transformFeedbackVAO2->attachAllAttributes(m_transformFeedbackBuffer2);
m_transformFeedbackBuffer2->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
m_transformFeedbackBuffer2->bind(GL_TRANSFORM_FEEDBACK_BUFFER);
m_transformFeedbackVAO2->bind();
m_transformFeedbackBuffer2->setData(GL_TRANSFORM_FEEDBACK_BUFFER, 300000 * 3 * 3 * 2, NULL, GL_DYNAMIC_COPY);
// Feedback objects
Feedback = 0;
glGenTransformFeedbacks(1, &Feedback);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
m_transformFeedbackBuffer->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
// Feedback objects
Feedback = 0;
glGenTransformFeedbacks(1, &Feedback);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback);
m_transformFeedbackBuffer->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
Feedback2 = 0;
glGenTransformFeedbacks(1, &Feedback2);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback2);
m_transformFeedbackBuffer2->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
Feedback2 = 0;
glGenTransformFeedbacks(1, &Feedback2);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, Feedback2);
m_transformFeedbackBuffer2->bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
m_deferredCombineProgram = ShaderProgramFileManager::the()->get(ShaderProgramCreator("DeferredCombine"));
......@@ -132,12 +132,12 @@ bool RendererSystem::startup() {
m_shadowMapProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("ShadowMap"));
m_txaaProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TXAA").fragmentDataLocations(m_secondaryCompositingBuffer->getAttachmentLocations()));
m_tfShaderProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TerrainTransformFeedback"));
m_tfShaderProg = ShaderProgramFileManager::the()->get(ShaderProgramCreator("TerrainTransformFeedback"));
char * outs[] = { "gNormal", "gPosition", "gTexCoord"};
glTransformFeedbackVaryings(m_tfShaderProg->getObjectName(), 3, outs, GL_INTERLEAVED_ATTRIBS);
m_tfShaderProg->link();
char * outs[] = { "gNormal", "gPosition", "gTexCoord"};
glTransformFeedbackVaryings(m_tfShaderProg->getObjectName(), 3, outs, GL_INTERLEAVED_ATTRIBS);
m_tfShaderProg->link();
m_events->subscribe<ResizeWindowEvent>([this](const ResizeWindowEvent &e) {
glViewport(0, 0, e.newSize.x, e.newSize.y);
......@@ -615,13 +615,13 @@ void RendererSystem::shutdown() {
}
glm::mat4 RendererSystem::getProjectionMatrix() {
return aaProj;
return aaProj;
}
GLfloat RendererSystem::getDepthAtPixel(int x, int y) {
m_gBufferObject->bind();
GLfloat depth;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
return depth;
};
\ No newline at end of file
m_gBufferObject->bind();
GLfloat depth;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
return depth;
};
......@@ -20,26 +20,26 @@
#include <glm/gtx/transform.hpp>
bool OrbitalSimulationSystem::startup() {
RESOLVE_DEPENDENCY(m_events);
RESOLVE_DEPENDENCY(m_scene);
RESOLVE_DEPENDENCY(m_renderer);
RESOLVE_DEPENDENCY(m_events);
RESOLVE_DEPENDENCY(m_scene);
RESOLVE_DEPENDENCY(m_renderer);
m_events->subscribe<SimulateEvent>([this](const SimulateEvent &e) { simulateOrbitals(e.dt, e.totalTime); });
m_events->subscribe<SimulateEvent>([this](const SimulateEvent &e) { simulateOrbitals(e.dt, e.totalTime); });
// Make a default geometry (TODO)
auto vaoSphere = VertexArrayObjectCreator("icosphere2.obj").create();
auto texture = Texture2DFileManager::the()->get(Texture2DCreator("checkerboard.png"));
// Make a default geometry (TODO)
auto vaoSphere = VertexArrayObjectCreator("icosphere2.obj").create();
auto texture = Texture2DFileManager::the()->get(Texture2DCreator("checkerboard.png"));
//auto texture = Texture2DFileManager::the()->get(Texture2DCreator("clownfishBunny.png"));
// Debug lines
auto vaoCircle = VertexArrayObjectCreator("circle2.obj").create();
// Debug lines
auto vaoCircle = VertexArrayObjectCreator("circle2.obj").create();
orbitTorus = { vaoCircle };
orbitTorus.vao->setMode(GL_LINES);
defaultGeom = { vaoSphere };
defaultGeom.vao->setMode(GL_PATCHES);
orbitTorus = { vaoCircle };
orbitTorus.vao->setMode(GL_LINES);
defaultGeom = { vaoSphere };
defaultGeom.vao->setMode(GL_PATCHES);
auto pbrShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("PBR")
auto pbrShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("PBR")
.attributeLocations(vaoSphere->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
......@@ -100,95 +100,94 @@ bool OrbitalSimulationSystem::startup() {
glm::dvec3 OrbitalSimulationSystem::applyKepler(Planet::Handle planet, float dt) {
// compute the mean anomaly
// compute the mean anomaly
double meanAnomaly = planet->M0 + planet->dailyMotion * (dt);
meanAnomaly = meanAnomaly - 2 * PI * floor(meanAnomaly / (2 * PI)); // Normalize angle
planet->M0 = meanAnomaly;
double meanAnomaly = planet->M0 + planet->dailyMotion * (dt);
meanAnomaly = meanAnomaly - 2 * PI * floor(meanAnomaly / (2 * PI)); // Normalize angle
planet->M0 = meanAnomaly;
//meanAnomaly = 0;
//meanAnomaly = 0;
// Compute the eccentric anomaly
double eccentricAnomaly = meanAnomaly + planet->eccentricity * sin(meanAnomaly) * (1.0 + planet->eccentricity * cos(meanAnomaly));
// Compute the eccentric anomaly
double eccentricAnomaly = meanAnomaly + planet->eccentricity * sin(meanAnomaly) * (1.0 + planet->eccentricity * cos(meanAnomaly));
if (planet->eccentricity > 0.06) {
int limit = 10;
double E_0 = eccentricAnomaly;
double E_1 = E_0;
do {
E_0 = E_1;
E_1 = E_0 - (E_0 - planet->eccentricity * sin(E_0) - meanAnomaly) / (1 - planet->eccentricity * cos(E_0));
limit--;
} while (fabs(E_1 - E_0) > 0.000000001 && limit > 0);
eccentricAnomaly = E_1;
}
if (planet->eccentricity > 0.06) {
int limit = 10;
double E_0 = eccentricAnomaly;
double E_1 = E_0;
do {
E_0 = E_1;
E_1 = E_0 - (E_0 - planet->eccentricity * sin(E_0) - meanAnomaly) / (1 - planet->eccentricity * cos(E_0));
limit--;
} while (fabs(E_1 - E_0) > 0.000000001 && limit > 0);
eccentricAnomaly = E_1;
}
double xv = planet->semimajor * (cos(eccentricAnomaly) - planet->eccentricity);
double yv = planet->semimajor * (sqrt(1.0 - planet->eccentricity * planet->eccentricity) * sin(eccentricAnomaly));
double xv = planet->semimajor * (cos(eccentricAnomaly) - planet->eccentricity);
double yv = planet->semimajor * (sqrt(1.0 - planet->eccentricity * planet->eccentricity) * sin(eccentricAnomaly));
// Calculate the true anomaly
double trueAnomaly = atan2(yv, xv);
// Calculate the true anomaly
double trueAnomaly = atan2(yv, xv);
// Radial distance to sun
double r = sqrt(xv*xv + yv*yv);
// Radial distance to sun
double r = sqrt(xv*xv + yv*yv);
glm::dvec3 position;
glm::dvec3 position;
position.x = r*(cos(planet->ascendingNode)*cos(planet->longitudePerihelion + trueAnomaly) -
sin(planet->ascendingNode)*sin(planet->longitudePerihelion + trueAnomaly)*cos(planet->inclination));
position.x = r*(cos(planet->ascendingNode)*cos(planet->longitudePerihelion + trueAnomaly) -
sin(planet->ascendingNode)*sin(planet->longitudePerihelion + trueAnomaly)*cos(planet->inclination));
position.z = r*(sin(planet->ascendingNode)*cos(planet->longitudePerihelion + trueAnomaly) +
cos(planet->ascendingNode)*sin(planet->longitudePerihelion + trueAnomaly)*cos(planet->inclination));
position.z = r*(sin(planet->ascendingNode)*cos(planet->longitudePerihelion + trueAnomaly) +
cos(planet->ascendingNode)*sin(planet->longitudePerihelion + trueAnomaly)*cos(planet->inclination));
position.y = r*(sin(planet->longitudePerihelion + trueAnomaly)*sin(planet->inclination));
position.y = r*(sin(planet->longitudePerihelion + trueAnomaly)*sin(planet->inclination));
return position;
return position;
}
void OrbitalSimulationSystem::simulateOrbitals(float dt, float totalTime) {
auto planets = m_scene->entities_with_components<Planet, Transform>();
auto planets = m_scene->entities_with_components<Planet, Transform>();
Planet::Handle planet;
Transform::Handle transform;
glm::dvec3 position;
Planet::Handle planet;
Transform::Handle transform;
glm::dvec3 position;
for (auto p : planets) {
p.unpack<Planet, Transform>(planet, transform);
for (auto p : planets) {
p.unpack<Planet, Transform>(planet, transform);
// dt here is interpreted as a DAY NUMBER. TODO: Conversion/scale
position = applyKepler(planet, dt*0.1 );
position = glm::dvec3(AUToWorld(position.x), AUToWorld(position.y), AUToWorld(position.z));
// dt here is interpreted as a DAY NUMBER. TODO: Conversion/scale
position = applyKepler(planet, dt*0.1 );
position = glm::dvec3(AUToWorld(position.x), AUToWorld(position.y), AUToWorld(position.z));
// TODO: Natural conversion from au to world coords
transform->position = glm::dvec3(position.x, position.y, position.z);
}
// TODO: Natural conversion from au to world coords
transform->position = glm::dvec3(position.x, position.y, position.z);
}
}
// 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) {
// 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 planetTransform = planetEntity.assign<Transform>();
planetTransform->parent = sun;
//planetEntity.assign<Light>(glm::vec4(1, 1, 1, 1), glm::vec3(1, 0, 0), false);
auto planetEntity = m_scene->create();
auto planetTransform = planetEntity.assign<Transform>();
planetTransform->parent = sun;
//planetEntity.assign<Light>(glm::vec4(1, 1, 1, 1), glm::vec3(1, 0, 0), false);
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
auto planetComponent = planetEntity.assign<Planet>(n, m, r, e, a, i, N, P, T);
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
auto planetComponent = planetEntity.assign<Planet>(n, m, r, e, a, i, N, P, T);
// Move the planet to the right position:
glm::dvec3 pos = applyKepler(planetComponent, 0);
pos = glm::dvec3(AUToWorld(pos.x), AUToWorld(pos.y), AUToWorld(pos.z));
// Move the planet to the right position:
glm::dvec3 pos = applyKepler(planetComponent, 0);
pos = glm::dvec3(AUToWorld(pos.x), AUToWorld(pos.y), AUToWorld(pos.z));
planetTransform->scale = glm::dvec3(solarToWorld(r), solarToWorld(r), solarToWorld(r));
planetTransform->position = pos;
planetTransform->position = pos;
planetEntity.assign<Drawable>(defaultGeom, planetMat, 2);
planetEntity.assign<Drawable>(defaultGeom, planetMat, 2);
// Add an atmosphere to the planet
auto atmosphere = m_scene->create();
......@@ -204,66 +203,66 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
water.assign<Drawable>(defaultGeom, waterMat, 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, planetMat);
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);
pos = applyKepler(moonComponent, 0);
pos = glm::dvec3(AUToWorld(pos.x), AUToWorld(pos.y), AUToWorld(pos.z));
moonTransform->position = pos;
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);
double distLength = AUToWorld(sqrt(a*a - b*b));
glm::dvec3 dist = planetTransform->position * (distLength / glm::length(planetTransform->position));
glm::dvec3 tScale = glm::dvec3(AUToWorld(b), 1, AUToWorld(a));
glm::dmat4 tRot = glm::rotate<double>(P, glm::dvec3( 0, -1, 0));
tRot = tRot * glm::rotate<double>(i, glm::dvec3(-1, 0, 0));
auto traj = m_scene->create();
auto trajTransform = traj.assign<Transform>();
auto drawable = traj.assign<Drawable>(orbitTorus, trajectoryMat);
drawable->visible = false;
trajTransform->rotation = tRot;
trajTransform->scale = tScale;
trajTransform->position = -dist;
trajectories.push_back(traj);
return planetEntity;
// Let's add a moon!
auto moon = m_scene->create();
auto moonTransform = moon.assign<Transform>();
moonTransform->parent = planetTransform;
moon.assign<Drawable>(defaultGeom, planetMat);
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);
pos = applyKepler(moonComponent, 0);
pos = glm::dvec3(AUToWorld(pos.x), AUToWorld(pos.y), AUToWorld(pos.z));
moonTransform->position = pos;
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);
double distLength = AUToWorld(sqrt(a*a - b*b));
glm::dvec3 dist = planetTransform->position * (distLength / glm::length(planetTransform->position));
glm::dvec3 tScale = glm::dvec3(AUToWorld(b), 1, AUToWorld(a));
glm::dmat4 tRot = glm::rotate<double>(P, glm::dvec3( 0, -1, 0));
tRot = tRot * glm::rotate<double>(i, glm::dvec3(-1, 0, 0));
auto traj = m_scene->create();
auto trajTransform = traj.assign<Transform>();
auto drawable = traj.assign<Drawable>(orbitTorus, trajectoryMat);
drawable->visible = false;
trajTransform->rotation = tRot;
trajTransform->scale = tScale;
trajTransform->position = -dist;
trajectories.push_back(traj);
return planetEntity;
}
void OrbitalSimulationSystem::showTrajectories() {
for (Entity e : trajectories) {
e.component<Drawable>()->visible = !e.component<Drawable>()->visible;
}
for (Entity e : trajectories) {
e.component<Drawable>()->visible = !e.component<Drawable>()->visible;
}
}
// Right now planets are 10 times closer to each other than in reality and 10 times bigger
double OrbitalSimulationSystem::AUToWorld(double au) {
return distanceScale * solarToWorld(AUToSolar(au));
return distanceScale * solarToWorld(AUToSolar(au));
}
double OrbitalSimulationSystem::solarToWorld(double solar) {
return (solar) * solarRadius * scaleFactor;
return (solar) * solarRadius * scaleFactor;
}
double OrbitalSimulationSystem::solarToAU(double s) {
return s * 0.004652472637379;
return s * 0.004652472637379;
}
double OrbitalSimulationSystem::AUToSolar(double au) {
return au * 214.9394693836;
return au * 214.9394693836;
}
void OrbitalSimulationSystem::shutdown() {}
......
......@@ -111,6 +111,21 @@ bool AtmosphereTestScene::startup() {
sunLight->dir = -glm::normalize(m_player->getWorldPosition());
});
m_events->subscribe<KeyboardEvent>([this](const KeyboardEvent& e) {
switch (e.originalEvent.key.keysym.scancode) {
case SDL_SCANCODE_TAB:
if (e.originalEvent.key.type == SDL_KEYDOWN) {
m_player->attachToParent(earth);
float r = earth.component<Transform>()->scale.x;
m_player->setPosition(glm::vec3(0, 0, r * 1.2));
m_player->setRotation(glm::mat4());
}
break;
default:
break;
}
});
// Subscribe to the UI drawing event.
// This is called once per frame
m_events->subscribe<"DrawUI"_sh>([this]() {
......
......@@ -279,4 +279,4 @@ void UISystem::prepareRender() {
renderDrawLists(ImGui::GetDrawData());
}
void UISystem::shutdown() { ImGui::Shutdown(); }
\ No newline at end of file
void UISystem::shutdown() { ImGui::Shutdown(); }
#include <iostream>
#include <memory>
#include <engine/core/Context.hpp>
#include <engine/events/EventSystem.hpp>
#include <engine/core/SettingsSystem.hpp>
#include <engine/core/WindowSystem.hpp>
......
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