Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4632 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jun 14, 2005, 6:31:21 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: the separation plane is also drawn for debug purposes. vert separation seems to malfunction

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4631 r4632  
    102102  this->bvElement = new OBB();
    103103  PRINTF(0)("Created OBBox\n");
    104   this->calculateBoxAttributes1(this->bvElement, verticesList, length);
     104  this->calculateBoxCovariance(this->bvElement, verticesList, length);
    105105  PRINTF(0)("Calculated attributes1\n");
    106   this->calculateBoxAttributes2(this->bvElement, verticesList, length);
     106  this->calculateBoxEigenvectors(this->bvElement, verticesList, length);
    107107  PRINTF(0)("Calculated attributes2\n");
    108   this->calculateBoxAttributes3(this->bvElement, verticesList, length);
     108  this->calculateBoxAxis(this->bvElement, verticesList, length);
    109109  PRINTF(0)("Calculated attributes3\n");
     110
    110111
    111112  if( likely( this->depth > 0))
     
    127128
    128129
    129 void OBBTreeNode::calculateBoxAttributes1(OBB* box, sVec3D* verticesList, int length)
     130void OBBTreeNode::calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length)
    130131{
    131132  float     facelet[length];                         //!< surface area of the i'th triangle of the convex hull
     
    218219
    219220
    220 void OBBTreeNode::calculateBoxAttributes2(OBB* box, sVec3D* verticesList, int length)
     221void OBBTreeNode::calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length)
    221222{
    222223
     
    228229  */
    229230  Vector**              axis = new Vector*[3];                //!< the references to the obb axis
    230 //   float**               a = new float*[4];
    231 //   float**               b = new float*[4];
    232 //   float                 eigval[3];
    233 //   int*                  rot = new int;
    234 
    235 
    236   //coMat[0] = new float[4]; coMat[1] = new float[4]; coMat[2] = new float[4]; coMat[3] = new float[4];
    237   //eigvMat[0] = new float[4]; eigvMat[1] = new float[4]; eigvMat[2] = new float[4]; eigvMat[3] = new float[4];
    238231
    239232  coMat[1][1] = box->covarianceMatrix[0][0]; coMat[1][2] = box->covarianceMatrix[0][1]; coMat[1][3] = box->covarianceMatrix[0][2];
     
    244237  JacobI(coMat, 3, eigvlMat, eigvMat, rotCount);
    245238  PRINTF(0)("-- Done Jacobi Decomposition\n");
    246 
    247239
    248240
     
    267259//   printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
    268260//   printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
    269 
    270 
    271 //   delete [] a[0]; delete [] a[1]; delete [] a[2]; delete [] a[3];
    272 //   delete [] a;
    273 //
    274 //   delete [] b[0]; delete [] b[1]; delete [] b[2]; delete [] b[3];
    275 //   delete [] b;
    276 //
    277 //   delete rot;
    278 }
    279 
    280 void OBBTreeNode::calculateBoxAttributes3(OBB* box, sVec3D* verticesList, int length)
     261}
     262
     263
     264void OBBTreeNode::calculateBoxAxis(OBB* box, sVec3D* verticesList, int length)
    281265{
    282266
     
    370354  the points depending on which side they are located
    371355  */
    372   Plane              separationPlane(*box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
    373356  tList<sVec3D>      partition1;                           //!< the vertex partition 1
    374357  tList<sVec3D>      partition2;                           //!< the vertex partition 2
    375358
     359
     360  this->separationPlane = new Plane(*box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
     361  this->sepPlaneCenter = &box->vertices[vertexIndex];
     362  this->longestAxisIndex = axisIndex;
     363
    376364  for(int i = 0; i < box->numOfVertices; ++i)
    377365  {
    378     if( separationPlane.distancePoint(box->vertices[i]) > 0.0f)
     366    if( this->separationPlane->distancePoint(box->vertices[i]) > 0.0f)
    379367      partition1.add(&box->vertices[i]);
    380368    else
     
    573561  glEnd();
    574562
    575 /*
    576   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] - axis[2]->x * len[2],
    577   cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] - axis[2]->y * len[2],
    578   cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] - axis[2]->z * len[2]);
    579   glVertex3f(cen.x - axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
    580   cen.y - axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
    581   cen.z - axis[0]->z * len[0] + axis[1]->z * len[1] + axis[2]->z * len[2]);*/
    582 
    583 
    584   glEnd();
     563
     564  if( depth != 0)
     565  {
     566    /* now draw the separation plane */
     567    Vector a1 = *this->bvElement->axis[(this->longestAxisIndex + 1)%3];
     568    Vector a2 = *this->bvElement->axis[(this->longestAxisIndex + 2)%3];
     569    Vector c = *this->bvElement->center;
     570    float l1 = this->bvElement->halfLength[(this->longestAxisIndex + 1)%3];
     571    float l2 = this->bvElement->halfLength[(this->longestAxisIndex + 2)%3];
     572    glBegin(GL_QUADS);
     573    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);
     574    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);
     575    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);
     576    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);
     577
     578    glEnd();
     579  }
    585580
    586581  if( this->nodeLeft != NULL && depth != 0 )
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.h

    r4631 r4632  
    1616class OBB;
    1717class OBBTree;
     18class Plane;
    1819//struct sVec3D;
    1920
     
    4142
    4243  private:
    43     void calculateBoxAttributes1(OBB* box, sVec3D* verticesList, int length);
    44     void calculateBoxAttributes2(OBB* box, sVec3D* verticesList, int length);
    45     void calculateBoxAttributes3(OBB* box, sVec3D* verticesList, int length);
     44    void calculateBoxCovariance(OBB* box, sVec3D* verticesList, int length);
     45    void calculateBoxEigenvectors(OBB* box, sVec3D* verticesList, int length);
     46    void calculateBoxAxis(OBB* box, sVec3D* verticesList, int length);
    4647    void forkBox(OBB* box);
    4748
     
    5960    int                 depth;                      //!< the depth of the node in the tree
    6061    static OBBTree*     obbTree;                    //!< reference to the obb tree
     62    Plane*              separationPlane;            //!< the separation plane of the obb
     63    sVec3D*             sepPlaneCenter;             //!< only needed to draw plane \todo: separationPlane drawing
     64    int                 longestAxisIndex;           //!< only needed to draw plane
    6165
    6266    /* tmp saving place for obb variables */
    63     sVec3D*             tmpVert1;
    64     sVec3D*             tmpVert2;
    65     int                 tmpLen1;
    66     int                 tmpLen2;
     67    sVec3D*             tmpVert1;                   //!< pointer to the vert data of obbox1
     68    sVec3D*             tmpVert2;                   //!< pointer to the vert data of obbox1
     69    int                 tmpLen1;                    //!< len vert data obbox1
     70    int                 tmpLen2;                    //!< len vert data obbox2
    6771
    68     static float**       coMat;
    69     static float**       eigvMat;
    70     static float*        eigvlMat;
    71     static int*          rotCount;
     72    static float**       coMat;                     //!< temp covariance matrice save place - consumes less mem
     73    static float**       eigvMat;                   //!< temp eigenvector matrice save place
     74    static float*        eigvlMat;                  //!< temp eigenvalue vector save place
     75    static int*          rotCount;                  //!< temp rotations count save place: how many givens-rotations where needed to transform the matrix :)
    7276};
    7377
  • orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc

    r4631 r4632  
    4747//   }
    4848
    49   CDEngine::getInstance()->debugSpawnTree(4, model->data->pVertices, model->data->numVertices);
     49  CDEngine::getInstance()->debugSpawnTree(2, model->data->pVertices, model->data->numVertices);
    5050
    5151
     
    8282void Framework::moduleDraw() const
    8383{
    84   CDEngine::getInstance()->drawBV(3);
     84  CDEngine::getInstance()->drawBV(1);
    8585
    8686  LightManager::getInstance()->draw();
Note: See TracChangeset for help on using the changeset viewer.