Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: FINALLY! MUAHHAHAHAA, i found a function to compute the eigenvec. just wanted to go to sleep, but…

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