RigsofRods
Soft-body Physics Simulation
MovableText.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5 
6  For more information, see http://www.rigsofrods.org/
7 
8  Rigs of Rods is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License version 3, as
10  published by the Free Software Foundation.
11 
12  Rigs of Rods is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
25 
26 #pragma once
27 
28 #include "Application.h"
29 
30 #include <Ogre.h>
31 #include <Overlay/OgreFontManager.h>
32 
33 #include <OgreUTFString.h>
34 namespace RoR {
35 
38 
39 class MovableText : public Ogre::MovableObject, public Ogre::Renderable
40 {
41  /******************************** MovableText data ****************************/
42 public:
45 
46 protected:
47  Ogre::UTFString mFontName;
48  Ogre::UTFString mType;
49  Ogre::String mName;
50  Ogre::UTFString mCaption;
53 
54  Ogre::ColourValue mColor;
55  Ogre::RenderOperation mRenderOp;
56  Ogre::AxisAlignedBox mAABB;
57  Ogre::LightList mLList;
58 
59  Ogre::Real mCharHeight;
60  Ogre::Real mSpaceWidth;
61 
64  bool mOnTop;
65 
67  Ogre::Real mRadius;
68  Ogre::Real mAdditionalHeight;
69 
70  Ogre::Camera *mpCam;
71  Ogre::RenderWindow *mpWin;
72  Ogre::Font *mpFont;
73  Ogre::MaterialPtr mpMaterial;
74  Ogre::MaterialPtr mpBackgroundMaterial;
75 
76  /******************************** public methods ******************************/
77 public:
78  MovableText(const Ogre::UTFString &name, const Ogre::UTFString &caption,
79  const Ogre::UTFString &fontName = "highcontrast_black",
80  Ogre::Real charHeight = 1.0, const Ogre::ColourValue &color = Ogre::ColourValue::Black);
81  virtual ~MovableText();
82 
83  // Add to build on Shoggoth:
84  virtual void visitRenderables(Ogre::Renderable::Visitor* visitor, bool debugRenderables = false) {};
85 
86  // Set settings
87  void setFontName(const Ogre::UTFString &fontName);
88  void setCaption(const Ogre::UTFString &caption);
89  void setColor(const Ogre::ColourValue &color);
90  void setCharacterHeight(Ogre::Real height);
91  void setSpaceWidth(Ogre::Real width);
92  void setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment);
93  void setAdditionalHeight(Ogre::Real height );
94  void showOnTop(bool show=true);
95 
96  // Get settings
97  const Ogre::UTFString &getFontName() const {return mFontName;}
98  const Ogre::UTFString &getCaption() const {return mCaption;}
99  const Ogre::ColourValue &getColor() const {return mColor;}
100 
101  Ogre::uint getCharacterHeight() const {return (Ogre::uint) mCharHeight;}
102  Ogre::uint getSpaceWidth() const {return (Ogre::uint) mSpaceWidth;}
103  Ogre::Real getAdditionalHeight() const {return mAdditionalHeight;}
104  bool getShowOnTop() const {return mOnTop;}
105  Ogre::AxisAlignedBox GetAABB(void) { return mAABB; }
106 
107  /******************************** protected methods and overload **************/
108 protected:
109 
110  // from MovableText, create the object
111  void _setupGeometry();
112  void _updateColors();
113 
114  // from MovableObject
115  void getWorldTransforms(Ogre::Matrix4 *xform) const;
116  Ogre::Real getBoundingRadius(void) const {return mRadius;};
117  Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const {return 0;};
118  const Ogre::Quaternion &getWorldOrientation(void) const;
119  const Ogre::Vector3 &getWorldPosition(void) const;
120  const Ogre::AxisAlignedBox &getBoundingBox(void) const {return mAABB;};
121  const Ogre::String &getName(void) const {return mName;};
122  const Ogre::String &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
123 
124  void _notifyCurrentCamera(Ogre::Camera *cam);
125  void _updateRenderQueue(Ogre::RenderQueue* queue);
126 
127  // from renderable
128  void getRenderOperation(Ogre::RenderOperation &op);
129  const Ogre::MaterialPtr &getMaterial(void) const {ROR_ASSERT(!mpMaterial.isNull());return mpMaterial;};
130  const Ogre::LightList &getLights(void) const {return mLList;};
131 };
132 
134 
135 } // namespace
136 
RoR::MovableText::setTextAlignment
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
Definition: MovableText.cpp:144
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
RoR::MovableText::setColor
void setColor(const Ogre::ColourValue &color)
Definition: MovableText.cpp:117
RoR::MovableText::mpBackgroundMaterial
Ogre::MaterialPtr mpBackgroundMaterial
Definition: MovableText.h:74
RoR::MovableText::setCaption
void setCaption(const Ogre::UTFString &caption)
Definition: MovableText.cpp:108
RoR::MovableText::mColor
Ogre::ColourValue mColor
Definition: MovableText.h:54
RoR::MovableText::visitRenderables
virtual void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables=false)
Definition: MovableText.h:84
RoR::MovableText::GetAABB
Ogre::AxisAlignedBox GetAABB(void)
Definition: MovableText.h:105
RoR::MovableText::H_CENTER
@ H_CENTER
Definition: MovableText.h:43
RoR::MovableText::mSpaceWidth
Ogre::Real mSpaceWidth
Definition: MovableText.h:60
RoR::MovableText::getBoundingBox
const Ogre::AxisAlignedBox & getBoundingBox(void) const
Definition: MovableText.h:120
RoR::MovableText::getSpaceWidth
Ogre::uint getSpaceWidth() const
Definition: MovableText.h:102
RoR::MovableText::showOnTop
void showOnTop(bool show=true)
Definition: MovableText.cpp:167
RoR::MovableText::setSpaceWidth
void setSpaceWidth(Ogre::Real width)
Definition: MovableText.cpp:135
RoR::MovableText::mVerticalAlignment
VerticalAlignment mVerticalAlignment
Definition: MovableText.h:52
RoR::MovableText::mpCam
Ogre::Camera * mpCam
Definition: MovableText.h:70
RoR::MovableText::getAdditionalHeight
Ogre::Real getAdditionalHeight() const
Definition: MovableText.h:103
RoR::MovableText::setFontName
void setFontName(const Ogre::UTFString &fontName)
Definition: MovableText.cpp:73
RoR::MovableText::getWorldPosition
const Ogre::Vector3 & getWorldPosition(void) const
Definition: MovableText.cpp:488
RoR::MovableText::mCharHeight
Ogre::Real mCharHeight
Definition: MovableText.h:59
RoR::MovableText::mLList
Ogre::LightList mLList
Definition: MovableText.h:57
RoR::MovableText::getLights
const Ogre::LightList & getLights(void) const
Definition: MovableText.h:130
RoR::MovableText::mFontName
Ogre::UTFString mFontName
Definition: MovableText.h:47
RoR::MovableText::mpWin
Ogre::RenderWindow * mpWin
Definition: MovableText.h:71
RoR::MovableText::mUpdateColors
bool mUpdateColors
Definition: MovableText.h:63
RoR::MovableText::getSquaredViewDepth
Ogre::Real getSquaredViewDepth(const Ogre::Camera *cam) const
Definition: MovableText.h:117
RoR::MovableText::getCharacterHeight
Ogre::uint getCharacterHeight() const
Definition: MovableText.h:101
RoR::MovableText
Definition: MovableText.h:39
RoR::MovableText::MovableText
MovableText(const Ogre::UTFString &name, const Ogre::UTFString &caption, const Ogre::UTFString &fontName="highcontrast_black", Ogre::Real charHeight=1.0, const Ogre::ColourValue &color=Ogre::ColourValue::Black)
Definition: MovableText.cpp:37
RoR::MovableText::getRenderOperation
void getRenderOperation(Ogre::RenderOperation &op)
Definition: MovableText.cpp:517
RoR::MovableText::getWorldOrientation
const Ogre::Quaternion & getWorldOrientation(void) const
Definition: MovableText.cpp:482
RoR::MovableText::mAABB
Ogre::AxisAlignedBox mAABB
Definition: MovableText.h:56
RoR::MovableText::mpMaterial
Ogre::MaterialPtr mpMaterial
Definition: MovableText.h:73
RoR::MovableText::getWorldTransforms
void getWorldTransforms(Ogre::Matrix4 *xform) const
Definition: MovableText.cpp:494
RoR::MovableText::mOnTop
bool mOnTop
Definition: MovableText.h:64
RoR::MovableText::_setupGeometry
void _setupGeometry()
Definition: MovableText.cpp:178
Application.h
Central state/object manager and communications hub.
RoR::MovableText::mCaption
Ogre::UTFString mCaption
Definition: MovableText.h:50
RoR::MovableText::getMaterial
const Ogre::MaterialPtr & getMaterial(void) const
Definition: MovableText.h:129
RoR::MovableText::mRenderOp
Ogre::RenderOperation mRenderOp
Definition: MovableText.h:55
RoR::MovableText::V_BELOW
@ V_BELOW
Definition: MovableText.h:44
RoR::MovableText::mType
Ogre::UTFString mType
Definition: MovableText.h:48
RoR::MovableText::VerticalAlignment
VerticalAlignment
Definition: MovableText.h:44
RoR::MovableText::mName
Ogre::String mName
Definition: MovableText.h:49
RoR::MovableText::mpFont
Ogre::Font * mpFont
Definition: MovableText.h:72
RoR::MovableText::getColor
const Ogre::ColourValue & getColor() const
Definition: MovableText.h:99
RoR::MovableText::getFontName
const Ogre::UTFString & getFontName() const
Definition: MovableText.h:97
RoR::MovableText::H_LEFT
@ H_LEFT
Definition: MovableText.h:43
RoR::MovableText::setCharacterHeight
void setCharacterHeight(Ogre::Real height)
Definition: MovableText.cpp:126
RoR::MovableText::_updateColors
void _updateColors()
Definition: MovableText.cpp:462
RoR::MovableText::getMovableType
const Ogre::String & getMovableType(void) const
Definition: MovableText.h:122
RoR::MovableText::HorizontalAlignment
HorizontalAlignment
Definition: MovableText.h:43
RoR::MovableText::mNeedUpdate
bool mNeedUpdate
Definition: MovableText.h:62
RoR::MovableText::~MovableText
virtual ~MovableText()
Definition: MovableText.cpp:67
RoR::MovableText::_updateRenderQueue
void _updateRenderQueue(Ogre::RenderQueue *queue)
Definition: MovableText.cpp:534
RoR::MovableText::mHorizontalAlignment
HorizontalAlignment mHorizontalAlignment
Definition: MovableText.h:51
RoR::MovableText::_notifyCurrentCamera
void _notifyCurrentCamera(Ogre::Camera *cam)
Definition: MovableText.cpp:529
RoR::MovableText::setAdditionalHeight
void setAdditionalHeight(Ogre::Real height)
Definition: MovableText.cpp:158
RoR::MovableText::mRadius
Ogre::Real mRadius
Definition: MovableText.h:67
RoR::MovableText::getBoundingRadius
Ogre::Real getBoundingRadius(void) const
Definition: MovableText.h:116
RoR::MovableText::getName
const Ogre::String & getName(void) const
Definition: MovableText.h:121
RoR
Definition: AppContext.h:36
RoR::MovableText::mAdditionalHeight
Ogre::Real mAdditionalHeight
Definition: MovableText.h:68
RoR::MovableText::mTimeUntilNextToggle
Ogre::Real mTimeUntilNextToggle
Definition: MovableText.h:66
RoR::MovableText::getShowOnTop
bool getShowOnTop() const
Definition: MovableText.h:104
RoR::MovableText::V_ABOVE
@ V_ABOVE
Definition: MovableText.h:44
RoR::MovableText::getCaption
const Ogre::UTFString & getCaption() const
Definition: MovableText.h:98