loading savefiles now works :)
This commit is contained in:
parent
19a7802823
commit
1d797bcc4d
|
@ -3,6 +3,7 @@
|
|||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "mesh/mesh.hpp"
|
||||
#include "input/keyboard.hpp"
|
||||
#include "../util/math.hpp"
|
||||
|
||||
|
@ -18,6 +19,7 @@ static bool on_ground = false;
|
|||
static double yaw = 0, pitch = 0;
|
||||
static glm::vec<3, double> pos(0, 0, 2);
|
||||
static glm::vec<3, double> velocity(0);
|
||||
static mesh collision_scene;
|
||||
static glm::mat4 camera_mat;
|
||||
|
||||
Json::Value camera::serialize()
|
||||
|
@ -77,6 +79,11 @@ glm::vec<3, double> camera::get_pos()
|
|||
return pos;
|
||||
}
|
||||
|
||||
void camera::init()
|
||||
{
|
||||
collision_scene.load_model("../assets/model", "scene_collisions.stl");
|
||||
}
|
||||
|
||||
void camera::update(double dt)
|
||||
{
|
||||
glm::vec<2, double> off(0, 0);
|
||||
|
@ -119,8 +126,8 @@ void camera::update(double dt)
|
|||
glm::vec<3, double> normal_last(0);
|
||||
glm::vec<3, double> velocity2;
|
||||
|
||||
velocity2 = system::active.scene.calc_intersect(pos, velocity * dt, normal_last);
|
||||
velocity2 = system::active.scene.calc_intersect(pos + glm::vec<3, double>(0, 0, -1.5), velocity2, normal_last) / dt;
|
||||
velocity2 = collision_scene.calc_intersect(pos, velocity * dt, normal_last);
|
||||
velocity2 = collision_scene.calc_intersect(pos + glm::vec<3, double>(0, 0, -1.5), velocity2, normal_last) / dt;
|
||||
|
||||
pos += velocity2 * dt;
|
||||
on_ground = ((velocity * dt / dt).z != velocity2.z);
|
||||
|
|
|
@ -16,6 +16,7 @@ glm::vec<3, double> get_pos();
|
|||
Json::Value serialize();
|
||||
void load(const Json::Value& node);
|
||||
|
||||
void init();
|
||||
void rotate(double pitch, double yaw);
|
||||
void move(double x, double y, double z);
|
||||
void update(double dt);
|
||||
|
|
|
@ -30,11 +30,11 @@ using namespace sim::graphics;
|
|||
static GLFWwindow* win;
|
||||
static bool win_should_close = false;
|
||||
|
||||
static glmesh MeshScene;
|
||||
static monitor::vessel MonitorVessel;
|
||||
static monitor::core MonitorCore;
|
||||
static monitor::primary_loop MonitorPrimaryLoop;
|
||||
static monitor::secondary_loop MonitorSecondaryLoop;
|
||||
static glmesh mesh_scene;
|
||||
static monitor::vessel monitor_vessel;
|
||||
static monitor::core monitor_core;
|
||||
static monitor::primary_loop monitor_primary_loop;
|
||||
static monitor::secondary_loop monitor_secondary_loop;
|
||||
|
||||
glm::mat4 window::projection_matrix;
|
||||
|
||||
|
@ -99,6 +99,7 @@ void window::create()
|
|||
mouse::init();
|
||||
resize::init();
|
||||
texture::init();
|
||||
camera::init();
|
||||
font::init();
|
||||
ui::init();
|
||||
|
||||
|
@ -108,17 +109,13 @@ void window::create()
|
|||
mesh m;
|
||||
|
||||
m.load_model("../assets", "scene-baked.glb");
|
||||
MeshScene.bind();
|
||||
MeshScene.set(m, GL_STATIC_DRAW);
|
||||
mesh_scene.bind();
|
||||
mesh_scene.set(m, GL_STATIC_DRAW);
|
||||
|
||||
sys.scene.load_model("../assets/model", "scene_collisions.stl");
|
||||
// MeshCollisionScene.bind();
|
||||
// MeshCollisionScene.set(sys.scene.to_lines(), GL_STATIC_DRAW);
|
||||
|
||||
MonitorCore.init();
|
||||
MonitorVessel.init();
|
||||
MonitorPrimaryLoop.init();
|
||||
MonitorSecondaryLoop.init();
|
||||
monitor_core.init();
|
||||
monitor_vessel.init();
|
||||
monitor_primary_loop.init();
|
||||
monitor_secondary_loop.init();
|
||||
|
||||
glfwShowWindow(win);
|
||||
glViewport(0, 0, 800, 600);
|
||||
|
@ -128,10 +125,10 @@ void window::update(double dt)
|
|||
{
|
||||
glfwPollEvents();
|
||||
|
||||
MonitorCore.update(dt);
|
||||
MonitorVessel.update(dt);
|
||||
MonitorPrimaryLoop.update(dt);
|
||||
MonitorSecondaryLoop.update(dt);
|
||||
monitor_core.update(dt);
|
||||
monitor_vessel.update(dt);
|
||||
monitor_primary_loop.update(dt);
|
||||
monitor_secondary_loop.update(dt);
|
||||
|
||||
ui::update(dt);
|
||||
}
|
||||
|
@ -147,14 +144,14 @@ void window::render()
|
|||
glClearColor(0, 0, 0, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
MeshScene.bind();
|
||||
MeshScene.uniform();
|
||||
MeshScene.render();
|
||||
mesh_scene.bind();
|
||||
mesh_scene.uniform();
|
||||
mesh_scene.render();
|
||||
|
||||
MonitorCore.render();
|
||||
MonitorVessel.render();
|
||||
MonitorPrimaryLoop.render();
|
||||
MonitorSecondaryLoop.render();
|
||||
monitor_core.render();
|
||||
monitor_vessel.render();
|
||||
monitor_primary_loop.render();
|
||||
monitor_secondary_loop.render();
|
||||
|
||||
ui::render();
|
||||
|
||||
|
|
|
@ -254,7 +254,10 @@ reactor::reactor(const Json::Value& node, coolant::vessel* v) :
|
|||
|
||||
for(int i = 0; i < size; i++)
|
||||
{
|
||||
rods.push_back(load_rod(j_rods[i], v));
|
||||
std::unique_ptr<rod> r = load_rod(j_rods[i], v);
|
||||
r->reactor = this;
|
||||
|
||||
rods.push_back(std::move(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "coolant/evaporator.hpp"
|
||||
#include "coolant/sink.hpp"
|
||||
#include "electric/turbine.hpp"
|
||||
#include "graphics/mesh/mesh.hpp"
|
||||
|
||||
namespace sim
|
||||
{
|
||||
|
@ -38,7 +37,6 @@ struct system
|
|||
std::unique_ptr<sim::coolant::valve> turbine_bypass_valve;
|
||||
std::unique_ptr<sim::coolant::valve> turbine_inlet_valve;
|
||||
|
||||
sim::graphics::mesh scene;
|
||||
double speed = 1;
|
||||
double clock = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue