Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4887 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jul 18, 2005, 9:56:55 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: center now gets calculated correctly, some nicer debug output

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

Legend:

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

    r4868 r4887  
    5757 *  gives the signal to separate the model into a quadtree
    5858 */
    59 void Quadtree::separate(int treeDepth)
     59void Quadtree::separate(const int maxDepth)
    6060{
    61   this->rootNode->separateNode(treeDepth);
     61  this->rootNode->separateNode(0, maxDepth);
    6262}
    6363
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h

    r4868 r4887  
    2222
    2323  void separate();
    24   void separate(int treeDepth);
     24  void separate(const int maxDepth);
    2525  void separate(float minLength);
    2626
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4869 r4887  
    2727 *  standard constructor
    2828*/
    29 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 
    30                             const float* pVertices, int numVertices, Quadtree* quadtree)
     29QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles,
     30                            const float* pVertices, int numVertices, Quadtree* quadtree)
    3131{
    3232  this->pTriangles = triangles;
     
    3535  this->numVertices = numVertices;
    3636  this->quadtree = quadtree;
    37  
    38   this->pDimension = this->getDimension();
     37  this->treeDepth = 0;
     38
     39//   this->pDimension = this->getDimension();
    3940  this->init();
    4041}
     
    4748{
    4849  this->pModelInfo = pModelInfo;
    49  
     50
    5051  /* create an array of triangle references */
    5152  this->pTriangles = new sTriangleExt*[this->pModelInfo->numTriangles];
     
    5556  for( int i = 0; i < this->pModelInfo->numTriangles; ++i)
    5657    this->pTriangles[i] = &this->pModelInfo->pTriangles[i];
    57 
    58   this->pDimension = this->getDimension(this->pModelInfo);
     58  this->treeDepth = 0;
     59
     60//   this->pDimension = this->getDimension(this->pModelInfo);
    5961  this->init();
    6062}
     
    7577}
    7678
    77  
     79
    7880/**
    7981 *  standard deconstructor
     
    9698 * @param treeDepth the max depth, the steps to go if treeDept == 0 leaf reached
    9799 */
    98 void QuadtreeNode::separateNode(int treeDepth)
    99 {
    100   if( treeDepth <= 0)
     100void QuadtreeNode::separateNode(int treeDepth, const int maxDepth)
     101{
     102  for( int i = 0; i < treeDepth; ++i)
     103    PRINT(3)("  ");
     104  PRINT(3)("   +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
     105
     106  this->pDimension = this->getDimension();
     107
     108  this->treeDepth = treeDepth;
     109  if( treeDepth >= maxDepth)
    101110    return;
    102   PRINTF(0)("separate Node Nr: %i\n", treeDepth);
     111
    103112  this->separateNode();
    104113
    105   this->nodeA->separateNode(treeDepth - 1);
    106   this->nodeB->separateNode(treeDepth - 1);
    107   this->nodeC->separateNode(treeDepth - 1);
    108   this->nodeD->separateNode(treeDepth - 1);
     114  this->nodeA->separateNode(treeDepth + 1, maxDepth);
     115  this->nodeB->separateNode(treeDepth + 1, maxDepth);
     116  this->nodeC->separateNode(treeDepth + 1, maxDepth);
     117  this->nodeD->separateNode(treeDepth + 1, maxDepth);
    109118}
    110119
     
    116125void QuadtreeNode::separateNode(float minLength)
    117126{
     127  this->pDimension = this->getDimension();
     128
    118129  if( minLength <= this->pDimension->getAxis())
    119130    return;
     131
    120132  this->separateNode();
    121133
     
    133145void QuadtreeNode::separateNode()
    134146{
    135   PRINTF(0)("got command to separate node\n");
    136 
    137147  tList<sTriangleExt*>*           listA = new tList<sTriangleExt*>();    //!< triangle list of nodeA
    138148  tList<sTriangleExt*>*           listB = new tList<sTriangleExt*>();    //!< triangle list of nodeB
     
    146156    {
    147157      for( int j = 0; j < 3; ++j)
    148         {
    149           pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
    150           if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
    151             listA->add(&this->pTriangles[i]);
    152           if( pVert[0] > rectCenter->x + this->offset && pVert[2]< rectCenter->z + this->offset)
    153             listB->add(&this->pTriangles[i]);
    154           if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
    155             listC->add(&this->pTriangles[i]);
    156           if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
    157             listD->add(&this->pTriangles[i]);
    158         }
    159     }
    160   printf("Temp. list Num. o El: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize());
    161 
    162  
     158        {
     159          pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
     160          if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
     161            listA->add(&this->pTriangles[i]);
     162          if( pVert[0] > rectCenter->x + this->offset && pVert[2]< rectCenter->z + this->offset)
     163            listB->add(&this->pTriangles[i]);
     164          if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
     165            listC->add(&this->pTriangles[i]);
     166          if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
     167            listD->add(&this->pTriangles[i]);
     168        }
     169    }
     170    for( int i = 0; i < treeDepth; ++i)
     171      PRINT(3)("  ");
     172    PRINT(3)("   +-| (II) Quadtree Counts: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize());
     173
    163174  /* Separating into to the triangle lists  */
    164175  sTriangleExt**                 pTriA;                                 //!< Triangle array A
     
    178189  lenC = listC->getSize();
    179190  lenD = listD->getSize();
    180  
     191
    181192  pTriA = new sTriangleExt*[listA->getSize()];
    182193  pTriB = new sTriangleExt*[listB->getSize()];
    183   pTriC = new sTriangleExt*[listC->getSize()]; 
     194  pTriC = new sTriangleExt*[listC->getSize()];
    184195  pTriD = new sTriangleExt*[listD->getSize()];
    185196
     
    204215      ++counter;
    205216    }
    206  
     217
    207218  counter = 0;
    208219  iterator = listC->getIterator();
     
    237248  this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree);
    238249  this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree);
    239 
    240 
    241   PRINTF(0)("separation complete\n");
    242250}
    243251
     
    300308  rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
    301309
    302   PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY);
    303   PRINTF(0)("Center: %f, %f, %f   Axis: %f\n", rect->getCenter()->x, rect->getCenter()->y, rect->getCenter()->z, rect->getAxis());
     310  for( int i = 0; i < this->treeDepth; ++i)
     311    PRINT(3)("  ");
     312  PRINT(3)("   +-| (II) Rectangle Dimension  (%f, %f) to (%f, %f), Center (%f, %f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());
    304313  return rect;
    305314}
     
    309318   \brief gets the maximal dimension of a model
    310319   \return the dimension of the AbstractModel as a Rectangle
    311    
     320
    312321   The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
    313322   size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to
     
    320329  float            minX, minY;                       //!< minimal axis coorindates
    321330  const float*     pVertices;                        //!< pointer to the current vertices
    322  
     331
    323332  maxX = -999999; maxY = -999999;
    324333  minX =  999999; minY =  999999;
    325334  /* get maximal/minimal x/y */
    326   for( int i = 0; i < this->numVertices; ++i)
     335  for( int i = 0; i < this->numTriangles; ++i)
    327336  {
    328     pVertices = &this->pVertices[i * 3];
    329     if( pVertices[0] > maxX)
    330       maxX = pVertices[0];
    331     if( pVertices[2] > maxY)
    332       maxY = pVertices[2];
    333 
    334     if( pVertices[0] < minX)
    335       minX = pVertices[0];
    336     if( pVertices[2] < minY)
    337       minY = pVertices[2];
     337    for( int j = 0; j < 3; ++j)
     338    {
     339
     340      pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
     341      if( pVertices[0] > maxX)
     342        maxX = pVertices[0];
     343      if( pVertices[2] > maxY)
     344        maxY = pVertices[2];
     345
     346      if( pVertices[0] < minX)
     347        minX = pVertices[0];
     348      if( pVertices[2] < minY)
     349        minY = pVertices[2];
     350    }
    338351  }
    339352
     
    342355  rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
    343356
    344   PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY);
    345   PRINTF(0)("Center: %f, %f, %f   Axis: %f\n", rect->getCenter()->x, rect->getCenter()->y, rect->getCenter()->z, rect->getAxis());
     357  for( int i = 0; i < this->treeDepth; ++i)
     358    PRINT(3)("  ");
     359  PRINT(3)("   +-| (II) Rectangle Dimension  (%f, %f) to (%f, %f), Center (%f, %f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());
    346360  return rect;
    347361}
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4868 r4887  
    2020
    2121  public:
    22     QuadtreeNode(sTriangleExt** triangles, int numTriangles, 
    23                 const float* pVertices, int numVertices, Quadtree* quadtree);
     22    QuadtreeNode(sTriangleExt** triangles, int numTriangles,
     23                const float* pVertices, int numVertices, Quadtree* quadtree);
    2424    QuadtreeNode(modelInfo* pModelInfo);
    2525    virtual ~QuadtreeNode();
    2626
    27     void separateNode(int treeDepth);
     27    void separateNode(int treeDepth, const int maxDepth);
    2828    void separateNode(float minLength);
    2929    void separateNode();
     
    4444    float                           offset;             //!< offset of the actual quadtree rectangle
    4545
     46    int                             treeDepth;          //!< the depth of the tree
     47
    4648    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
    4749    const float*                    pVertices;          //!< reference to vertices data
  • orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc

    r4868 r4887  
    3333SpatialSeparation::SpatialSeparation (AbstractModel* model, float overlapSize)
    3434{
    35   PRINTF(0)("Spatial Separation process kicked on\n");
     35  PRINT(3)("\n");
     36  PRINT(3)("+---------Debug Information SpatialSeparation----------\n");
     37  PRINT(3)("+-| (Event) Spatial Separation process kicked on\n");
     38
    3639   this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation");
    3740   /* debug vice */
Note: See TracChangeset for help on using the changeset viewer.