Annwvyn::Ann3DTextPlane Class Reference

Abstract movable implementation : Manual plane object with some text rendered on it. More...

#include <Ann3DTextPlane.hpp>

Inheritance diagram for Annwvyn::Ann3DTextPlane:
Collaboration diagram for Annwvyn::Ann3DTextPlane:

Public Types

enum  TextAlign { ALIGN_LEFT = 'l', ALIGN_CENTER = 'c', ALIGN_RIGHT = 'r' }
 Text alignment flag. More...
 

Public Member Functions

 Ann3DTextPlane (const float &w, const float &h, const std::string &caption="", const int &size=128, const float &resolution=96.0f, const std::string &font="defaultFont", const std::string &fontTTF="VeraMono.ttf")
 
 ~Ann3DTextPlane ()
 Class destructor. More...
 
void setCaption (const std::string &newCaption)
 
void setAutoUpdate (bool state)
 
void setTextColor (const AnnColor &color)
 
void setBackgroundColor (const AnnColor &color)
 Change the background color. Alpha blending works. More...
 
void update ()
 Call text re-render (if needed) More...
 
void setPosition (AnnVect3 p) override
 Set the position of the plane. More...
 
void setOrientation (AnnQuaternion q) override
 Set the orient of the plane. More...
 
void setTextAlign (TextAlign talign)
 Set the text alignment mode. More...
 
AnnVect3 getPosition () override
 Get the position of the plane. More...
 
AnnQuaternion getOrientation () override
 Get the orientation. More...
 
void setMargin (float margin)
 
void setBackgroundImage (const std::string &imgName)
 
- Public Member Functions inherited from Annwvyn::AnnAbstractMovable
virtual ~AnnAbstractMovable ()=default
 
- Public Member Functions inherited from Annwvyn::AnnAbstractTranslatable
virtual ~AnnAbstractTranslatable ()=default
 

Private Member Functions

void createFont (const int &size)
 Create the font. More...
 
void createPlane ()
 Create the plane geometry. More...
 
void renderText ()
 Render the text. More...
 
void clearTexture ()
 Fill the texture with transparent black. More...
 
void calculateVerticesForPlaneSize ()
 Calculate the actual vertex coordinates for the plane geometry. More...
 
void autoUpdateCheck ()
 Check if auto-update is on. If so, call update. More...
 
void generateMaterialName ()
 Generate a random material name. More...
 
void createMaterial ()
 Create the material. More...
 

Private Attributes

Ogre::ManualObject * renderPlane
 The actual 3D text plane. More...
 
Ogre::SceneNode * node
 Node where the object is attached. More...
 
Ogre::TexturePtr texture
 Textures. More...
 
Ogre::TexturePtr bgTexture
 
std::string fontName
 Font configuration. More...
 
std::string fontTTF
 
std::string caption
 Text to display. More...
 
bool needUpdating
 If true, next update call will update. More...
 
const size_t materialNameLen = 30
 Length of the random material name. More...
 
std::string materialName
 Name of the material. More...
 
std::array< AnnVect3, 4 > vertices
 Vertex buffer. More...
 
const std::array< AnnVect2, 4 > textureCoords = { { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } } }
 Static texture coordinates. More...
 
float width
 Various floats for size computation. More...
 
float height
 
float resolutionFactor
 
float xOffset
 
float yOffset
 
Ogre::FontPtr font
 The font from the Ogre::FontManager. More...
 
AnnColor textColor
 Colors. More...
 
AnnColor bgColor
 
TextAlign align
 Text alignment. More...
 
bool autoUpdate
 if true, will update each time something is updated More...
 
int fontSize
 Size of the font, in points. More...
 
const float dpi2dpm = 0.0254f
 Static conversions factor between Dot Per Inch and Dot Per Meters. More...
 
float dpi
 DPI resolution of the rendered fonts. More...
 
unsigned int pixelMargin
 Margin in pixels. More...
 
float margin
 Margin in meters. More...
 
bool useImageAsBackground
 Will use an image as background. More...
 

Additional Inherited Members

Detailed Description

Abstract movable implementation : Manual plane object with some text rendered on it.

Definition at line 16 of file Ann3DTextPlane.hpp.

Member Enumeration Documentation

◆ TextAlign

Text alignment flag.

Enumerator
ALIGN_LEFT 
ALIGN_CENTER 
ALIGN_RIGHT 

Definition at line 20 of file Ann3DTextPlane.hpp.

Constructor & Destructor Documentation

◆ Ann3DTextPlane()

Ann3DTextPlane::Ann3DTextPlane ( const float &  w,
const float &  h,
const std::string caption = "",
const int &  size = 128,
const float &  resolution = 96.0f,
const std::string font = "defaultFont",
const std::string fontTTF = "VeraMono.ttf" 
)

