#include <simulation.hpp>
Definition at line 54 of file simulation.hpp.
Public Member Functions | |
void | cleanup () |
This is called at the end of the simulation. | |
void | draw () |
This is called to draw the frame. It may be called concurrently with update(), which is updating the next frame while the current one is being drawn. | |
context * | get_context () |
bool | handle_event (sg_event &e) |
This is called to pass events to the scene graph after they have been left unhandled by the UI. | |
void | init () |
This is called at the beginning of a simulation. It will initialize all the nodes in the scene graph. | |
bool | is_running () const |
void | pre_draw () |
This is called at the beginning of each frame. It records drawing information for all the nodes in the scene graph. | |
simulation (const data::config_record &sim_config, platform::display *console, context *sim_context, scenegraph::node *scenery) | |
void | update () |
This is called to update the scene graph. It may be called concurrently with draw(), which is drawing the previous frame. | |
~simulation () | |
Private Member Functions | |
void | cleanup_context () |
void | cleanup_node (scenegraph::node *n) |
bool | handle_event (sg_event &e, node *n) |
void | init_context () |
void | init_node (scenegraph::node *n) |
void | update_context () |
void | update_node (scenegraph::node *n) |
Private Attributes | |
platform::display * | console |
The game's single console. | |
data::simple_array< gsgl::real_t > | frame_deltas |
platform::font * | info_font |
data::list< node * > | non_scenery_nodes |
These get removed from the scene graph & deleted when the simulation ends. | |
node::pre_draw_rec | pre_rec |
bool | running |
node * | scenery |
The root node of the simulation scene graph. | |
context * | sim_context |
time_t | start_time |
gsgl::real_t | time_scale |
freeview * | view |
The main view node. |
simulation | ( | const data::config_record & | sim_config, | |
platform::display * | console, | |||
context * | sim_context, | |||
scenegraph::node * | scenery | |||
) |
Definition at line 73 of file simulation.cpp.
References assert, node::connect(), broker::create_object(), simulation::frame_deltas, config_record::get_children(), config_record::get_file(), file::get_full_path(), node::get_name(), config_record::get_name(), broker::global_instance(), simulation::info_font, simulation::non_scenery_nodes, freeview::reset(), simulation::start_time, julian_day::to_time_t(), simulation::view, and string::w_string().
~simulation | ( | ) |
Definition at line 163 of file simulation.cpp.
References simulation::info_font, and simulation::non_scenery_nodes.
void cleanup | ( | ) |
This is called at the end of the simulation.
Definition at line 333 of file simulation.cpp.
References simulation::cleanup_context(), simulation::cleanup_node(), and simulation::scenery.
Referenced by application::unload_and_quit_simulation().
void cleanup_context | ( | ) | [private] |
void cleanup_node | ( | scenegraph::node * | n | ) | [private] |
Definition at line 427 of file simulation.cpp.
References assert, node::cleanup(), node::get_children(), and simulation::sim_context.
Referenced by simulation::cleanup().
void draw | ( | ) |
This is called to draw the frame. It may be called concurrently with update(), which is updating the next frame while the current one is being drawn.
Definition at line 264 of file simulation.cpp.
References font::calc_height(), context::cam, CHECK_GL_ERRORS, simulation::console, context::cur_t_time, font::draw(), node::draw_scene(), display::draw_text_start(), display::draw_text_stop(), string::format(), simulation::frame_deltas, freeview::get_camera(), display::get_height(), simulation::info_font, freeview::is_relative(), simulation::pre_rec, context::screen, simulation::sim_context, simulation::time_scale, simulation::view, and context::view.
Referenced by application::run().
context* get_context | ( | ) | [inline] |
Definition at line 438 of file simulation.cpp.
References assert, node::get_children(), simulation::handle_event(), node::handle_event(), and simulation::sim_context.
bool handle_event | ( | sg_event & | e | ) |
This is called to pass events to the scene graph after they have been left unhandled by the UI.
Definition at line 346 of file simulation.cpp.
References sg_event::get_code(), context::RENDER_COORD_SYSTEMS, context::render_flags, context::RENDER_LABELS, sg_event::RENDER_TOGGLE_COORD_SYSTEMS, sg_event::RENDER_TOGGLE_LABELS, simulation::running, simulation::scenery, simulation::sim_context, sg_event::SIM_QUIT, sg_event::TIME_DEC_SCALE, sg_event::TIME_INC_SCALE, sg_event::TIME_PAUSE, sg_event::TIME_RESET_SCALE, and simulation::time_scale.
Referenced by simulation::handle_event(), and event_map::handle_event().
void init | ( | ) |
This is called at the beginning of a simulation. It will initialize all the nodes in the scene graph.
Definition at line 247 of file simulation.cpp.
References simulation::init_context(), simulation::init_node(), and simulation::scenery.
Referenced by application::load_and_run_simulation().
void init_context | ( | ) | [private] |
Definition at line 176 of file simulation.cpp.
References context::cam, simulation::console, context::console, context::cur_t_time, context::cur_tick, context::cur_time, context::delta_tick, context::delta_time, context::frame, freeview::get_camera(), julian_day::get_jdn(), context::julian_cur, context::julian_dt, context::julian_start, context::RENDER_ANISOTROPIC, context::render_flags, simulation::scenery, context::scenery, context::screen, context::sim, simulation::sim_context, context::start_t_time, context::start_tick, context::start_time, simulation::start_time, simulation::time_scale, context::time_scale, simulation::view, and context::view.
Referenced by simulation::init().
void init_node | ( | scenegraph::node * | n | ) | [private] |
Definition at line 398 of file simulation.cpp.
References assert, node::get_children(), node::init(), and simulation::sim_context.
Referenced by simulation::init().
bool is_running | ( | ) | const [inline] |
void pre_draw | ( | ) |
This is called at the beginning of each frame. It records drawing information for all the nodes in the scene graph.
Definition at line 257 of file simulation.cpp.
References node::pre_draw_scene(), simulation::pre_rec, and simulation::sim_context.
Referenced by application::run().
void update | ( | ) |
This is called to update the scene graph. It may be called concurrently with draw(), which is drawing the previous frame.
Definition at line 321 of file simulation.cpp.
References context::delta_tick, context::frame, simulation::frame_deltas, simulation::scenery, simulation::sim_context, simulation::time_scale, simulation::update_context(), and simulation::update_node().
Referenced by application::run().
void update_context | ( | ) | [private] |
Definition at line 212 of file simulation.cpp.
References context::cam, simulation::console, context::console, context::cur_t_time, context::cur_tick, context::cur_time, context::delta_tick, context::delta_time, context::frame, freeview::get_camera(), julian_day::JDAY, context::julian_cur, context::julian_dt, simulation::scenery, context::scenery, context::screen, context::sim, simulation::sim_context, simulation::time_scale, context::time_scale, simulation::view, and context::view.
Referenced by simulation::update().
void update_node | ( | scenegraph::node * | n | ) | [private] |
Definition at line 412 of file simulation.cpp.
References assert, node::get_children(), brokered_object::get_type_name(), simulation::sim_context, and node::update().
Referenced by simulation::update().
platform::display* console [private] |
The game's single console.
Definition at line 59 of file simulation.hpp.
Referenced by simulation::draw(), simulation::init_context(), and simulation::update_context().
data::simple_array<gsgl::real_t> frame_deltas [private] |
Definition at line 71 of file simulation.hpp.
Referenced by simulation::draw(), simulation::simulation(), and simulation::update().
platform::font* info_font [private] |
Definition at line 70 of file simulation.hpp.
Referenced by simulation::draw(), simulation::simulation(), and simulation::~simulation().
data::list<node *> non_scenery_nodes [private] |
These get removed from the scene graph & deleted when the simulation ends.
Definition at line 63 of file simulation.hpp.
Referenced by simulation::simulation(), and simulation::~simulation().
node::pre_draw_rec pre_rec [private] |
Definition at line 73 of file simulation.hpp.
Referenced by simulation::draw(), and simulation::pre_draw().
bool running [private] |
The root node of the simulation scene graph.
Definition at line 62 of file simulation.hpp.
Referenced by simulation::cleanup(), simulation::handle_event(), simulation::init(), simulation::init_context(), simulation::update(), and simulation::update_context().
context* sim_context [private] |
Definition at line 60 of file simulation.hpp.
Referenced by simulation::cleanup_node(), simulation::draw(), simulation::handle_event(), simulation::init_context(), simulation::init_node(), simulation::pre_draw(), simulation::update(), simulation::update_context(), and simulation::update_node().
time_t start_time [private] |
Definition at line 67 of file simulation.hpp.
Referenced by simulation::init_context(), and simulation::simulation().
gsgl::real_t time_scale [private] |
Definition at line 68 of file simulation.hpp.
Referenced by simulation::draw(), simulation::handle_event(), simulation::init_context(), simulation::update(), and simulation::update_context().
The main view node.
Definition at line 65 of file simulation.hpp.
Referenced by simulation::draw(), simulation::init_context(), simulation::simulation(), and simulation::update_context().