Changeset 4868 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
- Timestamp:
- Jul 15, 2005, 12:17:37 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4867 r4868 17 17 18 18 #include "quadtree_node.h" 19 #include "abstract_model.h" 19 20 #include "list.h" 20 21 #include "vector.h" … … 26 27 * standard constructor 27 28 */ 28 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, Quadtree* quadtree) 29 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 30 const float* pVertices, int numVertices, Quadtree* quadtree) 29 31 { 30 32 this->pTriangles = triangles; 31 33 this->numTriangles = numTriangles; 34 this->pVertices = pVertices; 35 this->numVertices = numVertices; 32 36 this->quadtree = quadtree; 33 37 38 this->pDimension = this->getDimension(); 34 39 this->init(); 35 40 } … … 47 52 this->numTriangles = this->pModelInfo->numTriangles; 48 53 this->pVertices = this->pModelInfo->pVertices; 54 this->numVertices = this->pModelInfo->numVertices; 49 55 for( int i = 0; i < this->pModelInfo->numTriangles; ++i) 50 56 this->pTriangles[i] = &this->pModelInfo->pTriangles[i]; 51 57 58 this->pDimension = this->getDimension(this->pModelInfo); 52 59 this->init(); 53 60 } … … 93 100 if( treeDepth <= 0) 94 101 return; 102 PRINTF(0)("separate Node Nr: %i\n", treeDepth); 95 103 this->separateNode(); 96 104 … … 126 134 { 127 135 PRINTF(0)("got command to separate node\n"); 128 129 this->pDimension = this->getDimension(this->pModelInfo);130 136 131 137 tList<sTriangleExt*>* listA = new tList<sTriangleExt*>(); //!< triangle list of nodeA … … 227 233 228 234 /* now propagate */ 229 this->nodeA = new QuadtreeNode(pTriA, lenA, this-> quadtree);230 this->nodeB = new QuadtreeNode(pTriB, lenB, this-> quadtree);231 this->nodeC = new QuadtreeNode(pTriC, lenC, this-> quadtree);232 this->nodeD = new QuadtreeNode(pTriD, lenD, this-> quadtree);235 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree); 236 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree); 237 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree); 238 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree); 233 239 234 240 … … 299 305 } 300 306 307 308 /** 309 \brief gets the maximal dimension of a model 310 \return the dimension of the AbstractModel as a Rectangle 311 312 The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the 313 size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to 314 patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be 315 happy to see orxonox used to extensivly :) 316 */ 317 Rectangle* QuadtreeNode::getDimension() 318 { 319 float maxX, maxY; //!< the maximal coordinates axis 320 float minX, minY; //!< minimal axis coorindates 321 const float* pVertices; //!< pointer to the current vertices 322 323 maxX = -999999; maxY = -999999; 324 minX = 999999; minY = 999999; 325 /* get maximal/minimal x/y */ 326 for( int i = 0; i < this->numVertices; ++i) 327 { 328 pVertices = &pModelInfo->pVertices[i * 3]; 329 if( pVertices[0] > maxX) 330 maxX = pVertices[0]; 331 if( pVertices[2] > maxY) 332 maxY = pVertices[2]; 333 334 if( pVertices[0] < minX) 335 minX = pVertices[0]; 336 if( pVertices[2] < minY) 337 minY = pVertices[2]; 338 } 339 340 Rectangle* rect = new Rectangle(); 341 rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */ 342 rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f))); 343 344 PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY); 345 PRINTF(0)("Center: %f, %f, %f Axis: %f\n", rect->getCenter()->x, rect->getCenter()->y, rect->getCenter()->z, rect->getAxis()); 346 return rect; 347 } 348
Note: See TracChangeset
for help on using the changeset viewer.