Browse Source

initialize scene with world 'Z' as camera 'up'

main
cinnaboot 4 years ago
parent
commit
04d5a4a0e7
  1. 25
      src/main.cpp

25
src/main.cpp

@ -104,10 +104,12 @@ addCoordinateOverlay(RenderState* rs)
rg->shader->attrib_mappings,
"coordinate overlay",
GL_LINES);
scaleEntity(e, 5);
// TODO: add a gameoverlay that can 'unproject' world coordinates to screen
// coords
setEntityPosition(e, vec3(0, 0, 75 / SCALING - 100));
// NOTE: place overlay at origin, and scale so it's big enough to see
setEntityPosition(e, vec3(0, 0, 0));
scaleEntity(e, 20 / SCALING);
return e;
}
@ -229,7 +231,7 @@ loadOrbit(GameState* gs,
bool
loadScene(GameState* gs, RenderState* rs)
{
initCamera(rs, vec3(0, 0, 75 / SCALING), vec3(0, 0, 0), vec3(0,1,0));
initCamera(rs, vec3(-20 / SCALING, -20 / SCALING, 20 / SCALING), vec3(0, 0, 0), vec3(0,0,1));
initLights(rs);
gs->running = true;
@ -245,9 +247,9 @@ loadScene(GameState* gs, RenderState* rs)
gs->coord_overlay = addCoordinateOverlay(rs);
OrbitalElements oe_2 = orbitInit(20180, 0.15, DEG2RAD(10), DEG2RAD(-90), 0, 0);
GameOrbit* go_2 = loadOrbit(gs, rs, body, oe_2, rg, "sat_02");
addManeuver(go_2, ImpulseType::PROGRADE, DEG2RAD(45), 0.5);
OrbitalElements el = orbitInit(8000, 0, 0, 0, 0, 0);
GameOrbit* go_1 = loadOrbit(gs, rs, body, el, rg, "sat_01");
addManeuver(go_1, ImpulseType::PROGRADE, DEG2RAD(-90), 0.4);
return true;
}
@ -280,15 +282,6 @@ updateSatelliteModel(TwoBodySystem& sys, double time_step)
sat.position = sys.rotation * glm::vec3(polarToRect(sat.theta, sat.r), 0);
}
void
updateSatelliteEntity(Entity* e, const Satellite& sat)
{
const static mat4 xform =
glm::rotate(mat4(1.0), (float) M_PI_2, vec3(1, 0, 0));
const vec3& v = sat.position;
setEntityPosition(e, xform * vec4(v.x, v.y, v.z, 1));
}
void
updateOrbit(GameOrbit* orbit, bool running, double time_step)
{
@ -297,7 +290,7 @@ updateOrbit(GameOrbit* orbit, bool running, double time_step)
if (running && orbit->in_use) {
double previous_true_anom = orbit->system.sat.theta;
updateSatelliteModel(orbit->system, time_step);
updateSatelliteEntity(orbit->satellite_entity, orbit->system.sat);
setEntityPosition(orbit->satellite_entity, orbit->system.sat.position);
if (testManeuverStep(orbit->maneuver,
previous_true_anom,

Loading…
Cancel
Save