Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

octree.h

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:17 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: octree.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: octree.h,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:17  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00043 #include            "vector.h"
00044 #include            "forward.h"
00045 
00046 /**************************************************************************** 
00047  **************************************************************************** 
00048  * TYPES ******************************************************************** 
00049  **************************************************************************** 
00050  ****************************************************************************/ 
00051 
00052 #ifndef             OMICRON_OCTREE_TYPES_DEFINED
00053 #define             OMICRON_OCTREE_TYPES_DEFINED
00054 
00055 template <class T>
00056 class octree_c
00058 {
00059 protected:
00060 
00061 #if !defined(__GNUG__)
00062     template <class T>
00063 #endif
00064     struct node_t
00066     {
00067         list_c<T>       *data;          
00068         struct node_t   *subnodes[8];   
00069         vec3_t          min, max;       
00070         vec3_t          pts[8];         
00071     };
00072 
00073     node_t<T> root;                     
00074 
00075     node_t<T> *                         
00076     create_node
00077     (node_t<T> *node, ulong num);
00078 
00079     slong                               
00080     get_subnode_num_vec
00081     (node_t<T> *node, vec3_t p);
00082 
00083     slong                               
00084     get_subnode_num
00085     (node_t<T> *node, vec3_t mn, vec3_t mx);
00086 
00087     void                                
00088     add_to_subnode
00089     (node_t<T> *node, T *d, vec3_t mn, vec3_t mx);
00090 
00091     slong                               
00092     get_visibility
00096     (node_t<T> *node);
00097 
00098     void                                
00099     add_complete_node_to_array          
00100     (node_t<T> *node, array_c<T> &list);
00101 
00102     void                                
00103     add_node_to_array
00104     (node_t<T> *node, array_c<T> &list);
00105 
00106     void                                
00107     remove_node
00108     (node_t<T> *node);
00109 
00110 public:
00111 
00112     vec3_c          viewmin, viewmax;
00113 
00114     octree_c();                         
00115     virtual ~octree_c();                
00116 
00117     void                                
00118     set_extents(vec3_t mn, vec3_t mx)
00119     {
00120         AssertThis;
00121 
00122         vector_copy(mn, root.min);
00123         vector_copy(mx, root.max);
00124     }
00125 
00126     void                                
00127     add(T *d, vec3_t mn, vec3_t mx);
00128 
00129     void                                
00130     remove(T *d);
00131 
00132     void                                
00133     get_visible(array_c<T> &list);
00134 
00135     void                                
00136     update_view();
00137 };
00138 
00139 #endif
00140 

Generated on Wed Dec 18 15:48:47 2002 for omicron engine by doxygen1.2.18