node Class Reference

#include <node.hpp>

Inheritance diagram for node:

Inheritance graph
[legend]
Collaboration diagram for node:

Collaboration graph
[legend]

List of all members.


Detailed Description

Base class for nodes in the scene graph.

Definition at line 79 of file node.hpp.


Scene Graph Functionality.

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...
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_tget_draw_flags ()
const gsgl::flags_tget_draw_flags () const
gsgl::flags_tget_draw_results ()
const gsgl::flags_tget_draw_results () const
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.

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
virtual gsgl::real_t default_view_distance () const
virtual gsgl::real_t get_priority (gsgl::scenegraph::context *)
 Called to determine the draw priority of the node.
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

Public Member Functions

virtual const gsgl::stringget_type_name () const
 node (const data::config_record &conf)
 Creates a node from a config_record record.
 node (const gsgl::string &name, node *parent)
 Creates a node with a given name and parent.
virtual ~node ()
Node Life Cycle.
virtual void cleanup (gsgl::scenegraph::context *c)
 Called when the simulation is done.
virtual void draw (gsgl::scenegraph::context *c)
 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 bool handle_event (gsgl::scenegraph::context *c, sg_event &e)
 Called with events.
virtual void init (gsgl::scenegraph::context *c)
 Called when the simulation is created. The node's modelview matrix is invalid at this point.
virtual data::config_recordsave () 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.
Accessors.
data::simple_array< node * > & get_children ()
math::transformget_modelview ()
stringget_name ()
const stringget_name () const
math::transformget_orientation ()
node *& get_parent ()
const nodeget_parent () const
stringget_parent_name ()
gsgl::real_tget_scale ()
math::vectorget_translation ()

Static Private Member Functions

static void build_draw_list (node *cur, node *prev, context *c, const math::transform &modelview, pre_draw_rec &)

Private Attributes

data::simple_array< node * > children
gsgl::flags_t draw_flags
 Flags that control how the node should be drawn (these stay fairly constant).
gsgl::flags_t draw_results
 Flags that indicate what happened to the node when it was drawn (these may change frame to frame).
math::transform modelview
 The modelview matrix the node should be drawn with.
string name
math::transform orientation
 Multiply this by a position in the node's frame to yield the position in the parent's frame. Should never contain a translation component!
nodeparent
string parent_name
gsgl::real_t scale
 The scale of the node in meters per unit.
math::vector translation
 The translation of the node's frame in its parent's frame and scale.

Classes

struct  pre_draw_rec
 Contains information about the current drawing pass. More...

Member Enumeration Documentation

Flags that control node drawing.

Enumerator:
NODE_NO_DRAW_FLAGS 
NODE_NO_FRUSTUM_CHECK  Don't perform a frustum check when drawing this node.
NODE_DUMMY_OBJECT  This node should never be drawn.
NODE_DRAW_UNLIT  This node should not be lit.

Definition at line 141 of file node.hpp.

Flags that indicate what happened when the node was drawn.

Enumerator:
NODE_NO_DRAW_RESULTS 
NODE_OFF_SCREEN  The node was not drawn because it was out-of-frame.
NODE_DREW_POINT  The node was drawn as a point.
NODE_DISTANCE_CULLED  The node was not drawn due to distance.

Definition at line 157 of file node.hpp.


Constructor & Destructor Documentation

node ( const gsgl::string name,
node parent 
)

Creates a node with a given name and parent.

Definition at line 122 of file node.cpp.

References node::add_child().

node ( const data::config_record conf  ) 

Creates a node from a config_record record.

Definition at line 134 of file node.cpp.

References node::name, node::orientation, node::parent_name, gsgl::math::units::parse(), node::scale, and node::translation.

~node (  )  [virtual]

Definition at line 153 of file node.cpp.

References node::children.


Member Function Documentation

void add_child ( node child  ) 

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 build_draw_list ( node cur,
node prev,
context c,
const math::transform modelview,
pre_draw_rec rec 
) [static, private]

