Browse Source

use new updateSimpleMesh to update orbit from gooey

main
= 5 years ago
parent
commit
67fd7895f4
  1. 2
      ext/tangerine
  2. 10
      src/gooey.cpp
  3. 31
      src/main.cpp

2
ext/tangerine

@ -1 +1 @@
Subproject commit e412f21c7e3ca25283cdd8fe7db7d093bc63bc92
Subproject commit ca151b5c770eb586c697fe3d29c49f0de3450e1e

10
src/gooey.cpp

@ -6,6 +6,7 @@
#include <backends/imgui_impl_sdl.h>
#include "gooey.h"
#include "orbits.h"
bool
@ -56,8 +57,13 @@ gooDraw(SDL_Window* window, orbital_elements& orbit)
ImGui::Text("e: %f", orbit.ep.e);
ImGui::Text("mu: %f km^3/s^2", orbit.mu);
static char str0[128] = "Hello";
ImGui::InputText("testing", str0, IM_ARRAYSIZE(str0));
ImGui::Text("a:");
ImGui::SameLine();
ImGui::InputDouble("##orbit.ep.a", &orbit.ep.a, 1000.0f);
ImGui::Text("e:");
ImGui::SameLine();
ImGui::InputDouble("##orbit.ep.e", &orbit.ep.e, 0.1f);
ImGui::End();

31
src/main.cpp

@ -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));

Loading…
Cancel
Save