Changeset 4845 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
- Timestamp:
- Jul 12, 2005, 11:48:39 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4836 r4845 27 27 { 28 28 this->setClassID(CL_QUADTREE_NODE, "QuadtreeNode"); 29 } 30 31 32 /** 33 * standard constructor 34 */ 35 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo) 36 { 37 this->pModelInfo = pModelInfo; 38 this->getDimension(this->pModelInfo); 29 39 } 30 40 … … 61 71 void QuadtreeNode::drawTree(int depth, int drawMode) const 62 72 {} 73 74 75 76 /** 77 \brief gets the maximal dimension of a model 78 * @param playerModel the model that this measurement is based on 79 \return the dimension of the AbstractModel as a Rectangle 80 81 The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the 82 size of 999999.0, there probably will be some errors in the dimensions calculations. 83 */ 84 Rectangle* QuadtreeNode::getDimension(modelInfo* pModelInfo) 85 { 86 float maxX, maxY; //!< the maximal coordinates axis 87 float minX, minY; //!< minimal axis coorindates 88 const float* pVertices; //!< pointer to the current vertices 89 90 maxX = -999999; maxY = -999999; 91 minX = 999999; minY = 999999; 92 /* get maximal/minimal x/y */ 93 for( int i = 0; i < pModelInfo->numVertices; ++i) 94 { 95 pVertices = &pModelInfo->pVertices[i * 3]; 96 if( pVertices[0] > maxX) 97 maxX = pVertices[0]; 98 if( pVertices[2] > maxY) 99 maxY = pVertices[2]; 100 101 if( pVertices[0] < minX) 102 minX = pVertices[0]; 103 if( pVertices[2] < minY) 104 minY = pVertices[2]; 105 } 106 107 Rectangle* rect = new Rectangle(); 108 rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */ 109 rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f))); 110 111 PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY); 112 return rect; 113 } 114
Note: See TracChangeset
for help on using the changeset viewer.