void cleanup ( gsgl::scenegraph::context c  )  [virtual]

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.

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]

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 (  ) 

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 in vehicle, submesh_node, test_frame, checkered_box, celestial_body, galaxy, large_lithosphere, large_rocky_body, planet_system, solar_system, spacecraft, star, and stellar_db.

Definition at line 311 of file node.cpp.

Referenced by vehicle::draw(), large_rocky_body::draw(), and node::draw_scene().

void draw_scene ( gsgl::scenegraph::context c,
pre_draw_rec rec 
) [static]

data::simple_array< node * > & get_children (  ) 

gsgl::flags_t& get_draw_flags (  )  [inline]

Returns:
The node's draw flags (a bitset using node_draw_flags).

Definition at line 153 of file node.hpp.

const gsgl::flags_t& get_draw_flags (  )  const [inline]

gsgl::flags_t& get_draw_results (  )  [inline]

Returns:
The node's draw results (a bitset using node_draw_results).

Definition at line 169 of file node.hpp.

const gsgl::flags_t& get_draw_results (  )  const [inline]

Returns:
The node's draw results (a bitset using node_draw_results).

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 (  ) 

string & get_name (  ) 

Definition at line 205 of file node.cpp.

References node::name.

const string & get_name (  )  const

math::transform & get_orientation (  ) 

node *& get_parent (  ) 

Definition at line 168 of file node.cpp.

References node::parent.

const node * get_parent (  )  const

string & get_parent_name (  ) 

Definition at line 210 of file node.cpp.

References node::parent_name.

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 in vehicle, submesh_node, test_frame, checkered_box, celestial_body, galaxy, large_lithosphere, large_rocky_body, planet_system, solar_system, and stellar_db.

Definition at line 243 of file node.cpp.

References node::NODE_DRAW_IGNORE.

Referenced by node::build_draw_list().

gsgl::real_t & get_scale (  ) 

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 (  ) 

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]

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 in rigid_body, vehicle, submesh_node, test_frame, checkered_box, celestial_body, galaxy, large_lithosphere, large_rocky_body, orbital_frame, rotating_body, solar_system, spacecraft, star, and stellar_db.

Definition at line 307 of file node.cpp.

Referenced by simulation::init_node().

gsgl::real_t max_extent (  )  const [virtual]

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]

void pre_draw_scene ( gsgl::scenegraph::context c,
pre_draw_rec rec 
) [static]

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]

Called to save the node to a config_record structure.

Definition at line 328 of file node.cpp.

void update ( gsgl::scenegraph::context c  )  [virtual]

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().


Member Data Documentation

Flags that control how the node should be drawn (these stay fairly constant).

Definition at line 94 of file node.hpp.

Referenced by node::build_draw_list().

Flags that indicate what happened to the node when it was drawn (these may change frame to frame).

Definition at line 95 of file node.hpp.

Referenced by node::draw_scene().

The modelview matrix the node should be drawn with.

Definition at line 92 of file node.hpp.

Referenced by node::build_draw_list(), and node::get_modelview().

string name [private]

Definition at line 85 of file node.hpp.

Referenced by node::connect(), node::get_name(), and node::node().

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]

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]

Multiply this by a position in the node's frame to yield the position in the parent's frame. Should never contain a translation component!

Definition at line 90 of file node.hpp.

Referenced by node::build_draw_list(), node::get_orientation(), and node::node().

node* parent [private]

string parent_name [private]

Definition at line 85 of file node.hpp.

Referenced by node::connect(), node::get_parent_name(), and node::node().

gsgl::real_t scale [private]

The scale of the node in meters per unit.

Definition at line 87 of file node.hpp.

Referenced by node::build_draw_list(), node::draw_scene(), node::get_scale(), and node::node().

The translation of the node's frame in its parent's frame and scale.

Definition at line 89 of file node.hpp.

Referenced by node::build_draw_list(), node::get_translation(), and node::node().


The documentation for this class was generated from the following files:

Generated on Sat Mar 1 13:50:07 2008 for Periapsis Project by  doxygen 1.5.5