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