Changeset 4845 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.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/spatial_separation.cc
r4844 r4845 34 34 { 35 35 this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation"); 36 this-> getDimension(model);36 this->createQuadtree(model); 37 37 } 38 38 … … 97 97 this->quadtree->separate(); 98 98 99 99 100 return this->quadtree; 100 }101 102 103 /**104 \brief gets the maximal dimension of a model105 * @param playerModel the model that this measurement is based on106 \return the dimension of the AbstractModel as a Rectangle107 108 The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the109 size of 999999.0, there probably will be some errors in the dimensions calculations.110 */111 Rectangle* SpatialSeparation::getDimension(AbstractModel* playerModel)112 {113 float maxX, maxY; //!< the maximal coordinates axis114 float minX, minY; //!< minimal axis coorindates115 const float* pVertices; //!< pointer to the current vertices116 117 maxX = -999999; maxY = -999999;118 minX = 999999; minY = 999999;119 /* get maximal/minimal x/y */120 for( int i = 0; i < playerModel->getModelInfo()->numVertices; ++i)121 {122 pVertices = &playerModel->getModelInfo()->pVertices[i * 3];123 if( pVertices[0] > maxX)124 maxX = pVertices[0];125 if( pVertices[2] > maxY)126 maxY = pVertices[2];127 128 if( pVertices[0] < minX)129 minX = pVertices[0];130 if( pVertices[2] < minY)131 minY = pVertices[2];132 }133 Rectangle* rect = new Rectangle();134 135 rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f);136 137 138 PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY);139 101 } 140 102
Note: See TracChangeset
for help on using the changeset viewer.