Changeset 4887 in orxonox.OLD
- Timestamp:
- Jul 18, 2005, 9:56:55 PM (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
r4868 r4887 57 57 * gives the signal to separate the model into a quadtree 58 58 */ 59 void Quadtree::separate( int treeDepth)59 void Quadtree::separate(const int maxDepth) 60 60 { 61 this->rootNode->separateNode( treeDepth);61 this->rootNode->separateNode(0, maxDepth); 62 62 } 63 63 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
r4868 r4887 22 22 23 23 void separate(); 24 void separate( int treeDepth);24 void separate(const int maxDepth); 25 25 void separate(float minLength); 26 26 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4869 r4887 27 27 * standard constructor 28 28 */ 29 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 30 29 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 30 const float* pVertices, int numVertices, Quadtree* quadtree) 31 31 { 32 32 this->pTriangles = triangles; … … 35 35 this->numVertices = numVertices; 36 36 this->quadtree = quadtree; 37 38 this->pDimension = this->getDimension(); 37 this->treeDepth = 0; 38 39 // this->pDimension = this->getDimension(); 39 40 this->init(); 40 41 } … … 47 48 { 48 49 this->pModelInfo = pModelInfo; 49 50 50 51 /* create an array of triangle references */ 51 52 this->pTriangles = new sTriangleExt*[this->pModelInfo->numTriangles]; … … 55 56 for( int i = 0; i < this->pModelInfo->numTriangles; ++i) 56 57 this->pTriangles[i] = &this->pModelInfo->pTriangles[i]; 57 58 this->pDimension = this->getDimension(this->pModelInfo); 58 this->treeDepth = 0; 59 60 // this->pDimension = this->getDimension(this->pModelInfo); 59 61 this->init(); 60 62 } … … 75 77 } 76 78 77 79 78 80 /** 79 81 * standard deconstructor … … 96 98 * @param treeDepth the max depth, the steps to go if treeDept == 0 leaf reached 97 99 */ 98 void QuadtreeNode::separateNode(int treeDepth) 99 { 100 if( treeDepth <= 0) 100 void QuadtreeNode::separateNode(int treeDepth, const int maxDepth) 101 { 102 for( int i = 0; i < treeDepth; ++i) 103 PRINT(3)(" "); 104 PRINT(3)(" +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth); 105 106 this->pDimension = this->getDimension(); 107 108 this->treeDepth = treeDepth; 109 if( treeDepth >= maxDepth) 101 110 return; 102 PRINTF(0)("separate Node Nr: %i\n", treeDepth); 111 103 112 this->separateNode(); 104 113 105 this->nodeA->separateNode(treeDepth - 1);106 this->nodeB->separateNode(treeDepth - 1);107 this->nodeC->separateNode(treeDepth - 1);108 this->nodeD->separateNode(treeDepth - 1);114 this->nodeA->separateNode(treeDepth + 1, maxDepth); 115 this->nodeB->separateNode(treeDepth + 1, maxDepth); 116 this->nodeC->separateNode(treeDepth + 1, maxDepth); 117 this->nodeD->separateNode(treeDepth + 1, maxDepth); 109 118 } 110 119 … … 116 125 void QuadtreeNode::separateNode(float minLength) 117 126 { 127 this->pDimension = this->getDimension(); 128 118 129 if( minLength <= this->pDimension->getAxis()) 119 130 return; 131 120 132 this->separateNode(); 121 133 … … 133 145 void QuadtreeNode::separateNode() 134 146 { 135 PRINTF(0)("got command to separate node\n");136 137 147 tList<sTriangleExt*>* listA = new tList<sTriangleExt*>(); //!< triangle list of nodeA 138 148 tList<sTriangleExt*>* listB = new tList<sTriangleExt*>(); //!< triangle list of nodeB … … 146 156 { 147 157 for( int j = 0; j < 3; ++j) 148 { 149 pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]]; 150 if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset) 151 listA->add(&this->pTriangles[i]); 152 if( pVert[0] > rectCenter->x + this->offset && pVert[2]< rectCenter->z + this->offset) 153 listB->add(&this->pTriangles[i]); 154 if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset) 155 listC->add(&this->pTriangles[i]); 156 if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset) 157 listD->add(&this->pTriangles[i]); 158 } 159 } 160 printf("Temp. list Num. o El: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize()); 161 162 158 { 159 pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]]; 160 if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset) 161 listA->add(&this->pTriangles[i]); 162 if( pVert[0] > rectCenter->x + this->offset && pVert[2]< rectCenter->z + this->offset) 163 listB->add(&this->pTriangles[i]); 164 if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset) 165 listC->add(&this->pTriangles[i]); 166 if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset) 167 listD->add(&this->pTriangles[i]); 168 } 169 } 170 for( int i = 0; i < treeDepth; ++i) 171 PRINT(3)(" "); 172 PRINT(3)(" +-| (II) Quadtree Counts: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize()); 173 163 174 /* Separating into to the triangle lists */ 164 175 sTriangleExt** pTriA; //!< Triangle array A … … 178 189 lenC = listC->getSize(); 179 190 lenD = listD->getSize(); 180 191 181 192 pTriA = new sTriangleExt*[listA->getSize()]; 182 193 pTriB = new sTriangleExt*[listB->getSize()]; 183 pTriC = new sTriangleExt*[listC->getSize()]; 194 pTriC = new sTriangleExt*[listC->getSize()]; 184 195 pTriD = new sTriangleExt*[listD->getSize()]; 185 196 … … 204 215 ++counter; 205 216 } 206 217 207 218 counter = 0; 208 219 iterator = listC->getIterator(); … … 237 248 this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree); 238 249 this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree); 239 240 241 PRINTF(0)("separation complete\n");242 250 } 243 251 … … 300 308 rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f))); 301 309 302 PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY); 303 PRINTF(0)("Center: %f, %f, %f Axis: %f\n", rect->getCenter()->x, rect->getCenter()->y, rect->getCenter()->z, rect->getAxis()); 310 for( int i = 0; i < this->treeDepth; ++i) 311 PRINT(3)(" "); 312 PRINT(3)(" +-| (II) Rectangle Dimension (%f, %f) to (%f, %f), Center (%f, %f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis()); 304 313 return rect; 305 314 } … … 309 318 \brief gets the maximal dimension of a model 310 319 \return the dimension of the AbstractModel as a Rectangle 311 320 312 321 The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the 313 322 size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to … … 320 329 float minX, minY; //!< minimal axis coorindates 321 330 const float* pVertices; //!< pointer to the current vertices 322 331 323 332 maxX = -999999; maxY = -999999; 324 333 minX = 999999; minY = 999999; 325 334 /* get maximal/minimal x/y */ 326 for( int i = 0; i < this->num Vertices; ++i)335 for( int i = 0; i < this->numTriangles; ++i) 327 336 { 328 pVertices = &this->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]; 337 for( int j = 0; j < 3; ++j) 338 { 339 340 pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]]; 341 if( pVertices[0] > maxX) 342 maxX = pVertices[0]; 343 if( pVertices[2] > maxY) 344 maxY = pVertices[2]; 345 346 if( pVertices[0] < minX) 347 minX = pVertices[0]; 348 if( pVertices[2] < minY) 349 minY = pVertices[2]; 350 } 338 351 } 339 352 … … 342 355 rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f))); 343 356 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()); 357 for( int i = 0; i < this->treeDepth; ++i) 358 PRINT(3)(" "); 359 PRINT(3)(" +-| (II) Rectangle Dimension (%f, %f) to (%f, %f), Center (%f, %f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis()); 346 360 return rect; 347 361 } -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4868 r4887 20 20 21 21 public: 22 QuadtreeNode(sTriangleExt** triangles, int numTriangles, 23 22 QuadtreeNode(sTriangleExt** triangles, int numTriangles, 23 const float* pVertices, int numVertices, Quadtree* quadtree); 24 24 QuadtreeNode(modelInfo* pModelInfo); 25 25 virtual ~QuadtreeNode(); 26 26 27 void separateNode(int treeDepth );27 void separateNode(int treeDepth, const int maxDepth); 28 28 void separateNode(float minLength); 29 29 void separateNode(); … … 44 44 float offset; //!< offset of the actual quadtree rectangle 45 45 46 int treeDepth; //!< the depth of the tree 47 46 48 sTriangleExt** pTriangles; //!< reference to the triangles of the node 47 49 const float* pVertices; //!< reference to vertices data -
orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
r4868 r4887 33 33 SpatialSeparation::SpatialSeparation (AbstractModel* model, float overlapSize) 34 34 { 35 PRINTF(0)("Spatial Separation process kicked on\n"); 35 PRINT(3)("\n"); 36 PRINT(3)("+---------Debug Information SpatialSeparation----------\n"); 37 PRINT(3)("+-| (Event) Spatial Separation process kicked on\n"); 38 36 39 this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation"); 37 40 /* debug vice */
Note: See TracChangeset
for help on using the changeset viewer.