#include <stellardb.hpp>
Definition at line 51 of file stellardb.hpp.
Scene Graph Functionality. | |
void | add_child (node *child) |
Add a child node. Also sets the child's parent to this . | |
bool | connect (node *branch) |
If this is called on the root of a scene graph, it will insert the branch node in the appropriate place in the graph, or return false. | |
void | detach () |
Removes the node from the scene graph (does not delete it!). | |
gsgl::flags_t & | get_draw_flags () |
const gsgl::flags_t & | get_draw_flags () const |
gsgl::flags_t & | get_draw_results () |
const gsgl::flags_t & | get_draw_results () const |
enum | node_draw_flags { NODE_NO_DRAW_FLAGS = 0, NODE_NO_FRUSTUM_CHECK = 1 << 0, NODE_DUMMY_OBJECT = 1 << 2, NODE_DRAW_UNLIT = 1 << 3 } |
Flags that control node drawing. More... | |
enum | node_draw_results { NODE_NO_DRAW_RESULTS = 0, NODE_OFF_SCREEN = 1 << 0, NODE_DREW_POINT = 1 << 1, NODE_DISTANCE_CULLED = 1 << 2 } |
Flags that indicate what happened when the node was drawn. More... | |
static void | draw_scene (gsgl::scenegraph::context *c, pre_draw_rec &rec) |
Draws a scene. Safe to call while update is also being called in the tree. | |
static void | pre_draw_scene (gsgl::scenegraph::context *c, pre_draw_rec &rec) |
Collect information about the scene to draw. Unsafe to call while update is being called in the tree. | |
Drawing Information Functions. | |
virtual gsgl::real_t | default_view_distance () const |
virtual gsgl::real_t | max_extent () const |
Should return the maximum extent of the object (in the node's coordinates, i.e. not scaled to meters). | |
virtual gsgl::real_t | minimum_view_distance () const |
static const gsgl::real_t | NODE_DRAW_FIRST = FLT_MAX |
static const gsgl::real_t | NODE_DRAW_IGNORE = 0.000f |
static const gsgl::real_t | NODE_DRAW_SOLID = 0.001f |
static const gsgl::real_t | NODE_DRAW_TRANSLUCENT = 0.002f |
Public Member Functions | |
BROKER_DECLARE_CREATOR (periapsis::space::stellar_db) | |
virtual void | cleanup (gsgl::scenegraph::context *) |
Called when the simulation is done. | |
virtual void | draw (gsgl::scenegraph::context *) |
Called to draw the node. The node's modelview matrix is in the correct state for drawing, and already loaded into the OpenGL modelview matrix. | |
virtual gsgl::real_t | get_priority (gsgl::scenegraph::context *) |
Called to determine the draw priority of the node. | |
virtual const gsgl::string & | get_type_name () const |
virtual void | init (gsgl::scenegraph::context *) |
Called when the simulation is created. The node's modelview matrix is invalid at this point. | |
stellar_db (const gsgl::data::config_record &conf) | |
virtual | ~stellar_db () |
Accessors. | |
data::simple_array< node * > & | get_children () |
math::transform & | get_modelview () |
string & | get_name () |
const string & | get_name () const |
math::transform & | get_orientation () |
node *& | get_parent () |
const node * | get_parent () const |
string & | get_parent_name () |
gsgl::real_t & | get_scale () |
math::vector & | get_translation () |
Node Life Cycle. | |
virtual bool | handle_event (gsgl::scenegraph::context *c, sg_event &e) |
Called with events. | |
virtual data::config_record * | save () const |
Called to save the node to a config_record structure. | |
virtual void | update (gsgl::scenegraph::context *c) |
Called from the root of the world-tree up to update the node's state. The node's modelview matrix is that of the previously-drawn frame. | |
Private Member Functions | |
void | add_star_name (const gsgl::math::vector &pos, const gsgl::string &name) |
void | load_db (const gsgl::string &fname) |
Private Attributes | |
float | farthest_distance |
float | nearest_distance |
int | num_stars |
gsgl::data::simple_array < gsgl::real_t > | star_name_vertices |
gsgl::data::simple_array < gsgl::string * > | star_names |
gsgl::platform::shader_program | star_shader |
gsgl::platform::vertex_buffer | vertices |
enum node_draw_flags [inherited] |
enum node_draw_results [inherited] |
stellar_db | ( | const gsgl::data::config_record & | conf | ) |
Definition at line 68 of file stellardb.cpp.
References shader_program::add_vertex_shader(), config_record::get_directory(), node::get_draw_flags(), directory::get_full_path(), countable::is_empty(), stellar_db::load_db(), stellar_db::star_shader, and application::SYS_DATA_PATH.
~stellar_db | ( | ) | [virtual] |
Definition at line 89 of file stellardb.cpp.
References simple_array::size(), and stellar_db::star_names.
void add_child | ( | node * | child | ) | [inherited] |
Add a child node. Also sets the child's parent to this
.
Definition at line 267 of file node.cpp.
References assert, node::children, and node::parent.
Referenced by node::connect(), application::load_objects(), application::load_scenery(), model::model(), node::node(), vehicle::vehicle(), and vehicle_module::vehicle_module().
void add_star_name | ( | const gsgl::math::vector & | pos, | |
const gsgl::string & | name | |||
) | [private] |
Definition at line 229 of file stellardb.cpp.
References simple_array::append(), vector::get_x(), vector::get_y(), vector::get_z(), stellar_db::star_name_vertices, and stellar_db::star_names.
Referenced by stellar_db::load_db().
BROKER_DECLARE_CREATOR | ( | periapsis::space::stellar_db | ) |
void cleanup | ( | gsgl::scenegraph::context * | c | ) | [virtual] |
Called when the simulation is done.
Reimplemented from node.
Definition at line 253 of file stellardb.cpp.
References stellar_db::star_shader, and shader_program::unload().
bool connect | ( | node * | branch | ) | [inherited] |
If this is called on the root of a scene graph, it will insert the branch node in the appropriate place in the graph, or return false.
Definition at line 289 of file node.cpp.
References node::add_child(), node::children, node::name, and node::parent_name.
Referenced by simulation::simulation().
gsgl::real_t default_view_distance | ( | ) | const [virtual, inherited] |
Reimplemented in vehicle, checkered_box, celestial_body, and large_lithosphere.
Definition at line 255 of file node.cpp.
Referenced by large_lithosphere::default_view_distance(), and freeview::reset().
void detach | ( | ) | [inherited] |
Removes the node from the scene graph (does not delete it!).
Definition at line 276 of file node.cpp.
References node::children, and node::parent.
void draw | ( | gsgl::scenegraph::context * | c | ) | [virtual] |
Called to draw the node. The node's modelview matrix is in the correct state for drawing, and already loaded into the OpenGL modelview matrix.
Reimplemented from node.
Definition at line 263 of file stellardb.cpp.
References vbuffer_base::bind(), shader_program::bind(), context::cam, CHECK_GL_ERRORS, display::draw_3d_text(), display::draw_text_start(), display::draw_text_stop(), stellar_db::farthest_distance, display::get_aspect_ratio(), camera::get_field_of_view(), node::get_scale(), stellar_db::nearest_distance, stellar_db::num_stars, display::record_3d_text_info(), context::render_flags, context::screen, simple_array::size(), stellar_db::star_name_vertices, stellar_db::star_names, stellar_db::star_shader, shader_program::unbind(), and stellar_db::vertices.
void draw_scene | ( | gsgl::scenegraph::context * | c, | |
pre_draw_rec & | rec | |||
) | [static, inherited] |
Draws a scene. Safe to call while update is also being called in the tree.
Definition at line 397 of file node.cpp.
References light::bind(), context::cam, CHECK_GL_ERRORS, node::draw(), node::draw_results, display::get_aspect_ratio(), camera::get_field_of_view(), display::get_height(), node::get_modelview(), brokered_object::get_type_name(), display::get_width(), gsgl::scenegraph::utils::is_on_screen(), node::pre_draw_rec::light_queue, vector::mag(), node::max_extent(), gsgl::max_val(), node::NODE_DISTANCE_CULLED, node::NODE_NO_DRAW_RESULTS, node::NODE_OFF_SCREEN, context::num_lights, node::pre_draw_rec::paint_queue, gsgl::scenegraph::utils::pos_in_eye_space(), matrix::ptr(), context::render_flags, context::RENDER_UNLIT, node::scale, context::screen, node::pre_draw_rec::solids, node::pre_draw_rec::translucents, and vector::ZERO.
Referenced by simulation::draw().
data::simple_array< node * > & get_children | ( | ) | [inherited] |
Definition at line 174 of file node.cpp.
References node::children.
Referenced by simulation::cleanup_node(), node::get_name(), gsgl::scenegraph::utils::greatest_extent(), simulation::handle_event(), rigid_body::init(), simulation::init_node(), application::load_scenery(), sim_view_box::load_scenery_info(), application::remove_viewpoint_nodes(), planet_earth::update(), and simulation::update_node().
gsgl::flags_t& get_draw_flags | ( | ) | [inline, inherited] |
const gsgl::flags_t& get_draw_flags | ( | ) | const [inline, inherited] |
Definition at line 150 of file node.hpp.
Referenced by large_rocky_body::draw(), celestial_body::draw(), galaxy::galaxy(), gsgl::scenegraph::utils::is_on_screen(), planet_system::planet_system(), solar_system::solar_system(), star::star(), and stellar_db::stellar_db().
gsgl::flags_t& get_draw_results | ( | ) | [inline, inherited] |
const gsgl::flags_t& get_draw_results | ( | ) | const [inline, inherited] |
Definition at line 166 of file node.hpp.
Referenced by large_rocky_body::draw(), celestial_body::draw(), and large_lithosphere::update().
math::transform & get_modelview | ( | ) | [inherited] |
Definition at line 230 of file node.cpp.
References node::modelview.
Referenced by gsgl::scenegraph::utils::dot_in_eye_space(), large_rocky_body::draw(), celestial_body::draw(), gsgl::scenegraph::utils::draw_billboard(), node::draw_scene(), gsgl::scenegraph::utils::is_on_screen(), spherical_quadtree::node_radius(), gsgl::scenegraph::utils::pos_in_eye_space(), spherical_quadtree::update(), and large_lithosphere::update().
string & get_name | ( | ) | [inherited] |
const string & get_name | ( | ) | const [inherited] |
Definition at line 182 of file node.cpp.
References string::format(), node::get_children(), node::get_name(), countable::is_empty(), node::name, and node::parent.
Referenced by vehicle::calculate_inertia_tensor(), solar_system::draw(), planet_system::draw(), celestial_body::draw_name(), gas_body::gas_body(), node::get_name(), planet_system::get_priority(), large_rocky_body::large_rocky_body(), sim_view_box::load_scenery_info(), model::model(), model_part::model_part(), simulation::simulation(), vehicle::vehicle(), and vehicle_module::vehicle_module().
math::transform & get_orientation | ( | ) | [inherited] |
Definition at line 225 of file node.cpp.
References node::orientation.
Referenced by camera::camera(), rotating_body::init(), rigid_body::init(), test_frame::recalc(), freeview::reset(), freeview::rot_absolute(), freeview::rot_relative(), solar_system::solar_system(), rotating_body::update(), rigid_body::update(), freeview::update(), and vehicle::vehicle().
node *& get_parent | ( | ) | [inherited] |
const node * get_parent | ( | ) | const [inherited] |
Definition at line 162 of file node.cpp.
References node::parent.
Referenced by large_lithosphere::default_view_distance(), freeview::handle_event(), lithosphere::lithosphere(), large_lithosphere::max_extent(), large_lithosphere::minimum_view_distance(), freeview::reset(), and planet_earth::update().
string & get_parent_name | ( | ) | [inherited] |
gsgl::real_t get_priority | ( | gsgl::scenegraph::context * | ) | [virtual] |
Called to determine the draw priority of the node.
A value of NODE_DRAW_IGNORE means don't draw (invisible nodes or nodes that are drawn by their parents -- the modelview matrix is still built). A value of NODE_DRAW_SOLID means the object is solid and should be drawn after the painter's algorithm. A value of NODE_DRAW_TRANSLUCENT means the object is translucent and should be drawn after solid objects. A value > NODE_DRAW_TRANSLUCENT is interpreted as the distance to the object. Objects that return > 2.0 are drawn with a painter's algorithm.
Reimplemented from node.
Definition at line 97 of file stellardb.cpp.
References node::NODE_DRAW_FIRST.
gsgl::real_t & get_scale | ( | ) | [inherited] |
Definition at line 215 of file node.cpp.
References node::scale.
Referenced by stellar_db::draw(), gsgl::scenegraph::utils::greatest_extent(), and stellar_db::init().
math::vector & get_translation | ( | ) | [inherited] |
Definition at line 220 of file node.cpp.
References node::translation.
Referenced by freeview::handle_event(), rigid_body::init(), orbital_frame::init(), freeview::reset(), rigid_body::update(), orbital_frame::update(), freeview::update(), planet_earth::update(), and vehicle::vehicle().
const gsgl::string & get_type_name | ( | ) | const [virtual, inherited] |
Definition at line 54 of file broker.cpp.
References countable::is_empty(), and brokered_object::type_name.
Referenced by node::draw_scene(), and simulation::update_node().
bool handle_event | ( | gsgl::scenegraph::context * | c, | |
sg_event & | e | |||
) | [virtual, inherited] |
Called with events.
Reimplemented in freeview.
Definition at line 323 of file node.cpp.
Referenced by simulation::handle_event().
void init | ( | gsgl::scenegraph::context * | c | ) | [virtual] |
Called when the simulation is created. The node's modelview matrix is invalid at this point.
Reimplemented from node.
Definition at line 240 of file stellardb.cpp.
References shader_program::bind(), CHECK_GL_ERRORS, stellar_db::farthest_distance, shader_program::get_id(), node::get_scale(), shader_program::load(), stellar_db::star_shader, and shader_program::unbind().
void load_db | ( | const gsgl::string & | fname | ) | [private] |
Definition at line 107 of file stellardb.cpp.
References stellar_db::add_star_name(), gsgl::math::clamp(), gsgl::math::DEG2RAD, periapsis::space::EQUATORIAL_WRT_GALACTIC, stellar_db::farthest_distance, vector::get_x(), vector::get_y(), vector::get_z(), stellar_db::nearest_distance, stellar_db::num_stars, stellar_db::vertices, and string::w_string().
Referenced by stellar_db::stellar_db().
gsgl::real_t max_extent | ( | ) | const [virtual, inherited] |
Should return the maximum extent of the object (in the node's coordinates, i.e. not scaled to meters).
Reimplemented in submesh_node, checkered_box, celestial_body, and large_lithosphere.
Definition at line 249 of file node.cpp.
Referenced by node::draw_scene(), gsgl::scenegraph::utils::greatest_extent(), large_lithosphere::max_extent(), and node::minimum_view_distance().
gsgl::real_t minimum_view_distance | ( | ) | const [virtual, inherited] |
Reimplemented in vehicle, checkered_box, celestial_body, and large_lithosphere.
Definition at line 261 of file node.cpp.
References node::max_extent().
Referenced by freeview::handle_event(), and large_lithosphere::minimum_view_distance().
void pre_draw_scene | ( | gsgl::scenegraph::context * | c, | |
pre_draw_rec & | rec | |||
) | [static, inherited] |
Collect information about the scene to draw. Unsafe to call while update is being called in the tree.
Definition at line 380 of file node.cpp.
References node::build_draw_list(), context::cam, transform::IDENTITY, node::pre_draw_rec::light_queue, node::pre_draw_rec::paint_queue, node::pre_draw_rec::solids, and node::pre_draw_rec::translucents.
Referenced by simulation::pre_draw().
data::config_record * save | ( | ) | const [virtual, inherited] |
void update | ( | gsgl::scenegraph::context * | c | ) | [virtual, inherited] |
Called from the root of the world-tree up to update the node's state. The node's modelview matrix is that of the previously-drawn frame.
Reimplemented in rigid_body, vehicle, freeview, submesh_node, test_frame, checkered_box, planet_earth, large_lithosphere, large_rocky_body, orbital_frame, rotating_body, and spacecraft.
Definition at line 315 of file node.cpp.
Referenced by checkered_box::update(), and simulation::update_node().
float farthest_distance [private] |
Definition at line 56 of file stellardb.hpp.
Referenced by stellar_db::draw(), stellar_db::init(), and stellar_db::load_db().
float nearest_distance [private] |
Definition at line 56 of file stellardb.hpp.
Referenced by stellar_db::draw(), and stellar_db::load_db().
const gsgl::real_t NODE_DRAW_FIRST = FLT_MAX [static, inherited] |
Definition at line 218 of file node.hpp.
Referenced by stellar_db::get_priority(), solar_system::get_priority(), and galaxy::get_priority().
const gsgl::real_t NODE_DRAW_IGNORE = 0.000f [static, inherited] |
Definition at line 215 of file node.hpp.
Referenced by vehicle::get_priority(), planet_system::get_priority(), and node::get_priority().
const gsgl::real_t NODE_DRAW_SOLID = 0.001f [static, inherited] |
Definition at line 216 of file node.hpp.
Referenced by node::build_draw_list(), and submesh_node::get_priority().
const gsgl::real_t NODE_DRAW_TRANSLUCENT = 0.002f [static, inherited] |
Definition at line 217 of file node.hpp.
Referenced by node::build_draw_list(), checkered_box::get_priority(), and submesh_node::get_priority().
int num_stars [private] |
Definition at line 54 of file stellardb.hpp.
Referenced by stellar_db::draw(), and stellar_db::load_db().
Definition at line 61 of file stellardb.hpp.
Referenced by stellar_db::add_star_name(), and stellar_db::draw().
gsgl::data::simple_array<gsgl::string *> star_names [private] |
Definition at line 62 of file stellardb.hpp.
Referenced by stellar_db::add_star_name(), stellar_db::draw(), and stellar_db::~stellar_db().
gsgl::platform::shader_program star_shader [private] |
Definition at line 59 of file stellardb.hpp.
Referenced by stellar_db::cleanup(), stellar_db::draw(), stellar_db::init(), and stellar_db::stellar_db().
gsgl::platform::vertex_buffer vertices [private] |
Definition at line 58 of file stellardb.hpp.
Referenced by stellar_db::draw(), and stellar_db::load_db().