Changeset 10193 for code/trunk/src/libraries
- Timestamp:
- Jan 11, 2015, 10:06:04 PM (10 years ago)
- Location:
- code/trunk/src/libraries/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/tools/BulletDebugDrawer.cc
r10191 r10193 21 21 BulletDebugDrawer::BulletDebugDrawer(Ogre::SceneManager* sceneManager) 22 22 { 23 this->drawer = new DebugDrawer(sceneManager, 0.5f); 23 this->drawer_ = new DebugDrawer(sceneManager, 0.5f); 24 this->bFill_ = true; 24 25 25 26 mContactPoints = &mContactPoints1; 26 //mLines->estimateVertexCount(100000);27 //mLines->estimateIndexCount(0);28 27 29 28 static const char* matName = "OgreBulletCollisionsDebugDefault"; … … 44 43 { 45 44 Ogre::Root::getSingleton().removeFrameListener(this); 46 delete this->drawer ;45 delete this->drawer_; 47 46 } 48 47 49 48 void BulletDebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color) 50 49 { 51 this->drawer ->drawLine(vector3(from), vector3(to), colour(color, 1.0f));50 this->drawer_->drawLine(vector3(from), vector3(to), colour(color, 1.0f)); 52 51 } 53 52 … … 59 58 void BulletDebugDrawer::drawSphere(const btVector3& p, btScalar radius, const btVector3& color) 60 59 { 61 this->drawer ->drawSphere(vector3(p), Ogre::Quaternion::IDENTITY, radius, colour(color, 1.0f), true);60 this->drawer_->drawSphere(vector3(p), Ogre::Quaternion::IDENTITY, radius, colour(color, 1.0f), this->bFill_); 62 61 } 63 62 … … 65 64 { 66 65 Ogre::Matrix4 matrix = matrix4(transform); 67 this->drawer ->drawSphere(matrix.getTrans(), matrix.extractQuaternion(), radius, colour(color, 1.0f), true);66 this->drawer_->drawSphere(matrix.getTrans(), matrix.extractQuaternion(), radius, colour(color, 1.0f), this->bFill_); 68 67 } 69 68 … … 79 78 corners[6] = Ogre::Vector3(bbMin[0], bbMin[1], bbMax[2]); 80 79 corners[7] = Ogre::Vector3(bbMax[0], bbMin[1], bbMax[2]); 81 this->drawer ->drawCuboid(corners, colour(color, 1.0f), true);80 this->drawer_->drawCuboid(corners, colour(color, 1.0f), this->bFill_); 82 81 } 83 82 … … 93 92 corners[6] = Ogre::Vector3(trans * btVector3(bbMin[0], bbMin[1], bbMax[2])); 94 93 corners[7] = Ogre::Vector3(trans * btVector3(bbMax[0], bbMin[1], bbMax[2])); 95 this->drawer ->drawCuboid(corners, colour(color, 1.0f), true);94 this->drawer_->drawCuboid(corners, colour(color, 1.0f), this->bFill_); 96 95 } 97 96 … … 99 98 { 100 99 Ogre::Matrix4 matrix = matrix4(transform); 101 this->drawer ->drawCylinder(matrix.getTrans(), matrix.extractQuaternion(), radius, halfHeight * 2, colour(color, 1.0f), true);100 this->drawer_->drawCylinder(matrix.getTrans(), matrix.extractQuaternion(), radius, halfHeight * 2, colour(color, 1.0f), this->bFill_); 102 101 } 103 102 … … 105 104 { 106 105 Ogre::Matrix4 matrix = matrix4(transform); 107 this->drawer ->drawCone(matrix.getTrans(), matrix.extractQuaternion(), radius, height, colour(color, 1.0f), true);106 this->drawer_->drawCone(matrix.getTrans(), matrix.extractQuaternion(), radius, height, colour(color, 1.0f), this->bFill_); 108 107 } 109 108 … … 127 126 { 128 127 ContactPoint& cp = *i; 129 this->drawer ->drawLine(cp.from, cp.to, cp.color);128 this->drawer_->drawLine(cp.from, cp.to, cp.color); 130 129 if (now <= cp.dieTime) 131 130 newCP->push_back(cp); … … 135 134 136 135 // Right before the frame is rendered, call DebugDrawer::build(). 137 this->drawer ->build();136 this->drawer_->build(); 138 137 return true; 139 138 } … … 142 141 { 143 142 // After the frame is rendered, call DebugDrawer::clear() 144 this->drawer ->clear();143 this->drawer_->clear(); 145 144 return true; 146 145 } … … 166 165 return mDebugMode; 167 166 } 167 168 void BulletDebugDrawer::configure(bool bFill, float fillAlpha) 169 { 170 this->bFill_ = bFill; 171 this->drawer_->setFillAlpha(fillAlpha); 172 } 168 173 } -
code/trunk/src/libraries/tools/BulletDebugDrawer.h
r10191 r10193 38 38 virtual int getDebugMode() const; 39 39 40 void configure(bool bFill, float fillAlpha); 41 40 42 protected: 41 43 bool frameStarted(const Ogre::FrameEvent& evt); … … 51 53 }; 52 54 53 DebugDrawer* drawer; 55 bool bFill_; 56 DebugDrawer* drawer_; 57 54 58 DebugDrawModes mDebugMode; 55 59 std::vector<ContactPoint>* mContactPoints; -
code/trunk/src/libraries/tools/DebugDrawer.cc
r10191 r10193 146 146 Ogre::Matrix4 transform(rotation); 147 147 transform.setTrans(centre + rotation * Ogre::Vector3(0, height / 2, 0)); 148 this->buildCircle(transform, radius, segmentsCount, colour , alpha);148 this->buildCircle(transform, radius, segmentsCount, colour); 149 149 this->buildFilledCircle(transform, radius, segmentsCount, colour, true, alpha); 150 150 151 151 transform.setTrans(centre + rotation * Ogre::Vector3(0, -height / 2, 0)); 152 this->buildCircle(transform, radius, segmentsCount, colour , alpha);152 this->buildCircle(transform, radius, segmentsCount, colour); 153 153 this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha); 154 154 … … 181 181 Ogre::Matrix4 transform(rotation); 182 182 transform.setTrans(centre + rotation * Ogre::Vector3(0, -height / 2, 0)); 183 this->buildCircle(transform, radius, segmentsCount, colour , alpha);183 this->buildCircle(transform, radius, segmentsCount, colour); 184 184 this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha); 185 185 … … 300 300 void DebugDrawer::drawCircle(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled) 301 301 { 302 int segmentsCount = std::min (100.0, radius / 2.5);302 int segmentsCount = std::min<int>(100, (int) (radius / 2.5)); 303 303 304 304 Ogre::Matrix4 transform(rotation); … … 312 312 void DebugDrawer::drawCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled) 313 313 { 314 int segmentsCount = std::min (100.0, radius / 2.5);314 int segmentsCount = std::min<int>(100, (int) (radius / 2.5)); 315 315 316 316 if (isFilled) … … 322 322 void DebugDrawer::drawCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled) 323 323 { 324 int segmentsCount = std::min (100.0, radius / 2.5);324 int segmentsCount = std::min<int>(100, (int) (radius / 2.5)); 325 325 326 326 if (isFilled) -
code/trunk/src/libraries/tools/DebugDrawer.h
r10191 r10193 43 43 void drawSphere(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled = false); 44 44 void drawTetrahedron(const Ogre::Vector3& centre, float scale, const Ogre::ColourValue& colour, bool isFilled = false); 45 46 void setFillAlpha(float alpha) 47 { 48 fillAlpha = alpha; 49 } 45 50 46 51 bool getEnabled()
Note: See TracChangeset
for help on using the changeset viewer.