Changeset 4898 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jul 19, 2005, 9:59:28 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/spatial_separation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
r4889 r4898 26 26 @todo this constructor is not jet implemented - do it 27 27 */ 28 Quadtree::Quadtree (modelInfo* pModelInfo )28 Quadtree::Quadtree (modelInfo* pModelInfo, const int treeDepth) 29 29 { 30 30 this->setClassID(CL_QUADTREE, "Quadtree"); 31 31 this->pModelInfo = pModelInfo; 32 this->treeDepth = treeDepth; 32 33 33 this->rootNode = new QuadtreeNode(this->pModelInfo );34 this->rootNode = new QuadtreeNode(this->pModelInfo, this->treeDepth); 34 35 } 35 36 … … 46 47 47 48 /** 48 * gives the signal to separate the model into a quadtree49 */50 void Quadtree::separate()51 {52 this->rootNode->separateNode();53 }54 55 56 /**57 * gives the signal to separate the model into a quadtree58 */59 void Quadtree::separate(const int maxDepth)60 {61 this->rootNode->separateNode(0, maxDepth);62 }63 64 65 /**66 * gives the signal to separate the model into a quadtree67 */68 void Quadtree::separate(float minLength)69 {70 this->rootNode->separateNode(minLength);71 }72 73 74 /**75 49 * draws the debug quadtree boxes around the model 76 50 */ -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
r4887 r4898 18 18 19 19 public: 20 Quadtree(modelInfo* pModelInfo );20 Quadtree(modelInfo* pModelInfo, const int treeDepth); 21 21 virtual ~Quadtree(); 22 23 void separate();24 void separate(const int maxDepth);25 void separate(float minLength);26 22 27 23 void drawTree(int depth, int drawMode) const; … … 30 26 QuadtreeNode* rootNode; //!< reference to the root node of the quadtree 31 27 modelInfo* pModelInfo; //!< reference to the modelInfo of the object 32 28 int treeDepth; //!< depth of the tree 33 29 }; 34 30 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4897 r4898 30 30 const float* pVertices, int numVertices, 31 31 Quadtree* quadtree, QuadtreeNode* parent, 32 Rectangle* rect 32 Rectangle* rect, int treeDepth, const int maxDepth 33 33 ) 34 34 { … … 41 41 this->parent = parent; 42 42 this->pDimension = rect; 43 this->treeDepth = treeDepth; 44 this->maxDepth = maxDepth; 45 46 47 /* debug output */ 48 for( int i = 0; i < this->treeDepth; ++i) 49 PRINT(3)(" |"); 50 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 51 52 for( int i = 0; i < this->treeDepth; ++i) 53 PRINT(3)(" |"); 54 PRINT(3)(" | +-| (II) Rectangle Center (%5.2f, %5.2f), half axis length: %5.2f\n", 55 this->pDimension->getCenter()->x, this->pDimension->getCenter()->z, this->pDimension->getAxis()); 43 56 44 57 this->init(); … … 49 62 * standard constructor 50 63 */ 51 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo )64 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, const int maxDepth) 52 65 { 53 66 this->pModelInfo = pModelInfo; … … 61 74 this->pTriangles[i] = &this->pModelInfo->pTriangles[i]; 62 75 this->treeDepth = 0; 76 this->maxDepth = maxDepth; 77 78 /* debug output */ 79 for( int i = 0; i < this->treeDepth; ++i) 80 PRINT(3)(" |"); 81 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 63 82 64 83 this->pDimension = this->getDimFromModel(); … … 80 99 this->nodeC = NULL; 81 100 this->nodeD = NULL; 101 102 this->separateNode(this->treeDepth, this->maxDepth); 82 103 } 83 104 … … 105 126 void QuadtreeNode::separateNode(int treeDepth, const int maxDepth) 106 127 { 107 this->treeDepth = treeDepth; 108 /* debug output */ 109 for( int i = 0; i < treeDepth; ++i) 110 PRINT(3)(" |"); 111 PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 128 112 129 113 130 /* dimension calculation & limit checking */ … … 118 135 /* node separation */ 119 136 this->separateNode(); 120 this->nodeA->separateNode(treeDepth + 1, maxDepth); 121 this->nodeB->separateNode(treeDepth + 1, maxDepth); 122 this->nodeC->separateNode(treeDepth + 1, maxDepth); 123 this->nodeD->separateNode(treeDepth + 1, maxDepth); 137 138 // this->nodeA->separateNode(treeDepth + 1, maxDepth); 139 // this->nodeB->separateNode(treeDepth + 1, maxDepth); 140 // this->nodeC->separateNode(treeDepth + 1, maxDepth); 141 // this->nodeD->separateNode(treeDepth + 1, maxDepth); 124 142 } 125 143 … … 252 270 Vector v; 253 271 254 v.x = this-> center.x + this->pDimension->getAxis() / 2.0f;255 v.z = this-> center.z + this->pDimension->getAxis() / 2.0f;272 v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f; 273 v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f; 256 274 Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 257 275 258 v.z = this-> center.z - this->pDimension->getAxis() / 2.0f;276 v.z = this->pDimension->getCenter()->z - this->pDimension->getAxis() / 2.0f; 259 277 Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 260 278 261 v.x = this-> center.x - this->pDimension->getAxis() / 2.0f;279 v.x = this->pDimension->getCenter()->x - this->pDimension->getAxis() / 2.0f; 262 280 Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 263 281 264 v.z = this-> center.z + this->pDimension->getAxis() / 2.0f;282 v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f; 265 283 Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 266 284 267 285 /* now propagate */ 268 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA );269 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB );270 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC );271 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD );286 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth); 287 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth); 288 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth); 289 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth); 272 290 } 273 291 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4897 r4898 23 23 const float* pVertices, int numVertices, 24 24 Quadtree* quadtree, QuadtreeNode* parent, 25 Rectangle* rect );26 QuadtreeNode(modelInfo* pModelInfo );25 Rectangle* rect, int treeDepth, const int maxDepth); 26 QuadtreeNode(modelInfo* pModelInfo, const int maxDepth); 27 27 virtual ~QuadtreeNode(); 28 29 void separateNode(int treeDepth, const int maxDepth);30 void separateNode(float minLength);31 void separateNode();32 28 33 29 void drawTree(int depth, int drawMode) const; … … 37 33 void init(); 38 34 35 void separateNode(int treeDepth, const int maxDepth); 36 void separateNode(float minLength); 37 void separateNode(); 38 39 39 Rectangle* getDimFromModel(); 40 41 40 42 41 protected: … … 55 54 56 55 int treeDepth; //!< the depth of the tree 56 int maxDepth; //!< the maximal depth of the tree 57 57 58 58 sTriangleExt** pTriangles; //!< reference to the triangles of the node -
orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
r4889 r4898 99 99 Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model) 100 100 { 101 this->quadtree = new Quadtree(model->getModelInfo()); 102 this->quadtree->separate(4); 101 this->quadtree = new Quadtree(model->getModelInfo(), 4); 103 102 104 103 return this->quadtree;
Note: See TracChangeset
for help on using the changeset viewer.