Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc @ 5868

Last change on this file since 5868 was 5868, checked in by patrick, 18 years ago

collision_detection: box dimension calculation adjusted

File size: 38.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_DETECTION
17
18#include "obb_tree_node.h"
19#include "list.h"
20#include "obb.h"
21#include "obb_tree.h"
22#include "matrix.h"
23#include "abstract_model.h"
24#include "world_entity.h"
25
26#include "color.h"
27
28#include "debug.h"
29#include "glincl.h"
30
31
32
33using namespace std;
34
35float**  OBBTreeNode::coMat = NULL;
36float**  OBBTreeNode::eigvMat = NULL;
37float*   OBBTreeNode::eigvlMat = NULL;
38int*     OBBTreeNode::rotCount = NULL;
39GLUquadricObj* OBBTreeNode_sphereObj = NULL;
40
41/**
42 *  standard constructor
43 */
44OBBTreeNode::OBBTreeNode (const OBBTree& tree, unsigned int depth)
45    : BVTreeNode()
46{
47  this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode");
48
49  this->obbTree = &tree;
50  this->depth = depth;
51
52  this->nodeLeft = NULL;
53  this->nodeRight = NULL;
54  this->bvElement = NULL;
55
56  this->tmpVert1 = NULL;
57  this->tmpVert2 = NULL;
58
59  if( OBBTreeNode::coMat == NULL)
60  {
61    OBBTreeNode::coMat = new float*[4];
62    for(int i = 0; i < 4; i++)
63      OBBTreeNode::coMat[i] = new float[4];
64  }
65  if( OBBTreeNode::eigvMat == NULL)
66  {
67    OBBTreeNode::eigvMat = new float*[4];
68    for( int i = 0; i < 4; i++)
69      OBBTreeNode::eigvMat[i] = new float[4];
70  }
71  if( OBBTreeNode::eigvlMat == NULL)
72  {
73    OBBTreeNode::eigvlMat = new float[4];
74  }
75  if( OBBTreeNode::rotCount == NULL)
76    OBBTreeNode::rotCount = new int;
77
78  if( OBBTreeNode_sphereObj == NULL)
79    OBBTreeNode_sphereObj = gluNewQuadric();
80}
81
82
83/**
84 *  standard deconstructor
85 */
86OBBTreeNode::~OBBTreeNode ()
87{
88  if( this->nodeLeft)
89  {
90    delete this->nodeLeft;
91    this->nodeLeft = NULL;
92  }
93  if( this->nodeRight)
94  {
95    delete this->nodeRight;
96    this->nodeRight = NULL;
97  }
98  if( this->bvElement)
99    delete this->bvElement;
100  this->bvElement = NULL;
101
102  if (this->tmpVert1 != NULL)
103    delete this->tmpVert1;
104  if (this->tmpVert2 != NULL)
105    delete this->tmpVert2;
106}
107
108
109/**
110 *  creates a new BVTree or BVTree partition
111 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper!
112 * @param modInfo: model informations from the abstrac model
113 *
114 * this function creates the Bounding Volume tree from a modelInfo struct and bases its calculations
115 * on the triangle informations (triangle soup not polygon soup)
116 */
117void OBBTreeNode::spawnBVTree(const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
118{
119  sVec3D* verticesList;
120
121  PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
122  printf("OBBTreeNode::spawnBVTree()\n");
123  this->depth = depth;
124
125  this->bvElement = new OBB();
126  this->bvElement->modelInf = &modelInf;
127  this->bvElement->triangleIndexes = triangleIndexes;
128  this->bvElement->numTriangles = length;
129
130  /* create the boxes in three steps */
131  this->calculateBoxCovariance(*this->bvElement, modelInf, triangleIndexes, length);
132  this->calculateBoxEigenvectors(*this->bvElement, modelInf, triangleIndexes, length);
133  this->calculateBoxAxis(*this->bvElement, modelInf, triangleIndexes, length);
134
135  /* do we need to descent further in the obb tree?*/
136  if( likely( this->depth > 0))
137  {
138    //this->forkBox(*this->bvElement);
139
140
141    //     if(this->tmpLen1 > 2)
142    //     {
143    //       OBBTreeNode* node1 = new OBBTreeNode();
144    //       this->nodeLeft = node1;
145    //       this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
146    //     }
147    //     else
148    //     {
149    //       PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n");
150    //     }
151    //
152    //     if( this->tmpLen2 > 2)
153    //     {
154    //       OBBTreeNode* node2 = new OBBTreeNode();
155    //       this->nodeRight = node2;
156    //       this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
157    //     }
158    //     else
159    //     {
160    //       PRINTF(3)("Abording tree walk: less than 3 vertices left\n");
161    //     }
162
163  }
164}
165
166
167/**
168 *  creates a new BVTree or BVTree partition
169 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper!
170 * @param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle
171 *
172 * this function creates an Bounding Volume tree from a vertices soup (no triangle data)
173 */
174void OBBTreeNode::spawnBVTree(const sVec3D *verticesList, unsigned int length)
175{
176  //   PRINTF(3)("\n");
177  //   PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
178  //   this->depth = depth;
179  //
180  //
181  //   this->bvElement = new OBB();
182  //   this->bvElement->vertices = verticesList;
183  //   this->bvElement->numOfVertices = length;
184  //   PRINTF(3)("Created OBBox\n");
185  //   this->calculateBoxCovariance(this->bvElement, verticesList, length);
186  //   PRINTF(3)("Calculated attributes1\n");
187  //   this->calculateBoxEigenvectors(this->bvElement, verticesList, length);
188  //   PRINTF(3)("Calculated attributes2\n");
189  //   this->calculateBoxAxis(this->bvElement, verticesList, length);
190  //   PRINTF(3)("Calculated attributes3\n");
191  //
192  //
193  //
194  //   if( likely( this->depth > 0))
195  //   {
196  //     this->forkBox(this->bvElement);
197  //
198  //
199  //     if(this->tmpLen1 > 2)
200  //     {
201  //       OBBTreeNode* node1 = new OBBTreeNode(this->obbTree);
202  //       this->nodeLeft = node1;
203  //       this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
204  //     }
205  //     else
206  //     {
207  //       PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n");
208  //     }
209  //
210  //     if( this->tmpLen2 > 2)
211  //     {
212  //       OBBTreeNode* node2 = new OBBTreeNode(this->obbTree);
213  //       this->nodeRight = node2;
214  //       this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
215  //     }
216  //     else
217  //     {
218  //       PRINTF(3)("Abording tree walk: less than 3 vertices left\n");
219  //     }
220  //   }
221}
222
223
224void OBBTreeNode::calculateBoxCovariance(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
225{
226
227  PRINTF(3)("Created OBBox\n");
228
229  float     facelet[length];                         //!< surface area of the i'th triangle of the convex hull
230  float     face = 0.0f;                             //!< surface area of the entire convex hull
231  Vector    centroid[length];                        //!< centroid of the i'th convex hull
232  Vector    center;                                  //!< the center of the entire hull
233  Vector    p, q, r;                                 //!< holder of the polygon data, much more conveniant to work with Vector than sVec3d
234  Vector    t1, t2;                                  //!< temporary values
235  float     covariance[3][3] = {0,0,0, 0,0,0, 0,0,0};//!< the covariance matrix
236  sVec3D*   tmpVec = NULL;                           //!< a temp saving place for sVec3Ds
237
238
239  /* fist compute all the convex hull face/facelets and centroids */
240  for( int i = 0; i < length ; ++i)
241  {
242    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]);
243    p = *tmpVec;
244    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]);
245    q = *tmpVec;
246    tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]);
247    r = *tmpVec;
248
249    /* finding the facelet surface via cross-product */
250    t1 = p - q;
251    t2 = p - r;
252    facelet[i] = 0.5f * fabs( t1.cross(t2).len() );
253    /* update the entire convex hull surface */
254    face += facelet[i];
255
256    /* calculate the cetroid of the hull triangles */
257    centroid[i] = (p + q + r) * 1/3;
258    /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */
259    center += centroid[i] * facelet[i];
260  }
261  /* take the average of the centroid sum */
262  center /= face;
263
264
265  /* now calculate the covariance matrix - if not written in three for-loops,
266     it would compute faster: minor */
267  for( int j = 0; j < 3; ++j)
268  {
269    for( int k = 0; k < 3; ++k)
270    {
271      for( int i = 0; i + 3 < length; i+=3)
272      {
273        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[0]]);
274        p = *tmpVec;
275        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[1]]);
276        q = *tmpVec;
277        tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[i]].indexToVertices[2]]);
278        r = *tmpVec;
279
280        covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j] * p[k] +
281                           q[j] * q[k] + r[j] * r[k]) - center[j] * center[k];
282      }
283    }
284  }
285
286  PRINTF(3)("\nOBB Covariance Matrix:\n");
287  for(int j = 0; j < 3; ++j)
288  {
289    PRINTF(3)(" |");
290    for(int k = 0; k < 3; ++k)
291    {
292      PRINTF(3)(" \b%f ", covariance[j][k]);
293    }
294    PRINTF(3)(" |\n");
295  }
296  PRINTF(3)("OBB Center: %f, %f, %f\n", center.x, center.y, center.z);
297
298  /* write back the covariance matrix data to the object oriented bouning box */
299  for(int i = 0; i < 3; ++i)
300  {
301    box.covarianceMatrix[i][0] = covariance[i][0];
302    box.covarianceMatrix[i][1] = covariance[i][1];
303    box.covarianceMatrix[i][2] = covariance[i][2];
304  }
305  box.center = center;
306}
307
308
309
310/**
311 *  calculate the eigenvectors for the object oriented box
312 * @param box: reference to the box
313 * @param modelInf: the model info structure of the model
314 * @param tirangleIndexes: an array with the indexes of the triangles inside this
315 * @param length: the length of the indexes array
316 */
317void OBBTreeNode::calculateBoxEigenvectors(OBB& box, const modelInfo& modelInf,
318    const int* triangleIndexes, unsigned int length)
319{
320
321  PRINTF(3)("Calculate the Box Eigenvectors\n");
322
323  Vector         axis[3];                            //!< the references to the obb axis
324  Matrix         covMat(  box.covarianceMatrix  );   //!< covariance matrix (in the matrix dataform)
325
326  /*
327  now getting spanning vectors of the sub-space:
328  the eigenvectors of a symmertric matrix, such as the
329  covarience matrix are mutually orthogonal.
330  after normalizing them, they can be used as a the basis
331  vectors
332  */
333
334  /* calculate the axis */
335  covMat.getEigenVectors(axis[0], axis[1], axis[2] );
336  box.axis[0] = axis[0];
337  box.axis[1] = axis[1];
338  box.axis[2] = axis[2];
339
340  PRINTF(0)("-- Got Axis\n");
341  PRINTF(0)("Eigenvector: %f, %f, %f\n", box.axis[0].x, box.axis[0].y, box.axis[0].z);
342  PRINTF(0)("Eigenvector: %f, %f, %f\n", box.axis[1].x, box.axis[1].y, box.axis[1].z);
343  PRINTF(0)("Eigenvector: %f, %f, %f\n", box.axis[2].x, box.axis[2].y, box.axis[2].z);
344}
345
346
347
348
349/**
350 *  calculate the eigenvectors for the object oriented box
351 * @param box: reference to the box
352 * @param modelInf: the model info structure of the model
353 * @param tirangleIndexes: an array with the indexes of the triangles inside this
354 * @param length: the length of the indexes array
355 */
356void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
357{
358
359  sVec3D* verticesList;
360
361
362  PRINTF(3)("Calculated attributes3\n");
363  /* now get the axis length */
364  Line                ax[3];                                 //!< the axis
365  float               halfLength[3];                         //!< half length of the axis
366  float               tmpLength;                             //!< tmp save point for the length
367  Plane               p0(box.axis[0], box.center);        //!< the axis planes
368  Plane               p1(box.axis[1], box.center);
369  Plane               p2(box.axis[2], box.center);
370  float               maxLength[3];
371  float               minLength[3];
372  const sVec3D*       tmpVec;
373
374  /*
375  this step is split up in two: first there will be made a bounding box which is
376  very badly centered. In the secon step there will be calculated a new center
377  and a better bounding box.
378  */
379
380  /* get a bad bounding box axis */
381  halfLength[0] = -1.0f;
382  for( int j = 0; j < length; ++j)
383  {
384    for( int i = 0; i < 3; ++i)
385    {
386      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
387      tmpLength = fabs(p0.distancePoint(*tmpVec));
388      if( tmpLength > halfLength[0])
389        halfLength[0] = tmpLength;
390    }
391  }
392
393  halfLength[1] = -1.0f;
394  for( int j = 0; j < length; ++j)
395  {
396    for( int i = 0; i < 3; ++i)
397    {
398      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
399      tmpLength = fabs(p0.distancePoint(*tmpVec));
400      if( tmpLength > halfLength[1])
401        halfLength[1] = tmpLength;
402    }
403  }
404
405  halfLength[2] = -1.0f;
406  for( int j = 0; j < length; ++j)
407  {
408    for( int i = 0; i < 3; ++i)
409    {
410      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
411      tmpLength = fabs(p0.distancePoint(*tmpVec));
412      if( tmpLength > halfLength[2])
413        halfLength[2] = tmpLength;
414    }
415  }
416
417
418
419  /* get the maximal dimensions of the body in all directions */
420  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
421  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
422  maxLength[0] = p0.distancePoint(*tmpVec);
423  minLength[0] = p0.distancePoint(*tmpVec);
424  for( int j = 0; j < length; ++j)
425  {
426    for( int i = 0; i < 3; ++i)
427    {
428      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
429      tmpLength = p0.distancePoint(*tmpVec);
430      if( tmpLength > maxLength[0])
431        maxLength[0] = tmpLength;
432      else if( tmpLength < minLength[0])
433        minLength[0] = tmpLength;
434    }
435  }
436
437  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
438  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
439  maxLength[1] = p1.distancePoint(*tmpVec);
440  minLength[1] = p1.distancePoint(*tmpVec);
441  for( int j = 0; j < length; ++j)
442  {
443    for( int i = 0; i < 3; ++i)
444    {
445      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
446      tmpLength = p0.distancePoint(*tmpVec);
447      if( tmpLength > maxLength[1])
448        maxLength[1] = tmpLength;
449      else if( tmpLength < minLength[1])
450        minLength[1] = tmpLength;
451    }
452  }
453
454  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
455  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
456  maxLength[2] = p2.distancePoint(*tmpVec);
457  minLength[2] = p2.distancePoint(*tmpVec);
458  for( int j = 0; j < length; ++j)
459  {
460    for( int i = 0; i < 3; ++i)
461    {
462      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
463      tmpLength = p0.distancePoint(*tmpVec);
464      if( tmpLength > maxLength[2])
465        maxLength[2] = tmpLength;
466      else if( tmpLength < minLength[2])
467        minLength[2] = tmpLength;
468    }
469  }
470
471
472  /* calculate the real centre of the body by using the axis length */
473  float centerOffset[3];
474  float newHalfLength[3];
475  for(int i = 0; i < 3; ++i)
476  {
477    PRINTF(3)("max: %f, min: %f \n", maxLength[i], minLength[i]);
478    centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;       // min length is negatie
479    newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;      // min length is negative
480    box.center +=  (box.axis[i] * centerOffset[i]);            // update the new center vector
481    halfLength[i] = newHalfLength[i];
482  }
483
484
485
486  box.halfLength[0] = halfLength[0];
487  box.halfLength[1] = halfLength[1];
488  box.halfLength[2] = halfLength[2];
489  PRINTF(3)("-- Written Axis to obb\n");
490  PRINTF(3)("-- Finished Calculating Attributes\n");
491}
492
493
494
495/**
496  \brief this separates an ob-box in the middle
497* @param box: the box to separate
498
499  this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis
500 */
501void OBBTreeNode::forkBox(OBB& box)
502{
503  /* get the longest axis of the box */
504  float               aLength = -1.0f;                     //!< the length of the longest axis
505  int                 axisIndex = 0;                       //!< this is the nr of the longest axis
506
507  for(int i = 0; i < 3; ++i)
508  {
509    if( aLength < box.halfLength[i])
510    {
511      aLength = box.halfLength[i];
512      axisIndex = i;
513    }
514  }
515
516  PRINTF(3)("longest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength);
517
518
519  /* get the closest vertex near the center */
520  float               dist = 999999.0f;                    //!< the smallest distance to each vertex
521  float               tmpDist;                             //!< temporary distance
522  int                 vertexIndex;
523  Plane               middlePlane(box.axis[axisIndex], box.center); //!< the middle plane
524
525  vertexIndex = 0;
526  for(int i = 0; i < box.numOfVertices; ++i)
527  {
528    tmpDist = fabs(middlePlane.distancePoint(box.vertices[i]));
529    if( tmpDist < dist)
530    {
531      dist = tmpDist;
532      vertexIndex = i;
533    }
534  }
535
536  PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
537
538
539  /* now definin the separation plane through this specified nearest point and partition
540  the points depending on which side they are located
541  */
542  tList<const sVec3D>      partition1;                           //!< the vertex partition 1
543  tList<const sVec3D>      partition2;                           //!< the vertex partition 2
544
545
546  PRINTF(3)("vertex index: %i, of %i\n", vertexIndex, box.numOfVertices);
547  this->separationPlane = Plane(box.axis[axisIndex], box.vertices[vertexIndex]);  //!< separation plane
548  this->sepPlaneCenter = &box.vertices[vertexIndex];
549  this->longestAxisIndex = axisIndex;
550
551  for(int i = 0; i < box.numOfVertices; ++i)
552  {
553    if( i == vertexIndex)
554      continue;
555    tmpDist = this->separationPlane.distancePoint(box.vertices[i]);
556    if( tmpDist > 0.0)
557      partition1.add(&box.vertices[i]); /* positive numbers plus zero */
558    else
559      partition2.add(&box.vertices[i]); /* negatice numbers */
560  }
561  partition1.add(&box.vertices[vertexIndex]);
562  partition2.add(&box.vertices[vertexIndex]);
563
564  PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
565
566
567  /* now comes the separation into two different sVec3D arrays */
568  tIterator<const sVec3D>* iterator;                       //!< the iterator to go through the lists
569  const sVec3D*      element;                              //!< the elements
570  int                index;                                //!< index storage place
571  sVec3D*            vertList1;                            //!< the vertex list 1
572  sVec3D*            vertList2;                            //!< the vertex list 2
573
574  vertList1 = new sVec3D[partition1.getSize()];
575  vertList2 = new sVec3D[partition2.getSize()];
576
577  iterator = partition1.getIterator();
578  element = iterator->firstElement();
579  index = 0;
580  while( element != NULL)
581  {
582    vertList1[index][0] = element[0][0];
583    vertList1[index][1] = element[0][1];
584    vertList1[index][2] = element[0][2];
585    ++index;
586    element = iterator->nextElement();
587  }
588  delete iterator;
589  //   PRINTF(0)("\npartition 1:\n");
590  //   for(int i = 0; i < partition1.getSize(); ++i)
591  //   {
592  //     PRINTF(0)("v[%i][0] = %f,\tv[%i][1] = %f,\tv[%i][1] = %f\n", i, vertList1[i][0], i, vertList1[i][1], i, vertList1[i][2]);
593  //   }
594
595  iterator = partition2.getIterator();
596  element = iterator->firstElement();
597  index = 0;
598  while( element != NULL)
599  {
600    vertList2[index][0] = element[0][0];
601    vertList2[index][1] = element[0][1];
602    vertList2[index][2] = element[0][2];
603    ++index;
604    element = iterator->nextElement();
605  }
606
607  if (this->tmpVert1 != NULL)
608    delete[] this->tmpVert1;
609  this->tmpVert1 = vertList1;
610  if (this->tmpVert2 != NULL)
611    delete[] this->tmpVert2;
612  this->tmpVert2 = vertList2;
613  this->tmpLen1 = partition1.getSize();
614  this->tmpLen2 = partition2.getSize();
615
616  delete iterator;
617
618  //   PRINTF(0)("\npartition 2:\n");
619  //   for(int i = 0; i < partition2.getSize(); ++i)
620  //   {
621  //     PRINTF(0)("v[%i][0] = %f,\tv[%i][1] = %f,\tv[%i][1] = %f\n", i, vertList2[i][0], i,  vertList2[i][1], i, vertList2[i][2]);
622  //   }
623}
624
625
626
627
628void OBBTreeNode::collideWith(const BVTreeNode& treeNode, const WorldEntity& nodeA, const WorldEntity& nodeB) const
629{
630  PRINTF(3)("collideWith\n");
631  /* if the obb overlap, make subtests: check which node is realy overlaping  */
632  PRINTF(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode.getIndex());
633  //   if( unlikely(treeNode == NULL)) return;
634
635
636  if( this->overlapTest(*this->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
637  {
638    PRINTF(3)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA.getClassName(), nodeB.getClassName(), this->nodeLeft, this->nodeRight);
639
640    /* check if left node overlaps */
641    if( likely( this->nodeLeft != NULL))
642    {
643      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode.getIndex());
644      if( this->overlapTest(*this->nodeLeft->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
645      {
646        this->nodeLeft->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeLeft), nodeA, nodeB);
647        this->nodeLeft->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeRight), nodeA, nodeB);
648      }
649    }
650    /* check if right node overlaps */
651    if( likely( this->nodeRight != NULL))
652    {
653      PRINTF(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode.getIndex());
654      if(this->overlapTest(*this->nodeRight->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
655      {
656        this->nodeRight->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeLeft), nodeA, nodeB);
657        this->nodeRight->collideWith(*(((const OBBTreeNode*)&treeNode)->nodeRight), nodeA, nodeB);
658      }
659    }
660
661    /* so there is a collision and this is the last box in the tree (i.e. leaf) */
662    /* FIXME: If we would choose || insead of && there would also be asymmetrical cases supported */
663    if( unlikely(this->nodeRight == NULL && this->nodeLeft == NULL))
664    {
665      nodeA.collidesWith(nodeB, (((const OBBTreeNode*)&treeNode)->bvElement->center));
666
667      nodeB.collidesWith(nodeA, this->bvElement->center);
668    }
669
670  }
671}
672
673
674
675bool OBBTreeNode::overlapTest(const OBB& boxA, const OBB& boxB, const WorldEntity& nodeA, const WorldEntity& nodeB) const
676{
677  //   if( boxB == NULL || boxA == NULL)
678  //     return false;
679
680  /* first check all axis */
681  Vector t;
682  float rA = 0.0f;
683  float rB = 0.0f;
684  Vector l;
685  Vector rotAxisA[3];
686  Vector rotAxisB[3];
687
688  rotAxisA[0] =  nodeA.getAbsDir().apply(boxA.axis[0]);
689  rotAxisA[1] =  nodeA.getAbsDir().apply(boxA.axis[1]);
690  rotAxisA[2] =  nodeA.getAbsDir().apply(boxA.axis[2]);
691
692  rotAxisB[0] =  nodeB.getAbsDir().apply(boxB.axis[0]);
693  rotAxisB[1] =  nodeB.getAbsDir().apply(boxB.axis[1]);
694  rotAxisB[2] =  nodeB.getAbsDir().apply(boxB.axis[2]);
695
696
697  t = nodeA.getAbsCoor() + nodeA.getAbsDir().apply(boxA.center) - ( nodeB.getAbsCoor() + nodeB.getAbsDir().apply(boxB.center));
698
699  //   printf("\n");
700  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[0].x, boxA->axis[0].y, boxA->axis[0].z, rotAxisA[0].x, rotAxisA[0].y, rotAxisA[0].z);
701  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[1].x, boxA->axis[1].y, boxA->axis[1].z, rotAxisA[1].x, rotAxisA[1].y, rotAxisA[1].z);
702  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[2].x, boxA->axis[2].y, boxA->axis[2].z, rotAxisA[2].x, rotAxisA[2].y, rotAxisA[2].z);
703  //
704  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[0].x, boxB->axis[0].y, boxB->axis[0].z, rotAxisB[0].x, rotAxisB[0].y, rotAxisB[0].z);
705  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[1].x, boxB->axis[1].y, boxB->axis[1].z, rotAxisB[1].x, rotAxisB[1].y, rotAxisB[1].z);
706  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[2].x, boxB->axis[2].y, boxB->axis[2].z, rotAxisB[2].x, rotAxisB[2].y, rotAxisB[2].z);
707
708
709  /* All 3 axis of the object A */
710  for( int j = 0; j < 3; ++j)
711  {
712    rA = 0.0f;
713    rB = 0.0f;
714    l = rotAxisA[j];
715
716    rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
717    rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
718    rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
719
720    rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
721    rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
722    rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
723
724    PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
725
726    if( (rA + rB) < fabs(t.dot(l)))
727    {
728      PRINTF(3)("no Collision\n");
729      return false;
730    }
731  }
732
733  /* All 3 axis of the object B */
734  for( int j = 0; j < 3; ++j)
735  {
736    rA = 0.0f;
737    rB = 0.0f;
738    l = rotAxisB[j];
739
740    rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
741    rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
742    rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
743
744    rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
745    rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
746    rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
747
748    PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
749
750    if( (rA + rB) < fabs(t.dot(l)))
751    {
752      PRINTF(3)("no Collision\n");
753      return false;
754    }
755  }
756
757
758  /* Now check for all face cross products */
759
760  for( int j = 0; j < 3; ++j)
761  {
762    for(int k = 0; k < 3; ++k )
763    {
764      rA = 0.0f;
765      rB = 0.0f;
766      l = rotAxisA[j].cross(rotAxisB[k]);
767
768      rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
769      rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
770      rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
771
772      rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
773      rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
774      rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
775
776      PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
777
778      if( (rA + rB) < fabs(t.dot(l)))
779      {
780        PRINTF(3)("keine Kollision\n");
781        return false;
782      }
783    }
784  }
785
786  /* FIXME: there is no collision mark set now */
787  //   boxA.bCollided = true; /* use this ONLY(!!!!) for drawing operations */
788  //   boxB.bCollided = true;
789
790
791  PRINTF(3)("Kollision!\n");
792  return true;
793}
794
795
796
797
798
799void OBBTreeNode::drawBV(int depth, int drawMode, const Vector& color,  bool top) const
800{
801
802  /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */
803  if( drawMode & DRAW_MODEL || drawMode & DRAW_ALL)
804  {
805    if( !(drawMode & DRAW_SINGLE && depth != 0))
806    {
807      if( drawMode & DRAW_POINTS)
808        glBegin(GL_POINTS);
809      for(int i = 0; i < this->bvElement->numOfVertices; ++i)
810      {
811        if( drawMode & DRAW_POINTS)
812          glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
813        else
814        {
815          glPushMatrix();
816          glTranslatef(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
817          gluSphere(OBBTreeNode_sphereObj, 0.1, 10, 10);
818          glPopMatrix();
819        }
820      }
821      if( drawMode & DRAW_POINTS)
822        glEnd();
823    }
824  }
825
826  if (top)
827  {
828    glPushAttrib(GL_ENABLE_BIT);
829    glDisable(GL_LIGHTING);
830    glDisable(GL_TEXTURE_2D);
831  }
832  glColor3f(color.x, color.y, color.z);
833
834
835  /* draw world axes */
836  if( drawMode & DRAW_BV_AXIS)
837  {
838    glBegin(GL_LINES);
839    glColor3f(1.0, 0.0, 0.0);
840    glVertex3f(0.0, 0.0, 0.0);
841    glVertex3f(3.0, 0.0, 0.0);
842
843    glColor3f(0.0, 1.0, 0.0);
844    glVertex3f(0.0, 0.0, 0.0);
845    glVertex3f(0.0, 3.0, 0.0);
846
847    glColor3f(0.0, 0.0, 1.0);
848    glVertex3f(0.0, 0.0, 0.0);
849    glVertex3f(0.0, 0.0, 3.0);
850    glEnd();
851  }
852
853
854  if( drawMode & DRAW_BV_AXIS || drawMode & DRAW_ALL)
855  {
856    if( !(drawMode & DRAW_SINGLE && depth != 0))
857    {
858      /* draw the obb axes */
859      glBegin(GL_LINES);
860      glColor3f(0.0, 0.4, 0.3);
861      glVertex3f(this->bvElement->center.x, this->bvElement->center.y, this->bvElement->center.z);
862      glVertex3f(this->bvElement->center.x + this->bvElement->axis[0].x * this->bvElement->halfLength[0],
863                 this->bvElement->center.y + this->bvElement->axis[0].y * this->bvElement->halfLength[0],
864                 this->bvElement->center.z + this->bvElement->axis[0].z * this->bvElement->halfLength[0]);
865
866      glVertex3f(this->bvElement->center.x, this->bvElement->center.y, this->bvElement->center.z);
867      glVertex3f(this->bvElement->center.x + this->bvElement->axis[1].x * this->bvElement->halfLength[1],
868                 this->bvElement->center.y + this->bvElement->axis[1].y * this->bvElement->halfLength[1],
869                 this->bvElement->center.z + this->bvElement->axis[1].z * this->bvElement->halfLength[1]);
870
871      glVertex3f(this->bvElement->center.x, this->bvElement->center.y, this->bvElement->center.z);
872      glVertex3f(this->bvElement->center.x + this->bvElement->axis[2].x * this->bvElement->halfLength[2],
873                 this->bvElement->center.y + this->bvElement->axis[2].y * this->bvElement->halfLength[2],
874                 this->bvElement->center.z + this->bvElement->axis[2].z * this->bvElement->halfLength[2]);
875      glEnd();
876    }
877  }
878
879
880  /* DRAW POLYGONS */
881  if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)
882  {
883    if (top)
884    {
885      glEnable(GL_BLEND);
886      glBlendFunc(GL_SRC_ALPHA, GL_ONE);
887    }
888
889    if(this->nodeLeft == NULL || this->nodeRight == NULL)
890      depth = 0;
891    if( !(drawMode & DRAW_SINGLE && depth != 0))
892    {
893      Vector cen = this->bvElement->center;
894      Vector* axis = this->bvElement->axis;
895      float* len = this->bvElement->halfLength;
896
897      if( this->bvElement->bCollided)
898      {
899        glColor4f(1.0, 1.0, 1.0, .5); // COLLISION COLOR
900      }
901      else if( drawMode & DRAW_BV_BLENDED)
902      {
903        glColor4f(color.x, color.y, color.z, .5);
904      }
905
906      /* draw bounding box */
907      if( drawMode & DRAW_BV_BLENDED)
908        glBegin(GL_QUADS);
909      else
910        glBegin(GL_LINE_LOOP);
911      glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
912                 cen.y + axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
913                 cen.z + axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
914      glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
915                 cen.y + axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
916                 cen.z + axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
917      glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
918                 cen.y + axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
919                 cen.z + axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
920      glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
921                 cen.y + axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
922                 cen.z + axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
923      glEnd();
924
925      if( drawMode & DRAW_BV_BLENDED)
926        glBegin(GL_QUADS);
927      else
928        glBegin(GL_LINE_LOOP);
929      glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
930                 cen.y + axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
931                 cen.z + axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
932      glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
933                 cen.y + axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
934                 cen.z + axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
935      glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
936                 cen.y - axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
937                 cen.z - axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
938      glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
939                 cen.y - axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
940                 cen.z - axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
941      glEnd();
942
943      if( drawMode & DRAW_BV_BLENDED)
944        glBegin(GL_QUADS);
945      else
946        glBegin(GL_LINE_LOOP);
947      glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
948                 cen.y - axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
949                 cen.z - axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
950      glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
951                 cen.y - axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
952                 cen.z - axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
953      glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
954                 cen.y - axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
955                 cen.z - axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
956      glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
957                 cen.y - axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
958                 cen.z - axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
959      glEnd();
960
961      if( drawMode & DRAW_BV_BLENDED)
962        glBegin(GL_QUADS);
963      else
964        glBegin(GL_LINE_LOOP);
965      glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
966                 cen.y - axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
967                 cen.z - axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
968      glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
969                 cen.y - axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
970                 cen.z - axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
971      glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
972                 cen.y + axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
973                 cen.z + axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
974      glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
975                 cen.y + axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
976                 cen.z + axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
977      glEnd();
978
979
980      if( drawMode & DRAW_BV_BLENDED)
981      {
982        glBegin(GL_QUADS);
983        glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
984                   cen.y - axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
985                   cen.z - axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
986        glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2],
987                   cen.y + axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2],
988                   cen.z + axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]);
989        glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
990                   cen.y + axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
991                   cen.z + axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
992        glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2],
993                   cen.y - axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2],
994                   cen.z - axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]);
995        glEnd();
996
997        glBegin(GL_QUADS);
998        glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
999                   cen.y - axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
1000                   cen.z - axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
1001        glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2],
1002                   cen.y + axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2],
1003                   cen.z + axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]);
1004        glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
1005                   cen.y + axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
1006                   cen.z + axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
1007        glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2],
1008                   cen.y - axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2],
1009                   cen.z - axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]);
1010        glEnd();
1011      }
1012
1013
1014      if( drawMode & DRAW_BV_BLENDED)
1015        glColor3f(color.x, color.y, color.z);
1016    }
1017
1018  }
1019
1020  /* DRAW SEPARATING PLANE */
1021  if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL)
1022  {
1023    if( !(drawMode & DRAW_SINGLE && depth != 0))
1024    {
1025      if( drawMode & DRAW_BV_BLENDED)
1026        glColor4f(color.x, color.y, color.z, .6);
1027
1028      /* now draw the separation plane */
1029      Vector a1 = this->bvElement->axis[(this->longestAxisIndex + 1)%3];
1030      Vector a2 = this->bvElement->axis[(this->longestAxisIndex + 2)%3];
1031      Vector c = this->bvElement->center;
1032      float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3];
1033      float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3];
1034      glBegin(GL_QUADS);
1035      glVertex3f(c.x + a1.x * l1 + a2.x * l2, c.y + a1.y * l1+ a2.y * l2, c.z + a1.z * l1 + a2.z * l2);
1036      glVertex3f(c.x - a1.x * l1 + a2.x * l2, c.y - a1.y * l1+ a2.y * l2, c.z - a1.z * l1 + a2.z * l2);
1037      glVertex3f(c.x - a1.x * l1 - a2.x * l2, c.y - a1.y * l1- a2.y * l2, c.z - a1.z * l1 - a2.z * l2);
1038      glVertex3f(c.x + a1.x * l1 - a2.x * l2, c.y + a1.y * l1- a2.y * l2, c.z + a1.z * l1 - a2.z * l2);
1039      glEnd();
1040
1041      if( drawMode & DRAW_BV_BLENDED)
1042        glColor4f(color.x, color.y, color.z, 1.0);
1043
1044    }
1045  }
1046
1047
1048
1049  if (depth > 0)
1050  {
1051    if( this->nodeLeft != NULL)
1052      this->nodeLeft->drawBV(depth - 1, drawMode, Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(15.0,0.0,0.0)), false);
1053    if( this->nodeRight != NULL)
1054      this->nodeRight->drawBV(depth - 1, drawMode, Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(30.0,0.0,0.0)), false);
1055  }
1056  this->bvElement->bCollided = false;
1057
1058  if (top)
1059    glPopAttrib();
1060}
1061
1062
1063
1064void OBBTreeNode::debug() const
1065{
1066  PRINT(0)("========OBBTreeNode::debug()=====\n");
1067  PRINT(0)(" Current depth: %i", this->depth);
1068  PRINT(0)(" ");
1069  PRINT(0)("=================================\n");
1070}
Note: See TracBrowser for help on using the repository browser.