Changeset 5481 in orxonox.OLD for trunk/src/lib/collision_detection
- Timestamp:
- Nov 3, 2005, 10:22:30 PM (19 years ago)
- Location:
- trunk/src/lib/collision_detection
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_detection/bv_tree.h
r5405 r5481 45 45 virtual void collideWith(WorldEntity* entity1, WorldEntity* entity2) = 0; 46 46 47 /** @param depth: depth, @param drawMode: how to draw the Model */ 47 48 virtual void drawBV(int depth, int drawMode) const = 0; 48 49 -
trunk/src/lib/collision_detection/bv_tree_node.h
r5405 r5481 10 10 #include "base_object.h" 11 11 #include "abstract_model.h" 12 #include "vector.h" 12 13 13 14 // FORWARD DECLARATION … … 32 33 virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB) = 0; 33 34 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; 35 36 36 37 -
trunk/src/lib/collision_detection/obb_tree.cc
r5115 r5481 49 49 50 50 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);82 51 83 52 this->id = 0; -
trunk/src/lib/collision_detection/obb_tree.h
r5431 r5481 33 33 virtual void drawBV(int depth, int drawMode) const; 34 34 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 39 35 int getID() { return ++this->id;} 40 36 inline OBBTreeNode* getRootNode() { return this->rootNode; } … … 42 38 void debug(); 43 39 44 public:45 46 47 48 40 private: 49 41 OBBTreeNode* rootNode; //!< reference to the root node of the tree 50 Material** material;51 Material** transparentMaterial;52 Material* collisionMaterial;53 42 int id; 54 43 }; -
trunk/src/lib/collision_detection/obb_tree_node.cc
r5449 r5481 25 25 26 26 #include <math.h> 27 #include "color.h" 27 28 28 29 #include "stdincl.h" 29 30 30 #include "lin_alg.h" 31 31 #include "glincl.h" … … 806 806 807 807 808 void OBBTreeNode::drawBV(int depth, int drawMode )808 void OBBTreeNode::drawBV(int depth, int drawMode, const Vector& color, bool top) const 809 809 { 810 this->obbTree->getMaterial(treeIndex)->select();811 810 812 811 /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */ … … 834 833 } 835 834 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 836 844 837 845 /* draw world axes */ … … 839 847 { 840 848 glBegin(GL_LINES); 841 glColor3f( 0.0, 0.4, 0.3);849 glColor3f(1.0, 0.0, 0.0); 842 850 glVertex3f(0.0, 0.0, 0.0); 843 851 glVertex3f(3.0, 0.0, 0.0); 844 852 853 glColor3f(0.0, 1.0, 0.0); 845 854 glVertex3f(0.0, 0.0, 0.0); 846 855 glVertex3f(0.0, 3.0, 0.0); 847 856 857 glColor3f(0.0, 0.0, 1.0); 848 858 glVertex3f(0.0, 0.0, 0.0); 849 859 glVertex3f(0.0, 0.0, 3.0); … … 890 900 891 901 if( this->bvElement->bCollided) 892 this->obbTree->getCollisionMaterial()->select(); 902 { 903 glColor3f(1.0, 1.0, 1.0); // COLLISION COLOR 904 } 893 905 else if( drawMode & DRAW_BV_BLENDED) 894 this->obbTree->getTransparentMaterial(treeIndex)->select(); 906 { 907 glColor4f(color.x, color.y, color.z, .5); 908 } 895 909 896 910 … … 1005 1019 1006 1020 if( drawMode & DRAW_BV_BLENDED) 1007 this->obbTree->getMaterial(treeIndex)->select();1021 glColor3f(color.x, color.y, color.z); 1008 1022 } 1009 1023 … … 1016 1030 { 1017 1031 if( drawMode & DRAW_BV_BLENDED) 1018 this->obbTree->getTransparentMaterial(treeIndex)->select();1032 glColor4f(color.x, color.y, color.z, .6); 1019 1033 1020 1034 /* now draw the separation plane */ … … 1032 1046 1033 1047 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 } 1046 1063 this->bvElement->bCollided = false; 1064 1065 if (top) 1066 glPopAttrib(); 1047 1067 } 1048 1068 -
trunk/src/lib/collision_detection/obb_tree_node.h
r5431 r5481 36 36 virtual void collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB); 37 37 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; 39 39 40 40 void debug() const;
Note: See TracChangeset
for help on using the changeset viewer.