Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: drawing in diffrent hirarchies works now, with diffrent colors

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