SoText2(3)
πΈ NAME πΈ
hiii bestie, welcome to the SoText2(3) page from the Library Functions Manual π
So basically: SoText2 β the SoText2 class is a node type for visualizing 2D text aligned with the camera plane. that's it, that's the whole vibe. 2D text. stuck to the camera plane. iconic behavior honestly β¨
β¨ SYNOPSIS β¨
#include <Inventor/nodes/SoText2.h>
Inherits SoShape. yes queen, she's part of the SoShape family tree π«Ά
π Public Types π
enum Justification { LEFT = 1, RIGHT, CENTER }β the three ways your text can line up:LEFT,RIGHT, orCENTER. pick your fighter π
Public Types inherited from SoShape
enum TriangleShape { TRIANGLE_STRIP, TRIANGLE_FAN, TRIANGLES, POLYGON, QUADS, QUAD_STRIP, POINTS, LINES, LINE_STRIP }β all the shapesSoShapeknows how to serve
Public Types inherited from SoNode
enum NodeType { INVENTOR = 0x0000, VRML1 = 0x0001, VRML2 = 0x0002, INVENTOR_1 = 0x0004, INVENTOR_2_0 = 0x0008, INVENTOR_2_1 = 0x0010, INVENTOR_2_5 = 0x0020, INVENTOR_2_6 = 0x0040, COIN_1_0 = 0x0080, COIN_2_0 = 0x0100, EXTENSION = 0x0200, COIN_2_2 = 0x0400, COIN_2_3 = 0x0800, COIN_2_4 = 0x1000, INVENTOR_5_0 = 0x2000, COIN_2_5 = 0x4000 }β every node-type bit flag, spelled out with its exact hex value, no skips
π Public Member Functions π
virtual SoType getTypeId (void) constβ grabs the type id for this instanceSoText2 (void)β the constructor, aka the birth of your text node π£virtual void GLRender (SoGLRenderAction *action)β renders the thingvirtual void rayPick (SoRayPickAction *action)β handles ray pickingvirtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)β reports how many primitives we're working with
Public Member Functions inherited from SoShape
virtual SbBool affectsState (void) constβ does this node affect state? asking the real questionsvirtual void notify (SoNotList *nl)β the notification hookvirtual void getBoundingBox (SoGetBoundingBoxAction *action)β computes the bounding boxvirtual void callback (SoCallbackAction *action)β the callback traversal hookconst SoBoundingBoxCache * getBoundingBoxCache (void) constβ hands you the bounding box cache
Public Member Functions inherited from SoNode
void setOverride (const SbBool state)β flips override mode on or offSbBool isOverride (void) constβ are we overridden rn?void setNodeType (const NodeType type)β sets the node typeNodeType getNodeType (void) constβ reads the node type back outvirtual SoNode * copy (SbBool copyconnections=0) constβ makes a copy; passcopyconnections=0by defaultvirtual void doAction (SoAction *action)β runs an actionvirtual void GLRenderBelowPath (SoGLRenderAction *action)β the below-path GL rendervirtual void GLRenderInPath (SoGLRenderAction *action)β the in-path GL rendervirtual void GLRenderOffPath (SoGLRenderAction *action)β the off-path GL rendervirtual void getMatrix (SoGetMatrixAction *action)β the matrix gettervirtual void handleEvent (SoHandleEventAction *action)β event handling, go offvirtual void pick (SoPickAction *action)β picking behaviorvirtual void search (SoSearchAction *action)β the search actionvirtual void write (SoWriteAction *action)β the write actionvirtual void audioRender (SoAudioRenderAction *action)β yes, audio rendering is a whole thingvirtual void grabEventsSetup (void)β sets up event grabbingvirtual void grabEventsCleanup (void)β cleans up event grabbingvirtual void startNotify (void)β kicks off notificationuint32_t getNodeId (void) constβ your node's id numbervirtual SoChildList * getChildren (void) constβ the children list pointervirtual void writeInstance (SoOutput *out)β writes this instance outvirtual SoNode * addToCopyDict (void) constβ adds itself to the copy dictionaryvirtual void copyContents (const SoFieldContainer *from, SbBool copyconnections)β copies contents over from another containervirtual SoFieldContainer * copyThroughConnection (void) constβ copies through a connection
Public Member Functions inherited from SoFieldContainer
void setToDefaults (void)β resets everything to defaultsSbBool hasDefaultValues (void) constβ still at default values or nah?SbBool fieldsAreEqual (const SoFieldContainer *container) constβ compares fields with another containervoid copyFieldValues (const SoFieldContainer *container, SbBool copyconnections=0)β copies field values over;copyconnections=0by defaultSbBool set (const char *const fielddata)β sets from a field data stringvoid get (SbString &fielddata)β pulls the field data outvirtual int getFields (SoFieldList &l) constβ fills a list with the fieldsvirtual int getAllFields (SoFieldList &l) constβ literally all of themvirtual SoField * getField (const SbName &name) constβ look up a field by namevirtual SoField * getEventIn (const SbName &name) constβ look up an event-in by namevirtual SoField * getEventOut (const SbName &name) constβ look up an event-out by nameSbBool getFieldName (const SoField *const field, SbName &name) constβ get the name of a given fieldSbBool enableNotify (const SbBool flag)β toggles notificationSbBool isNotifyEnabled (void) constβ is notification on?SbBool set (const char *fielddata, SoInput *in)β theSoInputflavor ofsetvoid get (SbString &fielddata, SoOutput *out)β theSoOutputflavor ofgetvirtual SbBool validateNewFieldValue (SoField *field, void *newval)β checks a new field value is validvirtual void addWriteReference (SoOutput *out, SbBool isfromfield=0)β adds a write reference;isfromfield=0by defaultSbBool getIsBuiltIn (void) constβ is it built in?void setUserData (void *userdata) constβ attaches user datavoid * getUserData (void) constβ grabs that user data back
Public Member Functions inherited from SoBase
void ref (void) constβ bumps the reference countvoid unref (void) constβ drops the reference countvoid unrefNoDelete (void) constβ unref but don't deleteint32_t getRefCount (void) constβ how many refs we holdingvoid touch (void)β touches it, classicSbBool isOfType (SoType type) constβ type checkvirtual SbName getName (void) constβ what's my namevirtual void setName (const SbName &newname)β renames itvoid addAuditor (void *const auditor, const SoNotRec::Type type)β adds an auditorvoid removeAuditor (void *const auditor, const SoNotRec::Type type)β removes an auditorconst SoAuditorList & getAuditors (void) constβ the whole auditor listSbBool shouldWrite (void)β should this be written?void assertAlive (void) constβ asserts the object is alive, very dramatic of it
π Static Public Member Functions π
static SoType getClassTypeId (void)β the class-level type idstatic void initClass (void)β initializes the class
Static Public Member Functions inherited from SoShape
static SoType getClassTypeId (void)β class type id,SoShapeeditionstatic void initClass (void)β init the classstatic void getScreenSize (SoState *const state, const SbBox3f &boundingbox, SbVec2s &rectsize)β computes screen size from a bounding boxstatic float getDecimatedComplexity (SoState *state, float complexity)β returns the decimated complexity value
Static Public Member Functions inherited from SoNode
static uint32_t getCompatibilityTypes (const SoType &nodetype)β compatibility type bits for a node typestatic SoType getClassTypeId (void)β class type idstatic SoNode * getByName (const SbName &name)β find a node by namestatic int getByName (const SbName &name, SoNodeList &l)β find nodes by name into a liststatic void initClass (void)β init the classstatic void initClasses (void)β init all the classesstatic uint32_t getNextNodeId (void)β hands out the next node idstatic int getActionMethodIndex (const SoType type)β the action method index for a typestatic void getBoundingBoxS (SoAction *action, SoNode *node)β the static bounding box entry pointstatic void GLRenderS (SoAction *action, SoNode *node)β the static GL render entry pointstatic void callbackS (SoAction *action, SoNode *node)β static callback entry pointstatic void getMatrixS (SoAction *action, SoNode *node)β static matrix entry pointstatic void handleEventS (SoAction *action, SoNode *node)β static event handling entry pointstatic void pickS (SoAction *action, SoNode *node)β static pick entry pointstatic void rayPickS (SoAction *action, SoNode *node)β static ray pick entry pointstatic void searchS (SoAction *action, SoNode *node)β static search entry pointstatic void writeS (SoAction *action, SoNode *node)β static write entry pointstatic void audioRenderS (SoAction *action, SoNode *node)β static audio render entry pointstatic void getPrimitiveCountS (SoAction *action, SoNode *node)β static primitive count entry point
Static Public Member Functions inherited from SoFieldContainer
static void initClass (void)β init the classstatic SoType getClassTypeId (void)β class type idstatic void initCopyDict (void)β sets up the copy dictionarystatic void addCopy (const SoFieldContainer *orig, const SoFieldContainer *copy)β registers a copy pairstatic SoFieldContainer * checkCopy (const SoFieldContainer *orig)β checks the copy dictionarystatic SoFieldContainer * findCopy (const SoFieldContainer *orig, const SbBool copyconnections)β finds a copy for an originalstatic void copyDone (void)β wraps up copying
Static Public Member Functions inherited from SoBase
static void initClass (void)β init the classstatic SoType getClassTypeId (void)β class type idstatic void addName (SoBase *const base, const char *const name)β registers a namestatic void removeName (SoBase *const base, const char *const name)β unregisters a namestatic void incrementCurrentWriteCounter (void)β bumps the write counterstatic void decrementCurrentWriteCounter (void)β drops the write counterstatic SoBase * getNamedBase (const SbName &name, SoType type)β gets a named base of a given typestatic int getNamedBases (const SbName &name, SoBaseList &baselist, SoType type)β collects named bases into a liststatic SbBool read (SoInput *in, SoBase *&base, SoType expectedtype)β the static read entry pointstatic void setInstancePrefix (const SbString &c)β sets the instance prefixstatic void setTraceRefs (SbBool trace)β turns reference tracing on or offstatic SbBool getTraceRefs (void)β is ref tracing on?static SbBool connectRoute (SoInput *in, const SbName &fromnodename, const SbName &fromfieldname, const SbName &tonodename, const SbName &tofieldname)β wires up a routestatic SbBool readRoute (SoInput *in)β reads a route
π¦ Public Attributes π¦
SoMFString stringβ the actual text field, it's a multi-stringSoSFFloat spacingβ the spacing value, single floatSoSFEnum justificationβ which justification mode we're on
π Protected Member Functions π
virtual const SoFieldData * getFieldData (void) constβ returns the field datavirtual ~SoText2 ()β the destructorvirtual void generatePrimitives (SoAction *action)β generates the primitivesvirtual void computeBBox (SoAction *action, SbBox3f &box, SbVec3f ¢er)β computes the bounding box and center
Protected Member Functions inherited from SoShape
SoShape (void)β the constructorvirtual ~SoShape ()β the destructorfloat getComplexityValue (SoAction *action)β returns the complexity valuevirtual SbBool shouldGLRender (SoGLRenderAction *action)β should we render this?void beginSolidShape (SoGLRenderAction *action)β starts a solid shapevoid endSolidShape (SoGLRenderAction *action)β ends a solid shapevoid GLRenderBoundingBox (SoGLRenderAction *action)β renders the bounding boxSbBool shouldPrimitiveCount (SoGetPrimitiveCountAction *action)β should we count primitives?SbBool shouldRayPick (SoRayPickAction *const action)β should we ray pick?void computeObjectSpaceRay (SoRayPickAction *const action)β computes the object space rayvoid computeObjectSpaceRay (SoRayPickAction *const action, const SbMatrix &matrix)β same thing but with a matrixvirtual SoDetail * createTriangleDetail (SoRayPickAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3, SoPickedPoint *pp)β builds triangle detailvirtual SoDetail * createLineSegmentDetail (SoRayPickAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, SoPickedPoint *pp)β builds line segment detailvirtual SoDetail * createPointDetail (SoRayPickAction *action, const SoPrimitiveVertex *v, SoPickedPoint *pp)β builds point detailvoid invokeTriangleCallbacks (SoAction *const action, const SoPrimitiveVertex *const v1, const SoPrimitiveVertex *const v2, const SoPrimitiveVertex *const v3)β fires the triangle callbacksvoid invokeLineSegmentCallbacks (SoAction *const action, const SoPrimitiveVertex *const v1, const SoPrimitiveVertex *const v2)β fires the line segment callbacksvoid invokePointCallbacks (SoAction *const action, const SoPrimitiveVertex *const v)β fires the point callbacksvoid beginShape (SoAction *const action, const TriangleShape shapetype, SoDetail *const detail=NULL)β opens a shape;detaildefaults toNULLvoid shapeVertex (const SoPrimitiveVertex *const v)β feeds a shape vertexvoid endShape (void)β closes the shapevoid generateVertex (SoPrimitiveVertex *const pv, const SbVec3f &point, const SbBool useTexFunc, const SoTextureCoordinateElement *const tce, const float s, const float t, const SbVec3f &normal)β generates a vertex, thes/tversionvoid generateVertex (SoPrimitiveVertex *const pv, const SbVec3f &point, const SbBool useTexFunc, const SoTextureCoordinateElement *const tce, const float s, const float t, const float r, const SbVec3f &normal)β generates a vertex, thes/t/rversionSbBool startVertexArray (SoGLRenderAction *action, const SoCoordinateElement *coords, const SbVec3f *pervertexnormals, const SbBool texpervertex, const SbBool colorpervertex)β starts the vertex arrayvoid finishVertexArray (SoGLRenderAction *action, const SbBool vbo, const SbBool normpervertex, const SbBool texpervertex, const SbBool colorpervertex)β finishes the vertex array
Protected Member Functions inherited from SoNode
SoNode (void)β constructorvirtual ~SoNode ()β destructorvirtual SbBool readInstance (SoInput *in, unsigned short flags)β reads an instance
Protected Member Functions inherited from SoFieldContainer
SoFieldContainer (void)β constructor~SoFieldContainer ()β destructor
Protected Member Functions inherited from SoBase
SoBase (void)β constructorvirtual ~SoBase ()β destructorvirtual void destroy (void)β destroy itSbBool hasMultipleWriteRefs (void) constβ multiple write refs or notSbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine) constβ writes the headervoid writeFooter (SoOutput *out) constβ writes the footervirtual const char * getFileFormatName (void) constβ returns the file format name
β Static Protected Member Functions β
static const SoFieldData ** getFieldDataPtr (void)β pointer to the field data pointer
Static Protected Member Functions inherited from SoShape
static const SoFieldData ** getFieldDataPtr (void)β same deal, inherited fromSoShape
okay bestie that's the whole class tour for part one π literally every flag, every inherited function, every default value, all of it. and there's more coming, so don't go anywhere π«Άβ¨
π«Ά Static Protected Member Functions inherited from SoNode
static const SoFieldData ** getFieldDataPtr (void)β a pointer-to-pointer of field data. yes bestie, that's the whole description, the source really said that and nothing else πstatic void setNextActionMethodIndex (int index)β sets the next action method index, taking anindex. no extra lore given.static int getNextActionMethodIndex (void)β gets it back. that's it, that's the tea.static void incNextActionMethodIndex (void)β increments it. zero notes provided, it's giving mysterious πstatic void setCompatibilityTypes (const SoType &nodetype, const uint32_t bitmask)β takes anodetypeand abitmask. the docs left it at that, so we're leaving it at that.
πΈ Static Protected Member Functions inherited from SoBase
static uint32_t getCurrentWriteCounter (void)β returns auint32_t. no description in the original, just vibes β¨static void staticDataLock (void)β locks the static data. go off.static void staticDataUnlock (void)β unlocks it. a matched set, iconic.
π¦ Friends
class SoText2Pβ officially a friend of this class. bestie privileges granted π«Ά
π Additional Inherited Members
Protected Types inherited from SoBase
enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }
Protected Attributes inherited from SoNode
uint32_t uniqueId
Protected Attributes inherited from SoFieldContainer
SbBool isBuiltIn
Static Protected Attributes inherited from SoNode
static uint32_t nextUniqueId = 0static int nextActionMethodIndex = 0
π Detailed Description
okay so SoText2 is the node type for visualizing 2D text that stays aligned with the camera plane. it's the "text that just sits there and faces you" girlie π
here's the thing though, and this is important: SoText2 text is not scaled according to the distance from the camera, and it is not influenced by rotation or scaling the way 3D primitives are. if those are properties you actually want the text to have, you should use an SoText3 or SoAsciiText node instead. periodt.
also note that even though the size of the 2D text isn't influenced by the distance from the camera, the text is still subject to the usual rules with regard to the depthbuffer, so it will be obscured by graphics laying in front of it. no cap, it can get hidden. π
the text gets positioned according to the current transformation. here's the geometry tea:
- the x origin of the text is the first pixel of the leftmost character of the text.
- the y origin of the text is the baseline of the first line of text β and the baseline is that imaginary line all your upper case characters are standing on π§
the size of the fonts on screen is decided from the SoFont::size field of a preceding SoFont-node in the scene graph, which specifies the size in pixel dimensions. this value sets the approximate vertical dimension of the letters. and if you don't use any SoFont-nodes at all? the default value is 10.
π¨ rendering performance, listen up
this is the part where i grab you by the shoulders. since the positioning and rendering of an SoText2 node depends on the current viewport and camera, having SoText2 nodes in the scene graph will lead to a cache dependency on the previously encountered SoCamera-node. and that can have severe influence on rendering performance, because if the camera is above the SoText2's nearest parent SoSeparator, that SoSeparator will not be able to cache the geometry under it. π
(and it gets even worse if theSoSeparator::renderCachingflag is explicitly set toON, because then theSoSeparatornode will continuously generate and destruct the same cache as the camera moves. not the move, bestie.)
so the correct way to do this: SoText2 nodes are best positioned under their own SoSeparator node, outside areas in the scene graph that otherwise contain static geometry. protect your frame rate π«Ά
also β and this is a sneaky one β SoText2 nodes cache the ids and positions of each glyph bitmap used to render a string. which means a USE of a DEF'ed SoText2 node, with a different font, will be noticeably slower than just using two separate SoText2 nodes, one for each font, because it'll have to recalculate glyph bitmap ids and positions for each call to GLrender(). two nodes > one reused node here, fr fr.
and finally: SoScale nodes can not be used to influence the dimensions of the rendering output of SoText2 nodes. don't try it, it's not giving what you think it's giving π
π FILE FORMAT/DEFAULTS
Text2 {
string ""
spacing 1
justification LEFT
}
π See also
SoFont, SoFontStyle, SoText3, SoAsciiText
π Member Enumeration Documentation
enum SoText2::Justification
this enum contains the various options for how the horizontal text layout of the text should be done. the valid values are LEFT, RIGHT and CENTER. pick your fighter β¨
π Constructor & Destructor Documentation
SoText2::SoText2 (void )
Constructor. that's the whole description, she's a simple girlie π
- References:
justification,SoText2(), andspacing. - Referenced by:
getFieldData(), andSoText2().
SoText2::~SoText2 () [protected], [virtual]
Destructor. short and sweet, no notes πΈ
π Member Function Documentation
SoType SoText2::getTypeId (void ) const [virtual]
returns the type identification of an object derived from a class inheriting SoBase. this is used for run-time type checking and "downward" casting. iykyk π«Ά
usage example, verbatim, do not touch:
void foo(SoNode * node)
{
if (node->getTypeId() == SoFile::getClassTypeId()) {
SoFile * filenode = (SoFile *)node; // safe downward cast, knows the type
}
else if (node->getTypeId().isOfType(SoGroup::getClassTypeId())) {
SoGroup * group = (SoGroup *)node; // safe downward cast, knows the type
}
}
for application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. this is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on.
for more info on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups.
Reimplemented from SoShape.
const SoFieldData * SoText2::getFieldData (void ) const [protected], [virtual]
returns a pointer to the class-wide field data storage object for this instance. if no fields are present, it returns NULL. π«
Reimplemented from SoShape.
References: SoText2().
void SoText2::GLRender (SoGLRenderAction * action) [virtual]
action method for the SoGLRenderAction. this gets called during rendering traversals. nodes that influence the rendering state in any way, or who want to throw geometry primitives at OpenGL, override this method. go off π
Reimplemented from SoShape.
References: SbString::getLength(), SoAction::getState(), SbViewportRegion::getViewportSizePixels(), justification, SbMatrix::multVecMatrix(), SoState::pop(), SoState::push(), SoShape::shouldGLRender(), and spacing.
void SoText2::rayPick (SoRayPickAction * action) [virtual]
calculates the picked point based on primitives generated by subclasses. π―
Reimplemented from SoShape.
References: SoRayPickAction::addIntersection(), SbLine::getClosestPoint(), SoAction::getState(), SoRayPickAction::intersect(), SoRayPickAction::isBetweenPlanes(), justification, SoTextDetail::setCharacterIndex(), SoPickedPoint::setDetail(), SoPickedPoint::setMaterialIndex(), SoPickedPoint::setObjectNormal(), SoRayPickAction::setObjectSpace(), SoTextDetail::setStringIndex(), and SoShape::shouldRayPick().
void SoText2::getPrimitiveCount (SoGetPrimitiveCountAction * action) [virtual]
action method for the SoGetPrimitiveCountAction. it calculates the number of triangle, line segment and point primitives for the node and adds these to the counters of the action. nodes that influence how geometry nodes calculate their primitive count also override this method to change the relevant state variables.
Reimplemented from SoShape.
References: SoGetPrimitiveCountAction::addNumText(), and SoShape::shouldPrimitiveCount().
void SoText2::generatePrimitives (SoAction * action) [protected], [virtual]
this method implements action behavior for shape nodes for SoCallbackAction. it's invoked from SoShape::callback(). (subclasses should not override SoNode::callback().)
the subclass implementations use the convenience methods SoShape::beginShape(), SoShape::shapeVertex(), and SoShape::endShape(), with SoDetail instances, to pass the primitives making up the shape back to the caller. β¨
Implements SoShape.
void SoText2::computeBBox (SoAction * action, SbBox3f & box, SbVec3f & center) [protected], [virtual]
implemented by SoShape subclasses to let the SoShape superclass know the exact size and weighted center point of the shape's bounding box. the bounding box and center point should be calculated and returned in the local coordinate system. π¦
this method implements action behavior for shape nodes for SoGetBoundingBoxAction. it's invoked from SoShape::getBoundingBox(). (subclasses should not override SoNode::getBoundingBox().)
the box parameter sent in is guaranteed to be an empty box, while center is undefined upon function entry. heads up on that one π
Implements SoShape.
References: SoAction::getState().
π Member Data Documentation
SoMFString SoText2::string
the set of strings to render. each string in the multiple value field will be rendered on its own line. π the default value of the field is a single empty string.
SoSFFloat SoText2::spacing
spacing between each consecutive vertical line. default value is 1.0, which means that the space between the uppermost line of each rendered string will equal the vertical size of the highest character in the bitmap alphabet.
Referenced by: GLRender(), and SoText2().
SoSFEnum SoText2::justification
decides how the horizontal layout of the text strings is done. π
Referenced by: GLRender(), rayPick(), and SoText2().
π§ Author
Generated automatically by Doxygen for Coin from the source code. (so don't blame a human for the typos, bestie π)
and that's the whole page!! π this was Coin, Version 2.5.0, dated as SoText2(3) β thanks for reading all the way to the bottom, you're literally the main character for that πβ¨
π¦ where this page comes from
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms