H3D API
2.4.1
|
The Text node specifies a two-sided, flat text string object positioned in the Z=0 plane of the local coordinate system based on values defined in the fontStyle field (see FontStyle). More...
#include <H3D/Text.h>
Classes | |
class | DisplayList |
We extend the DisplayList to build the fonts of the X3DFontStyleNode in the fontStyle field of the Text node this DisplayList resides in. More... | |
class | OutputUpdater |
Internal field class to update values of origin, textBounds, lineBounds. More... | |
class | SFBound |
The SFBound field is specialized to update itself from the values in the fields of the Text node. More... | |
Public Member Functions | |
Text (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< SFFontStyleNode > _fontStyle=0, Inst< MFFloat > _length=0, Inst< SFFloat > _maxExtent=0, Inst< MFString > _string=0, Inst< MFVec2f > _lineBounds=0, Inst< SFVec3f > _origin=0, Inst< SFVec2f > _textBounds=0, Inst< SFBool > _solid=0, Inst< OutputUpdater > _outputUpdater=0) | |
Constructor. | |
virtual void | render () |
Render the text with OpenGL. | |
virtual void | traverseSG (TraverseInfo &ti) |
Traverse the scenegraph. More... | |
virtual int | nrTriangles () |
The number of triangles renderered in this geometry, we don't know so return -1. | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the texts bounding box. More... | |
![]() | |
X3DGeometryNode (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< MFBool > _isTouched=0, Inst< MFVec3f > _force=0, Inst< MFVec3f > _contactPoint=0, Inst< MFVec3f > _contactNormal=0, Inst< MFVec3f > _contactTexCoord=0, Inst< SFBoundTree > _boundTree=0, Inst< SFVec3f > _centerOfMass=0) | |
Constructor. | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on this geometry to point p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the geometry. More... | |
virtual void | glRender () |
Function overridden from HAPIGLShape. More... | |
virtual H3DShadowObjectNode * | getShadowObject () |
Get the H3DShadowObjectNode used to create a shadow volume for this geometry. More... | |
void | useCulling (bool enabled) |
This function should be used by the render() function to disable or enable face culling. More... | |
bool | usingCulling () |
Returns if face culling is in use or not. | |
void | allowCulling (bool allow) |
Control if face culling is allowed or not. More... | |
void | useBackFaceCulling (bool enabled) |
Enabling/disabling back face culling. More... | |
bool | allowingCulling () |
Returns true if back face culling is allowed, false otherwise. | |
void | setCullFace (GLenum face) |
Set which side of a polygon to cull. More... | |
GLenum | getCullFace () |
Get which face will be culled if culling is enabled. | |
template<class OptionNodeType > | |
void | getOptionNode (OptionNodeType *&option) |
Get the first option node of the type of the pointer given as argument from the renderOptions fieeld The option argument will contain the node afterwards, or NULL if no option of that type exists. | |
int | getHapticShapeId (unsigned int index) |
Get a shape id to be used for rendering of this geometry with HLAPI for the given haptics device. More... | |
virtual | ~X3DGeometryNode () |
Destructor. | |
HAPI::HAPIHapticShape * | getOpenGLHapticShape (unsigned int hd_index, H3DSurfaceNode *_surface, const Matrix4f &_transform, int _nr_vertices=-1) |
Returns a either a HLFeedbackShape or a HLDepthBufferShape with the X3DGeometryNode. More... | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
virtual bool | supportsTangentAttributes () |
Returns true if this geometry supports the automatic generation of tangents and binormals as FloatVertexAttribues(needed by e.g. More... | |
virtual void | getBound (HAPI::Vec3 ¢er, HAPI::Vec3 &size) |
Overriden from HAPIGLShape to use the bound field in he X3DGeometryNode. More... | |
virtual void | initialize () |
Changes behaviour of X3DGeometryNode to be a thread safe RefCountedClass. | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
![]() | |
H3DBoundedObject (Inst< SFBound > _bound=0) | |
Constructor. | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
Public Attributes | |
H3DUniquePtr< SFFontStyleNode > | fontStyle |
The style the text should be rendered with. More... | |
H3DUniquePtr< MFFloat > | length |
The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system. More... | |
H3DUniquePtr< SFFloat > | maxExtent |
The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system. More... | |
H3DUniquePtr< MFString > | stringF |
The strings to render. More... | |
H3DUniquePtr< MFVec2f > | lineBounds |
A set of 2D vectors where each vector contains the size of the 2D bounding box for each line of rendered text in local text x and y units. More... | |
H3DUniquePtr< SFVec3f > | origin |
3D position that specifies the origin of the text local coordinate system in units of the coordinate system in which the Text node is embedded. More... | |
H3DUniquePtr< SFVec2f > | textBounds |
The dimensions of Text node's 2D bounding box. More... | |
H3DUniquePtr< SFBool > | solid |
The solid field determines whether one or both sides of each polygon shall be displayed. More... | |
![]() | |
H3DUniquePtr< MFBool > | isTouched |
Tells if a HapticsDevice has been in contact with the geometry in the last scenegraph loop. More... | |
H3DUniquePtr< MFVec3f > | force |
The last force delivered by this geometry to the haptics device. More... | |
H3DUniquePtr< MFVec3f > | contactPoint |
The last contact points of the HapticDevices on the geometry. More... | |
H3DUniquePtr< MFVec3f > | contactTexCoord |
The texture coordinate of last the contact points of the HapticDevices on the geometry. More... | |
H3DUniquePtr< MFVec3f > | contactNormal |
The normal at the last contact points of the HapticDevices on the geometry. More... | |
H3DUniquePtr< SFVec3f > | centerOfMass |
The field contains center of mass for the object, based on its bounding box. More... | |
H3DUniquePtr< SFBoundTree > | boundTree |
Contains a tree of the HAPI::GeometryPrimitives that build up the X3DGeometryNode. More... | |
H3DUniquePtr< MFOptionsNode > | options |
Contains nodes with options for haptics and graphics rendering. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< SFBound > | bound |
The field containing the bound object. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Protected Member Functions | |
void | updateLineBounds () |
Calculates and updates lineBounds field value. | |
virtual void | scaleToMaxExtent (const std::vector< std::string > &text, X3DFontStyleNode *font) |
Scales the scene so that the text given would be contained within the value of the maxExtent field. More... | |
virtual void | justifyMinor (const std::vector< std::string > &text, X3DFontStyleNode *font) |
Justify the text in the minor alignment by translating it in the way described in the FontStyle node. | |
virtual void | moveToNewLine (const std::string &text, X3DFontStyleNode *font) |
Move to the position of the next line. More... | |
virtual void | renderTextLine (const std::string &text, X3DFontStyleNode *font) |
Render a line of text in the style of the X3DFontStyleNode given. More... | |
virtual void | justifyLine (const std::string &text, X3DFontStyleNode *font) |
Justify the line of text in the major alignment by translating it in the way described in the FontStyle node. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
Protected Attributes | |
H3DUniquePtr< OutputUpdater > | outputUpdater |
Internal field to update output fields origin, lineBounds, textBounds. | |
![]() | |
AutoRef< Node > | shadow_volume |
The shadow volume used for this geometry when shadows enabled. More... | |
vector< pair< int, pair< Matrix4f, H3DTime > > > | haptic_shape_ids |
identifiers for the shapes geometry. | |
Static Protected Attributes | |
static AutoRef< FontStyle > | default_font_style |
The font style to use when no style is specified. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
![]() | |
static void | cleanUpFunction (void *userdata) |
Function sent to HAPIHapticsShape created to allow for deletion of X3DGeometryNode at the correct time. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The Text node specifies a two-sided, flat text string object positioned in the Z=0 plane of the local coordinate system based on values defined in the fontStyle field (see FontStyle).
Text nodes may contain multiple text strings specified using the UTF-8 encoding. The text strings are stored in the order in which the text mode characters are to be produced as defined by the parameters in the FontStyle node.
The text strings are contained in the string field. The fontStyle field contains one FontStyle node that specifies the font size, font family and style, direction of the text strings, and any specific language rendering techniques used for the text.
The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system. If the text string with the maximum length is shorter than the maxExtent, then there is no compressing. The maximum extent is measured horizontally for horizontal text (FontStyle node: horizontal=TRUE) and vertically for vertical text (FontStyle node: horizontal=FALSE). The maxExtent field shall be greater than or equal to zero.
The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system. If the string is too short, it is stretched (either by scaling the text or by adding space between the characters). If the string is too long, it is compressed (either by scaling the text or by subtracting space between the characters). If a length value is missing (for example, if there are four strings but only three length values), the missing values are considered to be 0. The length field shall be greater than or equal to zero.
Specifying a value of 0 for both the maxExtent and length fields indicates that the string may be any length.
The solid field determines whether one or both sides of each polygon shall be displayed. If solid is FALSE, each polygon is visible regardless of the viewing direction and if it is TRUE back face culling is performed to only show the front face of the polygons.
Examples:
|
virtual |
Detect intersection between a line segment and the texts bounding box.
from | The start of the line segment. |
to | The end of the line segment. |
result | Contains info about the closest intersection for every object that intersects the line. |
Reimplemented from H3D::X3DGeometryNode.
References H3D::Node::LineIntersectResult::addPtDevMap(), H3D::Node::NodeIntersectResult::addResults(), H3D::H3DBoundedObject::bound, H3D::Node::LineIntersectResult::detect_pt_device, H3D::Node::LineIntersectResult::hasCurrentPointingDevice(), and H3D::Bound::lineSegmentIntersect().
|
protectedvirtual |
Move to the position of the next line.
What the next line is depends on the values in the FontStyle node, i.e. if the text is horizontal, if it is top to bottom or the other way around, spacing etc.
References H3D::X3DFontStyleNode::getAlignment(), H3D::X3DFontStyleNode::getSpacing(), H3D::X3DFontStyleNode::isLeftToRight(), H3D::X3DFontStyleNode::isTopToBottom(), and H3D::X3DFontStyleNode::stringDimensions().
Referenced by render().
|
protectedvirtual |
Render a line of text in the style of the X3DFontStyleNode given.
The OpenGL transform matrices will not be changed by the call.
References H3D::X3DFontStyleNode::charDimensions(), H3D::X3DFontStyleNode::getAlignment(), H3D::X3DFontStyleNode::isLeftToRight(), H3D::X3DFontStyleNode::isTopToBottom(), H3D::X3DFontStyleNode::renderChar(), and H3D::X3DFontStyleNode::renderHorizontalLine().
Referenced by render().
|
protectedvirtual |
Scales the scene so that the text given would be contained within the value of the maxExtent field.
The length field is inspected as well as the dimensions of the text to determine what the scale should be.
References H3D::X3DFontStyleNode::getAlignment(), length, maxExtent, and H3D::X3DFontStyleNode::stringDimensions().
Referenced by render().
|
virtual |
Traverse the scenegraph.
A HAPIHapticShape is added for haptic rendering if haptics is enabled.
ti | The TraverseInfo object containing information about the traversal. |
Reimplemented from H3D::X3DGeometryNode.
References solid, H3D::X3DGeometryNode::traverseSG(), and H3D::X3DGeometryNode::useBackFaceCulling().
H3DUniquePtr< SFFontStyleNode > H3D::Text::fontStyle |
The style the text should be rendered with.
See X3DFontStyleNode.
Access type: inputOutput
Referenced by render(), Text(), and updateLineBounds().
H3DUniquePtr< MFFloat > H3D::Text::length |
The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system.
If the string is too short, it is stretched (either by scaling the text or by adding space between the characters). If the string is too long, it is compressed (either by scaling the text or by subtracting space between the characters). If a length value is missing (for example, if there are four strings but only three length values), the missing values are considered to be 0. The length field shall be greater than or equal to zero.
Access type: inputOutput
Default value: []
Valid range: >=0
Referenced by render(), scaleToMaxExtent(), Text(), and H3D::Text::OutputUpdater::update().
H3DUniquePtr< MFVec2f > H3D::Text::lineBounds |
A set of 2D vectors where each vector contains the size of the 2D bounding box for each line of rendered text in local text x and y units.
Access type: outputOnly
Referenced by updateLineBounds().
H3DUniquePtr< SFFloat > H3D::Text::maxExtent |
The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system.
If the text string with the maximum length is shorter than the maxExtent, then there is no compressing. The maximum extent is measured horizontally for horizontal text (FontStyle node: horizontal=TRUE) and vertically for vertical text (FontStyle node: horizontal=FALSE). The maxExtent field shall be greater than or equal to zero.
Access type: inputOutput
Default value: 0
Valid range: >=0
Referenced by scaleToMaxExtent(), Text(), and H3D::Text::OutputUpdater::update().
H3DUniquePtr< SFVec3f > H3D::Text::origin |
3D position that specifies the origin of the text local coordinate system in units of the coordinate system in which the Text node is embedded.
The value of the origin field represents the upper left corner of the textBounds.
Access type: outputOnly
Referenced by H3D::Text::OutputUpdater::update().
H3DUniquePtr< SFBool > H3D::Text::solid |
The solid field determines whether one or both sides of each polygon shall be displayed.
If solid is FALSE, each polygon is visible regardless of the viewing direction and if it is TRUE back face culling is performed to only show the front face of the polygons.
Access type: inputOutput
Default value: FALSE
Referenced by Text(), and traverseSG().
H3DUniquePtr< MFString > H3D::Text::stringF |
The strings to render.
Each string will be on its own line.
Access type: inputOutput
Referenced by render(), Text(), and updateLineBounds().
H3DUniquePtr< SFVec2f > H3D::Text::textBounds |
The dimensions of Text node's 2D bounding box.
Access type: outputOnly
Referenced by H3D::Text::OutputUpdater::update().