public class SoText2 extends SoShape
The text position is always at the local origin (0,0,0). Rotations and scales have no effect on the orientation or size of 2D text, just the location.
Note: A transform node, e.g. SoTranslation, must be used to position the text in 3D space.
Text supports both single byte Latin1 (ISO8859-1) characters and multi-byte UNICODE characters. ISO8859-1 is an 8-bit character set which is a superset of the older 7-bit ASCII character set. See the String class for more information.
Rendering:
The typeface and size (default = 10) are specified using an SoFont node. Note that for SoText2 the size is interpreted as a value in pixels, not 3D units.
Setting the SoFont
renderStyle field to TEXTURE is recommended for best appearance and performance. (antialiasing is applied).
Additional rendering styles can be applied using an SoTextProperty node, including underline, overline, strikethrough, background and background outline.
SoText2 is drawn using the diffuse color of the current material (SoMaterial). Lighting is not applied, regardless of the lighting model. Textures do not affect SoText2 (note this is independent of the fact that textures are used internally to render SoText2). Complexity (SoComplexity) does not affect SoText2. Drawing styles (SoDrawStyle) other than INVISIBLE do not affect SoText2.
Justification:
Horizontal alignment of the text can be specified using the justification field. Both horizontal and vertical alignment can be controlled using an SoTextProperty node, however the justification setting in the SoText2 node overrides the horizontal setting unless it is explicitly set to INHERITED.
Clipping:
If the transformed position (origin point) of the SoText2 is clipped, then the entire string is clipped, even if some part of the string should conceptually be visible. If the origin point is inside the view volume then the string is clipped similar to other geometry.
Bounding box:
Because 2D text is screen-aligned, it has some unusual characteristics. For example, the 3D bounding box surrounding a 2D text string depends on the current camera and the current viewport size, since changing the field of view or the mapping onto the window changes the relative size of the text with respect to the rest of the scene.
When computing the bounding box of a 2D text node (see SoGetBoundingBoxAction), be careful to:
SoSearchAction).
Picking:
Text can be picked (SoRayPickAction) like any other geometry. If a text node has been picked then SoPickedPoint can return an SoTextDetail object. This object contains information about which string (in a multi-string text node) was picked and which character within the string was picked.
Render caching:
If your Open Inventor version is older than 9.2, then SoText2 nodes using CENTER or RIGHT justification cannot be render cached because the bounding box and justification offset depend on the camera. As a result, no SoSeparator above the SoText2 will be able to build a render cache or a bounding box cache and this can reduce performance. If possible put other geometry, that can be cached, under its own SoSeparator. SoText2 nodes using LEFT justification (the default) can be cached. Since Open Inventor 9.2, SoText2 nodes can be render cached in all cases.
Antialiasing:
Shape Antialiasing type is SoShape.TEXT.
Export limitations:
SoText2 can be exported to VRML/X3D (SoToVRML2Action), but... SoText2 can be exported to PDF3D/U3D (SoToPDFAction), but... SoText2 can be exported to various Hardcopy formats (SoVectorizeAction), but... File format/default:
Text2 {
| string | "" |
| spacing | 1 |
| justification | LEFT |
Action behavior:
SoGLRenderAction
Draws text based on the current font, at a location based on the current transformation.
SoRayPickAction
Performs a pick on the text. Text will be picked if the picking ray intersects the bounding box of the strings. The string index and character position are available from the SoTextDetail.
SoGetBoundingBoxAction
Computes the bounding box that encloses the text.
See also:
SoFont, SoFullSceneAntialiasing, SoText3, SoTextDetail, SoTextProperty
| Modifier and Type | Class and Description |
|---|---|
static class |
SoText2.Justifications
Justification types.
|
SoShape.ShapeTypesInventor.ConstructorCommand| Modifier and Type | Field and Description |
|---|---|
static int |
CENTER
Deprecated.
Use
SoText2.Justifications.CENTER instead. |
static int |
INHERITED
Deprecated.
Use
SoText2.Justifications.INHERITED instead. |
SoSFEnum<SoText2.Justifications> |
justification
Specifies horizontal alignment of strings.
|
static int |
LEFT
Deprecated.
Use
SoText2.Justifications.LEFT instead. |
static int |
RIGHT
Deprecated.
Use
SoText2.Justifications.RIGHT instead. |
SoSFFloat |
spacing
Defines the distance (in the negative y direction) between the base points of successive strings, measured with respect to the current font height.
|
SoMFString |
string
The text string(s) to display.
|
boundingBoxIgnoring, LINES, POINTS, POLYGONS, TEXTVERBOSE_LEVEL, ZeroHandle| Constructor and Description |
|---|
SoText2()
Creates a 2D text node with default settings.
|
getShapeType, isPrimitiveRestartAvailable, isPrimitiveRestartAvailableaffectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, writecopyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaultsdispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizablegetAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads@Deprecated public static final int LEFT
SoText2.Justifications.LEFT instead.@Deprecated public static final int CENTER
SoText2.Justifications.CENTER instead.@Deprecated public static final int RIGHT
SoText2.Justifications.RIGHT instead.@Deprecated public static final int INHERITED
SoText2.Justifications.INHERITED instead.public final SoMFString string
public final SoSFFloat spacing
public final SoSFEnum<SoText2.Justifications> justification
Justification. Default is LEFT.
Both horizontal and vertical alignment can be specified using an SoTextProperty node. However the justification setting in this node overrides the horizontal setting in SoTextProperty unless this field is set to INHERITED.
Generated on July 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com