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(const std::string &name,
00045 const Ogre::UTFString &text,
00046 const std::string fontName = "Arial",
00047 float charHeight = 1.0,
00048 const Ogre::ColourValue &color = Ogre::ColourValue::White);
00050 public: virtual ~MovableText();
00051
00053 public: void SetFontName(const std::string &font);
00054
00056 public: const std::string &GetFont() const;
00057
00059 public: void SetText(const Ogre::UTFString & caption);
00060
00062 public: const Ogre::UTFString & GetText() const;
00063
00065 public: void SetColor(const Ogre::ColourValue & color);
00066
00068 public: const Ogre::ColourValue & GetColor() const;
00069
00071 public: void SetCharHeight(float height);
00072
00074 public: float GetCharHeight() const;
00075
00077 public:void SetSpaceWidth(float width);
00078
00080 public: float GetSpaceWidth() const;
00081
00083 public: void SetTextAlignment(const HorizAlign &hAlign,
00084 const VertAlign &vAlign);
00085
00087 public: void SetBaseline(float height);
00088
00090 public: float GetBaseline() const;
00091
00093 public: void SetShowOnTop(bool show);
00094
00096 public: bool GetShowOnTop() const;
00097
00099 public: Ogre::AxisAlignedBox GetAABB();
00100
00102 protected: void _setupGeometry();
00103
00105 protected: void _updateColors();
00106
00108 protected: void getWorldTransforms(Ogre::Matrix4 *xform) const;
00109
00111 protected: float getBoundingRadius() const;
00112
00114 protected: float getSquaredViewDepth(const Ogre::Camera *cam) const;
00115
00116 private: float viewportAspectCoef;
00117
00118 private: std::string fontName;
00119 private: Ogre::UTFString text;
00120
00121 private: HorizAlign horizAlign;
00122 private: VertAlign vertAlign;
00123
00124 private: Ogre::ColourValue color;
00125 private: Ogre::RenderOperation renderOp;
00126 private: Ogre::AxisAlignedBox aabb;
00127 private: Ogre::LightList lightList;
00128
00129 private: float charHeight;
00130 private: float spaceWidth;
00131
00132 private: bool needUpdate;
00133 private: bool updateColors;
00134 private: bool onTop;
00135
00136 private: float radius;
00137 private: float baseline;
00138
00139 private: Ogre::Camera *camera;
00140 private: Ogre::RenderWindow *renderWindow;
00141 private: Ogre::Font *font;
00142 private: Ogre::MaterialPtr material;
00143 private: Ogre::MaterialPtr backgroundMaterial;
00144
00145 private: const Ogre::Quaternion &getWorldOrientation(void) const;
00146 private: const Ogre::Vector3 &getWorldPosition(void) const;
00147 private: const Ogre::AxisAlignedBox &getBoundingBox(void) const;
00148
00149 private: const Ogre::String &getMovableType() const;
00150
00151 private: void _notifyCurrentCamera(Ogre::Camera *cam);
00152 private: void _updateRenderQueue(Ogre::RenderQueue* queue);
00153
00155 protected: void getRenderOperation(Ogre::RenderOperation &op);
00156
00158 protected: const Ogre::MaterialPtr &getMaterial(void) const;
00159
00161 protected: const Ogre::LightList &getLights(void) const;
00162
00163 };
00164
00165 #endif