Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4622 in orxonox.OLD for orxonox/trunk/src/lib/collision_detection


Ignore:
Timestamp:
Jun 13, 2005, 6:25:54 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: drawing in diffrent hirarchies works now, with diffrent colors

Location:
orxonox/trunk/src/lib/collision_detection
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/bv_tree.h

    r4553 r4622  
    1 /*! 
     1/*!
    22    \file bv_tree.h
    33    \brief Definition of a bounding volume tree
     
    2727
    2828
    29   virtual void drawBV(int currentDepth, const int depth) const = NULL;
    30   virtual void drawBVPolygon(int currentDepth, const int depth) const = NULL;
    31   virtual void drawBVBlended(int currentDepth, const int depth) const = NULL;
     29  virtual void drawBV(int depth) const = NULL;
     30  virtual void drawBVPolygon(int depth) const = NULL;
     31  virtual void drawBVBlended(int depth) const = NULL;
    3232
    3333 protected:
  • orxonox/trunk/src/lib/collision_detection/cd_engine.cc

    r4615 r4622  
    5353
    5454
    55 void CDEngine::drawBV(int currentDepth, const int depth) const
     55void CDEngine::drawBV(int depth) const
    5656{
    5757  /* this would operate on  worldList bases, for testing purposes, we only use one OBBTree */
    58   this->rootTree->drawBV(currentDepth, depth);
     58  this->rootTree->drawBV(depth);
    5959}
    6060
    6161
    62 void CDEngine::drawBVPolygon(int currentDepth, const int depth) const
     62void CDEngine::drawBVPolygon(int depth) const
    6363{}
    6464
    6565
    66 void CDEngine::drawBVBlended(int currentDepth, const int depth) const
     66void CDEngine::drawBVBlended(int depth) const
    6767{}
    6868
  • orxonox/trunk/src/lib/collision_detection/cd_engine.h

    r4615 r4622  
    4444  void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    4545
    46   void drawBV(int currentDepth, const int depth) const;
    47   void drawBVPolygon(int currentDepth, const int depth) const;
    48   void drawBVBlended(int currentDepth, const int depth) const;
     46  void drawBV(int depth) const;
     47  void drawBVPolygon(int depth) const;
     48  void drawBVBlended(int depth) const;
    4949
    5050  void checkCollisions();
  • orxonox/trunk/src/lib/collision_detection/obb_tree.cc

    r4618 r4622  
    2626
    2727
    28 Material* OBBTree::material = NULL;
    29 
    3028/**
    3129   \brief standard constructor
     
    3432{
    3533  this->setClassID(CL_OBB_TREE, "OBBTree");
    36   material = new Material("Tree");
    37   material->setIllum(3);
    38   material->setAmbient(1.0, 1.0, 1.0);
     34
     35  material = new Material*[3];
     36  for(int i = 0; i < 3; ++i)
     37  {
     38    material[i] = new Material();
     39    material[i]->setIllum(0);
     40  }
     41  material[0]->setAmbient(0.0, 0.3, 0.0);
     42  material[1]->setAmbient(0.0, 0.0, 0.2);
     43  material[2]->setAmbient(1.0, 0.0, 0.0);
    3944}
    4045
     
    5964  OBBTreeNode* node = new OBBTreeNode();
    6065  this->rootNode = node;
     66  this->rootNode->setTreeRef(this);
    6167  this->rootNode->spawnBVTree(depth, verticesList, length);
    6268}
     
    7177
    7278
    73 void OBBTree::drawBV(int currentDepth, const int depth) const
     79void OBBTree::drawBV(int depth) const
    7480{
    7581  if( likely(this->rootNode != NULL))
    7682  {
    77     this->rootNode->drawBV(currentDepth);
    78     this->rootNode->drawBVPolygon(currentDepth);
     83    this->rootNode->drawBV(depth);
     84    this->rootNode->drawBVPolygon(depth);
    7985  }
    8086}
    8187
    8288
    83 void OBBTree::drawBVPolygon(int currentDepth, const int depth) const
     89void OBBTree::drawBVPolygon(int depth) const
    8490{
    8591  if( likely(this->rootNode != NULL))
    86     this->rootNode->drawBVPolygon(currentDepth);
     92    this->rootNode->drawBVPolygon(depth);
    8793}
    8894
    8995
    90 void OBBTree::drawBVBlended(int currentDepth, const int depth) const
     96void OBBTree::drawBVBlended(int depth) const
    9197{
    9298  if( likely(this->rootNode != NULL))
    93     this->rootNode->drawBVBlended(currentDepth);
     99    this->rootNode->drawBVBlended(depth);
    94100}
    95101
  • orxonox/trunk/src/lib/collision_detection/obb_tree.h

    r4616 r4622  
    2727    void collideWith(const OBBTree &tree);
    2828
    29     virtual void drawBV(int currentDepth, const int depth) const;
    30     virtual void drawBVPolygon(int currentDepth, const int depth) const;
    31     virtual void drawBVBlended(int currentDepth, const int depth) const;
     29    virtual void drawBV(int depth) const;
     30    virtual void drawBVPolygon(int depth) const;
     31    virtual void drawBVBlended(int depth) const;
     32
     33    Material* getMaterial(unsigned int depth) { return material[depth%3]; }
    3234
    3335    void debug();
    3436
    3537  public:
    36     static Material* material;
     38
    3739
    3840
    3941  private:
    4042    OBBTreeNode*         rootNode;                        //!< reference to the root node of the tree
     43    Material**           material;
    4144
    4245};
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4618 r4622  
    4141using namespace std;
    4242
     43OBBTree*  OBBTreeNode::obbTree = NULL;
    4344
    4445/**
     
    391392void OBBTreeNode::drawBV(int depth) const
    392393{
    393 //   glBegin(GL_LINE_LOOP);
    394 //   glColor3f(1.0, 1.0, 1.0);
    395 //   for(int i = 0; i < this->bvElement->numOfVertices; ++i)
    396 //     {
    397 //       glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
    398 //       //printf("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
    399 //     }
    400 //   glEnd();
    401   //this->drawBVPolygon(currentDepth, depth);
     394  glBegin(GL_TRIANGLES);
     395  glColor3f(1.0, 1.0, 1.0);
     396  for(int i = 0; i < this->bvElement->numOfVertices; ++i)
     397    {
     398      glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
     399      //printf("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
     400    }
     401  glEnd();
     402  //this->drawBVPolygon(depth);
    402403}
    403404
     
    405406void OBBTreeNode::drawBVPolygon(int depth) const
    406407{
    407 
    408   OBBTree::material->select();
     408  //OBBTree::material->select();
     409
     410  this->obbTree->getMaterial(depth)->select();
    409411
    410412  /* draw world axes */
     
    520522  glEnd();
    521523
    522   if( this->nodeLeft != NULL && depth != 0)
    523     this->nodeLeft->drawBVPolygon(depth -1);
     524  if( this->nodeLeft != NULL && depth != 0 )
     525    this->nodeLeft->drawBVPolygon(depth - 1);
    524526  if( this->nodeRight != NULL && depth != 0)
    525     this->nodeRight->drawBVPolygon(depth -1);
     527    this->nodeRight->drawBVPolygon(depth - 1);
    526528
    527529}
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.h

    r4618 r4622  
    1515class BoundingVolume;
    1616class OBB;
     17class OBBTree;
    1718//struct sVec3D;
    1819
     
    2930    BoundingVolume* getBV(int index) const { return (BoundingVolume*)this->bvElement; }
    3031    inline const int getIndex() { return this->treeIndex; }
     32    inline void setTreeRef(OBBTree* tree) { this->obbTree = tree;}
    3133
    3234    virtual void collideWith(const BVTree &tree);
     
    5557    int                 numOfVertices;              //!< number of vertices in vertices data
    5658    int                 depth;                      //!< the depth of the node in the tree
    57 
     59    static OBBTree*     obbTree;                    //!< reference to the obb tree
    5860};
    5961
Note: See TracChangeset for help on using the changeset viewer.