Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4630 was 4630, checked in by patrick, 19 years ago

orxonox/trunk: the memory requirements are lowered, some strucural changes in the bv generation

File size: 20.3 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
25#include <math.h>
26
27
28#define WANT_STREAM
29#define WANT_MATH
30#define WANT_FSTREAM
31
32
33#include "include.h"
34#include "newmat.h"
35#include "newmatap.h"
36#include "newmatio.h"
37
38#include "lin_alg.h"
39
40
41
42
43using namespace std;
44
45OBBTree*  OBBTreeNode::obbTree = NULL;
46
47float**  OBBTreeNode::coMat = NULL;
48float**  OBBTreeNode::eigvMat = NULL;
49float*   OBBTreeNode::eigvlMat = NULL;
50int*     OBBTreeNode::rotCount = NULL;
51
52/**
53   \brief standard constructor
54 */
55OBBTreeNode::OBBTreeNode ()
56{
57  this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode");
58  this->nodeLeft = NULL;
59  this->nodeRight = NULL;
60
61  if(coMat == NULL)
62  {
63    coMat = new float*[4];
64    for(int i = 0; i < 4; i++)
65      coMat[i] = new float[4];
66  }
67  if(eigvMat == NULL)
68  {
69    eigvMat = new float*[4];
70    for(int i = 0; i < 4; i++)
71      eigvMat[i] = new float[4];
72  }
73  if( eigvlMat == NULL)
74  {
75    eigvlMat = new float[4];
76  }
77  if( rotCount == NULL)
78    rotCount = new int;
79}
80
81
82/**
83   \brief standard deconstructor
84 */
85OBBTreeNode::~OBBTreeNode ()
86{
87  // delete what has to be deleted here
88}
89
90
91
92/**
93   \brief creates a new BVTree or BVTree partition
94   \param depth: how much more depth-steps to go: if == 1 don't go any deeper!
95   \param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle
96 */
97void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length)
98{
99  printf("OBB Depth: %i, numVertices: %i\n", depth, length);
100  this->depth = depth;
101
102  this->bvElement = new OBB();
103  PRINTF(0)("Created OBBox\n");
104  this->calculateBoxAttributes(this->bvElement, verticesList, length);
105  PRINTF(0)("Calculated attributes\n");
106
107  if( likely( this->depth > 0))
108  {
109    this->forkBox(this->bvElement);
110
111    OBBTreeNode*       node1 = new OBBTreeNode();
112    OBBTreeNode*       node2 = new OBBTreeNode();
113
114    this->nodeLeft = node1;
115    this->nodeRight = node2;
116
117    this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
118    this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
119
120  }
121}
122
123
124
125void OBBTreeNode::calculateBoxAttributes(OBB* box, sVec3D* verticesList, int length)
126{
127  float     facelet[length];                         //!< surface area of the i'th triangle of the convex hull
128  float     face;                                    //!< surface area of the entire convex hull
129  Vector    centroid[length];                        //!< centroid of the i'th convex hull
130  Vector    center;                                  //!< the center of the entire hull
131  Vector    p, q, r;                                 //!< holder of the polygon data, much more conveniant to work with Vector than sVec3d
132  Vector    t1, t2;                                  //!< temporary values
133  float     covariance[3][3];                        //!< the covariance matrix
134
135  this->numOfVertices = length;
136  this->vertices = verticesList;
137  box->vertices = verticesList;
138  box->numOfVertices = length;
139
140
141  /* fist compute all the convex hull face/facelets and centroids */
142  for(int i = 0; i < length; i+=3)          /* FIX-ME-QUICK: hops of 3, array indiscontinuity*/
143  {
144    p = verticesList[i];
145    q = verticesList[i +1];
146    r = verticesList[i + 2];
147
148    t1 = p - q; t2 = p - r;
149
150    /* finding the facelet surface via cross-product */
151    facelet[i] = 0.5f * fabs( t1.cross(t2).len() );
152    /* update the entire convex hull surface */
153    face += facelet[i];
154
155    /* calculate the cetroid of the hull triangles */
156    centroid[i] = (p + q + r) * 1/3;
157    /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */
158    center += centroid[i] * facelet[i];
159  }
160  /* take the average of the centroid sum */
161  center /= face;
162  PRINTF(0)("-- Calculated Center\n");
163
164
165  /* now calculate the covariance matrix - if not written in three for-loops, it would compute faster: minor */
166  for(int j = 0; j < 3; ++j)
167  {
168    for(int k = 0; k < 3; ++k)
169    {
170      for(int i = 0; i < length; i+=3)
171      {
172        p = verticesList[i];
173        q = verticesList[i +1];
174        r = verticesList[i + 2];
175
176        covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j]* p[k] +
177            q[j] * q[k] + r[j]*r[k]) - center[j] * center[k];
178      }
179    }
180  }
181  PRINTF(0)("-- Calculated Covariance\n");
182
183//   printf("\nVertex Data:\n");
184//   for(int i = 0; i < length; i++)
185//   {
186//     printf("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
187//   }
188
189//   printf("\nCovariance Matrix:\n");
190//   for(int j = 0; j < 3; ++j)
191//   {
192//     printf(" |");
193//     for(int k = 0; k < 3; ++k)
194//     {
195//       printf(" \b%f ", covariance[j][k]);
196//     }
197//     printf(" |\n");
198//   }
199//   printf("center: %f, %f, %f\n\n", center.x, center.y, center.z);
200
201
202  for(int i = 0; i < 3; ++i)
203  {
204
205    box->covarianceMatrix[i][0] = covariance[i][0];
206    box->covarianceMatrix[i][1] = covariance[i][1];
207    box->covarianceMatrix[i][3] = covariance[i][2];
208  }
209  *box->center = center;
210  PRINTF(0)("-- Written Result to obb\n");
211
212  /* now getting spanning vectors of the sub-space:
213  the eigenvectors of a symmertric matrix, such as the
214  covarience matrix are mutually orthogonal.
215  after normalizing them, they can be used as a the basis
216  vectors
217  */
218  Vector**              axis = new Vector*[3];                //!< the references to the obb axis
219//   float**               a = new float*[4];
220//   float**               b = new float*[4];
221//   float                 eigval[3];
222//   int*                  rot = new int;
223
224
225  //coMat[0] = new float[4]; coMat[1] = new float[4]; coMat[2] = new float[4]; coMat[3] = new float[4];
226  //eigvMat[0] = new float[4]; eigvMat[1] = new float[4]; eigvMat[2] = new float[4]; eigvMat[3] = new float[4];
227
228  coMat[1][1] = covariance[0][0]; coMat[1][2] = covariance[0][1]; coMat[1][3] = covariance[0][2];
229  coMat[2][1] = covariance[1][0]; coMat[2][2] = covariance[1][1]; coMat[2][3] = covariance[1][2];
230  coMat[3][1] = covariance[2][0]; coMat[3][2] = covariance[2][1]; coMat[3][3] = covariance[2][2];
231
232  /* new jacobi tests */
233  JacobI(coMat, 3, eigvlMat, eigvMat, rotCount);
234  PRINTF(0)("-- Done Jacobi Decomposition\n");
235
236
237
238//   printf("Jacobi\n");
239//   for(int j = 1; j < 4; ++j)
240//   {
241//     printf(" |");
242//     for(int k = 1; k < 4; ++k)
243//     {
244//       printf(" \b%f ", eigvMat[j][k]);
245//     }
246//     printf(" |\n");
247//   }
248
249  axis[0] = new Vector(eigvMat[1][1], eigvMat[2][1], eigvMat[3][1]);
250  axis[1] = new Vector(eigvMat[1][2], eigvMat[2][2], eigvMat[3][2]);
251  axis[2] = new Vector(eigvMat[1][3], eigvMat[2][3], eigvMat[3][3]);
252  box->axis = axis;
253  PRINTF(0)("-- Got Axis\n");
254
255//   printf("\neigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
256//   printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
257//   printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
258
259
260//   delete [] a[0]; delete [] a[1]; delete [] a[2]; delete [] a[3];
261//   delete [] a;
262//
263//   delete [] b[0]; delete [] b[1]; delete [] b[2]; delete [] b[3];
264//   delete [] b;
265//
266//   delete rot;
267
268
269  /* now get the axis length */
270  Line                ax[3];                                 //!< the axis
271  float*              halfLength = new float[3];             //!< half length of the axis
272  float               tmpLength;                             //!< tmp save point for the length
273  Plane               p0(*box->axis[0], *box->center);       //!< the axis planes
274  Plane               p1(*box->axis[1], *box->center);
275  Plane               p2(*box->axis[2], *box->center);
276
277  halfLength[0] = -1.0f;
278  for(int j = 0; j < length; ++j)
279  {
280    tmpLength = fabs(p0.distancePoint(vertices[j]));
281    if( tmpLength > halfLength[0])
282      halfLength[0] = tmpLength;
283  }
284
285  halfLength[1] = -1.0f;
286  for(int j = 0; j < length; ++j)
287  {
288    tmpLength = fabs(p1.distancePoint(vertices[j]));
289    if( tmpLength > halfLength[1])
290      halfLength[1] = tmpLength;
291  }
292
293  halfLength[2] = -1.0f;
294  for(int j = 0; j < length; ++j)
295  {
296    tmpLength = fabs(p2.distancePoint(vertices[j]));
297    if( tmpLength > halfLength[2])
298      halfLength[2] = tmpLength;
299  }
300
301  box->halfLength = halfLength;
302  PRINTF(0)("-- Written Axis to obb\n");
303  PRINTF(0)("-- Finished Calculating Attributes\n");
304
305//   printf("\nwe got length: \n");
306//   for(int i = 0; i < 3; ++i)
307//     printf("length[%i] = %f\n", i, box->halfLength[i]);
308}
309
310
311
312/**
313  \brief this separates an ob-box in the middle
314  \param box: the box to separate
315
316  this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis
317 */
318void OBBTreeNode::forkBox(OBB* box)
319{
320  /* get the longest axis of the box */
321  float               aLength = -1.0f;                     //!< the length of the longest axis
322  int                 axisIndex = 0;                       //!< this is the nr of the longest axis
323
324  for(int i = 0; i < 3; ++i)
325  {
326    if( aLength < box->halfLength[i])
327    {
328      aLength = box->halfLength[i];
329      axisIndex = i;
330    }
331  }
332
333//   printf("\nlongest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength);
334
335
336  /* get the closest vertex near the center */
337  float               dist = 999999.0f;                    //!< the smallest distance to each vertex
338  float               tmpDist;                             //!< temporary distance
339  int                 vertexIndex;
340  Plane               middlePlane(*box->axis[axisIndex], *box->center); //!< the middle plane
341
342  for(int i = 0; i < box->numOfVertices; ++i)
343  {
344    tmpDist = fabs(middlePlane.distancePoint(box->vertices[i]));
345    if( tmpDist < dist)
346    {
347      dist = tmpDist;
348      vertexIndex = i;
349    }
350  }
351
352//   printf("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
353
354
355  /* now definin the separation plane through this specified nearest point and partition
356  the points depending on which side they are located
357  */
358  Plane              separationPlane(*box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
359  tList<sVec3D>      partition1;                           //!< the vertex partition 1
360  tList<sVec3D>      partition2;                           //!< the vertex partition 2
361
362  for(int i = 0; i < box->numOfVertices; ++i)
363  {
364    if( separationPlane.distancePoint(box->vertices[i]) > 0.0f)
365      partition1.add(&box->vertices[i]);
366    else
367      partition2.add(&box->vertices[i]);
368  }
369  partition1.add(&box->vertices[vertexIndex]);
370
371//   printf("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
372
373
374  /* now comes the separation into two different sVec3D arrays */
375  tIterator<sVec3D>* iterator;                             //!< the iterator to go through the lists
376  sVec3D*            element;                              //!< the elements
377  int                index;                                //!< index storage place
378  sVec3D*            vertList1;                            //!< the vertex list 1
379  sVec3D*            vertList2;                            //!< the vertex list 2
380
381  vertList1 = new sVec3D[partition1.getSize()];
382  vertList2 = new sVec3D[partition2.getSize()];
383
384  iterator = partition1.getIterator();
385  element = iterator->nextElement();
386  index = 0;
387  while( element != NULL)
388  {
389    vertList1[index][0] = element[0][0];
390    vertList1[index][1] = element[0][1];
391    vertList1[index][2] = element[0][2];
392    ++index;
393    element = iterator->nextElement();
394  }
395
396//   printf("\npartition 1:\n");
397//   for(int i = 0; i < partition1.getSize(); ++i)
398//   {
399//     printf("v[%i][0] = %f\n", i, vertList1[i][0]);
400//     printf("v[%i][1] = %f\n", i, vertList1[i][1]);
401//     printf("v[%i][2] = %f\n", i, vertList1[i][2]);
402//   }
403
404  iterator = partition2.getIterator();
405  element = iterator->nextElement();
406  index = 0;
407  while( element != NULL)
408  {
409    vertList2[index][0] = element[0][0];
410    vertList2[index][1] = element[0][1];
411    vertList2[index][2] = element[0][2];
412    ++index;
413    element = iterator->nextElement();
414  }
415
416  this->tmpVert1 = vertList1;
417  this->tmpVert2 = vertList2;
418  this->tmpLen1 = partition1.getSize();
419  this->tmpLen2 = partition2.getSize();
420
421  //delete iterator;
422//   printf("\npartition 2:\n");
423//   for(int i = 0; i < partition2.getSize(); ++i)
424//   {
425//     printf("v[%i][0] = %f\n", i, vertList2[i][0]);
426//     printf("v[%i][1] = %f\n", i, vertList2[i][1]);
427//     printf("v[%i][2] = %f\n", i, vertList2[i][2]);
428//   }
429}
430
431
432
433
434void OBBTreeNode::collideWith(const BVTree &tree)
435{}
436
437
438
439
440void OBBTreeNode::drawBV(int depth) const
441{
442  glBegin(GL_TRIANGLES);
443  glColor3f(1.0, 1.0, 1.0);
444  for(int i = 0; i < this->bvElement->numOfVertices; ++i)
445    {
446      glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
447      //printf("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
448    }
449  glEnd();
450  //this->drawBVPolygon(depth);
451}
452
453
454void OBBTreeNode::drawBVPolygon(int depth) const
455{
456  //OBBTree::material->select();
457
458  this->obbTree->getMaterial(depth)->select();
459
460  /* draw world axes */
461//   glBegin(GL_LINES);
462//   glColor3f(0.0, 0.4, 0.3);
463//   glVertex3f(0.0, 0.0, 0.0);
464//   glVertex3f(3.0, 0.0, 0.0);
465//
466//   glVertex3f(0.0, 0.0, 0.0);
467//   glVertex3f(0.0, 3.0, 0.0);
468//
469//   glVertex3f(0.0, 0.0, 0.0);
470//   glVertex3f(0.0, 0.0, 3.0);
471//   glEnd();
472
473
474
475  /* draw the obb axes */
476//   glBegin(GL_LINES);
477//   glColor3f(0.0, 0.4, 0.3);
478//   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
479//   glVertex3f(this->bvElement->center->x + this->bvElement->axis[0]->x * this->bvElement->halfLength[0],
480//              this->bvElement->center->y + this->bvElement->axis[0]->y * this->bvElement->halfLength[0],
481//              this->bvElement->center->z + this->bvElement->axis[0]->z * this->bvElement->halfLength[0]);
482//
483//   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
484//   glVertex3f(this->bvElement->center->x + this->bvElement->axis[1]->x * this->bvElement->halfLength[1],
485//              this->bvElement->center->y + this->bvElement->axis[1]->y * this->bvElement->halfLength[1],
486//              this->bvElement->center->z + this->bvElement->axis[1]->z * this->bvElement->halfLength[1]);
487//
488//   glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z);
489//   glVertex3f(this->bvElement->center->x + this->bvElement->axis[2]->x * this->bvElement->halfLength[2],
490//              this->bvElement->center->y + this->bvElement->axis[2]->y * this->bvElement->halfLength[2],
491//              this->bvElement->center->z + this->bvElement->axis[2]->z * this->bvElement->halfLength[2]);
492//   glEnd();
493
494
495  Vector cen = *this->bvElement->center;
496  Vector** axis = this->bvElement->axis;
497  float* len = this->bvElement->halfLength;
498
499  /* draw bounding box */
500  glBegin(GL_LINE_LOOP);
501  glColor3f(0.3, 0.4, 0.7);
502  glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
503             cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
504             cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
505  glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
506             cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
507             cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
508  glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
509             cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
510             cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
511  glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
512             cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
513             cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
514  glEnd();
515
516  glBegin(GL_LINE_LOOP);
517  glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
518             cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
519             cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
520  glVertex3f(cen.x + axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
521             cen.y + axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
522             cen.z + axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
523  glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
524             cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
525             cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
526  glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
527             cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
528             cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
529  glEnd();
530
531  glBegin(GL_LINE_LOOP);
532  glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] + axis[2]->x * len[2],
533             cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] + axis[2]->y * len[2],
534             cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] + axis[2]->z * len[2]);
535  glVertex3f(cen.x - axis[0]->x * len[0] - axis[1]->x * len[1] - axis[2]->x * len[2],
536             cen.y - axis[0]->y * len[0] - axis[1]->y * len[1] - axis[2]->y * len[2],
537             cen.z - axis[0]->z * len[0] - axis[1]->z * len[1] - axis[2]->z * len[2]);
538  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
539             cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
540             cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
541  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
542             cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
543             cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
544  glEnd();
545
546  glBegin(GL_LINE_LOOP);
547  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
548             cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
549             cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
550  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
551             cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
552             cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
553  glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
554             cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
555             cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);
556  glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
557             cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
558             cen.z + axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
559  glEnd();
560
561/*
562  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
563  cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
564  cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
565  glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
566  cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
567  cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);*/
568
569
570  glEnd();
571
572  if( this->nodeLeft != NULL && depth != 0 )
573    this->nodeLeft->drawBVPolygon(depth - 1);
574  if( this->nodeRight != NULL && depth != 0)
575    this->nodeRight->drawBVPolygon(depth - 1);
576
577}
578
579
580void OBBTreeNode::drawBVBlended(int depth) const
581{}
582
583
584void OBBTreeNode::debug()
585{
586
587  /*
588  for(int i = 0; i < length; i++)
589  {
590  printf("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
591}
592  */
593}
Note: See TracBrowser for help on using the repository browser.