MovableText.hh
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 #ifndef MOVABLETEXT_HH
00029 #define MOVABLETEXT_HH
00030
00031 #include <Ogre.h>
00032 #include <string>
00033
00035 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
00036 {
00038 public: enum HorizAlign {H_LEFT, H_CENTER};
00039
00041 public: enum VertAlign {V_BELOW, V_ABOVE};
00042
00044 public: MovableText();
00045
00047 public: virtual ~MovableText();
00048
00050 public: void Load(const std::string &name,
00051 const Ogre::UTFString &text,
00052 const std::string &fontName = "Arial",
00053 float charHeight = 1.0,
00054 const Ogre::ColourValue &color = Ogre::ColourValue::White);
00055
00057 public: void SetFontName(const std::string &font);
00058
00060 public: const std::string &GetFont() const;
00061
00063 public: void SetText(const Ogre::UTFString & caption);
00064
00066 public: const Ogre::UTFString & GetText() const;
00067
00069 public: void SetColor(const Ogre::ColourValue & color);
00070
00072 public: const Ogre::ColourValue & GetColor() const;
00073
00075 public: void SetCharHeight(float height);
00076
00078 public: float GetCharHeight() const;
00079
00081 public:void SetSpaceWidth(float width);
00082
00084 public: float GetSpaceWidth() const;
00085
00087 public: void SetTextAlignment(const HorizAlign &hAlign,
00088 const VertAlign &vAlign);
00089
00091 public: void SetBaseline(float height);
00092
00094 public: float GetBaseline() const;
00095
00097 public: void SetShowOnTop(bool show);
00098
00100 public: bool GetShowOnTop() const;
00101
00103 public: Ogre::AxisAlignedBox GetAABB();
00104
00106 protected: void _setupGeometry();
00107
00109 protected: void _updateColors();
00110
00112 protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
00113
00115 protected: float getBoundingRadius() const;
00116
00118 protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
00119
00120 private: float viewportAspectCoef;
00121
00122 private: std::string fontName;
00123 private: Ogre::UTFString text;
00124
00125 private: HorizAlign horizAlign;
00126 private: VertAlign vertAlign;
00127
00128 private: Ogre::ColourValue color;
00129 private: Ogre::RenderOperation renderOp;
00130 private: Ogre::AxisAlignedBox aabb;
00131 private: Ogre::LightList lightList;
00132
00133 private: float charHeight;
00134 private: float spaceWidth;
00135
00136 private: bool needUpdate;
00137 private: bool updateColors;
00138 private: bool onTop;
00139
00140 private: float radius;
00141 private: float baseline;
00142
00143 private: Ogre::Camera *camera;
00144 private: Ogre::RenderWindow *renderWindow;
00145 private: Ogre::Font *font;
00146 private: Ogre::MaterialPtr material;
00147 private: Ogre::MaterialPtr backgroundMaterial;
00148
00149 private: const Ogre::Quaternion &getWorldOrientation(void) const;
00150 private: const Ogre::Vector3 &getWorldPosition(void) const;
00151 private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
00152
00153 private: const Ogre::String &getMovableType() const;
00154
00155 private: void _notifyCurrentCamera(Ogre::Camera *cam);
00156 private: void _updateRenderQueue(Ogre::RenderQueue* queue);
00157
00159 protected: void getRenderOperation(Ogre::RenderOperation &op);
00160
00162 protected: const Ogre::MaterialPtr &getMaterial(void) const;
00163
00165 protected: const Ogre::LightList &getLights(void) const;
00166
00167 };
00168
00169 #endif