[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 | |
---|
[4638] | 27 | #include "stdincl.h" |
---|
[4572] | 28 | |
---|
[4627] | 29 | #include "lin_alg.h" |
---|
[4572] | 30 | |
---|
| 31 | |
---|
| 32 | |
---|
[4627] | 33 | |
---|
[4541] | 34 | using namespace std; |
---|
| 35 | |
---|
[4622] | 36 | OBBTree* OBBTreeNode::obbTree = NULL; |
---|
[4541] | 37 | |
---|
[4630] | 38 | float** OBBTreeNode::coMat = NULL; |
---|
| 39 | float** OBBTreeNode::eigvMat = NULL; |
---|
| 40 | float* OBBTreeNode::eigvlMat = NULL; |
---|
| 41 | int* OBBTreeNode::rotCount = NULL; |
---|
| 42 | |
---|
[4541] | 43 | /** |
---|
| 44 | \brief standard constructor |
---|
[4617] | 45 | */ |
---|
[4588] | 46 | OBBTreeNode::OBBTreeNode () |
---|
[4541] | 47 | { |
---|
[4617] | 48 | this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode"); |
---|
[4618] | 49 | this->nodeLeft = NULL; |
---|
| 50 | this->nodeRight = NULL; |
---|
[4630] | 51 | |
---|
| 52 | if(coMat == NULL) |
---|
| 53 | { |
---|
| 54 | coMat = new float*[4]; |
---|
| 55 | for(int i = 0; i < 4; i++) |
---|
| 56 | coMat[i] = new float[4]; |
---|
| 57 | } |
---|
| 58 | if(eigvMat == NULL) |
---|
| 59 | { |
---|
| 60 | eigvMat = new float*[4]; |
---|
| 61 | for(int i = 0; i < 4; i++) |
---|
| 62 | eigvMat[i] = new float[4]; |
---|
| 63 | } |
---|
| 64 | if( eigvlMat == NULL) |
---|
| 65 | { |
---|
| 66 | eigvlMat = new float[4]; |
---|
| 67 | } |
---|
| 68 | if( rotCount == NULL) |
---|
| 69 | rotCount = new int; |
---|
[4638] | 70 | |
---|
| 71 | this->sphereObj = gluNewQuadric(); |
---|
[4541] | 72 | } |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | /** |
---|
| 76 | \brief standard deconstructor |
---|
[4617] | 77 | */ |
---|
[4588] | 78 | OBBTreeNode::~OBBTreeNode () |
---|
[4541] | 79 | { |
---|
| 80 | // delete what has to be deleted here |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | |
---|
[4542] | 84 | |
---|
| 85 | /** |
---|
| 86 | \brief creates a new BVTree or BVTree partition |
---|
[4614] | 87 | \param depth: how much more depth-steps to go: if == 1 don't go any deeper! |
---|
[4542] | 88 | \param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle |
---|
[4617] | 89 | */ |
---|
[4544] | 90 | void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length) |
---|
[4542] | 91 | { |
---|
[4638] | 92 | PRINT(0)("\n"); |
---|
| 93 | this->treeIndex = this->obbTree->getID(); |
---|
| 94 | PRINTF(0)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length); |
---|
[4614] | 95 | this->depth = depth; |
---|
| 96 | |
---|
[4638] | 97 | |
---|
[4630] | 98 | this->bvElement = new OBB(); |
---|
[4638] | 99 | this->bvElement->vertices = verticesList; |
---|
| 100 | this->bvElement->numOfVertices = length; |
---|
| 101 | PRINTF(3)("Created OBBox\n"); |
---|
[4632] | 102 | this->calculateBoxCovariance(this->bvElement, verticesList, length); |
---|
[4638] | 103 | PRINTF(3)("Calculated attributes1\n"); |
---|
[4632] | 104 | this->calculateBoxEigenvectors(this->bvElement, verticesList, length); |
---|
[4638] | 105 | PRINTF(3)("Calculated attributes2\n"); |
---|
[4632] | 106 | this->calculateBoxAxis(this->bvElement, verticesList, length); |
---|
[4638] | 107 | PRINTF(3)("Calculated attributes3\n"); |
---|
[4617] | 108 | |
---|
[4632] | 109 | |
---|
[4614] | 110 | if( likely( this->depth > 0)) |
---|
| 111 | { |
---|
| 112 | this->forkBox(this->bvElement); |
---|
[4626] | 113 | |
---|
[4630] | 114 | |
---|
[4648] | 115 | if(this->tmpLen1 > 0) |
---|
[4638] | 116 | { |
---|
| 117 | OBBTreeNode* node1 = new OBBTreeNode(); |
---|
| 118 | this->nodeLeft = node1; |
---|
| 119 | this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1); |
---|
| 120 | } |
---|
| 121 | else |
---|
| 122 | { |
---|
| 123 | PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n"); |
---|
| 124 | } |
---|
[4630] | 125 | |
---|
[4648] | 126 | if( this->tmpLen2 > 0) |
---|
[4638] | 127 | { |
---|
| 128 | OBBTreeNode* node2 = new OBBTreeNode(); |
---|
| 129 | this->nodeRight = node2; |
---|
| 130 | this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2); |
---|
| 131 | } |
---|
| 132 | else |
---|
| 133 | { |
---|
| 134 | PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n"); |
---|
| 135 | } |
---|
[4630] | 136 | |
---|
[4614] | 137 | } |
---|
[4557] | 138 | } |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | |
---|
[4632] | 142 | void OBBTreeNode::calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length) |
---|
[4557] | 143 | { |
---|
[4543] | 144 | float facelet[length]; //!< surface area of the i'th triangle of the convex hull |
---|
| 145 | float face; //!< surface area of the entire convex hull |
---|
[4588] | 146 | Vector centroid[length]; //!< centroid of the i'th convex hull |
---|
[4557] | 147 | Vector center; //!< the center of the entire hull |
---|
[4544] | 148 | Vector p, q, r; //!< holder of the polygon data, much more conveniant to work with Vector than sVec3d |
---|
[4545] | 149 | Vector t1, t2; //!< temporary values |
---|
[4628] | 150 | float covariance[3][3]; //!< the covariance matrix |
---|
[4648] | 151 | int mode = 3; //!< mode = 0: vertex soup, no connections, mode = 1: 3 following verteces build a triangle |
---|
[4588] | 152 | |
---|
[4553] | 153 | this->numOfVertices = length; |
---|
| 154 | this->vertices = verticesList; |
---|
| 155 | |
---|
[4562] | 156 | |
---|
[4648] | 157 | if( likely(mode == 0)) |
---|
| 158 | { |
---|
| 159 | /* fist compute all the convex hull face/facelets and centroids */ |
---|
| 160 | for(int i = 0; i < length; i+=3) /* FIX-ME-QUICK: hops of 3, array indiscontinuity*/ |
---|
| 161 | { |
---|
| 162 | p = verticesList[i]; |
---|
| 163 | q = verticesList[i + 1]; |
---|
| 164 | r = verticesList[i + 2]; |
---|
[4638] | 165 | |
---|
[4648] | 166 | t1 = p - q; t2 = p - r; |
---|
[4638] | 167 | |
---|
[4648] | 168 | /* finding the facelet surface via cross-product */ |
---|
| 169 | facelet[i] = 0.5f * fabs( t1.cross(t2).len() ); |
---|
| 170 | /* update the entire convex hull surface */ |
---|
| 171 | face += facelet[i]; |
---|
| 172 | |
---|
| 173 | /* calculate the cetroid of the hull triangles */ |
---|
| 174 | centroid[i] = (p + q + r) * 1/3; |
---|
| 175 | /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */ |
---|
| 176 | center += centroid[i] * facelet[i]; |
---|
| 177 | } |
---|
| 178 | /* take the average of the centroid sum */ |
---|
| 179 | center /= face; |
---|
| 180 | PRINTF(3)("-- Calculated Center\n"); |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | /* now calculate the covariance matrix - if not written in three for-loops, it would compute faster: minor */ |
---|
| 184 | for(int j = 0; j < 3; ++j) |
---|
| 185 | { |
---|
| 186 | for(int k = 0; k < 3; ++k) |
---|
| 187 | { |
---|
| 188 | for(int i = 0; i < length; i+=3) |
---|
| 189 | { |
---|
| 190 | p = verticesList[i]; |
---|
| 191 | q = verticesList[i + 1]; |
---|
| 192 | r = verticesList[i + 2]; |
---|
| 193 | |
---|
| 194 | covariance[j][k] = facelet[i] / (12.0f * face) * (9.0f * centroid[i][j] * centroid[i][k] + p[j] * p[k] + |
---|
| 195 | q[j] * q[k] + r[j] * r[k]) - center[j] * center[k]; |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | PRINTF(3)("-- Calculated Covariance\n"); |
---|
| 200 | } |
---|
| 201 | else if( mode == 1) |
---|
[4617] | 202 | { |
---|
[4648] | 203 | for( int i = 0; i < length; i+=3) /* FIX-ME-QUICK: hops of 3, array indiscontinuity*/ |
---|
| 204 | { |
---|
| 205 | p = verticesList[i]; |
---|
| 206 | q = verticesList[i + 1]; |
---|
| 207 | r = verticesList[i + 2]; |
---|
[4588] | 208 | |
---|
[4648] | 209 | centroid[i] = (p + q + r) / 3.0f; |
---|
| 210 | center += centroid[i]; |
---|
| 211 | } |
---|
| 212 | center /= length; |
---|
[4588] | 213 | |
---|
[4648] | 214 | for( int j = 0; j < 3; ++j) |
---|
| 215 | { |
---|
| 216 | for( int k = 0; k < 3; ++k) |
---|
| 217 | { |
---|
| 218 | for( int i = 0; i < length; i+=3) |
---|
| 219 | { |
---|
| 220 | p = verticesList[i]; |
---|
| 221 | q = verticesList[i +1]; |
---|
| 222 | r = verticesList[i + 2]; |
---|
[4545] | 223 | |
---|
[4648] | 224 | covariance[j][k] = p[j] * p[k] + q[j] * q[k] + r[j] + r[k]; |
---|
| 225 | } |
---|
| 226 | covariance[j][k] /= (3.0f * length); |
---|
| 227 | } |
---|
| 228 | } |
---|
| 229 | PRINTF(3)("-- Calculated Covariance\n"); |
---|
[4617] | 230 | } |
---|
[4648] | 231 | else if( mode == 2) |
---|
| 232 | { |
---|
| 233 | /* fist compute all the convex hull face/facelets and centroids */ |
---|
| 234 | for(int i = 0; i < length; i+=3) /* FIX-ME-QUICK: hops of 3, array indiscontinuity*/ |
---|
| 235 | { |
---|
| 236 | p = verticesList[i]; |
---|
| 237 | q = verticesList[i + 1]; |
---|
| 238 | r = verticesList[i + 2]; |
---|
[4562] | 239 | |
---|
[4648] | 240 | t1 = p - q; t2 = p - r; |
---|
[4562] | 241 | |
---|
[4648] | 242 | /* finding the facelet surface via cross-product */ |
---|
| 243 | facelet[i] = 0.5f * fabs( t1.cross(t2).len() ); |
---|
| 244 | /* update the entire convex hull surface */ |
---|
| 245 | face += facelet[i]; |
---|
| 246 | |
---|
| 247 | /* calculate the cetroid of the hull triangles */ |
---|
| 248 | centroid[i] = (p + q + r) * 1/3; |
---|
| 249 | /* now calculate the centroid of the entire convex hull, weighted average of triangle centroids */ |
---|
| 250 | center += centroid[i] * facelet[i]; |
---|
| 251 | } |
---|
| 252 | /* take the average of the centroid sum */ |
---|
| 253 | center /= face; |
---|
| 254 | PRINTF(3)("-- Calculated Center\n"); |
---|
| 255 | |
---|
| 256 | for( int j = 0; j < 3; ++j) |
---|
| 257 | { |
---|
| 258 | for( int k = 0; k < 3; ++k) |
---|
| 259 | { |
---|
| 260 | for( int i = 0; i < length; i+=3) |
---|
| 261 | { |
---|
| 262 | p = verticesList[i]; |
---|
| 263 | q = verticesList[i +1]; |
---|
| 264 | r = verticesList[i + 2]; |
---|
| 265 | |
---|
| 266 | covariance[j][k] = p[j] * p[k] + q[j] * q[k] + r[j] + r[k]; |
---|
| 267 | } |
---|
| 268 | covariance[j][k] /= (3.0f * length); |
---|
| 269 | } |
---|
| 270 | } |
---|
| 271 | PRINTF(3)("-- Calculated Covariance\n"); |
---|
| 272 | } |
---|
| 273 | else |
---|
[4617] | 274 | { |
---|
[4648] | 275 | for( int i = 0; i < length; ++i) /* FIX-ME-QUICK: hops of 3, array indiscontinuity*/ |
---|
[4545] | 276 | { |
---|
[4648] | 277 | center += verticesList[i]; |
---|
| 278 | } |
---|
| 279 | center /= length; |
---|
| 280 | |
---|
| 281 | for( int j = 0; j < 3; ++j) |
---|
| 282 | { |
---|
| 283 | for( int k = 0; k < 3; ++k) |
---|
[4617] | 284 | { |
---|
[4648] | 285 | for( int i = 0; i < length; i+=3) |
---|
| 286 | { |
---|
| 287 | p = verticesList[i]; |
---|
| 288 | q = verticesList[i +1]; |
---|
| 289 | r = verticesList[i + 2]; |
---|
[4544] | 290 | |
---|
[4648] | 291 | covariance[j][k] = p[j] * p[k] + q[j] * q[k] + r[j] + r[k]; |
---|
| 292 | } |
---|
| 293 | covariance[j][k] /= (3.0f * length); |
---|
[4617] | 294 | } |
---|
[4545] | 295 | } |
---|
[4648] | 296 | PRINTF(3)("-- Calculated Covariance\n"); |
---|
[4617] | 297 | } |
---|
[4562] | 298 | |
---|
[4648] | 299 | PRINTF(3)("\nVertex Data:\n"); |
---|
[4638] | 300 | for(int i = 0; i < length; i++) |
---|
| 301 | { |
---|
| 302 | //PRINTF(0)("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]); |
---|
[4648] | 303 | PRINTF(3)("vertex %i: %f, %f, %f\n", i, box->vertices[i][0], box->vertices[i][1], box->vertices[i][2]); |
---|
[4638] | 304 | } |
---|
[4588] | 305 | |
---|
[4648] | 306 | |
---|
[4638] | 307 | // PRINTF(3)("\nCovariance Matrix:\n"); |
---|
[4629] | 308 | // for(int j = 0; j < 3; ++j) |
---|
| 309 | // { |
---|
[4638] | 310 | // PRINTF(3)(" |"); |
---|
[4629] | 311 | // for(int k = 0; k < 3; ++k) |
---|
| 312 | // { |
---|
[4638] | 313 | // PRINTF(3)(" \b%f ", covariance[j][k]); |
---|
[4629] | 314 | // } |
---|
[4638] | 315 | // PRINTF(3)(" |\n"); |
---|
[4629] | 316 | // } |
---|
[4638] | 317 | PRINTF(3)("center: %f, %f, %f\n", center.x, center.y, center.z); |
---|
[4553] | 318 | |
---|
[4588] | 319 | |
---|
[4633] | 320 | // for(int i = 0; i < 3; ++i) |
---|
| 321 | // { |
---|
| 322 | // box->covarianceMatrix[i][0] = covariance[i][0]; |
---|
| 323 | // box->covarianceMatrix[i][1] = covariance[i][1]; |
---|
| 324 | // box->covarianceMatrix[i][3] = covariance[i][2]; |
---|
| 325 | // } |
---|
[4560] | 326 | *box->center = center; |
---|
[4638] | 327 | PRINTF(3)("-- Written Result to obb\n"); |
---|
[4631] | 328 | } |
---|
[4557] | 329 | |
---|
[4631] | 330 | |
---|
| 331 | |
---|
[4632] | 332 | void OBBTreeNode::calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length) |
---|
[4631] | 333 | { |
---|
| 334 | |
---|
[4557] | 335 | /* now getting spanning vectors of the sub-space: |
---|
[4617] | 336 | the eigenvectors of a symmertric matrix, such as the |
---|
| 337 | covarience matrix are mutually orthogonal. |
---|
| 338 | after normalizing them, they can be used as a the basis |
---|
| 339 | vectors |
---|
[4557] | 340 | */ |
---|
[4660] | 341 | Vector* axis = new Vector[3]; //!< the references to the obb axis |
---|
[4588] | 342 | |
---|
[4631] | 343 | coMat[1][1] = box->covarianceMatrix[0][0]; coMat[1][2] = box->covarianceMatrix[0][1]; coMat[1][3] = box->covarianceMatrix[0][2]; |
---|
| 344 | coMat[2][1] = box->covarianceMatrix[1][0]; coMat[2][2] = box->covarianceMatrix[1][1]; coMat[2][3] = box->covarianceMatrix[1][2]; |
---|
| 345 | coMat[3][1] = box->covarianceMatrix[2][0]; coMat[3][2] = box->covarianceMatrix[2][1]; coMat[3][3] = box->covarianceMatrix[2][2]; |
---|
[4627] | 346 | |
---|
[4630] | 347 | /* new jacobi tests */ |
---|
| 348 | JacobI(coMat, 3, eigvlMat, eigvMat, rotCount); |
---|
[4638] | 349 | PRINTF(3)("-- Done Jacobi Decomposition\n"); |
---|
[4628] | 350 | |
---|
[4627] | 351 | |
---|
[4638] | 352 | // PRINTF(3)("Jacobi\n"); |
---|
[4629] | 353 | // for(int j = 1; j < 4; ++j) |
---|
| 354 | // { |
---|
[4638] | 355 | // PRINTF(3)(" |"); |
---|
[4629] | 356 | // for(int k = 1; k < 4; ++k) |
---|
| 357 | // { |
---|
[4638] | 358 | // PRINTF(3)(" \b%f ", eigvMat[j][k]); |
---|
[4629] | 359 | // } |
---|
[4638] | 360 | // PRINTF(3)(" |\n"); |
---|
[4629] | 361 | // } |
---|
| 362 | |
---|
[4660] | 363 | axis[0].x = eigvMat[1][1]; axis[0].y = eigvMat[2][1]; axis[0].z = eigvMat[3][1]; |
---|
| 364 | axis[1].x = eigvMat[1][2]; axis[1].y = eigvMat[2][2]; axis[1].z = eigvMat[3][2]; |
---|
| 365 | axis[2].x = eigvMat[1][3]; axis[2].y = eigvMat[2][3]; axis[2].z = eigvMat[3][3]; |
---|
[4576] | 366 | box->axis = axis; |
---|
[4660] | 367 | |
---|
[4638] | 368 | PRINTF(3)("-- Got Axis\n"); |
---|
[4588] | 369 | |
---|
[4660] | 370 | PRINTF(3)("eigenvector: %f, %f, %f\n", box->axis[0].x, box->axis[0].y, box->axis[0].z); |
---|
| 371 | PRINTF(3)("eigenvector: %f, %f, %f\n", box->axis[1].x, box->axis[1].y, box->axis[1].z); |
---|
| 372 | PRINTF(3)("eigenvector: %f, %f, %f\n", box->axis[2].x, box->axis[2].y, box->axis[2].z); |
---|
[4632] | 373 | } |
---|
[4588] | 374 | |
---|
[4626] | 375 | |
---|
[4632] | 376 | void OBBTreeNode::calculateBoxAxis(OBB* box, sVec3D* verticesList, int length) |
---|
[4631] | 377 | { |
---|
[4630] | 378 | |
---|
[4576] | 379 | /* now get the axis length */ |
---|
[4578] | 380 | Line ax[3]; //!< the axis |
---|
| 381 | float* halfLength = new float[3]; //!< half length of the axis |
---|
| 382 | float tmpLength; //!< tmp save point for the length |
---|
[4660] | 383 | Plane p0(box->axis[0], *box->center); //!< the axis planes |
---|
| 384 | Plane p1(box->axis[1], *box->center); |
---|
| 385 | Plane p2(box->axis[2], *box->center); |
---|
[4658] | 386 | float maxLength[3]; |
---|
| 387 | float minLength[3]; |
---|
[4588] | 388 | |
---|
[4658] | 389 | |
---|
| 390 | /* get a bad bounding box */ |
---|
[4589] | 391 | halfLength[0] = -1.0f; |
---|
[4585] | 392 | for(int j = 0; j < length; ++j) |
---|
[4658] | 393 | { |
---|
[4661] | 394 | tmpLength = fabs(p0.distancePoint(vertices[j])); |
---|
[4658] | 395 | if( tmpLength > halfLength[0]) |
---|
[4659] | 396 | halfLength[0] = tmpLength; |
---|
[4658] | 397 | } |
---|
| 398 | |
---|
| 399 | halfLength[1] = -1.0f; |
---|
| 400 | for(int j = 0; j < length; ++j) |
---|
| 401 | { |
---|
| 402 | tmpLength = fabs(p1.distancePoint(vertices[j])); |
---|
| 403 | if( tmpLength > halfLength[1]) |
---|
[4659] | 404 | halfLength[1] = tmpLength; |
---|
[4658] | 405 | } |
---|
| 406 | |
---|
| 407 | halfLength[2] = -1.0f; |
---|
| 408 | for(int j = 0; j < length; ++j) |
---|
| 409 | { |
---|
[4661] | 410 | tmpLength = fabs(p2.distancePoint(vertices[j])); |
---|
[4658] | 411 | if( tmpLength > halfLength[2]) |
---|
[4659] | 412 | halfLength[2] = tmpLength; |
---|
[4658] | 413 | } |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | /* get the maximal dimensions of the body in all directions */ |
---|
[4660] | 418 | maxLength[0] = 0.0f; |
---|
| 419 | minLength[0] = 0.0f; |
---|
| 420 | for(int j = 0; j < length; ++j) |
---|
| 421 | { |
---|
| 422 | tmpLength = p0.distancePoint(vertices[j]); |
---|
| 423 | if( tmpLength > maxLength[0]) |
---|
| 424 | maxLength[0] = tmpLength; |
---|
| 425 | else if( tmpLength < minLength[0]) |
---|
| 426 | minLength[0] = tmpLength; |
---|
| 427 | } |
---|
[4578] | 428 | |
---|
[4660] | 429 | maxLength[1] = 0.0f; |
---|
| 430 | minLength[1] = 0.0f; |
---|
| 431 | for(int j = 0; j < length; ++j) |
---|
| 432 | { |
---|
[4661] | 433 | tmpLength = p1.distancePoint(vertices[j]); |
---|
[4660] | 434 | if( tmpLength > maxLength[1]) |
---|
| 435 | maxLength[1] = tmpLength; |
---|
| 436 | else if( tmpLength < minLength[1]) |
---|
| 437 | minLength[1] = tmpLength; |
---|
| 438 | } |
---|
[4585] | 439 | |
---|
[4660] | 440 | maxLength[2] = 0.0f; |
---|
| 441 | minLength[2] = 0.0f; |
---|
| 442 | for(int j = 0; j < length; ++j) |
---|
| 443 | { |
---|
[4661] | 444 | tmpLength = p2.distancePoint(vertices[j]); |
---|
[4660] | 445 | if( tmpLength > maxLength[2]) |
---|
| 446 | maxLength[2] = tmpLength; |
---|
| 447 | else if( tmpLength < minLength[2]) |
---|
| 448 | minLength[2] = tmpLength; |
---|
| 449 | } |
---|
[4585] | 450 | |
---|
[4660] | 451 | |
---|
| 452 | /* calculate the real centre of the body by using the axis length */ |
---|
[4668] | 453 | float centerOffset[3]; |
---|
| 454 | float newHalfLength[3]; |
---|
[4660] | 455 | for(int i = 0; i < 3; ++i) |
---|
| 456 | { |
---|
[4661] | 457 | PRINTF(0)("max: %f, min: %f \n", maxLength[i], minLength[i]); |
---|
[4668] | 458 | centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f; // min length is negatie |
---|
| 459 | newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative |
---|
[4660] | 460 | //PRINTF(0)("Center Orig: %f, %f, %f ---- new: %f, %f, %f", box->center[]); |
---|
[4668] | 461 | *box->center += (box->axis[i] * centerOffset[i]); // update the new center vector |
---|
| 462 | //PRINTF(0)("Center Translation Operation: halfLength old: %f, new: %f\n", halfLength[i], center[i]); |
---|
| 463 | halfLength[i] = newHalfLength[i]; |
---|
[4660] | 464 | } |
---|
| 465 | |
---|
| 466 | |
---|
| 467 | |
---|
[4586] | 468 | box->halfLength = halfLength; |
---|
[4638] | 469 | PRINTF(3)("-- Written Axis to obb\n"); |
---|
| 470 | PRINTF(3)("-- Finished Calculating Attributes\n"); |
---|
[4585] | 471 | |
---|
[4638] | 472 | |
---|
| 473 | |
---|
| 474 | // PRINTF(3)("\nwe got length: \n"); |
---|
| 475 | for(int i = 0; i < 3; ++i) |
---|
| 476 | { |
---|
| 477 | //if( box->halfLength[i] == 0.0) |
---|
[4660] | 478 | PRINTF(3)("length[%i] = %f\n", i, box->halfLength[i]); |
---|
[4638] | 479 | } |
---|
[4542] | 480 | } |
---|
| 481 | |
---|
| 482 | |
---|
[4609] | 483 | |
---|
| 484 | /** |
---|
| 485 | \brief this separates an ob-box in the middle |
---|
| 486 | \param box: the box to separate |
---|
| 487 | |
---|
| 488 | this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis |
---|
| 489 | */ |
---|
[4557] | 490 | void OBBTreeNode::forkBox(OBB* box) |
---|
| 491 | { |
---|
| 492 | /* get the longest axis of the box */ |
---|
[4609] | 493 | float aLength = -1.0f; //!< the length of the longest axis |
---|
| 494 | int axisIndex = 0; //!< this is the nr of the longest axis |
---|
| 495 | |
---|
[4557] | 496 | for(int i = 0; i < 3; ++i) |
---|
[4609] | 497 | { |
---|
| 498 | if( aLength < box->halfLength[i]) |
---|
[4557] | 499 | { |
---|
[4609] | 500 | aLength = box->halfLength[i]; |
---|
| 501 | axisIndex = i; |
---|
[4557] | 502 | } |
---|
[4609] | 503 | } |
---|
[4588] | 504 | |
---|
[4638] | 505 | PRINTF(0)("longest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength); |
---|
[4609] | 506 | |
---|
| 507 | |
---|
[4557] | 508 | /* get the closest vertex near the center */ |
---|
[4611] | 509 | float dist = 999999.0f; //!< the smallest distance to each vertex |
---|
[4609] | 510 | float tmpDist; //!< temporary distance |
---|
| 511 | int vertexIndex; |
---|
[4660] | 512 | Plane middlePlane(box->axis[axisIndex], *box->center); //!< the middle plane |
---|
[4588] | 513 | |
---|
[4660] | 514 | vertexIndex = 0; |
---|
[4609] | 515 | for(int i = 0; i < box->numOfVertices; ++i) |
---|
| 516 | { |
---|
[4611] | 517 | tmpDist = fabs(middlePlane.distancePoint(box->vertices[i])); |
---|
| 518 | if( tmpDist < dist) |
---|
| 519 | { |
---|
[4609] | 520 | dist = tmpDist; |
---|
[4611] | 521 | vertexIndex = i; |
---|
| 522 | } |
---|
[4609] | 523 | } |
---|
| 524 | |
---|
[4638] | 525 | // PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist); |
---|
[4609] | 526 | |
---|
| 527 | |
---|
[4611] | 528 | /* now definin the separation plane through this specified nearest point and partition |
---|
[4617] | 529 | the points depending on which side they are located |
---|
[4611] | 530 | */ |
---|
| 531 | tList<sVec3D> partition1; //!< the vertex partition 1 |
---|
| 532 | tList<sVec3D> partition2; //!< the vertex partition 2 |
---|
| 533 | |
---|
[4660] | 534 | printf("vertex index: %i, of %i\n", vertexIndex, box->numOfVertices); |
---|
| 535 | this->separationPlane = new Plane(box->axis[axisIndex], box->vertices[vertexIndex]); //!< separation plane |
---|
[4632] | 536 | this->sepPlaneCenter = &box->vertices[vertexIndex]; |
---|
| 537 | this->longestAxisIndex = axisIndex; |
---|
| 538 | |
---|
[4612] | 539 | for(int i = 0; i < box->numOfVertices; ++i) |
---|
| 540 | { |
---|
[4632] | 541 | if( this->separationPlane->distancePoint(box->vertices[i]) > 0.0f) |
---|
[4612] | 542 | partition1.add(&box->vertices[i]); |
---|
| 543 | else |
---|
| 544 | partition2.add(&box->vertices[i]); |
---|
| 545 | } |
---|
[4613] | 546 | partition1.add(&box->vertices[vertexIndex]); |
---|
[4611] | 547 | |
---|
[4638] | 548 | // PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize()); |
---|
[4612] | 549 | |
---|
[4613] | 550 | |
---|
| 551 | /* now comes the separation into two different sVec3D arrays */ |
---|
| 552 | tIterator<sVec3D>* iterator; //!< the iterator to go through the lists |
---|
| 553 | sVec3D* element; //!< the elements |
---|
| 554 | int index; //!< index storage place |
---|
| 555 | sVec3D* vertList1; //!< the vertex list 1 |
---|
| 556 | sVec3D* vertList2; //!< the vertex list 2 |
---|
| 557 | |
---|
| 558 | vertList1 = new sVec3D[partition1.getSize()]; |
---|
| 559 | vertList2 = new sVec3D[partition2.getSize()]; |
---|
| 560 | |
---|
| 561 | iterator = partition1.getIterator(); |
---|
| 562 | element = iterator->nextElement(); |
---|
| 563 | index = 0; |
---|
| 564 | while( element != NULL) |
---|
| 565 | { |
---|
| 566 | vertList1[index][0] = element[0][0]; |
---|
| 567 | vertList1[index][1] = element[0][1]; |
---|
| 568 | vertList1[index][2] = element[0][2]; |
---|
| 569 | ++index; |
---|
| 570 | element = iterator->nextElement(); |
---|
| 571 | } |
---|
| 572 | |
---|
[4638] | 573 | // PRINTF(0)("\npartition 1:\n"); |
---|
[4626] | 574 | // for(int i = 0; i < partition1.getSize(); ++i) |
---|
| 575 | // { |
---|
[4638] | 576 | // 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]); |
---|
[4626] | 577 | // } |
---|
[4613] | 578 | |
---|
| 579 | iterator = partition2.getIterator(); |
---|
| 580 | element = iterator->nextElement(); |
---|
| 581 | index = 0; |
---|
| 582 | while( element != NULL) |
---|
| 583 | { |
---|
| 584 | vertList2[index][0] = element[0][0]; |
---|
| 585 | vertList2[index][1] = element[0][1]; |
---|
| 586 | vertList2[index][2] = element[0][2]; |
---|
| 587 | ++index; |
---|
| 588 | element = iterator->nextElement(); |
---|
| 589 | } |
---|
| 590 | |
---|
[4630] | 591 | this->tmpVert1 = vertList1; |
---|
| 592 | this->tmpVert2 = vertList2; |
---|
| 593 | this->tmpLen1 = partition1.getSize(); |
---|
| 594 | this->tmpLen2 = partition2.getSize(); |
---|
| 595 | |
---|
[4638] | 596 | delete iterator; |
---|
| 597 | |
---|
| 598 | // PRINTF(0)("\npartition 2:\n"); |
---|
[4626] | 599 | // for(int i = 0; i < partition2.getSize(); ++i) |
---|
| 600 | // { |
---|
[4638] | 601 | // 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]); |
---|
[4626] | 602 | // } |
---|
[4557] | 603 | } |
---|
| 604 | |
---|
| 605 | |
---|
[4626] | 606 | |
---|
| 607 | |
---|
[4542] | 608 | void OBBTreeNode::collideWith(const BVTree &tree) |
---|
| 609 | {} |
---|
| 610 | |
---|
| 611 | |
---|
[4626] | 612 | |
---|
| 613 | |
---|
[4635] | 614 | void OBBTreeNode::drawBV(int depth, int drawMode) const |
---|
[4553] | 615 | { |
---|
[4638] | 616 | this->obbTree->getMaterial(treeIndex)->select(); |
---|
[4635] | 617 | |
---|
| 618 | /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */ |
---|
| 619 | if( drawMode & DRAW_MODEL || drawMode & DRAW_ALL) |
---|
| 620 | { |
---|
[4638] | 621 | if( !(drawMode & DRAW_SINGLE && depth != 0)) |
---|
[4622] | 622 | { |
---|
[4648] | 623 | //glBegin(GL_LINE_STRIP); |
---|
[4638] | 624 | for(int i = 0; i < this->bvElement->numOfVertices; ++i) |
---|
| 625 | { |
---|
| 626 | glPushMatrix(); |
---|
[4648] | 627 | //glMatrixMode(GL_MODELVIEW); |
---|
| 628 | //glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]); |
---|
[4638] | 629 | glTranslatef(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]); |
---|
| 630 | gluSphere(this->sphereObj, 1, 10, 10); |
---|
[4648] | 631 | //PRINTF(0)("v(%f, %f, %f)\n", this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]); |
---|
[4638] | 632 | glPopMatrix(); |
---|
| 633 | } |
---|
[4648] | 634 | //glEnd(); |
---|
[4622] | 635 | } |
---|
[4635] | 636 | } |
---|
[4542] | 637 | |
---|
| 638 | |
---|
[4589] | 639 | /* draw world axes */ |
---|
[4618] | 640 | // glBegin(GL_LINES); |
---|
| 641 | // glColor3f(0.0, 0.4, 0.3); |
---|
| 642 | // glVertex3f(0.0, 0.0, 0.0); |
---|
| 643 | // glVertex3f(3.0, 0.0, 0.0); |
---|
| 644 | // |
---|
| 645 | // glVertex3f(0.0, 0.0, 0.0); |
---|
| 646 | // glVertex3f(0.0, 3.0, 0.0); |
---|
| 647 | // |
---|
| 648 | // glVertex3f(0.0, 0.0, 0.0); |
---|
| 649 | // glVertex3f(0.0, 0.0, 3.0); |
---|
| 650 | // glEnd(); |
---|
[4589] | 651 | |
---|
| 652 | |
---|
[4635] | 653 | if( drawMode & DRAW_BV_AXIS || drawMode & DRAW_ALL) |
---|
| 654 | { |
---|
[4636] | 655 | if( !(drawMode & DRAW_SINGLE && depth != 0)) |
---|
[4635] | 656 | { |
---|
| 657 | /* draw the obb axes */ |
---|
| 658 | glBegin(GL_LINES); |
---|
| 659 | glColor3f(0.0, 0.4, 0.3); |
---|
| 660 | glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z); |
---|
[4660] | 661 | glVertex3f(this->bvElement->center->x + this->bvElement->axis[0].x * this->bvElement->halfLength[0], |
---|
| 662 | this->bvElement->center->y + this->bvElement->axis[0].y * this->bvElement->halfLength[0], |
---|
| 663 | this->bvElement->center->z + this->bvElement->axis[0].z * this->bvElement->halfLength[0]); |
---|
[4589] | 664 | |
---|
[4635] | 665 | glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z); |
---|
[4660] | 666 | glVertex3f(this->bvElement->center->x + this->bvElement->axis[1].x * this->bvElement->halfLength[1], |
---|
| 667 | this->bvElement->center->y + this->bvElement->axis[1].y * this->bvElement->halfLength[1], |
---|
| 668 | this->bvElement->center->z + this->bvElement->axis[1].z * this->bvElement->halfLength[1]); |
---|
[4588] | 669 | |
---|
[4635] | 670 | glVertex3f(this->bvElement->center->x, this->bvElement->center->y, this->bvElement->center->z); |
---|
[4660] | 671 | glVertex3f(this->bvElement->center->x + this->bvElement->axis[2].x * this->bvElement->halfLength[2], |
---|
| 672 | this->bvElement->center->y + this->bvElement->axis[2].y * this->bvElement->halfLength[2], |
---|
| 673 | this->bvElement->center->z + this->bvElement->axis[2].z * this->bvElement->halfLength[2]); |
---|
[4635] | 674 | glEnd(); |
---|
| 675 | } |
---|
| 676 | } |
---|
[4581] | 677 | |
---|
[4588] | 678 | |
---|
[4635] | 679 | if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL) |
---|
| 680 | { |
---|
[4636] | 681 | if( !(drawMode & DRAW_SINGLE && depth != 0)) |
---|
[4635] | 682 | { |
---|
[4636] | 683 | Vector cen = *this->bvElement->center; |
---|
[4660] | 684 | Vector* axis = this->bvElement->axis; |
---|
[4636] | 685 | float* len = this->bvElement->halfLength; |
---|
[4588] | 686 | |
---|
[4636] | 687 | /* draw bounding box */ |
---|
[4669] | 688 | glBegin(GL_QUAD_STRIP); |
---|
[4660] | 689 | glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 690 | cen.y + axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 691 | cen.z + axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]); |
---|
| 692 | glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 693 | cen.y + axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 694 | cen.z + axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 695 | glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 696 | cen.y + axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 697 | cen.z + axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 698 | glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 699 | cen.y + axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 700 | cen.z + axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]); |
---|
[4636] | 701 | glEnd(); |
---|
[4588] | 702 | |
---|
[4636] | 703 | glBegin(GL_LINE_LOOP); |
---|
[4660] | 704 | glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 705 | cen.y + axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 706 | cen.z + axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]); |
---|
| 707 | glVertex3f(cen.x + axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 708 | cen.y + axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 709 | cen.z + axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 710 | glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 711 | cen.y - axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 712 | cen.z - axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 713 | glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 714 | cen.y - axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 715 | cen.z - axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]); |
---|
[4636] | 716 | glEnd(); |
---|
[4588] | 717 | |
---|
[4636] | 718 | glBegin(GL_LINE_LOOP); |
---|
[4660] | 719 | glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 720 | cen.y - axis[0].y * len[0] - axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 721 | cen.z - axis[0].z * len[0] - axis[1].z * len[1] + axis[2].z * len[2]); |
---|
| 722 | glVertex3f(cen.x - axis[0].x * len[0] - axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 723 | cen.y - axis[0].y * len[0] - axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 724 | cen.z - axis[0].z * len[0] - axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 725 | glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 726 | cen.y - axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 727 | cen.z - axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 728 | glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 729 | cen.y - axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 730 | cen.z - axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]); |
---|
[4636] | 731 | glEnd(); |
---|
[4588] | 732 | |
---|
[4636] | 733 | glBegin(GL_LINE_LOOP); |
---|
[4660] | 734 | glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 735 | cen.y - axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 736 | cen.z - axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]); |
---|
| 737 | glVertex3f(cen.x - axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 738 | cen.y - axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 739 | cen.z - axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]); |
---|
| 740 | glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] + axis[2].x * len[2], |
---|
| 741 | cen.y + axis[0].y * len[0] + axis[1].y * len[1] + axis[2].y * len[2], |
---|
| 742 | cen.z + axis[0].z * len[0] + axis[1].z * len[1] + axis[2].z * len[2]); |
---|
| 743 | glVertex3f(cen.x + axis[0].x * len[0] + axis[1].x * len[1] - axis[2].x * len[2], |
---|
| 744 | cen.y + axis[0].y * len[0] + axis[1].y * len[1] - axis[2].y * len[2], |
---|
| 745 | cen.z + axis[0].z * len[0] + axis[1].z * len[1] - axis[2].z * len[2]); |
---|
[4636] | 746 | glEnd(); |
---|
[4635] | 747 | } |
---|
[4636] | 748 | |
---|
[4635] | 749 | } |
---|
[4588] | 750 | |
---|
[4635] | 751 | if( drawMode & DRAW_SEPARATING_PLANE || drawMode & DRAW_ALL) |
---|
[4632] | 752 | { |
---|
[4636] | 753 | if( !(drawMode & DRAW_SINGLE && depth != 0)) |
---|
[4635] | 754 | { |
---|
[4636] | 755 | /* now draw the separation plane */ |
---|
[4660] | 756 | Vector a1 = this->bvElement->axis[(this->longestAxisIndex + 1)%3]; |
---|
| 757 | Vector a2 = this->bvElement->axis[(this->longestAxisIndex + 2)%3]; |
---|
[4636] | 758 | Vector c = *this->bvElement->center; |
---|
| 759 | float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3]; |
---|
| 760 | float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3]; |
---|
| 761 | glBegin(GL_QUADS); |
---|
| 762 | 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); |
---|
| 763 | 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); |
---|
| 764 | 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); |
---|
| 765 | 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); |
---|
| 766 | glEnd(); |
---|
[4635] | 767 | } |
---|
[4632] | 768 | } |
---|
[4588] | 769 | |
---|
[4622] | 770 | if( this->nodeLeft != NULL && depth != 0 ) |
---|
[4635] | 771 | this->nodeLeft->drawBV(depth - 1, drawMode); |
---|
[4618] | 772 | if( this->nodeRight != NULL && depth != 0) |
---|
[4635] | 773 | this->nodeRight->drawBV(depth - 1, drawMode); |
---|
[4588] | 774 | |
---|
[4557] | 775 | } |
---|
[4542] | 776 | |
---|
| 777 | |
---|
[4568] | 778 | |
---|
| 779 | void OBBTreeNode::debug() |
---|
| 780 | { |
---|
| 781 | |
---|
| 782 | /* |
---|
| 783 | for(int i = 0; i < length; i++) |
---|
[4617] | 784 | { |
---|
[4638] | 785 | PRINTF(3)("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]); |
---|
[4617] | 786 | } |
---|
[4568] | 787 | */ |
---|
| 788 | } |
---|