TextSprite Class Reference

A simple text sprite to display 2d text on the screen. More...

#include <TextSprite.h>

Inherits Sprite.

Public Member Functions

 TextSprite (ObjectManager *o, const std::string &name, vmml::Vector3f color, const std::string &text, FontPtr font, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 TextSprite (MaterialPtr material, const std::string &text, FontPtr font, PropertiesPtr properties=nullptr)
 Constructor. More...
 
virtual ~TextSprite ()
 Virtual destructor. More...
 
void setText (const std::string &text)
 Set a text string. More...
 
std::string getText ()
 Returns the text string of the sprite. More...
 
void setFont (FontPtr font)
 Set the font to be used to display the string. More...
 
FontPtr getFont ()
 Returns the font used to display the string. More...
 
void setColor (const vmml::Vector3f &color)
 Sets a color for the text. More...
 
- Public Member Functions inherited from Sprite
 Sprite ()
 Constructor. More...
 
 Sprite (MaterialPtr material, bool flipT, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Sprite (ObjectManager *o, const std::string &textureFileName, const std::string &materialName, ShaderPtr shader, bool flipT, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Sprite (ObjectManager *o, const std::string &name, const std::string &textureFileName, GLuint shaderMaxLights, bool variableNumberOfLights, bool flipT, PropertiesPtr properties=nullptr)
 Constructor. More...
 
virtual ~Sprite ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Model
 Model ()
 Constructor. More...
 
 Model (ObjectManager *o, const ModelData &modelData, GLuint shaderMaxLights, bool variableNumberOfLights, bool shaderFromFile, bool ambientLighting, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Model (ObjectManager *o, const ModelData &modelData, ShaderPtr shader, PropertiesPtr properties=nullptr)
 Constructor. More...
 
 Model (const ModelData &modelData, MaterialPtr material, PropertiesPtr properties=nullptr)
 Constructor. More...
 
virtual ~Model ()
 Virtual destructor. More...
 
virtual void draw (GLenum mode=GL_TRIANGLES) override
 Draws the model to the screen. More...
 
virtual void draw (const std::string &geometryName, GLenum mode=GL_TRIANGLES)
 Draws the specified group of geometry to the screen. More...
 
virtual void drawInstance (const std::string &instanceName, GLenum mode=GL_TRIANGLES) override
 Draws an instance of the model to the screen. More...
 
virtual InstanceMapPtr addInstance (const std::string &instanceName)
 Creates an instance of this model and associated geometry. More...
 
virtual PropertiesPtr getInstanceProperties (const std::string &instanceName, const std::string &geometryName)
 Get the properties of a geometry instance. More...
 
virtual InstanceMapPtr getInstanceProperties (const std::string &instanceName)
 Get the instance properties for every shader used in the model. More...
 
virtual void removeInstance (const std::string &instanceName)
 Removes an instance of the model and associated geometry. More...
 
virtual void clearInstances ()
 Removes all instances of the model and associated geometry. More...
 
MaterialPtr getMaterial ()
 Returns the material of the model. More...
 
void setMaterial (MaterialPtr arg)
 Sets the material of the model. More...
 
PropertiesPtr getProperties ()
 Returns the properties of the model. More...
 
void setProperties (PropertiesPtr arg)
 Sets the properties of the model. More...
 
GroupMapgetGroups ()
 Returns the groups of geometry of the model. More...
 
vmml::AABBf & getBoundingBoxObjectSpace ()
 Returns the bounding box of the geometry in object space. More...
 
void setBoundingBoxObjectSpace (vmml::AABBf arg)
 Sets the bounding box of the geometry in object space. More...
 
virtual void addGeometry (const std::string &name, GeometryPtr geometry)
 Adds geometry to the model. More...
 
virtual void removeGeometry (const std::string &name)
 Removes geometry from the model. More...
 
virtual void deleteModelGeometry ()
 Deletes all geometry of the model. More...
 
- Public Member Functions inherited from IDrawable
virtual ~IDrawable ()
 Virtual destructor. More...
 

Additional Inherited Members

- Public Types inherited from Model
typedef std::unordered_map< std::string, GeometryPtrGroupMap
 
typedef std::shared_ptr< std::unordered_map< ShaderPtr, PropertiesPtr > > InstanceMapPtr
 
typedef std::unordered_map< std::string, InstanceMapPtrInstancesMap
 

Detailed Description

A simple text sprite to display 2d text on the screen.

Author
Benjamin Buergisser

Constructor & Destructor Documentation

TextSprite::TextSprite ( ObjectManager o,
const std::string &  name,
vmml::Vector3f  color,
const std::string &  text,
FontPtr  font,
PropertiesPtr  properties = nullptr 
)

Constructor.

Parameters
[in]oObject management
[in]nameThe raw name of the sprite
[in]colorThe color of the text
[in]textThe string to be displayed
[in]fontThe font to be used to display the string
[in]propertiesProperties that will be passed to the shader of the model (optional)
TextSprite::TextSprite ( MaterialPtr  material,
const std::string &  text,
FontPtr  font,
PropertiesPtr  properties = nullptr 
)

Constructor.

Parameters
[in]material
[in]textThe string to be displayed
[in]fontThe font to be used to display the string
[in]propertiesProperties that will be passed to the shader of the model (optional)
virtual TextSprite::~TextSprite ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

FontPtr TextSprite::getFont ( )
inline

Returns the font used to display the string.

std::string TextSprite::getText ( )
inline

Returns the text string of the sprite.

void TextSprite::setColor ( const vmml::Vector3f &  color)
inline

Sets a color for the text.

Parameters
[in]colorThe color for the text
void TextSprite::setFont ( FontPtr  font)
inline

Set the font to be used to display the string.

Parameters
[in]fontThe font to be used to display the string
void TextSprite::setText ( const std::string &  text)
inline

Set a text string.

Parameters
[in]textThe string to be displayed