vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OctTree.h
Go to the documentation of this file.
1 /***************************************************************************
2  octtree.h - description
3  -------------------
4  begin : Jun 2002
5  copyright : (C) 2002 by Jan Flasar
6  email : flasar@fi.muni.cz
7  ***************************************************************************/
8 
9 
10 #ifndef OCTTREE_H
11 #define OCTTREE_H
12 
13 #include <vrecko/BaseClass.h>
15 
16 namespace vrecko {
17 
18 
19 class VRECKO_EXPORT OctTree: public BaseClass {
20  public:
21  OctTree();
22  OctTree(double _new_cell_size, double _new_space_size);
23  ~OctTree();
24 
25  void addObject(EnvironmentObject *_object);
26  void removeObject(EnvironmentObject *_object);
27  EnvironmentObject **getObjectNeighbourhood(EnvironmentObject *_object, int &_object_count);
28  void objectChanged(EnvironmentObject *_object);
29 
30 /* typedef struct OctTreeNode;
31  typedef struct {
32  OctTreeNode *parent_node;
33  EnvironmentObject **objects_in_cell;
34  long int object_count;
35  osg::Vec3 position;
36  } OctTreeCell;
37 */
38  typedef struct OctTreeNode{
40  OctTreeNode *(child_nodes[8]);
41  //OctTreeCell *(cell_nodes[8]);
42  double subspace_size;
43  osg::Vec3 position;
44  long int object_count;
46  bool isCell;
47  };
48 
49  protected:
50  double cell_size;
51  double space_size;
53 
54  OctTreeNode *addToNode(int _node_id, OctTreeNode *_parent, EnvironmentObject *_object);
55  OctTreeNode *addToCell(int _node_id, OctTreeNode *_parent, EnvironmentObject *_object);
56  void delFromNode(OctTreeNode *_node, EnvironmentObject *_object);
57 
59  void delFromCell(OctTreeNode *_node, EnvironmentObject *_object);
60 
61  bool isObjectInNode(OctTreeNode *_node, EnvironmentObject *_object);
62  bool isObjectInCell(OctTreeNode *_node, EnvironmentObject *_object);
63  OctTreeNode *findObject(EnvironmentObject *_object);
64  OctTreeNode *findObjectInNode(int _node_id, OctTreeNode *_node, EnvironmentObject *_object);
65 };
66 
67 }
68 
69 #endif
70