|
|
|
|
@ -82,14 +82,37 @@ doFrameCallbackPre(render_state* rs)
|
|
|
|
|
{ |
|
|
|
|
// handle input
|
|
|
|
|
static input_state is = {}; |
|
|
|
|
// TODO: probably need to break the while loop out of inputProcessEvents
|
|
|
|
|
// so we can send individual sdl events to ImGui_ImplSDL2_ProcessEvent()
|
|
|
|
|
// via gooProcessEvent()
|
|
|
|
|
inputProcessEvents(&is); |
|
|
|
|
SDL_Event e; |
|
|
|
|
bool gooey_wants = false; |
|
|
|
|
|
|
|
|
|
while (SDL_PollEvent(&e)) { |
|
|
|
|
gooey_wants = gooProcessEvent(e); |
|
|
|
|
if (!gooey_wants) inputProcessEvent(&is, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (is.window_closed || is.escape) |
|
|
|
|
rs->running = false; |
|
|
|
|
|
|
|
|
|
// update orbital elements/ellipse_3d
|
|
|
|
|
// TODO: could really use another ellipse constructor that uses a and e
|
|
|
|
|
g_orbit.ep = constructEllipseAB(g_orbit.ep.a, |
|
|
|
|
g_orbit.ep.a * sqrt(1 - pow(g_orbit.ep.e, 2.0))); |
|
|
|
|
entity& ellipse_entity = rs->render_groups[0].entities[0]; |
|
|
|
|
|
|
|
|
|
// TODO: fix this
|
|
|
|
|
double angle = 2 * M_PI / g_ellipse.vert_count; |
|
|
|
|
for (uint i = 0; i < g_ellipse.vert_count; i++) { |
|
|
|
|
double a = angle * i; |
|
|
|
|
double r = g_orbit.ep.a * |
|
|
|
|
(1 - pow(g_orbit.ep.e, 2)) / (1 + g_orbit.ep.e * cos(a)); |
|
|
|
|
g_ellipse.vertices[i] = glm::vec3(polarToRect(a, r), 0); |
|
|
|
|
// NOTE: update mesh
|
|
|
|
|
ellipse_entity.mesh->vertices[i] = g_ellipse.vertices[i]; |
|
|
|
|
// NOTE: update entity.render_object
|
|
|
|
|
entUpdateSimpleMesh(ellipse_entity, ellipse_entity.mesh, GL_LINE_LOOP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update satellite position
|
|
|
|
|
const static glm::mat4 xform = |
|
|
|
|
glm::rotate(glm::mat4(1.0), (float) M_PI_2, glm::vec3(1, 0, 0)); |
|
|
|
|
|