Changeset 4897 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation
- Timestamp:
- Jul 19, 2005, 9:33:23 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/spatial_separation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4896 r4897 29 29 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 30 30 const float* pVertices, int numVertices, 31 Quadtree* quadtree, QuadtreeNode* parent) 31 Quadtree* quadtree, QuadtreeNode* parent, 32 Rectangle* rect 33 ) 32 34 { 33 35 this->pTriangles = triangles; … … 38 40 this->treeDepth = 0; 39 41 this->parent = parent; 42 this->pDimension = rect; 40 43 41 44 this->init(); … … 59 62 this->treeDepth = 0; 60 63 64 this->pDimension = this->getDimFromModel(); 61 65 this->init(); 62 66 } … … 108 112 109 113 /* dimension calculation & limit checking */ 110 this->pDimension = this->getDimension(); 114 111 115 if( treeDepth >= maxDepth) 112 116 return; … … 128 132 { 129 133 /* dimension calculation & limit checking */ 130 this->pDimension = this->getDimension();131 134 if( minLength <= this->pDimension->getAxis()) 132 135 return; … … 245 248 delete iterator; 246 249 250 251 /* now create the rectangle dimensions */ 252 Vector v; 253 254 v.x = this->center.x + this->pDimension->getAxis() / 2.0f; 255 v.z = this->center.z + this->pDimension->getAxis() / 2.0f; 256 Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 257 258 v.z = this->center.z - this->pDimension->getAxis() / 2.0f; 259 Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 260 261 v.x = this->center.x - this->pDimension->getAxis() / 2.0f; 262 Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 263 264 v.z = this->center.z + this->pDimension->getAxis() / 2.0f; 265 Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f); 266 247 267 /* now propagate */ 248 this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this );249 this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this );250 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this );251 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this );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); 252 272 } 253 273 … … 282 302 283 303 284 /**285 \brief gets the maximal dimension of a model286 * @param playerModel the model that this measurement is based on287 \return the dimension of the AbstractModel as a Rectangle288 289 The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the290 size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to291 patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be292 happy to see orxonox used to extensivly :)293 */294 Rectangle* QuadtreeNode::getDimension(modelInfo* pModelInfo)295 {296 float maxX, maxY; //!< the maximal coordinates axis297 float minX, minY; //!< minimal axis coorindates298 const float* pVertices; //!< pointer to the current vertices299 300 maxX = -999999; maxY = -999999;301 minX = 999999; minY = 999999;302 /* get maximal/minimal x/y */303 for( int i = 0; i < pModelInfo->numVertices; ++i)304 {305 pVertices = &pModelInfo->pVertices[i * 3];306 if( pVertices[0] > maxX)307 maxX = pVertices[0];308 if( pVertices[2] > maxY)309 maxY = pVertices[2];310 311 if( pVertices[0] < minX)312 minX = pVertices[0];313 if( pVertices[2] < minY)314 minY = pVertices[2];315 }316 317 Rectangle* rect = new Rectangle();318 rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */319 rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));320 321 for( int i = 0; i < this->treeDepth; ++i)322 PRINT(3)(" |");323 PRINT(3)(" | +-| (II) Rectangle Dimension (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());324 return rect;325 }326 327 304 328 305 /** … … 335 312 happy to see orxonox used to extensivly :) 336 313 */ 337 Rectangle* QuadtreeNode::getDim ension()314 Rectangle* QuadtreeNode::getDimFromModel() 338 315 { 339 316 float maxX, maxY; //!< the maximal coordinates axis -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4896 r4897 22 22 QuadtreeNode(sTriangleExt** triangles, int numTriangles, 23 23 const float* pVertices, int numVertices, 24 Quadtree* quadtree, QuadtreeNode* parent); 24 Quadtree* quadtree, QuadtreeNode* parent, 25 Rectangle* rect); 25 26 QuadtreeNode(modelInfo* pModelInfo); 26 27 virtual ~QuadtreeNode(); … … 35 36 private: 36 37 void init(); 37 Rectangle* getDimension(modelInfo* pModelInfo); 38 Rectangle* getDim ension();38 39 Rectangle* getDimFromModel(); 39 40 40 41
Note: See TracChangeset
for help on using the changeset viewer.