You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.5 KiB
101 lines
2.5 KiB
|
|
#include <GL/glew.h> |
|
|
|
#include <imgui.h> |
|
#include <backends/imgui_impl_opengl3.h> |
|
#include <backends/imgui_impl_sdl.h> |
|
|
|
#include "gooey.h" |
|
#include "orbits.h" |
|
|
|
|
|
bool |
|
gooInit(SDL_Window* window, SDL_GLContext gl_context) |
|
{ |
|
IMGUI_CHECKVERSION(); |
|
ImGui::CreateContext(); |
|
ImGuiIO& io = ImGui::GetIO(); |
|
io.IniFilename = NULL; // don't save window state to imgui.ini |
|
ImGui::StyleColorsDark(); |
|
|
|
bool ret = true; |
|
ret = ret && ImGui_ImplSDL2_InitForOpenGL(window, gl_context); |
|
ret = ret && ImGui_ImplOpenGL3_Init(); |
|
|
|
return ret; |
|
} |
|
|
|
void |
|
gooFree() |
|
{ |
|
ImGui_ImplOpenGL3_Shutdown(); |
|
ImGui_ImplSDL2_Shutdown(); |
|
ImGui::DestroyContext(); |
|
} |
|
|
|
bool |
|
gooProcessEvent(SDL_Event& e) |
|
{ |
|
ImGui_ImplSDL2_ProcessEvent(&e); |
|
return (ImGui::GetIO().WantCaptureMouse |
|
|| ImGui::GetIO().WantCaptureKeyboard); |
|
} |
|
|
|
void |
|
gooDraw(SDL_Window* window, orbital_elements& orbit, uint& time_step) |
|
{ |
|
ImGui_ImplOpenGL3_NewFrame(); |
|
ImGui_ImplSDL2_NewFrame(window); |
|
ImGui::NewFrame(); |
|
|
|
const static int w = 300; |
|
int x = 0, y = 0; |
|
SDL_GetWindowSize(window, &x, &y); |
|
ImGui::SetNextWindowPos(ImVec2(x - w, 0)); |
|
ImGui::SetNextWindowSize(ImVec2(w, y)); |
|
ImGui::Begin("Orbital Elements"); |
|
|
|
ImGui::Text("iota, inclination: %f", orbit.iota); |
|
ImGui::Text("omega, argument of periapsis: %f", orbit.omega); |
|
ImGui::Text("mu, gravitational parameter: %f", orbit.mu); |
|
ImGui::Text("nu, true anomoly: "); |
|
ImGui::InputDouble("##orbit.nu", &orbit.nu, 0.1f); |
|
ImGui::SameLine(); |
|
ImGui::Text(" radians"); |
|
ImGui::Spacing(); |
|
|
|
ImGui::Separator(); |
|
ImGui::Spacing(); |
|
ImGui::Text("Ellipse Parameters:"); |
|
ImGui::Text("semi-major axis, a: "); |
|
ImGui::InputDouble("##orbit.ep.a", &orbit.ep.a, 1000.0f); |
|
ImGui::SameLine(); |
|
ImGui::Text(" km"); |
|
ImGui::Text("semi-minor axis, b: %f km", orbit.ep.b); |
|
ImGui::Text("eccentricity, e: "); |
|
ImGui::InputDouble("##orbit.ep.e", &orbit.ep.e, 0.01f); |
|
ImGui::Text("linear eccentricity, c: %f km", orbit.ep.c); |
|
ImGui::Spacing(); |
|
|
|
ImGui::Separator(); |
|
ImGui::Spacing(); |
|
ImGui::Text("Other Parameters"); |
|
ImGui::Spacing(); |
|
ImGui::Text("time_step:"); |
|
ImGui::SameLine(); |
|
uint step = 1; |
|
ImGui::InputScalar("##other.time_step", ImGuiDataType_U32, &time_step, &step); |
|
ImGui::Spacing(); |
|
ImGui::Text("Satellite Parameters:"); |
|
ImGui::Text("position:"); |
|
ImGui::Text(" x: %f km", orbit.pos.x); |
|
ImGui::Text(" y: %f km", orbit.pos.y); |
|
ImGui::Text(" z: %f km", orbit.pos.z); |
|
ImGui::Text("radial velocity:"); |
|
ImGui::Text("flight path angle:"); |
|
|
|
ImGui::End(); |
|
ImGui::Render(); |
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); |
|
} |
|
|
|
|