Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglTextSet Class Reference

#include <sglTextSet.hpp>

Inheritance diagram for sglTextSet::

sglDrawable sglObject List of all members.

Public Methods

 sglTextSet ()
virtual ~sglTextSet ()
void setString (const string &str)
const string& getString () const
void setFont (sglBitmapFont *font)
sglBitmapFontgetFont () const
void setColor (const sglVec4f &color)
void setColor (float r, float g, float b, float a)
const sglVec4f& getColor () const
void setPosition (const sglVec3f &pos)
void setPosition (float x, float y, float z)
const sglVec3f& getPosition () const
virtual void addStats (sglStats &stats) const
virtual void drawGeometry (const vector< sglTexCoords > &) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

virtual bool computeBounds ()

Detailed Description

sglTextSet is a subclass of sglDrawable that renders 2D (bitmapped, constant size in screen space) text in a 3D location in the 3D scene.

sglTextSet supports the rendering (rasterization really) of a 2D bitmap type font at a position relative to the origin of the parent sglGeode's local coordinate system in the 3D scene. The user specifies a single line of text (determining the raster position of the text after a carriage return for multiline text is an task on the TODO list), the color of the text, the font (via an sglBitmapFont object), and the position. Note that a default font is provided which is platform-specific if the user does not specify one. See sglBitMapFont (and its subclasses) for more information. This node also manages its own default statelet vector that includes an sglTransparency statelet which is set to true when the alpha component of the color is not 1.0. The user can override this state vector by calling setState(0, ...) on this drawable.

As a subclass of sglDrawable, the user also has the option of enabling or disabling the generation of an OpenGL display list for this drawable. The rule of thumb is that if the string is not going to change, it is more efficient to enable the display list generation (this is the default). The string will change often, it may be more efficient to explicitly disable this feature.

{\bf Example:}

\begin{verbatim} sglTextSet *text_node = new sglTextSet; text_node->setColor(1.0f, 1.0f, 0.0f, 0.3f); // translucent text_node->setPosition(10.0f, 0.0f, 0.0f); // offset along the X axis text_node->setString("This text is in the scene graph"); text_node->enableDisplayList(false); // disable display listing

sglGeode *geode = new sglGeode; geode->addGeometry(text_node); \end{verbatim}

Definition at line 73 of file sglTextSet.hpp.

Constructor & Destructor Documentation

sglTextSet::sglTextSet ( )


sglTextSet::~sglTextSet ( ) [virtual]


Member Function Documentation

void sglTextSet::setString ( const string & str )

Set the string to render.

str   the string to render

const string & sglTextSet::getString ( ) const [inline]

Get the string to render.

the string to render

Definition at line 91 of file sglTextSet.hpp.

void sglTextSet::setFont ( sglBitmapFont * font )

Set the font to use.

font   The font to use. If NULL, the default bitmap font will be used.

sglBitmapFont * sglTextSet::getFont ( ) const [inline]

Get the font to use.

the font to use

Definition at line 102 of file sglTextSet.hpp.

void sglTextSet::setColor ( const sglVec4f & color )

Set the text color.

color   the text color; default (1,1,1,1)

void sglTextSet::setColor ( float r,
float g,
float b,
float a )

Set the text color (default is white opaque).

r   Red color component.
g   Green color component.
b   Blue color component.
a   Alpha color component.

const sglVec4f & sglTextSet::getColor ( ) const [inline]

Get the text color.

the text color

Definition at line 121 of file sglTextSet.hpp.

void sglTextSet::setPosition ( const sglVec3f & pos )

Set the offset vector.

pos   The offset vector (default: 0, 0, 0).

void sglTextSet::setPosition ( float x,
float y,
float z )

Set the offset vector.

x   X component of the offset vector.
y   Y component of the offset vector.
z   Z component of the offset vector.

const sglVec3f & sglTextSet::getPosition ( ) const [inline]

Get the current offset vector.

The current offset vector.

Definition at line 138 of file sglTextSet.hpp.

void sglTextSet::addStats ( sglStats & stats ) const [inline, virtual]

Add this drawable's stats to the given sglStats.

stats   The sglStats object to which to add the statistics.

Reimplemented from sglDrawable.

Definition at line 142 of file sglTextSet.hpp.

virtual void sglTextSet::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglDrawable.

virtual bool sglTextSet::computeBounds ( ) [protected, virtual]

Compute the bounding box for this geometry and fill in the member variable, m_bbox, in this class.

true if successful (all information is available for computing a bounding box), otherwise false.

Reimplemented from sglDrawable.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:10 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001