Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/ogrebullet/Debug/OgreBulletCollisionsDebugContact.h @ 1971

Last change on this file since 1971 was 1971, checked in by rgrieder, 16 years ago

Added OgreBullet to the repository. The revision was 2493 (ogreaddons), trunk.

  • Property svn:eol-style set to native
File size: 7.2 KB
Line 
1/***************************************************************************
2
3This source file is part of OGREBULLET
4    (Object-oriented Graphics Rendering Engine Bullet Wrapper)
5        For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
6
7        Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
8
9
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GPL General Public License with runtime exception as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
19
20You should have received a copy of the GPL General Public License with runtime exception along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24-----------------------------------------------------------------------------
25*/
26
27#ifndef __OgreBulletCollisionsDebugContact_H__
28#define __OgreBulletCollisionsDebugContact_H__
29
30#include "OgreBulletCollisionsPreRequisites.h"
31#include "Debug/OgreBulletCollisionsDebugLines.h"
32
33
34namespace OgreBulletCollisions
35{
36    //------------------------------------------------------------------------------------------------
37    class DebugContact
38    {
39    public:
40        DebugContact(const Ogre::String &name, CollisionsWorld *world);
41         ~DebugContact();
42
43         bool isEnabled () const;
44         void setEnabled (bool enable);
45
46         void update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
47
48    private:
49        DebugNormal         *_normal;
50        DebugContactText    *_text;
51        Ogre::Entity        *_point;
52        bool                _enabled;
53        Ogre::String        _name;
54        Ogre::SceneNode     *_node;
55        Ogre::SceneNode     *_point_node;
56        CollisionsWorld               *_world;
57    };
58
59    //------------------------------------------------------------------------------------------------
60    class DebugNormal : public DebugLines
61    {
62    public:
63        DebugNormal() : DebugLines(){};
64        ~DebugNormal(){};
65
66        void update (const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
67    };
68
69    //------------------------------------------------------------------------------------------------
70    class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable
71    {
72    public:
73        enum HorizontalAlignment    {H_LEFT, H_CENTER};
74        enum VerticalAlignment      {V_BELOW, V_ABOVE};
75        /******************************** public methods ******************************/
76    public:
77        DebugContactText(const Ogre::String &name, 
78                         Ogre::SceneNode *node,
79                         const Ogre::String &caption = "", 
80                         const Ogre::String &fontName = "BlueHighway", 
81                         int charHeight = 32, 
82                         const Ogre::ColourValue &color = Ogre::ColourValue::White);
83
84
85         ~DebugContactText();
86
87#if (OGRE_VERSION >=  ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
88                void visitRenderables(Renderable::Visitor* visitor, bool debugRenderables);
89#endif
90        // Set settings
91        void    setPosition(const Ogre::Vector3 &pos);
92
93        void    setFontName(const Ogre::String &fontName);
94        void    setCaption(const Ogre::String &caption);
95        void    setColor(const Ogre::ColourValue &color);
96        void    setCharacterHeight(unsigned int height);
97        void    setSpaceWidth(unsigned int width);
98        void    setTextAlignment(const HorizontalAlignment& horizontalAlignment, 
99                                const VerticalAlignment& verticalAlignment);
100        void    setAdditionalHeight( Ogre::Real height );
101        void    showOnTop(bool show=true);
102
103        // Get settings
104        const   Ogre::String          &getFontName() const {return mFontName;}
105        const   Ogre::String          &getCaption() const {return mCaption;}
106        const   Ogre::ColourValue     &getColor() const {return mColor;}
107
108        unsigned int    getCharacterHeight() const {return mCharHeight;}
109        unsigned int    getSpaceWidth() const {return mSpaceWidth;}
110        Ogre::Real                  getAdditionalHeight() const {return mAdditionalHeight;}
111        bool                    getShowOnTop() const {return mOnTop;}
112        Ogre::AxisAlignedBox            GetAABB(void) { return mAABB; }
113
114        /******************************** protected methods and overload **************/
115    protected:
116
117        // from OgreBulletCollisionsDebugContact, create the object
118        void    _setupGeometry();
119        void    _updateColors();
120
121        // from MovableObject
122        void                            getWorldTransforms(Ogre::Matrix4 *xform) const;
123        Ogre::Real                      getBoundingRadius(void) const {return mRadius;};
124        Ogre::Real                      getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
125        const   Ogre::Quaternion        &getWorldOrientation(void) const;
126        const   Ogre::Vector3           &getWorldPosition(void) const;
127        const   Ogre::AxisAlignedBox    &getBoundingBox(void) const {return mAABB;};
128        const   Ogre::String            &getName(void) const {return mName;};
129        const   Ogre::String            &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
130
131        void                            _notifyCurrentCamera(Ogre::Camera *cam);
132        void                            _updateRenderQueue(Ogre::RenderQueue* queue);
133
134        // from renderable
135        void                            getRenderOperation(Ogre::RenderOperation &op);
136        const   Ogre::MaterialPtr       &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
137        const   Ogre::LightList         &getLights(void) const {return mLList;};
138
139        /******************************** OgreBulletCollisionsDebugContact data ****************************/
140 
141
142    protected:
143        Ogre::String                    mFontName;
144        Ogre::String                    mType;
145        Ogre::String                    mName;
146        Ogre::String                    mCaption;
147        HorizontalAlignment         mHorizontalAlignment;
148        VerticalAlignment           mVerticalAlignment;
149
150        Ogre::ColourValue               mColor;
151        Ogre::RenderOperation   mRenderOp;
152        Ogre::AxisAlignedBox    mAABB;
153        Ogre::LightList             mLList;
154
155        unsigned int                    mCharHeight;
156        unsigned int                    mSpaceWidth;
157
158        bool                            mNeedUpdate;
159        bool                            mUpdateColors;
160        bool                            mOnTop;
161
162        Ogre::Real                          mTimeUntilNextToggle;
163        Ogre::Real                          mRadius;
164        Ogre::Real              mAdditionalHeight;
165
166        Ogre::Camera                    *mpCam;
167        Ogre::RenderWindow          *mpWin;
168        Ogre::Font                          *mpFont;
169        Ogre::MaterialPtr               mpMaterial;
170        Ogre::MaterialPtr               mpBackgroundMaterial;
171
172        Ogre::SceneNode         *mNode;
173    };
174}
175
176#endif //__OgreBulletCollisionsDebugContact_H__
177
Note: See TracBrowser for help on using the repository browser.