Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4898 in orxonox.OLD


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

orxonox/trunk: again some very fundamental changes in the tree spawing algorithm. some strange effects left

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

Legend:

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

    r4889 r4898  
    2626   @todo this constructor is not jet implemented - do it
    2727*/
    28 Quadtree::Quadtree (modelInfo* pModelInfo)
     28Quadtree::Quadtree (modelInfo* pModelInfo, const int treeDepth)
    2929{
    3030   this->setClassID(CL_QUADTREE, "Quadtree");
    3131   this->pModelInfo = pModelInfo;
     32   this->treeDepth = treeDepth;
    3233
    33    this->rootNode = new QuadtreeNode(this->pModelInfo);
     34   this->rootNode = new QuadtreeNode(this->pModelInfo, this->treeDepth);
    3435}
    3536
     
    4647
    4748/**
    48  *  gives the signal to separate the model into a quadtree
    49  */
    50 void Quadtree::separate()
    51 {
    52   this->rootNode->separateNode();
    53 }
    54 
    55 
    56 /**
    57  *  gives the signal to separate the model into a quadtree
    58  */
    59 void Quadtree::separate(const int maxDepth)
    60 {
    61   this->rootNode->separateNode(0, maxDepth);
    62 }
    63 
    64 
    65 /**
    66  *  gives the signal to separate the model into a quadtree
    67  */
    68 void Quadtree::separate(float minLength)
    69 {
    70   this->rootNode->separateNode(minLength);
    71 }
    72 
    73 
    74 /**
    7549 *  draws the debug quadtree boxes around the model
    7650 */
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h

    r4887 r4898  
    1818
    1919 public:
    20   Quadtree(modelInfo* pModelInfo);
     20  Quadtree(modelInfo* pModelInfo, const int treeDepth);
    2121  virtual ~Quadtree();
    22 
    23   void separate();
    24   void separate(const int maxDepth);
    25   void separate(float minLength);
    2622
    2723  void drawTree(int depth, int drawMode) const;
     
    3026   QuadtreeNode*                   rootNode;              //!< reference to the root node of the quadtree
    3127   modelInfo*                      pModelInfo;            //!< reference to the modelInfo of the object
    32 
     28   int                             treeDepth;             //!< depth of the tree
    3329};
    3430
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r4897 r4898  
    3030                            const float* pVertices, int numVertices,
    3131                            Quadtree* quadtree, QuadtreeNode* parent,
    32                             Rectangle* rect
     32                            Rectangle* rect, int treeDepth, const int maxDepth
    3333                           )
    3434{
     
    4141  this->parent = parent;
    4242  this->pDimension = rect;
     43  this->treeDepth = treeDepth;
     44  this->maxDepth = maxDepth;
     45
     46
     47  /* debug output */
     48  for( int i = 0; i < this->treeDepth; ++i)
     49    PRINT(3)(" |");
     50  PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
     51
     52  for( int i = 0; i < this->treeDepth; ++i)
     53    PRINT(3)(" |");
     54  PRINT(3)(" | +-| (II) Rectangle Center (%5.2f, %5.2f), half axis length: %5.2f\n",
     55  this->pDimension->getCenter()->x, this->pDimension->getCenter()->z, this->pDimension->getAxis());
    4356
    4457  this->init();
     
    4962 *  standard constructor
    5063 */
    51 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo)
     64QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, const int maxDepth)
    5265{
    5366  this->pModelInfo = pModelInfo;
     
    6174    this->pTriangles[i] = &this->pModelInfo->pTriangles[i];
    6275  this->treeDepth = 0;
     76  this->maxDepth = maxDepth;
     77
     78  /* debug output */
     79  for( int i = 0; i < this->treeDepth; ++i)
     80    PRINT(3)(" |");
     81  PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
    6382
    6483  this->pDimension = this->getDimFromModel();
     
    8099  this->nodeC = NULL;
    81100  this->nodeD = NULL;
     101
     102  this->separateNode(this->treeDepth, this->maxDepth);
    82103}
    83104
     
    105126void QuadtreeNode::separateNode(int treeDepth, const int maxDepth)
    106127{
    107   this->treeDepth = treeDepth;
    108   /* debug output */
    109   for( int i = 0; i < treeDepth; ++i)
    110     PRINT(3)(" |");
    111   PRINT(3)(" | +-| (Event) Separating Node Depth: %i/%i\n", treeDepth, maxDepth);
     128
    112129
    113130  /* dimension calculation & limit checking */
     
    118135  /* node separation */
    119136  this->separateNode();
    120   this->nodeA->separateNode(treeDepth + 1, maxDepth);
    121   this->nodeB->separateNode(treeDepth + 1, maxDepth);
    122   this->nodeC->separateNode(treeDepth + 1, maxDepth);
    123   this->nodeD->separateNode(treeDepth + 1, maxDepth);
     137
     138//   this->nodeA->separateNode(treeDepth + 1, maxDepth);
     139//   this->nodeB->separateNode(treeDepth + 1, maxDepth);
     140//   this->nodeC->separateNode(treeDepth + 1, maxDepth);
     141//   this->nodeD->separateNode(treeDepth + 1, maxDepth);
    124142}
    125143
     
    252270  Vector v;
    253271
    254   v.x = this->center.x + this->pDimension->getAxis() / 2.0f;
    255   v.z = this->center.z + this->pDimension->getAxis() / 2.0f;
     272  v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f;
     273  v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
    256274  Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    257275
    258   v.z = this->center.z - this->pDimension->getAxis() / 2.0f;
     276  v.z = this->pDimension->getCenter()->z - this->pDimension->getAxis() / 2.0f;
    259277  Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    260278
    261   v.x = this->center.x - this->pDimension->getAxis() / 2.0f;
     279  v.x = this->pDimension->getCenter()->x - this->pDimension->getAxis() / 2.0f;
    262280  Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    263281
    264   v.z = this->center.z + this->pDimension->getAxis() / 2.0f;
     282  v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
    265283  Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
    266284
    267285  /* now propagate */
    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);
     286  this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth);
     287  this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth);
     288  this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth);
     289  this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth);
    272290}
    273291
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r4897 r4898  
    2323                 const float* pVertices, int numVertices,
    2424                 Quadtree* quadtree, QuadtreeNode* parent,
    25                  Rectangle* rect);
    26     QuadtreeNode(modelInfo* pModelInfo);
     25                 Rectangle* rect, int treeDepth, const int maxDepth);
     26    QuadtreeNode(modelInfo* pModelInfo, const int maxDepth);
    2727    virtual ~QuadtreeNode();
    28 
    29     void separateNode(int treeDepth, const int maxDepth);
    30     void separateNode(float minLength);
    31     void separateNode();
    3228
    3329    void drawTree(int depth, int drawMode) const;
     
    3733    void init();
    3834
     35    void separateNode(int treeDepth, const int maxDepth);
     36    void separateNode(float minLength);
     37    void separateNode();
     38
    3939    Rectangle* getDimFromModel();
    40 
    4140
    4241  protected:
     
    5554
    5655    int                             treeDepth;          //!< the depth of the tree
     56    int                             maxDepth;           //!< the maximal depth of the tree
    5757
    5858    sTriangleExt**                  pTriangles;         //!< reference to the triangles of the node
  • orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc

    r4889 r4898  
    9999Quadtree* SpatialSeparation::createQuadtree(AbstractModel* model)
    100100{
    101   this->quadtree = new Quadtree(model->getModelInfo());
    102   this->quadtree->separate(4);
     101  this->quadtree = new Quadtree(model->getModelInfo(), 4);
    103102
    104103  return this->quadtree;
Note: See TracChangeset for help on using the changeset viewer.