i6engine  1.0
MovableText.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_GRAPHICS_MOVABLETEXT_H__
26 #define __I6ENGINE_MODULES_GRAPHICS_MOVABLETEXT_H__
27 
29 
30 #include "OGRE/Ogre.h"
31 #include "OGRE/Overlay/OgreOverlay.h"
32 #include "OGRE/Overlay/OgreOverlayContainer.h"
33 
34 namespace i6e {
35 namespace modules {
36 
37  class MovableText : public Ogre::MovableObject, public Ogre::Renderable {
38  public:
41  };
44  };
45 
46  public:
47  MovableText(const Ogre::String & name, const Ogre::String & caption, const Ogre::String & fontName, Ogre::Real charHeight, const Ogre::ColourValue & color);
48  ~MovableText();
49 
50  // Add to build on Shoggoth:
51  void visitRenderables(Ogre::Renderable::Visitor * visitor, bool debugRenderables = false);
52 
53  // Set settings
54  void setFontName(const Ogre::String & fontName);
55  void setCaption(const Ogre::String & caption);
56  void setColor(const Ogre::ColourValue &color);
57  void setCharacterHeight(Ogre::Real height);
58  void setSpaceWidth(Ogre::Real width);
59  void setTextAlignment(const HorizontalAlignment & horizontalAlignment, const VerticalAlignment & verticalAlignment);
60  void setGlobalTranslation(Ogre::Vector3 trans);
61  void setLocalTranslation(Ogre::Vector3 trans);
62  void showOnTop(bool show = true);
63 
64  // Get settings
65  const Ogre::String & getFontName() const {
66  return _fontName;
67  }
68 
69  const Ogre::String & getCaption() const {
70  return _caption;
71  }
72 
73  const Ogre::ColourValue & getColor() const {
74  return _color;
75  }
76 
77  Ogre::Real getCharacterHeight() const {
78  return _charHeight;
79  }
80 
81  Ogre::Real getSpaceWidth() const {
82  return _spaceWidth;
83  }
84 
85  Ogre::Vector3 getGlobalTranslation() const {
86  return _globalTranslation;
87  }
88 
89  Ogre::Vector3 getLocalTranslation() const {
90  return _localTranslation;
91  }
92 
93  bool getShowOnTop() const {
94  return _onTop;
95  }
96 
97  Ogre::AxisAlignedBox GetAABB() {
98  return _AABB;
99  }
100 
101  private:
102  Ogre::String _fontName;
103  Ogre::String _type;
104  Ogre::String _name;
105  Ogre::String _caption;
106  HorizontalAlignment _horizontalAlignment;
107  VerticalAlignment _verticalAlignment;
108 
109  Ogre::ColourValue _color;
110  Ogre::RenderOperation _renderOp;
111  Ogre::AxisAlignedBox _AABB;
112  Ogre::LightList _lightList;
113 
114  Ogre::Real _charHeight;
115  Ogre::Real _spaceWidth;
116 
117  bool _needUpdate;
118  bool _updateColours;
119  bool _onTop;
120 
121  Ogre::Real _timeUntilNextToggle;
122  Ogre::Real _radius;
123 
124  Ogre::Vector3 _globalTranslation;
125  Ogre::Vector3 _localTranslation;
126 
127  Ogre::Camera * _camera;
128  Ogre::RenderWindow * _renderWindow;
129  Ogre::Font * _font;
130  Ogre::MaterialPtr _material;
131  Ogre::MaterialPtr _backgroundMaterial;
132 
133  // from MovableText, create the object
134  void _setupGeometry();
135  void _updateColors();
136 
137  // from MovableObject
138  void getWorldTransforms(Ogre::Matrix4 * xform) const;
139 
140  Ogre::Real getBoundingRadius() const {
141  return _radius;
142  }
143 
144  Ogre::Real getSquaredViewDepth(const Ogre::Camera * cam) const {
145  return 0.0;
146  }
147 
148  const Ogre::Quaternion & getWorldOrientation() const;
149 
150  const Ogre::Vector3 & getWorldPosition() const;
151 
152  const Ogre::AxisAlignedBox & getBoundingBox() const {
153  return _AABB;
154  }
155 
156  const Ogre::String & getName() const {
157  return _name;
158  }
159 
160  const Ogre::String & getMovableType() const {
161  static Ogre::String movType = "MovableText";
162  return movType;
163  }
164 
165  void _notifyCurrentCamera(Ogre::Camera * cam);
166  void _updateRenderQueue(Ogre::RenderQueue * queue);
167 
168  // from renderable
169  void getRenderOperation(Ogre::RenderOperation & op);
170 
171  const Ogre::MaterialPtr & getMaterial() const {
172  assert(!_material.isNull());
173  return _material;
174  }
175 
176  const Ogre::LightList & getLights() const {
177  return _lightList;
178  }
179  };
180 
181 } /* namespace modules */
182 } /* namespace i6e */
183 
184 #endif /* __I6ENGINE_MODULES_GRAPHICS_MOVABLETEXT_H__ */
185 
MovableText(const Ogre::String &name, const Ogre::String &caption, const Ogre::String &fontName, Ogre::Real charHeight, const Ogre::ColourValue &color)
void setFontName(const Ogre::String &fontName)
Ogre::Vector3 getLocalTranslation() const
Definition: MovableText.h:89
void setCharacterHeight(Ogre::Real height)
void setLocalTranslation(Ogre::Vector3 trans)
i6e::math::i6eQuaternion Quaternion
const Ogre::String & getCaption() const
Definition: MovableText.h:69
Ogre::Vector3 getGlobalTranslation() const
Definition: MovableText.h:85
void setSpaceWidth(Ogre::Real width)
void showOnTop(bool show=true)
const Ogre::String & getFontName() const
Definition: MovableText.h:65
Ogre::Real getCharacterHeight() const
Definition: MovableText.h:77
void setGlobalTranslation(Ogre::Vector3 trans)
void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables=false)
Ogre::AxisAlignedBox GetAABB()
Definition: MovableText.h:97
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
Ogre::Real getSpaceWidth() const
Definition: MovableText.h:81
void setCaption(const Ogre::String &caption)
void setColor(const Ogre::ColourValue &color)
const Ogre::ColourValue & getColor() const
Definition: MovableText.h:73
bool getShowOnTop() const
Definition: MovableText.h:93