Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/collision_detection/obb_tree_node.cc @ 5494

Last change on this file since 5494 was 5494, checked in by bensch, 18 years ago

orxonox/trunk: nicer color in the debug of the OBBTreeNode

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