Classes | Typedefs | Functions | Variables

Map kd-Tree Library
[AESOP Maps and Map Management]

The MapKdTree class is used to help manage drawing aesop Maps and Zones (see aesop::Map and aesop::Zone). More...

Collaboration diagram for Map kd-Tree Library:

Classes

struct  aesop::map_draw_stats_t
struct  aesop::kd_node_t
class  aesop::MapKdTree
 top-level object that manages the full kd-tree More...

Typedefs

typedef void(* aesop::kdtree_callback_fn )(const kd_node_t &node, void *context)
typedef void(* aesop::kdtree_object_fn )(glut::Renderable *model, const glut::render_context_t &rc, glut::RenderQueue *rq, void *context)

Functions

void aesop::map_draw_stats_t::clear (void) throw ()
virtual MapDynamics * aesop::MapKdTree::getMapDynamics (void)=0 throw ()
 get the underlying MapDynamics object
virtual void aesop::MapKdTree::walkNodes (kdtree_callback_fn callback, void *context)=0
 visit all nodes in the tree in arbitrary order
virtual void aesop::MapKdTree::walkFrontToBack (const glut::render_context_t &rc, glut::RenderQueue *rq, kdtree_object_fn callback, void *context)=0
 visit all objects in the tree, walking front to back
static smart_ptr< MapKdTree > aesop::MapKdTree::create (smart_ptr< MapDynamics > &map)
void aesop::drawMap (MapKdTree *mapKdTree,const glut::render_context_t &rc,glut::RenderQueue *rq,map_draw_stats_t &stats)
 helper method to draw a KdTree map.

Variables

int aesop::map_draw_stats_t::nObjects
 number of objects drawn
int aesop::kd_node_t::depth
 root-->depth=0, then increases

Detailed Description

The MapKdTree class is used to help manage drawing aesop Maps and Zones (see aesop::Map and aesop::Zone).

Internally, the MapKdTree maintains a kd-tree which provides efficient front-to-back traversal of all objects near the viewer within the view frustum. The MapKdTree is also aware of zone visibility flags and will use that to optimize tree walking. Furthermore, the MapKdTree is aware of virtual zones and will make objects in virtual leaf zones available for rendering if they should be visible.

In general, when walking a large 3D scee for rendering, you should:

In addition, the MapKdTree class knows how to update dynamic objects it contains. It will remove them and re-insert them at updated positions whenever you call MapKdTree::update().

The goal is to make things easy for the client: when you have a MapDynamics object, create a MapKdTree object for it, and then you can use the MapKdTree to efficiently render everything in the map. As a client, just call MapKdTree::walkFrontToBack() and you'll be given objects to render in the proper order (and these will only be objects within the view frustum and in zones visible to the viewer).


Typedef Documentation

typedef void(* aesop::kdtree_callback_fn)(const kd_node_t &node,void *context)

Definition at line 101 of file map-kdtree.h.

typedef void(* aesop::kdtree_object_fn)(glut::Renderable *model,const glut::render_context_t &rc,glut::RenderQueue *rq,void *context)

Definition at line 104 of file map-kdtree.h.


Function Documentation

void aesop::map_draw_stats_t::clear ( void   )  throw () [inline, inherited]

Definition at line 85 of file map-kdtree.h.

virtual MapDynamics* aesop::MapKdTree::getMapDynamics ( void   )  throw () [pure virtual, inherited]

get the underlying MapDynamics object

virtual void aesop::MapKdTree::walkNodes ( kdtree_callback_fn  callback,
void *  context 
) [pure virtual, inherited]

visit all nodes in the tree in arbitrary order

virtual void aesop::MapKdTree::walkFrontToBack ( const glut::render_context_t rc,
glut::RenderQueue rq,
kdtree_object_fn  callback,
void *  context 
) [pure virtual, inherited]

visit all objects in the tree, walking front to back

smart_ptr< MapKdTree > aesop::MapKdTree::create ( smart_ptr< MapDynamics > &  map  )  [static, inherited]

Definition at line 1038 of file map-kdtree.cpp.

void aesop::drawMap ( MapKdTree *  mapKdTree,
const glut::render_context_t rc,
glut::RenderQueue rq,
map_draw_stats_t &  stats 
)

helper method to draw a KdTree map.

Caller must provide an (empty) glut::RenderQueue object, which this routine uses to render transparent polygons.


Variable Documentation

number of objects drawn

Definition at line 90 of file map-kdtree.h.

int aesop::kd_node_t::depth [inherited]

root-->depth=0, then increases

Definition at line 97 of file map-kdtree.h.