Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 19, 2005, 10:44:16 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: debug draw implemented successfuly

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

Legend:

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

    r4901 r4902  
    3434
    3535   this->materials = new Material*[4];
    36 
    3736   for(int i = 0; i < 4; ++i)
    3837   {
     
    4645
    4746
    48    this->rootNode = new QuadtreeNode(this->pModelInfo, this->treeDepth);
     47   this->rootNode = new QuadtreeNode(this->pModelInfo, this, this->treeDepth);
    4948}
    5049
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h

    r4901 r4902  
    2525  void drawTree(int depth, int drawMode) const;
    2626
    27   Material* getMaterial(int indexNode) { return this->materials[indexNode%4]; }
     27  inline Material* getMaterial(int indexNode) const { return this->materials[indexNode % 4]; }
    2828
    2929 private:
     
    3232   int                             treeDepth;             //!< depth of the tree
    3333
    34    Material**                       materials;            //!< materials for debug drawing purposes
     34   Material**                      materials;             //!< materials for debug drawing purposes
    3535};
    3636
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4900 r4902  
    1717
    1818#include "quadtree_node.h"
     19#include "quadtree.h"
     20#include "material.h"
    1921#include "abstract_model.h"
    2022#include "list.h"
     
    6466 *  standard constructor
    6567 */
    66 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, const int maxDepth)
     68QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth)
    6769{
    6870  this->pModelInfo = pModelInfo;
     71  this->quadtree = quadtree;
    6972
    7073  /* create an array of triangle references */
     
    279282
    280283
     284/**
     285   \brief gets the maximal dimension of a model
     286   \return the dimension of the AbstractModel as a Rectangle
     287
     288   The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
     289   size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to
     290   patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be
     291   happy to see orxonox used to extensivly :)
     292 */
     293Rectangle* QuadtreeNode::getDimFromModel()
     294{
     295  float            maxX, maxY;                       //!< the maximal coordinates axis
     296  float            minX, minY;                       //!< minimal axis coorindates
     297  const float*     pVertices;                        //!< pointer to the current vertices
     298
     299  maxX = -999999; maxY = -999999;
     300  minX =  999999; minY =  999999;
     301  /* get maximal/minimal x/y */
     302  for( int i = 0; i < this->numTriangles; ++i)
     303  {
     304    for( int j = 0; j < 3; ++j)
     305    {
     306
     307      pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
     308      if( pVertices[0] > maxX)
     309        maxX = pVertices[0];
     310      if( pVertices[2] > maxY)
     311        maxY = pVertices[2];
     312
     313      if( pVertices[0] < minX)
     314        minX = pVertices[0];
     315      if( pVertices[2] < minY)
     316        minY = pVertices[2];
     317    }
     318  }
     319
     320  Rectangle* rect = new Rectangle();
     321  rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */
     322  rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
     323
     324  for( int i = 0; i < this->treeDepth; ++i)
     325    PRINT(3)(" |");
     326  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());
     327  return rect;
     328}
     329
    281330
    282331/**
     
    291340
    292341  glBegin(GL_QUADS);
     342  this->quadtree->getMaterial(this->indexNode)->select();
    293343  glVertex3f(t1.x + ax, h - depth * 10.0f, t1.z + ax);
    294344  glVertex3f(t1.x - ax, h - depth * 10.0f, t1.z + ax);
     
    306356    this->nodeD->drawTree(depth - 1, drawMode);
    307357}
    308 
    309 
    310 
    311 /**
    312    \brief gets the maximal dimension of a model
    313    \return the dimension of the AbstractModel as a Rectangle
    314 
    315    The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
    316    size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to
    317    patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be
    318    happy to see orxonox used to extensivly :)
    319  */
    320 Rectangle* QuadtreeNode::getDimFromModel()
    321 {
    322   float            maxX, maxY;                       //!< the maximal coordinates axis
    323   float            minX, minY;                       //!< minimal axis coorindates
    324   const float*     pVertices;                        //!< pointer to the current vertices
    325 
    326   maxX = -999999; maxY = -999999;
    327   minX =  999999; minY =  999999;
    328   /* get maximal/minimal x/y */
    329   for( int i = 0; i < this->numTriangles; ++i)
    330   {
    331     for( int j = 0; j < 3; ++j)
    332     {
    333 
    334       pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
    335       if( pVertices[0] > maxX)
    336         maxX = pVertices[0];
    337       if( pVertices[2] > maxY)
    338         maxY = pVertices[2];
    339 
    340       if( pVertices[0] < minX)
    341         minX = pVertices[0];
    342       if( pVertices[2] < minY)
    343         minY = pVertices[2];
    344     }
    345   }
    346 
    347   Rectangle* rect = new Rectangle();
    348   rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */
    349   rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
    350 
    351   for( int i = 0; i < this->treeDepth; ++i)
    352     PRINT(3)(" |");
    353   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());
    354   return rect;
    355 }
    356 
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4900 r4902  
    2424                 Quadtree* quadtree, QuadtreeNode* parent,
    2525                 Rectangle* rect, int treeDepth, const int maxDepth, int index);
    26     QuadtreeNode(modelInfo* pModelInfo, const int maxDepth);
     26    QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
    2727    virtual ~QuadtreeNode();
    2828
Note: See TracChangeset for help on using the changeset viewer.