| 1 | /** | 
|---|
| 2 | * File: OgreOdeDebugContact.h | 
|---|
| 3 | * | 
|---|
| 4 | * description: This create create a billboarding object that display a text. | 
|---|
| 5 | * derived from Movable Text | 
|---|
| 6 | * @author  2003 by cTh see gavocanov@rambler.ru | 
|---|
| 7 | * @update  2006 by barraq see nospam@barraquand.com | 
|---|
| 8 | */ | 
|---|
| 9 |  | 
|---|
| 10 | #ifndef __include_OgreOdeDebugContact_H__ | 
|---|
| 11 | #define __include_OgreOdeDebugContact_H__ | 
|---|
| 12 |  | 
|---|
| 13 | #include "OgreOdePreReqs.h" | 
|---|
| 14 |  | 
|---|
| 15 | #include <OgreMovableObject.h> | 
|---|
| 16 | #include <OgreRenderable.h> | 
|---|
| 17 | #include <OgreAxisAlignedBox.h> | 
|---|
| 18 | #include "OgreOdeDebugObject.h" | 
|---|
| 19 |  | 
|---|
| 20 | namespace OgreOde  | 
|---|
| 21 | { | 
|---|
| 22 |     class DebugContact | 
|---|
| 23 |     { | 
|---|
| 24 |     public: | 
|---|
| 25 |         DebugContact(const Ogre::String &name, World *world); | 
|---|
| 26 |          ~DebugContact(); | 
|---|
| 27 |  | 
|---|
| 28 |          bool isEnabled () const; | 
|---|
| 29 |          void setEnabled (bool enable); | 
|---|
| 30 |  | 
|---|
| 31 |         void update(Contact * const contact); | 
|---|
| 32 |  | 
|---|
| 33 |     private: | 
|---|
| 34 |         DebugNormal         *_normal; | 
|---|
| 35 |         DebugContactText    *_text; | 
|---|
| 36 |         Ogre::Entity        *_point; | 
|---|
| 37 |         bool                _enabled; | 
|---|
| 38 |         Ogre::String        _name; | 
|---|
| 39 |         Ogre::SceneNode     *_node; | 
|---|
| 40 |         Ogre::SceneNode     *_point_node; | 
|---|
| 41 |         World               *_world; | 
|---|
| 42 |     }; | 
|---|
| 43 |  | 
|---|
| 44 |     class DebugNormal : public DebugLines | 
|---|
| 45 |     { | 
|---|
| 46 |     public: | 
|---|
| 47 |         DebugNormal() : DebugLines(){}; | 
|---|
| 48 |         ~DebugNormal(){}; | 
|---|
| 49 |  | 
|---|
| 50 |         void update (Contact * const contact); | 
|---|
| 51 |     }; | 
|---|
| 52 |  | 
|---|
| 53 |     class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable | 
|---|
| 54 |     { | 
|---|
| 55 |     public: | 
|---|
| 56 |         enum HorizontalAlignment    {H_LEFT, H_CENTER}; | 
|---|
| 57 |         enum VerticalAlignment      {V_BELOW, V_ABOVE}; | 
|---|
| 58 |         /******************************** public methods ******************************/ | 
|---|
| 59 |     public: | 
|---|
| 60 |         DebugContactText(const Ogre::String &name,  | 
|---|
| 61 |                          Ogre::SceneNode *node, | 
|---|
| 62 |                          const Ogre::String &caption = "",  | 
|---|
| 63 |                          const Ogre::String &fontName = "BlueHighway",  | 
|---|
| 64 |                          int charHeight = 32,  | 
|---|
| 65 |                          const Ogre::ColourValue &color = Ogre::ColourValue::White); | 
|---|
| 66 |  | 
|---|
| 67 |  | 
|---|
| 68 |          ~DebugContactText(); | 
|---|
| 69 |  | 
|---|
| 70 |         // Set settings | 
|---|
| 71 |         void    setPosition(const Ogre::Vector3 &pos); | 
|---|
| 72 |  | 
|---|
| 73 |         void    setFontName(const Ogre::String &fontName); | 
|---|
| 74 |         void    setCaption(const Ogre::String &caption); | 
|---|
| 75 |         void    setColor(const Ogre::ColourValue &color); | 
|---|
| 76 |         void    setCharacterHeight(unsigned int height); | 
|---|
| 77 |         void    setSpaceWidth(unsigned int width); | 
|---|
| 78 |         void    setTextAlignment(const HorizontalAlignment& horizontalAlignment,  | 
|---|
| 79 |                                 const VerticalAlignment& verticalAlignment); | 
|---|
| 80 |         void    setAdditionalHeight( Ogre::Real height ); | 
|---|
| 81 |         void    showOnTop(bool show=true); | 
|---|
| 82 |  | 
|---|
| 83 |         // Get settings | 
|---|
| 84 |         const   Ogre::String          &getFontName() const {return mFontName;} | 
|---|
| 85 |         const   Ogre::String          &getCaption() const {return mCaption;} | 
|---|
| 86 |         const   Ogre::ColourValue     &getColor() const {return mColor;} | 
|---|
| 87 |  | 
|---|
| 88 |  | 
|---|
| 89 |         unsigned int    getCharacterHeight() const {return mCharHeight;} | 
|---|
| 90 |         unsigned int    getSpaceWidth() const {return mSpaceWidth;} | 
|---|
| 91 |         Ogre::Real                  getAdditionalHeight() const {return mAdditionalHeight;} | 
|---|
| 92 |         bool                    getShowOnTop() const {return mOnTop;} | 
|---|
| 93 |         Ogre::AxisAlignedBox            GetAABB(void) { return mAABB; } | 
|---|
| 94 |                  | 
|---|
| 95 | #if OGRE_VERSION >= ((1 << 16) | (5 << 8)) | 
|---|
| 96 |                 virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false){} | 
|---|
| 97 | #endif | 
|---|
| 98 |  | 
|---|
| 99 |         /******************************** protected methods and overload **************/ | 
|---|
| 100 |     protected: | 
|---|
| 101 |  | 
|---|
| 102 |         // from OgreOdeDebugContact, create the object | 
|---|
| 103 |         void    _setupGeometry(); | 
|---|
| 104 |         void    _updateColors(); | 
|---|
| 105 |  | 
|---|
| 106 |         // from MovableObject | 
|---|
| 107 |         void                            getWorldTransforms(Ogre::Matrix4 *xform) const; | 
|---|
| 108 |         Ogre::Real                      getBoundingRadius(void) const {return mRadius;}; | 
|---|
| 109 |         Ogre::Real                      getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;}; | 
|---|
| 110 | #if OGRE_VERSION < ((1 << 16) | (5 << 8)) | 
|---|
| 111 |         const   Ogre::Quaternion        &getWorldOrientation() const; | 
|---|
| 112 |         const   Ogre::Vector3           &getWorldPosition() const; | 
|---|
| 113 | #else | 
|---|
| 114 |         const   Ogre::Quaternion        &_getDerivedOrientation(void) const; | 
|---|
| 115 |         const   Ogre::Vector3           &_getDerivedPosition(void) const; | 
|---|
| 116 | #endif | 
|---|
| 117 |         const   Ogre::AxisAlignedBox    &getBoundingBox(void) const {return mAABB;}; | 
|---|
| 118 |         const   Ogre::String            &getName(void) const {return mName;}; | 
|---|
| 119 |         const   Ogre::String            &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;}; | 
|---|
| 120 |  | 
|---|
| 121 |         void                            _notifyCurrentCamera(Ogre::Camera *cam); | 
|---|
| 122 |         void                            _updateRenderQueue(Ogre::RenderQueue* queue); | 
|---|
| 123 |  | 
|---|
| 124 |         // from renderable | 
|---|
| 125 |         void                            getRenderOperation(Ogre::RenderOperation &op); | 
|---|
| 126 |         const   Ogre::MaterialPtr       &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;}; | 
|---|
| 127 |         const   Ogre::LightList         &getLights(void) const {return mLList;}; | 
|---|
| 128 |  | 
|---|
| 129 |         /******************************** OgreOdeDebugContact data ****************************/ | 
|---|
| 130 |    | 
|---|
| 131 |  | 
|---|
| 132 |     protected: | 
|---|
| 133 |         Ogre::String                    mFontName; | 
|---|
| 134 |         Ogre::String                    mType; | 
|---|
| 135 |         Ogre::String                    mName; | 
|---|
| 136 |         Ogre::String                    mCaption; | 
|---|
| 137 |         HorizontalAlignment         mHorizontalAlignment; | 
|---|
| 138 |         VerticalAlignment           mVerticalAlignment; | 
|---|
| 139 |  | 
|---|
| 140 |         Ogre::ColourValue               mColor; | 
|---|
| 141 |         Ogre::RenderOperation   mRenderOp; | 
|---|
| 142 |         Ogre::AxisAlignedBox    mAABB; | 
|---|
| 143 |         Ogre::LightList             mLList; | 
|---|
| 144 |  | 
|---|
| 145 |         unsigned int                    mCharHeight; | 
|---|
| 146 |         unsigned int                    mSpaceWidth; | 
|---|
| 147 |  | 
|---|
| 148 |         bool                            mNeedUpdate; | 
|---|
| 149 |         bool                            mUpdateColors; | 
|---|
| 150 |         bool                            mOnTop; | 
|---|
| 151 |  | 
|---|
| 152 |         Ogre::Real                          mTimeUntilNextToggle; | 
|---|
| 153 |         Ogre::Real                          mRadius; | 
|---|
| 154 |         Ogre::Real              mAdditionalHeight; | 
|---|
| 155 |  | 
|---|
| 156 |         Ogre::Camera                    *mpCam; | 
|---|
| 157 |         Ogre::RenderWindow          *mpWin; | 
|---|
| 158 |         Ogre::Font                          *mpFont; | 
|---|
| 159 |         Ogre::MaterialPtr               mpMaterial; | 
|---|
| 160 |         Ogre::MaterialPtr               mpBackgroundMaterial; | 
|---|
| 161 |  | 
|---|
| 162 |         Ogre::SceneNode         *mNode; | 
|---|
| 163 |     }; | 
|---|
| 164 | } | 
|---|
| 165 |  | 
|---|
| 166 | #endif | 
|---|
| 167 |  | 
|---|