Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 3, 2005, 10:22:30 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: BV-nodes are now renddered more efficiently.

Location:
trunk/src/lib/collision_detection
Files:
6 edited

Legend:

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

    r5405 r5481  
    4545  virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2) = 0;
    4646
     47  /** @param depth: depth, @param drawMode: how to draw the Model */
    4748  virtual void drawBV(int depth, int drawMode) const = 0;
    4849
  • trunk/src/lib/collision_detection/bv_tree_node.h

    r5405 r5481  
    1010#include "base_object.h"
    1111#include "abstract_model.h"
     12#include "vector.h"
    1213
    1314// FORWARD DECLARATION
     
    3233  virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) = 0;
    3334
    34   virtual void drawBV(int depth, int drawMode) = 0;
     35  virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const = 0;
    3536
    3637
  • trunk/src/lib/collision_detection/obb_tree.cc

    r5115 r5481  
    4949
    5050  this->rootNode = NULL;
    51 
    52   material = new Material*[5];
    53   for(int i = 0; i < 5; ++i)
    54   {
    55     material[i] = new Material();
    56     material[i]->setIllum(3);
    57   }
    58   material[0]->setAmbient(0.0, 0.3, 0.0);
    59   material[1]->setAmbient(0.4, 0.0, 0.2);
    60   material[2]->setAmbient(1.0, 0.0, 0.0);
    61   material[3]->setAmbient(5.0, 3.0, 1.0);
    62   material[4]->setAmbient(1.0, 0.0, 7.0);
    63 
    64 
    65   transparentMaterial = new Material*[5];
    66   for(int i = 0; i < 5; ++i)
    67   {
    68     transparentMaterial[i] = new Material();
    69     transparentMaterial[i]->setIllum(3);
    70     transparentMaterial[i]->setTransparency(0.2);
    71   }
    72   transparentMaterial[0]->setAmbient(0.0, 0.3, 0.0);
    73   transparentMaterial[1]->setAmbient(0.4, 0.0, 0.2);
    74   transparentMaterial[2]->setAmbient(1.0, 0.0, 0.0);
    75   transparentMaterial[3]->setAmbient(5.0, 3.0, 1.0);
    76   transparentMaterial[4]->setAmbient(1.0, 0.0, 7.0);
    77 
    78   this->collisionMaterial = new Material();
    79   this->collisionMaterial->setIllum(5);
    80   this->collisionMaterial->setTransparency(0.5);
    81   this->collisionMaterial->setAmbient(1.0, 1.0, 1.0);
    8251
    8352  this->id = 0;
  • trunk/src/lib/collision_detection/obb_tree.h

    r5431 r5481  
    3333    virtual void drawBV(int depth, int drawMode) const;
    3434
    35     Material* getMaterial(unsigned int depth) { return this->material[depth%5]; }
    36     Material* getTransparentMaterial(unsigned int depth) { return this->transparentMaterial[depth%5]; }
    37     Material* getCollisionMaterial() { return this->collisionMaterial; }
    38 
    3935    int getID() { return ++this->id;}
    4036    inline OBBTreeNode* getRootNode() { return this->rootNode; }
     
    4238    void debug();
    4339
    44   public:
    45 
    46 
    47 
    4840  private:
    4941    OBBTreeNode*         rootNode;                        //!< reference to the root node of the tree
    50     Material**           material;
    51     Material**           transparentMaterial;
    52     Material*            collisionMaterial;
    5342    int                  id;
    5443};
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r5449 r5481  
    2525
    2626#include <math.h>
     27#include "color.h"
    2728
    2829#include "stdincl.h"
    29 
    3030#include "lin_alg.h"
    3131#include "glincl.h"
     
    806806
    807807
    808 void OBBTreeNode::drawBV(int depth, int drawMode)
     808void OBBTreeNode::drawBV(int depth, int drawMode, const Vector& color,  bool top) const
    809809{
    810   this->obbTree->getMaterial(treeIndex)->select();
    811810
    812811  /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */
     
    834833  }
    835834
     835  if (top)
     836  {
     837    glPushAttrib(GL_ENABLE_BIT);
     838    glDisable(GL_LIGHTING);
     839    glDisable(GL_TEXTURE_2D);
     840    glDisable(GL_BLEND);
     841  }
     842  glColor3f(color.x, color.y, color.z);
     843
    836844
    837845  /* draw world axes */
     
    839847  {
    840848    glBegin(GL_LINES);
    841     glColor3f(0.0, 0.4, 0.3);
     849    glColor3f(1.0, 0.0, 0.0);
    842850    glVertex3f(0.0, 0.0, 0.0);
    843851    glVertex3f(3.0, 0.0, 0.0);
    844852
     853    glColor3f(0.0, 1.0, 0.0);
    845854    glVertex3f(0.0, 0.0, 0.0);
    846855    glVertex3f(0.0, 3.0, 0.0);
    847856
     857    glColor3f(0.0, 0.0, 1.0);
    848858    glVertex3f(0.0, 0.0, 0.0);
    849859    glVertex3f(0.0, 0.0, 3.0);
     
    890900
    891901    if( this->bvElement->bCollided)
    892       this->obbTree->getCollisionMaterial()->select();
     902    {
     903      glColor3f(1.0, 1.0, 1.0); // COLLISION COLOR
     904    }
    893905    else if( drawMode & DRAW_BV_BLENDED)
    894       this->obbTree->getTransparentMaterial(treeIndex)->select();
     906    {
     907      glColor4f(color.x, color.y, color.z, .5);
     908    }
    895909
    896910
     
    10051019
    10061020    if( drawMode & DRAW_BV_BLENDED)
    1007       this->obbTree->getMaterial(treeIndex)->select();
     1021      glColor3f(color.x, color.y, color.z);
    10081022    }
    10091023
     
    10161030    {
    10171031      if( drawMode & DRAW_BV_BLENDED)
    1018         this->obbTree->getTransparentMaterial(treeIndex)->select();
     1032        glColor4f(color.x, color.y, color.z, .6);
    10191033
    10201034    /* now draw the separation plane */
     
    10321046
    10331047    if( drawMode & DRAW_BV_BLENDED)
    1034       this->obbTree->getMaterial(treeIndex)->select();
    1035 
    1036     }
    1037   }
    1038 
    1039 
    1040 
    1041   if( this->nodeLeft != NULL && depth != 0 )
    1042     this->nodeLeft->drawBV(depth - 1, drawMode);
    1043   if( this->nodeRight != NULL && depth != 0)
    1044     this->nodeRight->drawBV(depth - 1, drawMode);
    1045 
     1048      glColor4f(color.x, color.y, color.z, 1.0);
     1049
     1050    }
     1051  }
     1052
     1053
     1054
     1055  if (depth > 0)
     1056  {
     1057    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
     1058    if( this->nodeLeft != NULL)
     1059      this->nodeLeft->drawBV(depth - 1, drawMode, childColor, false);
     1060    if( this->nodeRight != NULL)
     1061      this->nodeRight->drawBV(depth - 1, drawMode, childColor, false);
     1062  }
    10461063  this->bvElement->bCollided = false;
     1064
     1065  if (top)
     1066    glPopAttrib();
    10471067}
    10481068
  • trunk/src/lib/collision_detection/obb_tree_node.h

    r5431 r5481  
    3636    virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
    3737
    38     virtual void drawBV(int depth, int drawMode);
     38    virtual void drawBV(int depth, int drawMode, const Vector& color = Vector(1,0,0), bool top = true) const;
    3939
    4040    void debug() const;
Note: See TracChangeset for help on using the changeset viewer.