Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10193


Ignore:
Timestamp:
Jan 11, 2015, 10:06:04 PM (10 years ago)
Author:
landauf
Message:

details, made debug drawer more configurable

Location:
code/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/levels/collisionShapes.oxw

    r10191 r10193  
    22 name = "Collision shapes"
    33 description = "A level with some collision shapes."
    4  tags = "showcase"
     4 tags = "test"
    55 screenshot = "emptylevel.png"
    66/>
  • code/trunk/src/libraries/tools/BulletDebugDrawer.cc

    r10191 r10193  
    2121    BulletDebugDrawer::BulletDebugDrawer(Ogre::SceneManager* sceneManager)
    2222    {
    23         this->drawer = new DebugDrawer(sceneManager, 0.5f);
     23        this->drawer_ = new DebugDrawer(sceneManager, 0.5f);
     24        this->bFill_ = true;
    2425
    2526        mContactPoints = &mContactPoints1;
    26         //mLines->estimateVertexCount(100000);
    27         //mLines->estimateIndexCount(0);
    2827
    2928        static const char* matName = "OgreBulletCollisionsDebugDefault";
     
    4443    {
    4544        Ogre::Root::getSingleton().removeFrameListener(this);
    46         delete this->drawer;
     45        delete this->drawer_;
    4746    }
    4847
    4948    void BulletDebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
    5049    {
    51         this->drawer->drawLine(vector3(from), vector3(to), colour(color, 1.0f));
     50        this->drawer_->drawLine(vector3(from), vector3(to), colour(color, 1.0f));
    5251    }
    5352
     
    5958    void BulletDebugDrawer::drawSphere(const btVector3& p, btScalar radius, const btVector3& color)
    6059    {
    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_);
    6261    }
    6362
     
    6564    {
    6665        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_);
    6867    }
    6968
     
    7978        corners[6]  = Ogre::Vector3(bbMin[0], bbMin[1], bbMax[2]);
    8079        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_);
    8281    }
    8382
     
    9392        corners[6]  = Ogre::Vector3(trans * btVector3(bbMin[0], bbMin[1], bbMax[2]));
    9493        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_);
    9695    }
    9796
     
    9998    {
    10099        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_);
    102101    }
    103102
     
    105104    {
    106105        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_);
    108107    }
    109108
     
    127126        {
    128127            ContactPoint& cp = *i;
    129             this->drawer->drawLine(cp.from, cp.to, cp.color);
     128            this->drawer_->drawLine(cp.from, cp.to, cp.color);
    130129            if (now <= cp.dieTime)
    131130                newCP->push_back(cp);
     
    135134
    136135        // Right before the frame is rendered, call DebugDrawer::build().
    137         this->drawer->build();
     136        this->drawer_->build();
    138137        return true;
    139138    }
     
    142141    {
    143142        // After the frame is rendered, call DebugDrawer::clear()
    144         this->drawer->clear();
     143        this->drawer_->clear();
    145144        return true;
    146145    }
     
    166165        return mDebugMode;
    167166    }
     167
     168    void BulletDebugDrawer::configure(bool bFill, float fillAlpha)
     169    {
     170        this->bFill_ = bFill;
     171        this->drawer_->setFillAlpha(fillAlpha);
     172    }
    168173}
  • code/trunk/src/libraries/tools/BulletDebugDrawer.h

    r10191 r10193  
    3838            virtual int getDebugMode() const;
    3939
     40            void configure(bool bFill, float fillAlpha);
     41
    4042        protected:
    4143            bool frameStarted(const Ogre::FrameEvent& evt);
     
    5153            };
    5254
    53             DebugDrawer* drawer;
     55            bool bFill_;
     56            DebugDrawer* drawer_;
     57
    5458            DebugDrawModes mDebugMode;
    5559            std::vector<ContactPoint>* mContactPoints;
  • code/trunk/src/libraries/tools/DebugDrawer.cc

    r10191 r10193  
    146146        Ogre::Matrix4 transform(rotation);
    147147        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);
    149149        this->buildFilledCircle(transform, radius, segmentsCount, colour, true, alpha);
    150150
    151151        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);
    153153        this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha);
    154154
     
    181181        Ogre::Matrix4 transform(rotation);
    182182        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);
    184184        this->buildFilledCircle(transform, radius, segmentsCount, colour, false, alpha);
    185185
     
    300300    void DebugDrawer::drawCircle(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled)
    301301    {
    302         int segmentsCount = std::min(100.0, radius / 2.5);
     302        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
    303303
    304304        Ogre::Matrix4 transform(rotation);
     
    312312    void DebugDrawer::drawCylinder(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled)
    313313    {
    314         int segmentsCount = std::min(100.0, radius / 2.5);
     314        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
    315315
    316316        if (isFilled)
     
    322322    void DebugDrawer::drawCone(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, float height, const Ogre::ColourValue& colour, bool isFilled)
    323323    {
    324         int segmentsCount = std::min(100.0, radius / 2.5);
     324        int segmentsCount = std::min<int>(100, (int) (radius / 2.5));
    325325
    326326        if (isFilled)
  • code/trunk/src/libraries/tools/DebugDrawer.h

    r10191 r10193  
    4343            void drawSphere(const Ogre::Vector3& centre, const Ogre::Quaternion& rotation, float radius, const Ogre::ColourValue& colour, bool isFilled = false);
    4444            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            }
    4550
    4651            bool getEnabled()
Note: See TracChangeset for help on using the changeset viewer.