SOFIELD(3iv)
π SoField β the manual page, but make it make sense π
okay so welcome to SoField(3IV), bestie. This is the part 1 of the page, so don't go anywhere, there's more coming. β¨
πΈ NAME πΈ
SoField β the base class for all fields. Like, the mother of every field. The blueprint. The blueprint-est blueprint. π
π¦ INHERITS FROM π¦
SoField
(yes she's the root of it all, she inherits from nobody, she IS the moment)
β¨ SYNOPSIS β¨
#include <Inventor/fields/SoField.h>
π Methods from class SoField π
void setIgnored(SbBool ignore)
SbBool isIgnored() const
SbBool isDefault() const
static SoType getClassTypeId()
virtual SoType getTypeId() const
virtual SbBool isOfType(SoType type) const
SbBool set(const char *valueString)
void get(SbString &valueString)
int operator ==(const SoField &f) const
int operator !=(const SoField &f) const
void touch()
SbBool connectFrom(SoField *fromField)
SbBool connectFrom(SoEngineOutput *fromEngine)
void disconnect()
SbBool isConnected() const
SbBool isConnectedFromField() const
SbBool getConnectedField(SoField *&writingField) const
SbBool isConnectedFromEngine() const
SbBool getConnectedEngine(SoEngineOutput *&engineOutput)
const
void enableConnection(SbBool flag)
SbBool isConnectionEnabled() const
int getForwardConnections(SoFieldList &list) const
SoFieldContainer * getContainer() const
that's the whole roster, no gatekeeping π
π DESCRIPTION π
Okay so. SoField is the abstract base class for every single field. Fields are the data elements that live inside nodes, and they're also the input values for engines. Every node class or engine class declares its own set of fields and gives each one a name. Those names are what define the semantics of the field β like, for example, the SoCube node has three float fields named width, height, and depth. (Iconic naming honestly.) Field classes hand you the access methods that let you indirectly edit and query the data inside nodes. π«Ά
There are two abstract subclasses of SoField:
SoSFieldβ the base class for all single-valued field classes.SoMFieldβ the base class for all multiple-valued fields, which hold dynamic arrays of values.
Subclasses of SoSField get the SoSF prefix, and subclasses of SoMField get the SoMF prefix. If you want the extra methods, go read the reference pages for SoSField and SoMField. π
Fields are normally constructed only inside node or engine instances. If you need a field that isn't part of a node or engine, you can make a GlobalField β check the methods on SoDB for creating global fields. π
π connections, the whole vibe π
Fields can be connected directly to another field, or they can be connected to the output of an engine. Once a field has a connection, its value changes whenever the thing it's connected to changes.
Example time, because examples ate: say field "A" is connected from "B" (done via A->connectFrom(B)). When B's value changes, A's value changes too. π
BUT. Here's the catch, and it's important:AandBmay have different values even while they're connected. IfA's value gets set afterB's value, thenA's value will be different fromB's untilB's value gets set again. That's just how it is, no cap.
A field can be connected to several other fields, but it can be connected from only one source. One source only. Monogamous from-direction. π
π loops, yes really π
It is possible β and honestly often useful β to create loops of field connections (like, A connected from B and B connected from A). When there are loops, the rule is: the last setValue() done overrides any connections in to that value.
The way to picture it: setting a field's value immediately propagates that value forward into all the fields it's connected to, and the propagation stops at the place where the original setValue() happened, if there's a connection loop. π
fun fact: actually a more efficient mechanism than that is used, but the semantics are the same. So don't come for the vibes, the vibes are accurate.
π§ field converters π§
If you try to connect two fields of differing types, Inventor will automatically try to insert a field converter engine between them to convert values from one type into the other. Slay, honestly.
Inventor has most reasonable conversions built-in, including:
- multiple-valued field to single-valued, and vice versa
- anything to
SoSFString - anything to
SoSFTrigger float/short/unsigned short/int32_t/uint32_t/ etc numeric conversions
(and more, etc.)
You can add your own field converters using SoDB's extender method addConverter() β see the SoDB.h header file for the details. You can also check whether a converter is available with the SoDB::getConverter() method. π
π file format, the rules π
Each field defines its own file format for reading and for being written to files, but all fields follow the same conventions:
- Fields in a node or engine are written as the name of the field followed by the field's value.
- Fields are not written if they haven't been modified since they were created (i.e. if they have their default value). Not modified = not written. Simple as. β¨
π«§ the ignored flag π«§
The ignored flag is written as a "~" character after the field's value. And if the field's value is its default value, then just the "~" gets written. That's it, that's the whole rule. π
π writing connections π
Field connections are written as an "=" followed by the container of the field or engine output that the field is connected to, followed by a "." and the name of the field or engine output.
For example:
DEF node1 Transform { translation 1 1 1 }
DEF node2 Scale { scaleFactor 1 1 1 = USE node1.translation }
look at that, gorgeous, no notes π
π global fields π
Global fields are written as part of an internal SoFieldContainer class called GlobalField. That class writes out an SoSFName field named type whose value is the type of the global field, followed by a field of that type whose name is the name of the global field.
For example, a global uint32_t field called "FrameCounter" whose value is 494 would be written as:
GlobalField {
type SoSFUInt32
FrameCounter 494
}
okay that's part 1 bestie, keep scrolling, there's more π
π METHODS π
okay bestie, this is the part where the field actually does stuff. buckle up π
void setIgnored(SbBool ignore)/SbBool isIgnored() constβ sets/gets the ignore flag for this field. When a field's ignore flag is TRUE, the field is not used during traversal for rendering and other actions. default value of this flag is FALSE, no cap.SbBool isDefault() constβ gets the state of the default flag of the field. This flag will be TRUE for any field whose value is not modified after construction, and FALSE for the ones that have changed (each node or engine determines what the default values for its fields are, so it's giving very "ask your node" energy).
β οΈ note: the state of this flag should not be set explicitly from within applications. like, don't touch it. hands off. π
static SoType getClassTypeId()β return the type identifier for this field class. classic. iconic.virtual SoType getTypeId() constβ return the type identifier for this field instance (SoField *).virtual SbBool isOfType(SoType type) constβ returns TRUE if this field is the given type or derived from that type. This is typically used with thegetClassTypeId()method to figure out the type of anSoField *at run-time, and it's literally the main character move of runtime type checking:
SoField *field = ....;
if (field->isOfType(SoSFFloat::getClassTypeId())) {
SoSFFloat *floatField = (SoSFFloat *)field);
floatField->setValue(4.5);
}
SbBool set(const char *valueString)β sets the field to the given value, which is an ASCII string in the Inventor file format. Each field subclass defines its own file format, so go check their reference pages for the tea on that. β¨ The string should contain only the field's value, not the field's name (like"1.0", not"width 1.0"β no name-dropping bestie). This method returns TRUE if the string is valid, FALSE if it is not.void get(SbString &valueString)β returns the value of the field in the Inventor file format, even if the field has its default value. yeah, even then. it's that committed.int operator ==(const SoField &f) const/int operator !=(const SoField &f) constβ return TRUE (FALSE) if this field is of the same type and has the same value as f. twin check π―void touch()β simulates a change to the field, causing attached sensors to fire, connected fields and engines to be marked as needing evaluation, and so forth. so dramatic for no reason, we love her. π Callingtouch()on an instance of a derived field class is equivalent to callingsetValue(getValue())using the derived class's methods, except that the field'sisDefault()status remains unchanged. subtle but important, iykyk.SbBool connectFrom(SoField *fromField)/SbBool connectFrom(SoEngineOutput *fromEngine)β connects this field to another field or from an engine output. If the field was connected to something before, it will be automatically disconnected (a field may have only one connection writing into it at a time β monogamous fr fr). Unless connections to the field are disabled (seeenableConnection()), the field's value will be set to the value of the thing it is connected to.void disconnect()β disconnect the field from whatever it was connected to. This does nothing if the field was not connected. no connection, no problem. π¦SbBool isConnected() constβ returns TRUE if the field is connected to anything. anything at all. we don't judge.SbBool isConnectedFromField() constβ returns TRUE if the field is connected to another field.SbBool getConnectedField(SoField *&writingField) constβ returns TRUE if this field is being written into by another field, and returns the field it is connected to in writingField. Returns FALSE and does not modify writingField if it is not connected to a field. respectful. doesn't touch what isn't hers. π«ΆSbBool isConnectedFromEngine() constβ returns TRUE if the field is connected to an engine's output.SbBool getConnectedEngine(SoEngineOutput *&engineOutput) constβ returns TRUE if this field is being written into by an engine, and returns the engine output it is connected to in engineOutput. Returns FALSE and does not modify engineOutput if it is not connected to an engine.void enableConnection(SbBool flag)β field connections may be enabled and disabled. Disabling a field's connection is almost exactly like disconnecting it; the only difference is that you can later re-enable the connection by callingenableConnection(TRUE). π
β οΈ Note that disconnecting an engine output can cause the engine's reference count to be decremented and the engine to be deleted, but disabling the connection does not decrement its reference count. so like. know the difference. this is the serious part. π
Re-enabling a connection will cause the value of the field to be changed to the engine output or field to which it is connected.
A field's connection-enabled status is maintained even if the field is disconnected or reconnected. By default, connections are enabled.
SbBool isConnectionEnabled() constβ returns FALSE if connections to this field are disabled. Note that this may return FALSE even if the field is not connected to anything. confusing? a little. true? absolutely. πΈint getForwardConnections(SoFieldList &list) constβ adds pointers to all of the fields that this field is writing into (either fields in nodes, global fields or engine inputs) to the given field list, and returns the number of forward connections. it's giving β¨networkingβ¨SoFieldContainer *getContainer() constβ returns the object that contains this field. The type of the object will be eitherSoNode,SoEngine, or will be a global field container (note that the global field container class is internal to Inventor; see the methods for creating and accessing global fields onSoDB). For example:
SoFieldContainer *f = field->getContainer();
if (f->isOfType(SoNode::getClassTypeId())) {
... do something ...
} else if (f->isOfType(SoEngine::getClassTypeId())) {
... do someting else ...
} else {
... it must be a global field. We can figure out its name, but
that is about it:
const SbName &globalFieldName = f->getName();
}
π SEE ALSO π
SoSFieldSoMFieldSoNodeSoDB
and that's the whole page bestie, we ate and left no crumbs π the footer on this one is the SoField(3IV) source/version tag (the date slot is just sitting there empty, lowkey mysterious of her π«Ά). go forth and field responsibly πβ¨π
π¦ where this page comes from
- debian bookworm: inventor-doc 2.1.5-10+dfsg-2 Β· LGPL-2.0-or-later
- debian trixie: inventor-doc 2.1.6+ds-2 Β· LGPL-2.0-or-later
- ubuntu jammy: inventor-doc 2.1.5-10-24
- ubuntu noble: inventor-doc 2.1.5-10+dfsg-2.1build2 Β· LGPL-2.0-or-later
- ubuntu questing: inventor-doc 2.1.6+ds-2
- ubuntu resolute: inventor-doc 2.1.6.1+ds-1 Β· LGPL-2.0-or-later
- ubuntu stonking: inventor-doc 2.1.6.1+ds-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms