[Orxonox-commit 5530] r10193 - in code/trunk: data/levels src/libraries/tools

landauf at orxonox.net landauf at orxonox.net
Sun Jan 11 22:06:04 CET 2015


Author: landauf
Date: 2015-01-11 22:06:04 +0100 (Sun, 11 Jan 2015)
New Revision: 10193

Modified:
   code/trunk/data/levels/collisionShapes.oxw
   code/trunk/src/libraries/tools/BulletDebugDrawer.cc
   code/trunk/src/libraries/tools/BulletDebugDrawer.h
   code/trunk/src/libraries/tools/DebugDrawer.cc
   code/trunk/src/libraries/tools/DebugDrawer.h
Log:
details, made debug drawer more configurable

Modified: code/trunk/data/levels/collisionShapes.oxw
===================================================================
--- code/trunk/data/levels/collisionShapes.oxw	2015-01-11 20:30:08 UTC (rev 10192)
+++ code/trunk/data/levels/collisionShapes.oxw	2015-01-11 21:06:04 UTC (rev 10193)
@@ -1,7 +1,7 @@
 <LevelInfo
  name = "Collision shapes"
  description = "A level with some collision shapes."
- tags = "showcase"
+ tags = "test"
  screenshot = "emptylevel.png"
 />
 

Modified: code/trunk/src/libraries/tools/BulletDebugDrawer.cc
===================================================================
--- code/trunk/src/libraries/tools/BulletDebugDrawer.cc	2015-01-11 20:30:08 UTC (rev 10192)
+++ code/trunk/src/libraries/tools/BulletDebugDrawer.cc	2015-01-11 21:06:04 UTC (rev 10193)
@@ -20,11 +20,10 @@
 {
     BulletDebugDrawer::BulletDebugDrawer(Ogre::SceneManager* sceneManager)
     {
-        this->drawer = new DebugDrawer(sceneManager, 0.5f);
+        this->drawer_ = new DebugDrawer(sceneManager, 0.5f);
+        this->bFill_ = true;
 
         mContactPoints = &mContactPoints1;
-        //mLines->estimateVertexCount(100000);
-        //mLines->estimateIndexCount(0);
 
         static const char* matName = "OgreBulletCollisionsDebugDefault";
         Ogre::MaterialPtr mtl = Ogre::MaterialManager::getSingleton().getDefaultSettings()->clone(matName);
@@ -43,12 +42,12 @@
     BulletDebugDrawer::~BulletDebugDrawer()
     {
         Ogre::Root::getSingleton().removeFrameListener(this);
-        delete this->drawer;
+        delete this->drawer_;
     }
 
     void BulletDebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
     {
-        this->drawer->drawLine(vector3(from), vector3(to), colour(color, 1.0f));
+        this->drawer_->drawLine(vector3(from), vector3(to), colour(color, 1.0f));
     }
 
 //    void BulletDebugDrawer::drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& color, btScalar alpha)
@@ -58,13 +57,13 @@
 
     void BulletDebugDrawer::drawSphere(const btVector3& p, btScalar radius, const btVector3& color)
     {
-        this->drawer->drawSphere(vector3(p), Ogre::Quaternion::IDENTITY, radius, colour(color, 1.0f), true);
+        this->drawer_->drawSphere(vector3(p), Ogre::Quaternion::IDENTITY, radius, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawSphere(btScalar radius, const btTransform& transform, const btVector3& color)
     {
         Ogre::Matrix4 matrix = matrix4(transform);
-        this->drawer->drawSphere(matrix.getTrans(), matrix.extractQuaternion(), radius, colour(color, 1.0f), true);
+        this->drawer_->drawSphere(matrix.getTrans(), matrix.extractQuaternion(), radius, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color)
@@ -78,7 +77,7 @@
         corners[5]  = Ogre::Vector3(bbMin[0], bbMax[1], bbMax[2]);
         corners[6]  = Ogre::Vector3(bbMin[0], bbMin[1], bbMax[2]);
         corners[7]  = Ogre::Vector3(bbMax[0], bbMin[1], bbMax[2]);
-        this->drawer->drawCuboid(corners, colour(color, 1.0f), true);
+        this->drawer_->drawCuboid(corners, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color)
@@ -92,19 +91,19 @@
         corners[5]  = Ogre::Vector3(trans * btVector3(bbMin[0], bbMax[1], bbMax[2]));
         corners[6]  = Ogre::Vector3(trans * btVector3(bbMin[0], bbMin[1], bbMax[2]));
         corners[7]  = Ogre::Vector3(trans * btVector3(bbMax[0], bbMin[1], bbMax[2]));
-        this->drawer->drawCuboid(corners, colour(color, 1.0f), true);
+        this->drawer_->drawCuboid(corners, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color)
     {
         Ogre::Matrix4 matrix = matrix4(transform);
-        this->drawer->drawCylinder(matrix.getTrans(), matrix.extractQuaternion(), radius, halfHeight * 2, colour(color, 1.0f), true);
+        this->drawer_->drawCylinder(matrix.getTrans(), matrix.extractQuaternion(), radius, halfHeight * 2, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color)
     {
         Ogre::Matrix4 matrix = matrix4(transform);
-        this->drawer->drawCone(matrix.getTrans(), matrix.extractQuaternion(), radius, height, colour(color, 1.0f), true);
+        this->drawer_->drawCone(matrix.getTrans(), matrix.extractQuaternion(), radius, height, colour(color, 1.0f), this->bFill_);
     }
 
     void BulletDebugDrawer::drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color)
@@ -126,7 +125,7 @@
         for (std::vector<ContactPoint>::iterator i = mContactPoints->begin(); i < mContactPoints->end(); i++ )
         {
             ContactPoint& cp = *i;
-            this->drawer->drawLine(cp.from, cp.to, cp.color);
+            this->drawer_->drawLine(cp.from, cp.to, cp.color);
             if (now <= cp.dieTime)
                 newCP->push_back(cp);
         }
@@ -134,14 +133,14 @@
         mContactPoints = newCP;
 
         // Right before the frame is rendered, call DebugDrawer::build().
-        this->drawer->build();
+        this->drawer_->build();
         return true;
     }
 
     bool BulletDebugDrawer::frameEnded(const Ogre::FrameEvent& evt)
     {
         // After the frame is rendered, call DebugDrawer::clear()
-        this->drawer->clear();
+        this->drawer_->clear();
         return true;
     }
 
@@ -165,4 +164,10 @@
     {
         return mDebugMode;
     }
+
+    void BulletDebugDrawer::configure(bool bFill, float fillAlpha)
+    {
+        this->bFill_ = bFill;
+        this->drawer_->setFillAlpha(fillAlpha);
+    }
 }

Modified: code/trunk/src/libraries/tools/BulletDebugDrawer.h
===================================================================
--- code/trunk/src/libraries/tools/BulletDebugDrawer.h	2015-01-11 20:30:08 UTC (rev 10192)
+++ code/trunk/src/libraries/tools/BulletDebugDrawer.h	2015-01-11 21:06:04 UTC (rev 10193)
@@ -37,6 +37,8 @@
             virtual void setDebugMode(int debugMode);
             virtual int getDebugMode() const;
 
+            void configure(bool bFill, float fillAlpha);
+
         protected:
             bool frameStarted(const Ogre::FrameEvent& evt);
             bool frameEnded(const Ogre::FrameEvent& evt);
@@ -50,7 +52,9 @@
                 size_t dieTime;
             };
 
-            DebugDrawer* drawer;
+            bool bFill_;
+            DebugDrawer* drawer_;
+
             DebugDrawModes mDebugMode;
             std::vector<ContactPoint>* mContactPoints;
             std::vector<ContactPoint> mContactPoints1;

Modified: code/trunk/src/libraries/tools/DebugDrawer.cc
===================================================================
--- code/trunk/src/libraries/tools/DebugDrawer.cc	2015-01-11 20:30:08 UTC (rev 10192)
+++ code/trunk/src/libraries/tools/DebugDrawer.cc	2015-01-11 21:06:04 UTC (rev 10193)
@@ -145,11 +145,11 @@
 
         Ogre::Matrix4 transform(rotation);
         transform.setTrans(centre + rotation * Ogre::Vector3(0, height / 2, 0));
-        this->buildCircle(transform, radius, segmentsCount, colour, alpha);
+        this->buildCircle(transform, radius, segmentsCount, colour);
         this->buildFilledCircle(transform, radius, segmentsCount, colour, true, alpha);
 
         transform.setTrans(centre + rotation * Ogre::Vector3(0, -height / 2, 0));
-        this->buildCircle(transform, radius, segmentsCount, colour, alpha);
+        this->buildCircle(transform, radius, segmentsCount, colour);
         this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha);
 
         for (int i = 0; i < segmentsCount; i++)
@@ -180,7 +180,7 @@
 
         Ogre::Matrix4 transform(rotation);
         transform.setTrans(centre + rotation * Ogre::Vector3(0, -height / 2, 0));
-        this->buildCircle(transform, radius, segmentsCount, colour, alpha);
+        this->buildCircle(transform, radius, segmentsCount, colour);
         this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha);
 
         addTriangleVertex(centre + rotation * Ogre::Vector3(0, height / 2, 0), Ogre::ColourValue(colour.r, colour.g, colour.b, alpha));
@@ -299,7 +299,7 @@
 
     void DebugDrawer::drawCircle(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled)
     {
-        int segmentsCount = std::min(100.0, radius / 2.5);
+        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
 
         Ogre::Matrix4 transform(rotation);
         transform.setTrans(centre);
@@ -311,7 +311,7 @@
 
     void DebugDrawer::drawCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled)
     {
-        int segmentsCount = std::min(100.0, radius / 2.5);
+        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
 
         if (isFilled)
             buildFilledCylinder(centre, rotation, radius, segmentsCount, height, colour, fillAlpha);
@@ -321,7 +321,7 @@
 
     void DebugDrawer::drawCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled)
     {
-        int segmentsCount = std::min(100.0, radius / 2.5);
+        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
 
         if (isFilled)
             buildFilledCone(centre, rotation, radius, segmentsCount, height, colour, fillAlpha);

Modified: code/trunk/src/libraries/tools/DebugDrawer.h
===================================================================
--- code/trunk/src/libraries/tools/DebugDrawer.h	2015-01-11 20:30:08 UTC (rev 10192)
+++ code/trunk/src/libraries/tools/DebugDrawer.h	2015-01-11 21:06:04 UTC (rev 10193)
@@ -43,6 +43,11 @@
             void drawSphere(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled = false);
             void drawTetrahedron(const Ogre::Vector3& centre, float scale, const Ogre::ColourValue& colour, bool isFilled = false);
 
+            void setFillAlpha(float alpha)
+            {
+                fillAlpha = alpha;
+            }
+
             bool getEnabled()
             {
                 return isEnabled;




More information about the Orxonox-commit mailing list