|
|
|
@ -62,23 +62,24 @@ createSatelliteMesh() |
|
|
|
return sm; |
|
|
|
return sm; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: this should be 2 separate functions. 1 for updating the g_sys.sat true
|
|
|
|
|
|
|
|
// anomaly, and another for updating the renderer entity
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
updateSatellitePosition(entity& sat) |
|
|
|
updateSatelliteModel(const system_2body& sys, satellite& sat) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sat.theta = getPropagatedTrueAnomaly(sys, sat.theta, sys.time_step); |
|
|
|
|
|
|
|
sat.gamma = orbitGetFlightPathAngle(sys.ep.e, sat.theta); |
|
|
|
|
|
|
|
sat.r = orbitGetRadialDistance(sys.ep.e, sys.ep.p, sat.theta); |
|
|
|
|
|
|
|
sat.v = orbitGetVelocity(sys.epsilon, sys.body.mu, sat.r); |
|
|
|
|
|
|
|
sat.position = glm::vec3(polarToRect(sat.theta, sat.r), 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
updateSatelliteEntity(entity& ent, const satellite& sat) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: decouple framerate from time_step
|
|
|
|
// TODO: decouple framerate from time_step
|
|
|
|
const static glm::mat4 xform = |
|
|
|
const static glm::mat4 xform = |
|
|
|
glm::rotate(glm::mat4(1.0), (float) M_PI_2, glm::vec3(1, 0, 0)); |
|
|
|
glm::rotate(glm::mat4(1.0), (float) M_PI_2, glm::vec3(1, 0, 0)); |
|
|
|
|
|
|
|
const glm::vec3& v = sat.position; |
|
|
|
satellite& s1 = g_sys.sat; |
|
|
|
entSetWorldPosition(ent, xform * glm::vec4(v.x, v.y, v.z, 1)); |
|
|
|
s1.theta = getPropagatedTrueAnomaly(g_sys, s1.theta, g_sys.time_step); |
|
|
|
|
|
|
|
s1.gamma = orbitGetFlightPathAngle(g_sys.ep.e, s1.theta); |
|
|
|
|
|
|
|
s1.r = orbitGetRadialDistance(g_sys.ep.e, g_sys.ep.p, s1.theta); |
|
|
|
|
|
|
|
s1.v = orbitGetVelocity(g_sys.epsilon, g_sys.body.mu, s1.r); |
|
|
|
|
|
|
|
glm::vec2 coords = polarToRect(s1.theta, s1.r); |
|
|
|
|
|
|
|
glm::vec3 v = s1.position = glm::vec3(coords, 0); |
|
|
|
|
|
|
|
entSetWorldPosition(sat, xform * glm::vec4(v.x, v.y, v.z, 1)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: use ellipseValidate(ep) before calling to avoid failing assertions
|
|
|
|
// NOTE: use ellipseValidate(ep) before calling to avoid failing assertions
|
|
|
|
@ -117,7 +118,8 @@ postFrameCallback(render_state* rs) |
|
|
|
g_sys.ep = ellipseInitAE(g_sys.ep.a, g_sys.ep.e); |
|
|
|
g_sys.ep = ellipseInitAE(g_sys.ep.a, g_sys.ep.e); |
|
|
|
entity& ellipse_entity = rs->render_groups[0].entities[0]; |
|
|
|
entity& ellipse_entity = rs->render_groups[0].entities[0]; |
|
|
|
updateOrbit(g_sys, ellipse_entity); |
|
|
|
updateOrbit(g_sys, ellipse_entity); |
|
|
|
updateSatellitePosition(rs->render_groups[0].entities[2]); |
|
|
|
updateSatelliteModel(g_sys, g_sys.sat); |
|
|
|
|
|
|
|
updateSatelliteEntity(rs->render_groups[0].entities[2], g_sys.sat); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
int |
|
|
|
|