Changeset 4868 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jul 15, 2005, 12:17:37 AM (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
r4852 r4868 55 55 56 56 /** 57 * gives the signal to separate the model into a quadtree 58 */ 59 void Quadtree::separate(int treeDepth) 60 { 61 this->rootNode->separateNode(treeDepth); 62 } 63 64 65 /** 66 * gives the signal to separate the model into a quadtree 67 */ 68 void Quadtree::separate(float minLength) 69 { 70 this->rootNode->separateNode(minLength); 71 } 72 73 74 /** 57 75 * draws the debug quadtree boxes around the model 58 76 */ -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
r4845 r4868 22 22 23 23 void separate(); 24 void separate(int treeDepth); 25 void separate(float minLength); 24 26 25 27 void drawTree(int depth, int drawMode) const; -
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 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4867 r4868 14 14 // FORWARD DEFINITION 15 15 class Quadtree; 16 class QuadtreeNode; 16 17 17 18 18 //! A class for a Quadtree Node representation … … 20 20 21 21 public: 22 QuadtreeNode(sTriangleExt** triangles, int numTriangles, Quadtree* quadtree); 22 QuadtreeNode(sTriangleExt** triangles, int numTriangles, 23 const float* pVertices, int numVertices, Quadtree* quadtree); 23 24 QuadtreeNode(modelInfo* pModelInfo); 24 25 virtual ~QuadtreeNode(); … … 34 35 void init(); 35 36 Rectangle* getDimension(modelInfo* pModelInfo); 37 Rectangle* getDimension(); 36 38 37 39 private: … … 45 47 const float* pVertices; //!< reference to vertices data 46 48 unsigned int numTriangles; //!< number of triangles of the Node 49 unsigned int numVertices; //!< number of vertices of the node 47 50 modelInfo* pModelInfo; //!< reference to the modelInfo of the object 48 51 Rectangle* pDimension; //!< pointer to the local rectangle properties -
orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
r4855 r4868 97 97 { 98 98 this->quadtree = new Quadtree(model->getModelInfo()); 99 this->quadtree->separate( );99 this->quadtree->separate(4); 100 100 101 101 return this->quadtree;
Note: See TracChangeset
for help on using the changeset viewer.