00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __OgreBulletCollisionsDebugContact_H__
00032 #define __OgreBulletCollisionsDebugContact_H__
00033
00034 #include "OgreBulletCollisionsPreRequisites.h"
00035 #include "Debug/OgreBulletCollisionsDebugLines.h"
00036
00037
00038 namespace OgreBulletCollisions
00039 {
00040
00041 class DebugContact
00042 {
00043 public:
00044 DebugContact(const Ogre::String &name, CollisionsWorld *world);
00045 ~DebugContact();
00046
00047 bool isEnabled () const;
00048 void setEnabled (bool enable);
00049
00050 void update(const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
00051
00052 private:
00053 DebugNormal *_normal;
00054 DebugContactText *_text;
00055 Ogre::Entity *_point;
00056 bool _enabled;
00057 Ogre::String _name;
00058 Ogre::SceneNode *_node;
00059 Ogre::SceneNode *_point_node;
00060 CollisionsWorld *_world;
00061 };
00062
00063
00064 class DebugNormal : public DebugLines
00065 {
00066 public:
00067 DebugNormal() : DebugLines(){};
00068 ~DebugNormal(){};
00069
00070 void update (const Ogre::Vector3 &normal, const Ogre::Vector3 &pt, const Ogre::Real depth);
00071 };
00072
00073
00074 class DebugContactText : public Ogre::MovableObject, public Ogre::Renderable
00075 {
00076 public:
00077 enum HorizontalAlignment {H_LEFT, H_CENTER};
00078 enum VerticalAlignment {V_BELOW, V_ABOVE};
00079
00080 public:
00081 DebugContactText(const Ogre::String &name,
00082 Ogre::SceneNode *node,
00083 const Ogre::String &caption = "",
00084 const Ogre::String &fontName = "BlueHighway",
00085 int charHeight = 32,
00086 const Ogre::ColourValue &color = Ogre::ColourValue::White);
00087
00088
00089 ~DebugContactText();
00090
00091 #if (OGRE_VERSION >= ((1 << 16) | (5 << 8) | 0)) // must have at least shoggoth (1.5.0)
00092 void visitRenderables(Renderable::Visitor* visitor, bool debugRenderables);
00093 #endif
00094
00095 void setPosition(const Ogre::Vector3 &pos);
00096
00097 void setFontName(const Ogre::String &fontName);
00098 void setCaption(const Ogre::String &caption);
00099 void setColor(const Ogre::ColourValue &color);
00100 void setCharacterHeight(unsigned int height);
00101 void setSpaceWidth(unsigned int width);
00102 void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
00103 const VerticalAlignment& verticalAlignment);
00104 void setAdditionalHeight( Ogre::Real height );
00105 void showOnTop(bool show=true);
00106
00107
00108 const Ogre::String &getFontName() const {return mFontName;}
00109 const Ogre::String &getCaption() const {return mCaption;}
00110 const Ogre::ColourValue &getColor() const {return mColor;}
00111
00112 unsigned int getCharacterHeight() const {return mCharHeight;}
00113 unsigned int getSpaceWidth() const {return mSpaceWidth;}
00114 Ogre::Real getAdditionalHeight() const {return mAdditionalHeight;}
00115 bool getShowOnTop() const {return mOnTop;}
00116 Ogre::AxisAlignedBox GetAABB(void) { return mAABB; }
00117
00118
00119 protected:
00120
00121
00122 void _setupGeometry();
00123 void _updateColors();
00124
00125
00126 void getWorldTransforms(Ogre::Matrix4 *xform) const;
00127 Ogre::Real getBoundingRadius(void) const {return mRadius;};
00128 Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
00129 const Ogre::Quaternion &getWorldOrientation(void) const;
00130 const Ogre::Vector3 &getWorldPosition(void) const;
00131 const Ogre::AxisAlignedBox &getBoundingBox(void) const {return mAABB;};
00132 const Ogre::String &getName(void) const {return mName;};
00133 const Ogre::String &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
00134
00135 void _notifyCurrentCamera(Ogre::Camera *cam);
00136 void _updateRenderQueue(Ogre::RenderQueue* queue);
00137
00138
00139 void getRenderOperation(Ogre::RenderOperation &op);
00140 const Ogre::MaterialPtr &getMaterial(void) const {assert(!mpMaterial.isNull());return mpMaterial;};
00141 const Ogre::LightList &getLights(void) const {return mLList;};
00142
00143
00144
00145
00146 protected:
00147 Ogre::String mFontName;
00148 Ogre::String mType;
00149 Ogre::String mName;
00150 Ogre::String mCaption;
00151 HorizontalAlignment mHorizontalAlignment;
00152 VerticalAlignment mVerticalAlignment;
00153
00154 Ogre::ColourValue mColor;
00155 Ogre::RenderOperation mRenderOp;
00156 Ogre::AxisAlignedBox mAABB;
00157 Ogre::LightList mLList;
00158
00159 unsigned int mCharHeight;
00160 unsigned int mSpaceWidth;
00161
00162 bool mNeedUpdate;
00163 bool mUpdateColors;
00164 bool mOnTop;
00165
00166 Ogre::Real mTimeUntilNextToggle;
00167 Ogre::Real mRadius;
00168 Ogre::Real mAdditionalHeight;
00169
00170 Ogre::Camera *mpCam;
00171 Ogre::RenderWindow *mpWin;
00172 Ogre::Font *mpFont;
00173 Ogre::MaterialPtr mpMaterial;
00174 Ogre::MaterialPtr mpBackgroundMaterial;
00175
00176 Ogre::SceneNode *mNode;
00177 };
00178 }
00179
00180 #endif //__OgreBulletCollisionsDebugContact_H__
00181