Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
33namespace RoR {
34
37
38class MovableText : public Ogre::MovableObject, public Ogre::Renderable
39{
40 /******************************** MovableText data ****************************/
41public:
44
45protected:
46 std::string mFontName;
47 std::string mType;
48 Ogre::String mName;
49 std::string mCaption;
52
53 Ogre::ColourValue mColor;
54 Ogre::RenderOperation mRenderOp;
55 Ogre::AxisAlignedBox mAABB;
56 Ogre::LightList mLList;
57
58 Ogre::Real mCharHeight;
59 Ogre::Real mSpaceWidth;
60
63 bool mOnTop;
64
66 Ogre::Real mRadius;
68
69 Ogre::Camera *mpCam;
70 Ogre::RenderWindow *mpWin;
71 Ogre::Font *mpFont;
72 Ogre::MaterialPtr mpMaterial;
73 Ogre::MaterialPtr mpBackgroundMaterial;
74
75 /******************************** public methods ******************************/
76public:
77 MovableText(const std::string &name, const std::string &caption,
78 const std::string &fontName = "highcontrast_black",
79 Ogre::Real charHeight = 1.0, const Ogre::ColourValue &color = Ogre::ColourValue::Black);
80 virtual ~MovableText();
81
82 // Add to build on Shoggoth:
83 virtual void visitRenderables(Ogre::Renderable::Visitor*, bool) override {};
84
85 // Set settings
86 void setFontName(const std::string &fontName);
87 void setCaption(const std::string &caption);
88 void setColor(const Ogre::ColourValue &color);
89 void setCharacterHeight(Ogre::Real height);
90 void setSpaceWidth(Ogre::Real width);
91 void setTextAlignment(const HorizontalAlignment& horizontalAlignment, const VerticalAlignment& verticalAlignment);
92 void setAdditionalHeight(Ogre::Real height );
93 void showOnTop(bool show=true);
94
95 // Get settings
96 const std::string &getFontName() const {return mFontName;}
97 const std::string &getCaption() const {return mCaption;}
98 const Ogre::ColourValue &getColor() const {return mColor;}
99
100 Ogre::uint getCharacterHeight() const {return (Ogre::uint) mCharHeight;}
101 Ogre::uint getSpaceWidth() const {return (Ogre::uint) mSpaceWidth;}
102 Ogre::Real getAdditionalHeight() const {return mAdditionalHeight;}
103 bool getShowOnTop() const {return mOnTop;}
104 Ogre::AxisAlignedBox GetAABB(void) { return mAABB; }
105
106 /******************************** protected methods and overload **************/
107protected:
108
109 // from MovableText, create the object
110 void _setupGeometry();
111 void _updateColors();
112
113 // from MovableObject
114 void getWorldTransforms(Ogre::Matrix4 *xform) const;
115 Ogre::Real getBoundingRadius(void) const {return mRadius;};
116 Ogre::Real getSquaredViewDepth(const Ogre::Camera *) const {return 0;};
117 const Ogre::Quaternion &getWorldOrientation(void) const;
118 const Ogre::Vector3 &getWorldPosition(void) const;
119 const Ogre::AxisAlignedBox &getBoundingBox(void) const {return mAABB;};
120 const Ogre::String &getName(void) const {return mName;};
121 const Ogre::String &getMovableType(void) const {static Ogre::String movType = "MovableText"; return movType;};
122
123 void _notifyCurrentCamera(Ogre::Camera *cam);
124 void _updateRenderQueue(Ogre::RenderQueue* queue);
125
126 // from renderable
127 void getRenderOperation(Ogre::RenderOperation &op);
128 const Ogre::MaterialPtr &getMaterial(void) const {ROR_ASSERT(mpMaterial);return mpMaterial;};
129 const Ogre::LightList &getLights(void) const {return mLList;};
130};
131
133
134} // namespace
135
Central state/object manager and communications hub.
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
bool getShowOnTop() const
virtual void visitRenderables(Ogre::Renderable::Visitor *, bool) override
Definition MovableText.h:83
virtual ~MovableText()
void _notifyCurrentCamera(Ogre::Camera *cam)
const Ogre::String & getMovableType(void) const
const Ogre::MaterialPtr & getMaterial(void) const
Ogre::MaterialPtr mpMaterial
Definition MovableText.h:72
Ogre::Real getAdditionalHeight() const
void setColor(const Ogre::ColourValue &color)
Ogre::LightList mLList
Definition MovableText.h:56
std::string mCaption
Definition MovableText.h:49
std::string mType
Definition MovableText.h:47
Ogre::uint getSpaceWidth() const
Ogre::Real getSquaredViewDepth(const Ogre::Camera *) const
void getRenderOperation(Ogre::RenderOperation &op)
Ogre::Real mAdditionalHeight
Definition MovableText.h:67
const Ogre::LightList & getLights(void) const
Ogre::Font * mpFont
Definition MovableText.h:71
const Ogre::Quaternion & getWorldOrientation(void) const
Ogre::Real mSpaceWidth
Definition MovableText.h:59
Ogre::Real mRadius
Definition MovableText.h:66
void setCharacterHeight(Ogre::Real height)
Ogre::RenderOperation mRenderOp
Definition MovableText.h:54
void showOnTop(bool show=true)
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
VerticalAlignment mVerticalAlignment
Definition MovableText.h:51
void getWorldTransforms(Ogre::Matrix4 *xform) const
void setAdditionalHeight(Ogre::Real height)
Ogre::AxisAlignedBox GetAABB(void)
void _updateRenderQueue(Ogre::RenderQueue *queue)
void setFontName(const std::string &fontName)
const std::string & getCaption() const
Definition MovableText.h:97
Ogre::Camera * mpCam
Definition MovableText.h:69
std::string mFontName
Definition MovableText.h:46
const std::string & getFontName() const
Definition MovableText.h:96
Ogre::uint getCharacterHeight() const
Ogre::String mName
Definition MovableText.h:48
Ogre::ColourValue mColor
Definition MovableText.h:53
Ogre::AxisAlignedBox mAABB
Definition MovableText.h:55
HorizontalAlignment mHorizontalAlignment
Definition MovableText.h:50
Ogre::Real mCharHeight
Definition MovableText.h:58
Ogre::MaterialPtr mpBackgroundMaterial
Definition MovableText.h:73
void setCaption(const std::string &caption)
Ogre::Real mTimeUntilNextToggle
Definition MovableText.h:65
Ogre::Real getBoundingRadius(void) const
const Ogre::ColourValue & getColor() const
Definition MovableText.h:98
void setSpaceWidth(Ogre::Real width)
const Ogre::String & getName(void) const
const Ogre::AxisAlignedBox & getBoundingBox(void) const
const Ogre::Vector3 & getWorldPosition(void) const
Ogre::RenderWindow * mpWin
Definition MovableText.h:70