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.
98 lines
1.7 KiB
98 lines
1.7 KiB
#pragma once |
|
|
|
#include <glm/glm.hpp> |
|
using glm::vec3; |
|
|
|
#include "tangerine.h" |
|
#include "orbits.h" |
|
|
|
|
|
#define DEFAULT_ORBIT_VERTICES 256 |
|
|
|
const vec3 DEFAULT_ELLIPSE_COLOR = vec3(0.5, 0.5, 0.5); |
|
const vec3 SELECTED_ELLIPSE_COLOR = vec3(0.7, 0.2, 0.2); |
|
|
|
|
|
struct Ellipse3D |
|
{ |
|
vec3* vertices; |
|
uint vert_count; |
|
}; |
|
|
|
enum struct ManeuverType |
|
{ |
|
PROGRADE, |
|
RETROGRADE, |
|
INCLINATION_CHANGE, |
|
GENERAL_PLANE_CHANGE, |
|
OTHER, |
|
VECTOR_TYPE_COUNT |
|
}; |
|
|
|
struct ManeuverNode |
|
{ |
|
double true_anomaly; |
|
vec3 impulse_vector; |
|
ManeuverType impulse_type; |
|
double impulse_delta_v; |
|
// TODO: thrust calculations |
|
|
|
bool active; |
|
}; |
|
|
|
struct GameOrbit |
|
{ |
|
TwoBodySystem system; |
|
Ellipse3D e3d; |
|
// TODO: multiple maneuvers |
|
ManeuverNode maneuver; |
|
|
|
Entity* grav_body; |
|
Entity* ellipse_entity; |
|
Entity* satellite_entity; |
|
bool in_use; |
|
bool selected; |
|
}; |
|
|
|
struct GameState |
|
{ |
|
bool running; |
|
MemoryArena* arena; |
|
|
|
u64 game_time_ms; |
|
u64 sim_time_ms; |
|
float sim_speed; |
|
|
|
GameOrbit* orbits; |
|
u32 num_orbits; |
|
u32 max_orbits; |
|
|
|
GameOrbit* last_selected_orbit; |
|
}; |
|
|
|
GameOrbit* getFreeOrbit(GameState* gs); |
|
|
|
GameOrbit* getSelectedOrbit(GameState* gs); |
|
|
|
void disableGameOrbit(GameState* gs, GameOrbit* orbit); |
|
|
|
double getTimeStep(GameState* gs); |
|
|
|
// NOTE: create vertices for a 3d ellipse |
|
// all vertices are in the x/y plane with z = 0 |
|
Ellipse3D ellipse3DInit(EllipseParameters ep, uint vert_count); |
|
|
|
void ellipse3DUpdate(EllipseParameters ep, Ellipse3D& e3d); |
|
|
|
void selectOrbit(GameState* gs, GameOrbit* orbit); |
|
|
|
bool addManeuver(GameOrbit* orbit, double anomaly, vec3 impulse_vector, |
|
double impulse_delta_v); |
|
|
|
void removeManeuver(GameOrbit* orbit); |
|
|
|
bool testManeuverStep(const ManeuverNode& maneuver, |
|
double previous_theta, |
|
double next_theta); |
|
|
|
void applyManeuver(GameOrbit* orbit);
|
|
|