#ifndef RENDERER_H #define RENDERER_H #include "simulation.h" #include "spacecraft.h" #include "maneuver.h" #include "raylib.h" // Rendering state struct RenderState { Camera3D camera; double distance_scale; // Scale factor for distances double size_scale; // Scale factor for body sizes int selected_body_index; // -1 = no selection int selected_craft_index; // -1 = no selection bool camera_target_enabled; // Whether camera follows selected body/craft Vector3 camera_offset; // Offset from target when following body int last_target_index; // Tracks body or craft index (negative = spacecraft) Texture2D spacecraft_texture; // Shared texture for all spacecraft Texture2D maneuver_textures[6]; // One per burn direction bool texture_loaded; }; // Renderer initialization and cleanup void init_renderer(int width, int height, const char* title); void close_renderer(RenderState* render_state); // Texture generation Texture2D generate_spacecraft_texture(); Texture2D generate_maneuver_marker_texture(Color color); // Texture management void ensure_textures_loaded(RenderState* render_state); // Angle calculation float calculate_spacecraft_angle(Vec3 velocity, Camera3D camera); // Camera setup and control void setup_camera(RenderState* render_state); void update_camera(RenderState* render_state, SimulationState* sim); float get_initial_camera_distance(CelestialBody* body, SimulationState* sim, RenderState* render_state); // Rendering functions void render_body(CelestialBody* body, RenderState* render_state); void render_spacecraft_screen_space(Spacecraft* craft, RenderState* render_state); void render_maneuver_marker_screen_space(Spacecraft* craft, Maneuver* maneuver, RenderState* render_state); void render_orbit(Vec3 position, Vec3 velocity, Vec3 parent_position, double parent_mass, Color orbit_color, RenderState* render_state); Color get_body_orbit_color(CelestialBody* body); // NOTE: needs to be called between begin_frame() and end_frame() void render_simulation(SimulationState* sim, RenderState* render_state); void render_child_indicators(SimulationState* sim, RenderState* render_state); void begin_frame(); void end_frame(); // Scaling functions Vector3 scale_position(Vec3 pos, double scale); float scale_radius(double radius, double scale); #endif