Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2005, 9:33:23 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: changed the QuadtreeNode interface deeply and altered the entire dimension calculation

Location:
orxonox/trunk/src/lib/graphics/spatial_separation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4896 r4897  
    2929QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles,
    3030                            const float* pVertices, int numVertices,
    31                             Quadtree* quadtree, QuadtreeNode* parent)
     31                            Quadtree* quadtree, QuadtreeNode* parent,
     32                            Rectangle* rect
     33                           )
    3234{
    3335  this->pTriangles = triangles;
     
    3840  this->treeDepth = 0;
    3941  this->parent = parent;
     42  this->pDimension = rect;
    4043
    4144  this->init();
     
    5962  this->treeDepth = 0;
    6063
     64  this->pDimension = this->getDimFromModel();
    6165  this->init();
    6266}
     
    108112
    109113  /* dimension calculation & limit checking */
    110   this->pDimension = this->getDimension();
     114
    111115  if( treeDepth >= maxDepth)
    112116    return;
     
    128132{
    129133  /* dimension calculation & limit checking */
    130   this->pDimension = this->getDimension();
    131134  if( minLength <= this->pDimension->getAxis())
    132135    return;
     
    245248  delete iterator;
    246249
     250
     251  /* now create the rectangle dimensions */
     252  Vector v;
     253
     254  v.x = this->center.x + this->pDimension->getAxis() / 2.0f;
     255  v.z = this->center.z + this->pDimension->getAxis() / 2.0f;
     256  Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
     257
     258  v.z = this->center.z - this->pDimension->getAxis() / 2.0f;
     259  Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
     260
     261  v.x = this->center.x - this->pDimension->getAxis() / 2.0f;
     262  Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
     263
     264  v.z = this->center.z + this->pDimension->getAxis() / 2.0f;
     265  Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
     266
    247267  /* now propagate */
    248   this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this);
    249   this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this);
    250   this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this);
    251   this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this);
     268  this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA);
     269  this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB);
     270  this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC);
     271  this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD);
    252272}
    253273
     
    282302
    283303
    284 /**
    285   \brief gets the maximal dimension of a model
    286  * @param playerModel the model that this measurement is based on
    287     \return the dimension of the AbstractModel as a Rectangle
    288 
    289     The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
    290     size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to
    291     patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be
    292     happy to see orxonox used to extensivly :)
    293  */
    294 Rectangle* QuadtreeNode::getDimension(modelInfo* pModelInfo)
    295 {
    296   float            maxX, maxY;                       //!< the maximal coordinates axis
    297   float            minX, minY;                       //!< minimal axis coorindates
    298   const float*     pVertices;                        //!< pointer to the current vertices
    299 
    300   maxX = -999999; maxY = -999999;
    301   minX =  999999; minY =  999999;
    302   /* get maximal/minimal x/y */
    303   for( int i = 0; i < pModelInfo->numVertices; ++i)
    304   {
    305     pVertices = &pModelInfo->pVertices[i * 3];
    306     if( pVertices[0] > maxX)
    307       maxX = pVertices[0];
    308     if( pVertices[2] > maxY)
    309       maxY = pVertices[2];
    310 
    311     if( pVertices[0] < minX)
    312       minX = pVertices[0];
    313     if( pVertices[2] < minY)
    314       minY = pVertices[2];
    315   }
    316 
    317   Rectangle* rect = new Rectangle();
    318   rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */
    319   rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
    320 
    321   for( int i = 0; i < this->treeDepth; ++i)
    322     PRINT(3)(" |");
    323   PRINT(3)(" | +-| (II) Rectangle Dimension  (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());
    324   return rect;
    325 }
    326 
    327304
    328305/**
     
    335312   happy to see orxonox used to extensivly :)
    336313 */
    337 Rectangle* QuadtreeNode::getDimension()
     314Rectangle* QuadtreeNode::getDimFromModel()
    338315{
    339316  float            maxX, maxY;                       //!< the maximal coordinates axis
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4896 r4897  
    2222    QuadtreeNode(sTriangleExt** triangles, int numTriangles,
    2323                 const float* pVertices, int numVertices,
    24                  Quadtree* quadtree, QuadtreeNode* parent);
     24                 Quadtree* quadtree, QuadtreeNode* parent,
     25                 Rectangle* rect);
    2526    QuadtreeNode(modelInfo* pModelInfo);
    2627    virtual ~QuadtreeNode();
     
    3536  private:
    3637    void init();
    37     Rectangle* getDimension(modelInfo* pModelInfo);
    38     Rectangle* getDimension();
     38
     39    Rectangle* getDimFromModel();
    3940
    4041
Note: See TracChangeset for help on using the changeset viewer.