movable_text.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 // Adapted from: http://www.ogre3d.org/wiki/index.php/MovableText
31 // now: http://www.ogre3d.org/tikiwiki/tiki-index.php?page=MovableText
32 // Original authors:
33 /*
34  * File: MovableText.h
35  *
36  * description: This create create a billboarding object that display a text.
37  *
38  * @author 2003 by cTh see gavocanov@rambler.ru
39  * @update 2006 by barraq see nospam@barraquand.com
40  */
41 
42 #ifndef OGRE_TOOLS_MOVABLE_TEXT_H
43 #define OGRE_TOOLS_MOVABLE_TEXT_H
44 
45 #include <OgreMovableObject.h>
46 #include <OgreRenderable.h>
47 #include <OgreVector3.h>
48 #include <OgreQuaternion.h>
49 #include <OgreSharedPtr.h>
50 
51 
52 namespace Ogre
53 {
54 class RenderQueue;
55 class Camera;
56 class Font;
57 } // namespace Ogre
58 
59 namespace rviz
60 {
61 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
62 {
63  /******************************** MovableText data ****************************/
64 public:
66  {
68  H_CENTER
69  };
71  {
74  V_CENTER
75  };
76 
77 protected:
78  Ogre::String mFontName;
79  Ogre::String mType;
80  Ogre::String mName;
81  Ogre::String mCaption;
84 
85  Ogre::ColourValue mColor;
86  Ogre::RenderOperation mRenderOp;
87  Ogre::AxisAlignedBox mAABB;
88  Ogre::LightList mLList;
89 
90  Ogre::Real mCharHeight;
91  Ogre::Real mLineSpacing;
92  Ogre::Real mSpaceWidth;
93 
96  bool mOnTop;
97 
99  Ogre::Real mRadius;
100 
101  Ogre::Vector3 mGlobalTranslation;
102  Ogre::Vector3 mLocalTranslation;
103 
104  Ogre::Camera* mpCam;
105  Ogre::RenderWindow* mpWin;
106  Ogre::Font* mpFont;
107  Ogre::MaterialPtr mpMaterial;
108  Ogre::MaterialPtr mpBackgroundMaterial;
109 
110  /******************************** public methods ******************************/
111 public:
112  MovableText(const Ogre::String& caption,
113  const Ogre::String& fontName = "Liberation Sans",
114  Ogre::Real charHeight = 1.0,
115  const Ogre::ColourValue& color = Ogre::ColourValue::White);
116  ~MovableText() override;
117 
118 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
119  void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false) override;
120 #endif
121 
122  // Set settings
123  void setFontName(const Ogre::String& fontName);
124  void setCaption(const Ogre::String& caption);
125  void setColor(const Ogre::ColourValue& color);
126  void setCharacterHeight(Ogre::Real height);
127  void setLineSpacing(Ogre::Real height);
128  void setSpaceWidth(Ogre::Real width);
129  void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
130  const VerticalAlignment& verticalAlignment);
131  void setGlobalTranslation(Ogre::Vector3 trans);
132  void setLocalTranslation(Ogre::Vector3 trans);
133  void showOnTop(bool show = true);
134 
135  // Get settings
136  const Ogre::String& getFontName() const
137  {
138  return mFontName;
139  }
140  const Ogre::String& getCaption() const
141  {
142  return mCaption;
143  }
144  const Ogre::ColourValue& getColor() const
145  {
146  return mColor;
147  }
148 
149  Ogre::Real getCharacterHeight() const
150  {
151  return mCharHeight;
152  }
153  Ogre::Real getSpaceWidth() const
154  {
155  return mSpaceWidth;
156  }
157  Ogre::Vector3 getGlobalTranslation() const
158  {
159  return mGlobalTranslation;
160  }
161  Ogre::Vector3 getLocalTranslation() const
162  {
163  return mLocalTranslation;
164  }
165  bool getShowOnTop() const
166  {
167  return mOnTop;
168  }
169  Ogre::AxisAlignedBox GetAABB()
170  {
171  return mAABB;
172  }
173 
174  const Ogre::MaterialPtr& getMaterial() const override
175  {
176  assert(!mpMaterial.isNull());
177  return mpMaterial;
178  }
179 
180 
181  /******************************** protected methods and overload **************/
182 protected:
183  // from MovableText, create the object
184  void _setupGeometry();
185  void _updateColors();
186 
187  // from Ogre::MovableObject
188  void getWorldTransforms(Ogre::Matrix4* xform) const override;
189  Ogre::Real getBoundingRadius() const override
190  {
191  return mRadius;
192  }
193 
194  Ogre::Real getSquaredViewDepth(const Ogre::Camera* /*cam*/) const override
195  {
196  return 0;
197  }
198 
199  const Ogre::Quaternion& getWorldOrientation() const;
200  const Ogre::Vector3& getWorldPosition() const;
201  const Ogre::AxisAlignedBox& getBoundingBox() const override
202  {
203  return mAABB;
204  }
205 
206  const Ogre::String& getName() const override
207  {
208  return mName;
209  }
210 
211  const Ogre::String& getMovableType() const override
212  {
213  static Ogre::String movType = "MovableText";
214  return movType;
215  }
216 
217  void _notifyCurrentCamera(Ogre::Camera* cam) override;
218  void _updateRenderQueue(Ogre::RenderQueue* queue) override;
219 
220  // from renderable
221  void getRenderOperation(Ogre::RenderOperation& op) override;
222  const Ogre::LightList& getLights() const override
223  {
224  return mLList;
225  }
226 };
227 
228 } // namespace rviz
229 
230 #endif
Ogre::Real mSpaceWidth
Definition: movable_text.h:92
Ogre::String mName
Definition: movable_text.h:80
Ogre::Real mCharHeight
Definition: movable_text.h:90
const Ogre::LightList & getLights() const override
Definition: movable_text.h:222
Ogre::MaterialPtr mpBackgroundMaterial
Definition: movable_text.h:108
Ogre::RenderOperation mRenderOp
Definition: movable_text.h:86
Ogre::AxisAlignedBox mAABB
Definition: movable_text.h:87
Ogre::Vector3 getGlobalTranslation() const
Definition: movable_text.h:157
const Ogre::String & getCaption() const
Definition: movable_text.h:140
const Ogre::ColourValue & getColor() const
Definition: movable_text.h:144
const Ogre::String & getFontName() const
Definition: movable_text.h:136
Ogre::RenderWindow * mpWin
Definition: movable_text.h:105
Ogre::Real mRadius
Definition: movable_text.h:99
VerticalAlignment mVerticalAlignment
Definition: movable_text.h:83
const Ogre::AxisAlignedBox & getBoundingBox() const override
Definition: movable_text.h:201
Ogre::LightList mLList
Definition: movable_text.h:88
Ogre::Real mLineSpacing
Definition: movable_text.h:91
Ogre::Vector3 mGlobalTranslation
Definition: movable_text.h:101
HorizontalAlignment mHorizontalAlignment
Definition: movable_text.h:82
Ogre::AxisAlignedBox GetAABB()
Definition: movable_text.h:169
bool getShowOnTop() const
Definition: movable_text.h:165
Ogre::Real getCharacterHeight() const
Definition: movable_text.h:149
Ogre::Camera * mpCam
Definition: movable_text.h:104
Ogre::Real getSpaceWidth() const
Definition: movable_text.h:153
const Ogre::MaterialPtr & getMaterial() const override
Definition: movable_text.h:174
Ogre::Font * mpFont
Definition: movable_text.h:106
Ogre::Vector3 getLocalTranslation() const
Definition: movable_text.h:161
Ogre::Real mTimeUntilNextToggle
Definition: movable_text.h:98
Ogre::Vector3 mLocalTranslation
Definition: movable_text.h:102
Ogre::String mFontName
Definition: movable_text.h:78
Ogre::MaterialPtr mpMaterial
Definition: movable_text.h:107
Ogre::String mType
Definition: movable_text.h:79
const Ogre::String & getName() const override
Definition: movable_text.h:206
Ogre::Real getSquaredViewDepth(const Ogre::Camera *) const override
Definition: movable_text.h:194
Ogre::Real getBoundingRadius() const override
Definition: movable_text.h:189
const Ogre::String & getMovableType() const override
Definition: movable_text.h:211
Ogre::ColourValue mColor
Definition: movable_text.h:85
Ogre::String mCaption
Definition: movable_text.h:81


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24