Construct a 3D text plane. Need to provide a caption to auto render text

Parameters
wWidth in meter
hHeight in meter
captionText to print on the plane
sizeCharacter size in typographic point
resolutionCharacter "print" resolution in DPI. This will influence the texture resolution
fontYour name of the font. To reuse a font configuration
fontTTFName of the TTF file known by the resource manager

Definition at line 54 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ ~Ann3DTextPlane()

Ann3DTextPlane::~Ann3DTextPlane ( )

Class destructor.

Definition at line 105 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ autoUpdateCheck()

void Ann3DTextPlane::autoUpdateCheck ( )
private

Check if auto-update is on. If so, call update.

Definition at line 203 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateVerticesForPlaneSize()

void Ann3DTextPlane::calculateVerticesForPlaneSize ( )
private

Calculate the actual vertex coordinates for the plane geometry.

Definition at line 138 of file Ann3DTextPlane.cpp.

Here is the caller graph for this function:

◆ clearTexture()

void Ann3DTextPlane::clearTexture ( )
private

Fill the texture with transparent black.

Definition at line 292 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFont()

void Ann3DTextPlane::createFont ( const int &  size)
private

Create the font.

Definition at line 18 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createMaterial()

void Ann3DTextPlane::createMaterial ( )
private

Create the material.

Definition at line 162 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ createPlane()

void Ann3DTextPlane::createPlane ( )
private

Create the plane geometry.

Definition at line 30 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateMaterialName()

void Ann3DTextPlane::generateMaterialName ( )
private

Generate a random material name.

Definition at line 208 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrientation()

AnnQuaternion Ann3DTextPlane::getOrientation ( )
overridevirtual

Get the orientation.

Implements Annwvyn::AnnAbstractMovable.

Definition at line 255 of file Ann3DTextPlane.cpp.

◆ getPosition()

AnnVect3 Ann3DTextPlane::getPosition ( )
overridevirtual

Get the position of the plane.

Implements Annwvyn::AnnAbstractTranslatable.

Definition at line 249 of file Ann3DTextPlane.cpp.

◆ renderText()

void Ann3DTextPlane::renderText ( )
private

Render the text.

Definition at line 276 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAutoUpdate()

void Ann3DTextPlane::setAutoUpdate ( bool  state)

The plane will auto-re-render at changes if set to true

Parameters
stateIf true, the text will be updated each time you change something

Definition at line 133 of file Ann3DTextPlane.cpp.

◆ setBackgroundColor()

void Ann3DTextPlane::setBackgroundColor ( const AnnColor color)

Change the background color. Alpha blending works.

Definition at line 220 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ setBackgroundImage()

void Ann3DTextPlane::setBackgroundImage ( const std::string imgName)

Set background image

Parameters
imgNamename of an image loaded in the resource manager

Definition at line 270 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ setCaption()

void Ann3DTextPlane::setCaption ( const std::string newCaption)

Set or change the caption

Parameters
newCaptionthe new text to display

Definition at line 126 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ setMargin()

void Ann3DTextPlane::setMargin ( float  margin)

Set margin

Parameters
marginMargin in meters

Definition at line 261 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ setOrientation()

void Ann3DTextPlane::setOrientation ( AnnQuaternion  q)
overridevirtual

Set the orient of the plane.

Implements Annwvyn::AnnAbstractMovable.

Definition at line 239 of file Ann3DTextPlane.cpp.

◆ setPosition()

void Ann3DTextPlane::setPosition ( AnnVect3  p)
overridevirtual

Set the position of the plane.

Implements Annwvyn::AnnAbstractTranslatable.

Definition at line 234 of file Ann3DTextPlane.cpp.

◆ setTextAlign()

void Ann3DTextPlane::setTextAlign ( TextAlign  talign)

Set the text alignment mode.

Definition at line 244 of file Ann3DTextPlane.cpp.

◆ setTextColor()

void Ann3DTextPlane::setTextColor ( const AnnColor color)

Change the color

Parameters
colorThe color of the text

Definition at line 213 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:

◆ update()

void Ann3DTextPlane::update ( )

Call text re-render (if needed)

Definition at line 227 of file Ann3DTextPlane.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ align

TextAlign Annwvyn::Ann3DTextPlane::align
private

Text alignment.

Definition at line 143 of file Ann3DTextPlane.hpp.

◆ autoUpdate

bool Annwvyn::Ann3DTextPlane::autoUpdate
private

if true, will update each time something is updated

Definition at line 146 of file Ann3DTextPlane.hpp.

◆ bgColor

