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 }
58 
59 namespace rviz
60 {
61 
62 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
63 {
64  /******************************** MovableText data ****************************/
65 public:
67  {
68  H_LEFT, H_CENTER
69  };
71  {
72  V_BELOW, V_ABOVE, V_CENTER
73  };
74 
75 protected:
76  Ogre::String mFontName;
77  Ogre::String mType;
78  Ogre::String mName;
79  Ogre::String mCaption;
82 
83  Ogre::ColourValue mColor;
84  Ogre::RenderOperation mRenderOp;
85  Ogre::AxisAlignedBox mAABB;
86  Ogre::LightList mLList;
87 
88  Ogre::Real mCharHeight;
89  Ogre::Real mLineSpacing;
90  Ogre::Real mSpaceWidth;
91 
94  bool mOnTop;
95 
97  Ogre::Real mRadius;
98 
99  Ogre::Vector3 mGlobalTranslation;
100  Ogre::Vector3 mLocalTranslation;
101 
102  Ogre::Camera *mpCam;
103  Ogre::RenderWindow *mpWin;
104  Ogre::Font *mpFont;
105  Ogre::MaterialPtr mpMaterial;
106  Ogre::MaterialPtr mpBackgroundMaterial;
107 
108  /******************************** public methods ******************************/
109 public:
110  MovableText(
111  const Ogre::String &caption,
112  const Ogre::String &fontName = "Liberation Sans",
113  Ogre::Real charHeight = 1.0,
114  const Ogre::ColourValue &color = Ogre::ColourValue::White);
115  virtual ~MovableText();
116 
117 #if (OGRE_VERSION_MAJOR >= 1 && OGRE_VERSION_MINOR >= 6)
118  virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false);
119 #endif
120 
121  // Set settings
122  void setFontName(const Ogre::String &fontName);
123  void setCaption(const Ogre::String &caption);
124  void setColor(const Ogre::ColourValue &color);
125  void setCharacterHeight(Ogre::Real height);
126  void setLineSpacing(Ogre::Real height);
127  void setSpaceWidth(Ogre::Real width);
128  void setTextAlignment(const HorizontalAlignment& horizontalAlignment,
129  const VerticalAlignment& verticalAlignment);
130  void setGlobalTranslation(Ogre::Vector3 trans);
131  void setLocalTranslation(Ogre::Vector3 trans);
132  void showOnTop(bool show = true);
133 
134  // Get settings
135  const Ogre::String &getFontName() const
136  {
137  return mFontName;
138  }
139  const Ogre::String &getCaption() const
140  {
141  return mCaption;
142  }
143  const Ogre::ColourValue &getColor() const
144  {
145  return mColor;
146  }
147 
148  Ogre::Real getCharacterHeight() const
149  {
150  return mCharHeight;
151  }
152  Ogre::Real getSpaceWidth() const
153  {
154  return mSpaceWidth;
155  }
156  Ogre::Vector3 getGlobalTranslation() const
157  {
158  return mGlobalTranslation;
159  }
160  Ogre::Vector3 getLocalTranslation() const
161  {
162  return mLocalTranslation;
163  }
164  bool getShowOnTop() const
165  {
166  return mOnTop;
167  }
168  Ogre::AxisAlignedBox GetAABB(void)
169  {
170  return mAABB;
171  }
172 
173  const Ogre::MaterialPtr &getMaterial(void) const
174  {
175  assert(!mpMaterial.isNull());
176  return mpMaterial;
177  }
178  ;
179 
180 
181  /******************************** protected methods and overload **************/
182 protected:
183 
184  // from MovableText, create the object
185  void _setupGeometry();
186  void _updateColors();
187 
188  // from Ogre::MovableObject
189  void getWorldTransforms(Ogre::Matrix4 *xform) const;
190  Ogre::Real getBoundingRadius(void) const
191  {
192  return mRadius;
193  }
194  ;
195  Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
196  {
197  return 0;
198  }
199  ;
200  const Ogre::Quaternion &getWorldOrientation(void) const;
201  const Ogre::Vector3 &getWorldPosition(void) const;
202  const Ogre::AxisAlignedBox &getBoundingBox(void) const
203  {
204  return mAABB;
205  }
206  ;
207  const Ogre::String &getName(void) const
208  {
209  return mName;
210  }
211  ;
212  const Ogre::String &getMovableType(void) const
213  {
214  static Ogre::String movType = "MovableText";
215  return movType;
216  }
217  ;
218 
219  void _notifyCurrentCamera(Ogre::Camera *cam);
220  void _updateRenderQueue(Ogre::RenderQueue* queue);
221 
222  // from renderable
223  void getRenderOperation(Ogre::RenderOperation &op);
224  const Ogre::LightList &getLights(void) const
225  {
226  return mLList;
227  }
228  ;
229 };
230 
231 }
232 
233 #endif
Ogre::Real mSpaceWidth
Definition: movable_text.h:90
Ogre::String mName
Definition: movable_text.h:78
Ogre::Real mCharHeight
Definition: movable_text.h:88
Ogre::Real getSpaceWidth() const
Definition: movable_text.h:152
Ogre::MaterialPtr mpBackgroundMaterial
Definition: movable_text.h:106
Ogre::RenderOperation mRenderOp
Definition: movable_text.h:84
Ogre::AxisAlignedBox mAABB
Definition: movable_text.h:85
Ogre::Real getCharacterHeight() const
Definition: movable_text.h:148
Ogre::RenderWindow * mpWin
Definition: movable_text.h:103
Ogre::Real mRadius
Definition: movable_text.h:97
VerticalAlignment mVerticalAlignment
Definition: movable_text.h:81
Ogre::Vector3 getGlobalTranslation() const
Definition: movable_text.h:156
Ogre::LightList mLList
Definition: movable_text.h:86
Ogre::Real mLineSpacing
Definition: movable_text.h:89
Ogre::Vector3 mGlobalTranslation
Definition: movable_text.h:99
const Ogre::AxisAlignedBox & getBoundingBox(void) const
Definition: movable_text.h:202
Ogre::Real getBoundingRadius(void) const
Definition: movable_text.h:190
HorizontalAlignment mHorizontalAlignment
Definition: movable_text.h:80
const Ogre::String & getFontName() const
Definition: movable_text.h:135
Ogre::Vector3 getLocalTranslation() const
Definition: movable_text.h:160
Ogre::Camera * mpCam
Definition: movable_text.h:102
const Ogre::String & getMovableType(void) const
Definition: movable_text.h:212
const Ogre::ColourValue & getColor() const
Definition: movable_text.h:143
const Ogre::String & getCaption() const
Definition: movable_text.h:139
Ogre::Font * mpFont
Definition: movable_text.h:104
const Ogre::MaterialPtr & getMaterial(void) const
Definition: movable_text.h:173
Ogre::Real mTimeUntilNextToggle
Definition: movable_text.h:96
Ogre::Vector3 mLocalTranslation
Definition: movable_text.h:100
Ogre::String mFontName
Definition: movable_text.h:76
Ogre::AxisAlignedBox GetAABB(void)
Definition: movable_text.h:168
Ogre::MaterialPtr mpMaterial
Definition: movable_text.h:105
bool getShowOnTop() const
Definition: movable_text.h:164
Ogre::String mType
Definition: movable_text.h:77
const Ogre::String & getName(void) const
Definition: movable_text.h:207
const Ogre::LightList & getLights(void) const
Definition: movable_text.h:224
Ogre::ColourValue mColor
Definition: movable_text.h:83
Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
Definition: movable_text.h:195
Ogre::String mCaption
Definition: movable_text.h:79


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat Apr 27 2019 02:33:41