Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5684 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Nov 21, 2005, 10:33:42 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: extended the obb interface dramaticaly:D , in near future it will support the modelInfo structure and therefore will be based on triangles

Location:
trunk/src/lib/collision_detection
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_detection/bv_tree.h

    r5481 r5684  
    4040
    4141  virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length) = 0;
     42  virtual void spawnBVTree(int depth, const modelInfo& modInfo) = 0;
    4243  virtual void flushTree() = 0;
    4344
  • trunk/src/lib/collision_detection/bv_tree_node.h

    r5481 r5684  
    2727
    2828  virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length ) = 0;
     29  virtual void spawnBVTree(const int depth, const modelInfo& modInfo) = 0;
    2930
    3031  virtual BoundingVolume* getBV(int index) const = 0;
  • trunk/src/lib/collision_detection/obb_tree.cc

    r5481 r5684  
    4242}
    4343
     44OBBTree::OBBTree(int depth, const modelInfo& modInfo)
     45{
     46  this->init();
     47  this->spawnBVTree(depth, modInfo);
     48}
     49
    4450
    4551
     
    7480  this->rootNode->setTreeRef(this);
    7581  this->rootNode->spawnBVTree(--depth, verticesList, length);
     82}
     83
     84
     85void OBBTree::spawnBVTree(int depth, const modelInfo& modInfo)
     86{
     87  if( unlikely(this->rootNode != NULL))
     88  {
     89    PRINTF(2)("The BVTree has already been spawned, flushing and respawning again...\n");
     90    this->flushTree();
     91  }
     92  OBBTreeNode* node = new OBBTreeNode();
     93  this->rootNode = node;
     94  this->rootNode->setTreeRef(this);
     95  this->rootNode->spawnBVTree(--depth, modInfo);
    7696}
    7797
  • trunk/src/lib/collision_detection/obb_tree.h

    r5481 r5684  
    2222    OBBTree();
    2323    OBBTree(int depth, sVec3D *verticesList, const int length);
     24    OBBTree(int depth, const modelInfo& modInfo);
    2425    virtual ~OBBTree();
    2526    void init();
    2627
    2728    virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length);
     29    virtual void spawnBVTree(int depth, const modelInfo& modInfo);
    2830    virtual void flushTree();
    2931
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r5678 r5684  
    9696
    9797
     98/**
     99 *  creates a new BVTree or BVTree partition
     100 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper!
     101 * @param modInfo: model informations from the abstrac model
     102 *
     103 * this function creates the Bounding Volume tree from a modelInfo struct and bases its calculations
     104 * on the triangle informations (triangle soup not polygon soup)
     105 */
     106void OBBTreeNode::spawnBVTree(const int depth, const modelInfo& modInfo)
     107{
     108  int length = 0;
     109  sVec3D* verticesList;
     110 
     111  PRINT(3)("\n");
     112  this->treeIndex = this->obbTree->getID();
     113  PRINTF(3)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
     114  this->depth = depth;
     115
     116
     117  this->bvElement = new OBB();
     118  this->bvElement->vertices = verticesList;
     119  this->bvElement->numOfVertices = length;
     120  PRINTF(3)("Created OBBox\n");
     121  this->calculateBoxCovariance(this->bvElement, modInfo);
     122  PRINTF(3)("Calculated attributes1\n");
     123  this->calculateBoxEigenvectors(this->bvElement, modInfo);
     124  PRINTF(3)("Calculated attributes2\n");
     125  this->calculateBoxAxis(this->bvElement,modInfo);
     126  PRINTF(3)("Calculated attributes3\n");
     127
     128  /* if this is the first node, the vertices data are the original ones of the model itself, so dont delete them in cleanup */
     129  if( this->treeIndex == 1)
     130    this->bvElement->bOrigVertices = true;
     131
     132  if( likely( this->depth > 0))
     133  {
     134    this->forkBox(this->bvElement);
     135
     136
     137//     if(this->tmpLen1 > 2)
     138//     {
     139//       OBBTreeNode* node1 = new OBBTreeNode();
     140//       this->nodeLeft = node1;
     141//       this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
     142//     }
     143//     else
     144//     {
     145//       PRINTF(3)("Aboarding tree walk: less than 3 vertices left\n");
     146//     }
     147//
     148//     if( this->tmpLen2 > 2)
     149//     {
     150//       OBBTreeNode* node2 = new OBBTreeNode();
     151//       this->nodeRight = node2;
     152//       this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
     153//     }
     154//     else
     155//     {
     156//       PRINTF(3)("Abording tree walk: less than 3 vertices left\n");
     157//     }
     158
     159  }
     160}
     161
    98162
    99163/**
     
    101165 * @param depth: how much more depth-steps to go: if == 1 don't go any deeper!
    102166 * @param verticesList: the list of vertices of the object - each vertices triple is interpreted as a triangle
     167 *
     168 * this function creates an Bounding Volume tree from a vertices soup (no triangle data)
    103169 */
    104170void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length)
     
    151217      PRINTF(3)("Abording tree walk: less than 3 vertices left\n");
    152218    }
    153 
    154   }
    155 }
    156 
     219  }
     220}
     221
     222
     223void OBBTreeNode::calculateBoxCovariance(OBB* box, const modelInfo& modInfo)
     224{}
    157225
    158226
     
    346414
    347415
     416void OBBTreeNode::calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo)
     417{}
    348418
    349419void OBBTreeNode::calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length)
     
    394464//   PRINTF(0)("eigenvector: %f, %f, %f\n", box->axis[2].x, box->axis[2].y, box->axis[2].z);
    395465}
     466
     467
     468void OBBTreeNode::calculateBoxAxis(OBB* box, const modelInfo& modInfo)
     469{}
    396470
    397471
  • trunk/src/lib/collision_detection/obb_tree_node.h

    r5481 r5684  
    2929
    3030    virtual void spawnBVTree(const int depth, sVec3D *verticesList, const int length);
     31    virtual void spawnBVTree(const int depth, const modelInfo& modInfo);
    3132
    3233    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
     
    4445    void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length);
    4546    void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length);
     47   
     48    void calculateBoxCovariance(OBB* box, const modelInfo& modInfo);
     49    void calculateBoxEigenvectors(OBB* box, const modelInfo& modInfo);
     50    void calculateBoxAxis(OBB* box, const modelInfo& modInfo);
     51
     52   
    4653    void forkBox(OBB* box);
    4754
Note: See TracChangeset for help on using the changeset viewer.