AnnColor Annwvyn::Ann3DTextPlane::bgColor
private

Definition at line 140 of file Ann3DTextPlane.hpp.

◆ bgTexture

Ogre::TexturePtr Annwvyn::Ann3DTextPlane::bgTexture
private

Definition at line 110 of file Ann3DTextPlane.hpp.

◆ caption

std::string Annwvyn::Ann3DTextPlane::caption
private

Text to display.

Definition at line 116 of file Ann3DTextPlane.hpp.

◆ dpi

float Annwvyn::Ann3DTextPlane::dpi
private

DPI resolution of the rendered fonts.

Definition at line 155 of file Ann3DTextPlane.hpp.

◆ dpi2dpm

const float Annwvyn::Ann3DTextPlane::dpi2dpm = 0.0254f
private

Static conversions factor between Dot Per Inch and Dot Per Meters.

Definition at line 152 of file Ann3DTextPlane.hpp.

◆ font

Ogre::FontPtr Annwvyn::Ann3DTextPlane::font
private

The font from the Ogre::FontManager.

Definition at line 137 of file Ann3DTextPlane.hpp.

◆ fontName

std::string Annwvyn::Ann3DTextPlane::fontName
private

Font configuration.

Definition at line 113 of file Ann3DTextPlane.hpp.

◆ fontSize

int Annwvyn::Ann3DTextPlane::fontSize
private

Size of the font, in points.

Definition at line 149 of file Ann3DTextPlane.hpp.

◆ fontTTF

std::string Annwvyn::Ann3DTextPlane::fontTTF
private

Definition at line 113 of file Ann3DTextPlane.hpp.

◆ height

float Annwvyn::Ann3DTextPlane::height
private

Definition at line 134 of file Ann3DTextPlane.hpp.

◆ margin

float Annwvyn::Ann3DTextPlane::margin
private

Margin in meters.

Definition at line 161 of file Ann3DTextPlane.hpp.

◆ materialName

std::string Annwvyn::Ann3DTextPlane::materialName
private

Name of the material.

Definition at line 125 of file Ann3DTextPlane.hpp.

◆ materialNameLen

const size_t Annwvyn::Ann3DTextPlane::materialNameLen = 30
private

Length of the random material name.

Definition at line 122 of file Ann3DTextPlane.hpp.

◆ needUpdating

bool Annwvyn::Ann3DTextPlane::needUpdating
private

If true, next update call will update.

Definition at line 119 of file Ann3DTextPlane.hpp.

◆ node

Ogre::SceneNode* Annwvyn::Ann3DTextPlane::node
private

Node where the object is attached.

Definition at line 107 of file Ann3DTextPlane.hpp.

◆ pixelMargin

unsigned int Annwvyn::Ann3DTextPlane::pixelMargin
private

Margin in pixels.

Definition at line 158 of file Ann3DTextPlane.hpp.

◆ renderPlane

Ogre::ManualObject* Annwvyn::Ann3DTextPlane::renderPlane
private

The actual 3D text plane.

Definition at line 104 of file Ann3DTextPlane.hpp.

◆ resolutionFactor

float Annwvyn::Ann3DTextPlane::resolutionFactor
private

Definition at line 134 of file Ann3DTextPlane.hpp.

◆ textColor

AnnColor Annwvyn::Ann3DTextPlane::textColor
private

Colors.

Definition at line 140 of file Ann3DTextPlane.hpp.

◆ texture

Ogre::TexturePtr Annwvyn::Ann3DTextPlane::texture
private

Textures.

Definition at line 110 of file Ann3DTextPlane.hpp.

◆ textureCoords

const std::array<AnnVect2, 4> Annwvyn::Ann3DTextPlane::textureCoords = { { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } } }
private

Static texture coordinates.

Definition at line 131 of file Ann3DTextPlane.hpp.

◆ useImageAsBackground

bool Annwvyn::Ann3DTextPlane::useImageAsBackground
private

Will use an image as background.

Definition at line 164 of file Ann3DTextPlane.hpp.

◆ vertices

std::array<AnnVect3, 4> Annwvyn::Ann3DTextPlane::vertices
private

Vertex buffer.

Definition at line 128 of file Ann3DTextPlane.hpp.

◆ width

float Annwvyn::Ann3DTextPlane::width
private

Various floats for size computation.

Definition at line 134 of file Ann3DTextPlane.hpp.

◆ xOffset

float Annwvyn::Ann3DTextPlane::xOffset
private

Definition at line 134 of file Ann3DTextPlane.hpp.

◆ yOffset

float Annwvyn::Ann3DTextPlane::yOffset
private

Definition at line 134 of file Ann3DTextPlane.hpp.


The documentation for this class was generated from the following files: