00001 /* 00002 * map-kdtree.h 00003 * 00004 * Copyright (C) 2010 Thomas A. Vaughan 00005 * All rights reserved. 00006 * 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the <organization> nor the 00016 * names of its contributors may be used to endorse or promote products 00017 * derived from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY 00020 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY 00023 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00026 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 * 00030 */ 00031 00032 #ifndef AESOP_MAP_KDTREE_H__ 00033 #define AESOP_MAP_KDTREE_H__ 00034 00035 00036 // includes -------------------------------------------------------------------- 00037 #include "glut/renderable.h" 00038 #include "map-dynamics/map-dynamics.h" 00039 #include "kdtree/kdtree.h" 00040 00041 00042 namespace aesop { 00043 00044 00079 00082 struct map_draw_stats_t { 00083 // constructor, manipulators 00084 map_draw_stats_t(void) throw() { this->clear(); } 00085 void clear(void) throw() { 00086 nObjects = 0; 00087 } 00088 00089 // data fields 00090 int nObjects; 00091 }; 00092 00093 00094 00095 struct kd_node_t { 00096 rect3d_t rect; 00097 int depth; 00098 }; 00099 00100 00101 typedef void (*kdtree_callback_fn)(IN const kd_node_t& node, 00102 IN void * context); 00103 00104 typedef void (*kdtree_object_fn)(IN glut::Renderable * model, 00105 IN const glut::render_context_t& rc, 00106 IN glut::RenderQueue * rq, 00107 IN void * context); 00108 00109 00111 class MapKdTree { 00112 public: 00113 // virtual destructor -------------------------------------------------- 00114 virtual ~MapKdTree(void) throw(); 00115 00116 // aesop::MapKdTree class interface methods ---------------------------- 00117 00119 virtual MapDynamics * getMapDynamics(void) throw() = 0; 00120 00122 virtual void walkNodes(IN kdtree_callback_fn callback, 00123 IN void * context) = 0; 00124 00126 virtual void walkFrontToBack(IN const glut::render_context_t& rc, 00127 IN glut::RenderQueue * rq, 00128 IN kdtree_object_fn callback, 00129 IN void * context) = 0; 00130 00131 // public static methods (factory methods) ----------------------------- 00132 static smart_ptr<MapKdTree> create(IN smart_ptr<MapDynamics>& map); 00133 }; 00134 00135 00136 00140 void drawMap(IN MapKdTree * mapKdTree, 00141 IN const glut::render_context_t& rc, 00142 IN glut::RenderQueue * rq, 00143 OUT map_draw_stats_t& stats); 00144 00145 00146 00147 }; // aesop namespace 00148 00149 #endif // AESOP_MAP_KDTREE_H__ 00150
1.7.1