SoCalculator(3)
π SoCalculator(3) π β Library Functions Manual
β¨ NAME β¨
SoCalculator β bestie, it's literally the general purpose calculator for floats and 3D float vectors. Math? Handled. π
πΈ SYNOPSIS πΈ
#include <Inventor/engines/SoCalculator.h>
Inherits SoEngine. That's the vibe. π«Ά
π Public Member Functions π
The main character lineup, periodt:
virtual SoType getTypeId (void) constvirtual const SoFieldData * getFieldData (void) constvirtual const SoEngineOutputData * getOutputData (void) constSoCalculator (void)
π Public Member Functions inherited from SoEngine π
void evaluateWrapper (void)virtual int getOutputs (SoEngineOutputList &l) constSoEngineOutput * getOutput (const SbName &outputname) constSbBool getOutputName (const SoEngineOutput *output, SbName &outputname) constSbBool isNotifying (void) constvirtual void notify (SoNotList *nl)SoEngine * copy (void) constvirtual SoFieldContainer * copyThroughConnection (void) constSbBool shouldCopy (void) constvirtual void writeInstance (SoOutput *out)
π Public Member Functions inherited from SoFieldContainer π
void setToDefaults (void)SbBool hasDefaultValues (void) constSbBool fieldsAreEqual (const SoFieldContainer *container) constvoid copyFieldValues (const SoFieldContainer *container, SbBool copyconnections=FALSE)SbBool set (const char *const fielddata)void get (SbString &fielddata)virtual int getFields (SoFieldList &l) constvirtual int getAllFields (SoFieldList &l) constvirtual SoField * getField (const SbName &name) constvirtual SoField * getEventIn (const SbName &name) constvirtual SoField * getEventOut (const SbName &name) constSbBool getFieldName (const SoField *const field, SbName &name) constSbBool enableNotify (const SbBool flag)SbBool isNotifyEnabled (void) constSbBool set (const char *fielddata, SoInput *input)void get (SbString &fielddata, SoOutput *out)virtual SbBool validateNewFieldValue (SoField *field, void *newval)virtual void addWriteReference (SoOutput *out, SbBool isfromfield=FALSE)SbBool getIsBuiltIn (void) constvirtual void copyContents (const SoFieldContainer *from, SbBool copyconnections)virtual void getFieldsMemorySize (size_t &managed, size_t &unmanaged) constvoid setUserData (void *userdata) constvoid * getUserData (void) const
π©΅ Public Member Functions inherited from SoBase π©΅
void ref (void) constvoid unref (void) constvoid unrefNoDelete (void) constint32_t getRefCount (void) constvoid touch (void)SbBool isOfType (SoType type) constvirtual SbName getName (void) constvirtual void setName (const SbName &newname)virtual void startNotify (void)void addAuditor (void *const auditor, const SoNotRec::Type type)void removeAuditor (void *const auditor, const SoNotRec::Type type)const SoAuditorList & getAuditors (void) constSbBool shouldWrite (void)void assertAlive (void) const
β Static Public Member Functions β
static SoType getClassTypeId (void)static void * createInstance (void)static void initClass (void)
π Static Public Member Functions inherited from SoEngine π
static void initClass (void)static void initClasses (void)static SoType getClassTypeId (void)static SoEngine * getByName (const SbName &name)static int getByName (const SbName &name, SoEngineList &el)
β¨ Static Public Member Functions inherited from SoFieldContainer β¨
static void initClass (void)static SoType getClassTypeId (void)static void cleanupClass (void)static void initCopyDict (void)static void addCopy (const SoFieldContainer *orig, const SoFieldContainer *copy)static SoFieldContainer * checkCopy (const SoFieldContainer *orig)static SoFieldContainer * findCopy (const SoFieldContainer *orig, const SbBool copyconnections)static void copyDone (void)
π« Static Public Member Functions inherited from SoBase π«
static void initClass (void)static SoType getClassTypeId (void)static void addName (SoBase *const base, const char *const name)static void removeName (SoBase *const base, const char *const name)static void incrementCurrentWriteCounter (void)static void decrementCurrentWriteCounter (void)static SoBase * getNamedBase (const SbName &name, SoType type)static int getNamedBases (const SbName &name, SoBaseList &baselist, SoType type)static SbBool read (SoInput *input, SoBase *&base, SoType expectedtype)static void setInstancePrefix (const SbString &c)static void setTraceRefs (SbBool trace)static SbBool getTraceRefs (void)static SbBool connectRoute (SoInput *input, const SbName &fromnodename, const SbName &fromfieldname, const SbName &tonodename, const SbName &tofieldname)static SbBool readRoute (SoInput *input)
π Public Attributes π
SoMFFloat aSoMFFloat bSoMFFloat cSoMFFloat dSoMFFloat eSoMFFloat fSoMFFloat gSoMFFloat hSoMFVec3f ASoMFVec3f BSoMFVec3f CSoMFVec3f DSoMFVec3f ESoMFVec3f FSoMFVec3f GSoMFVec3f HSoMFString expressionSoEngineOutput oaSoEngineOutput obSoEngineOutput ocSoEngineOutput odSoEngineOutput oASoEngineOutput oBSoEngineOutput oCSoEngineOutput oD
π‘οΈ Protected Member Functions π‘οΈ
virtual ~SoCalculator (void)virtual void inputChanged (SoField *which)
π Protected Member Functions inherited from SoEngine π
SoEngine (void)virtual ~SoEngine (void)virtual SbBool readInstance (SoInput *in, unsigned short flags)void writeOutputTypes (SoOutput *out)
π Protected Member Functions inherited from SoFieldContainer π
SoFieldContainer (void)virtual ~SoFieldContainer ()
ποΈ Protected Member Functions inherited from SoBase ποΈ
SoBase (void)virtual ~SoBase ()SbBool hasMultipleWriteRefs (void) constSbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine) constvoid writeFooter (SoOutput *out) constvirtual const char * getFileFormatName (void) const
π§ Static Protected Member Functions π§
static const SoFieldData ** getInputDataPtr (void)static const SoEngineOutputData ** getOutputDataPtr (void)
π§ββοΈ Static Protected Member Functions inherited from SoEngine π§ββοΈ
static const SoFieldData ** getInputDataPtr (void)static const SoEngineOutputData ** getOutputDataPtr (void)
π§ββοΈ Static Protected Member Functions inherited from SoBase π§ββοΈ
static uint32_t getCurrentWriteCounter (void)static void staticDataLock (void)static void staticDataUnlock (void)
π«Ά Additional Inherited Members π«Ά
𧬠Protected Types inherited from SoBase π§¬
enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }
π¦ Protected Attributes inherited from SoFieldContainer π¦
SbBool isBuiltIn
β¨ DETAILED DESCRIPTION β¨
Okay bestie, listen up β this thing is a general purpose calculator for floats and 3D float vectors. It's giving math but make it glam. π
The SoCalculator uses the values from the input fields (which are either single floating point values or vectors) as variables in the free-form engine expressions, and places the results on the output fields. So it reads stuff, it does math, it writes stuff. Iconic behaviour, honestly.
The engine has sixteen input fields; eight scalar inputs (a, b, c, d, e, f, g, and h), and eight vector inputs (A, B, C, D, E, F, G, and H). π
There are eight output fields; four scalar outputs (oa, ob, oc, and od), and four vector outputs (oA, oB, oC, and oD).
The expression syntax is quite similar to C/C++, with a very limited set of keywords and functions. No cap.
An example:
oa = a * (0.5 + b) / c
Will multiply the value in a with the value in b plus 0.5, divide that result with c, and place the result in oa. Since this is an engine, the expression will only be evaluated when someone attempts to read the value in oa, not every time an input in changed. Lazy evaluation really said "I'll do it when I feel like it" and honestly? Respect. π¦
All inputs are multi-fields, and if there are several values in an input, the expression will be evaluated once for every input field value, and the output will create as many values as there are input field values.
If there is more than one input field, and the input fields do not have the same number of values, the engine will create as many output values as the input field with the biggest number of values. When the index get out of bounds for some other input field, the last field value will be used. It's like when one friend is late to the group photo so you just use the last pic of them you have. π
Vector expressions are similar to scalar expression. An example:
oA = A + vec3f(1.0, 0.0, 0.0) * B
Will take the vector in A, add the value in B multiplied with (1,0,0), and place the result in oA.
In addition to regular arithmetics, the SoCalculator syntax also includes some functions. π§
Scalar functions:
cos(x)β cosine function (xin radians)sin(x)β sinus functiontan(x)β tangent functionacos(x)β arc cosine functionasin(x)β arc sinus functionatan(x)β arc tangent functionatan2(y, x)β arc tangent function of two variables (y,x).cosh(x)β hyperbolic cosine functionsinh(x)β hyperbolic sinus functiontanh(x)β hyperbolic tangent functionsqrt(x)β square root functionpow(x,y)βxraised to the power ofyexp(x)βeto the power ofxlog(x)β natural logarithm ofxlog10()β base-10 logarithm ofxceil(x)β roundsxupwards to the nearest integerfloor(x)β roundsxdownwards to the nearest integerfabs(x)β absolute valuefmod(x, y)β remainder of dividingxbyyrand(x)β pseudo-random value between 0 and 1
Vector functions:
cross(x, y)β cross product ofxandydot(x,y)β dot product ofxandy(returns scalar value)length(x)β length ofx(returns scalar value)normalize(x)β returns normalized version ofxx[y]β access components inx(yshould be a scalar value in the range[0,2])
There are also some named constants that can be used: the lore of numbers β¨
MAXFLOATMINFLOATM_EM_LOG2EM_LOG10EM_LN2M_PIM_SQRT2βsqrt(2)M_SQRT1_2βsqrt(1/2)
The only control flow available is the ? operator. An example:
oa = (a > b) ? (a * 0.5) : (b * c)
(The parentheses are not necessary, they're there just to make the example easier to read) β the original author really said "I'm not explaining myself twice, here's a disclaimer" π
In addition to the standard comparators (<, >, <=, >=, ==, !=), you can also use && (AND) and || (OR) to combine expression, and the unary ! (NOT) operator.
One final thing worth mentioning is the temporary variables. There exists sixteen temporary variables that can be used in expressions. ta, tb, tc, td, te, tf, tg, and th are scalar variables, and tA, tB, tC, tD, tE, tF, tG, and tH are vector variables. They are usually used when you have more than one expression that should be evaluated in order. Basically they're your notes app. Use them to keep your thoughts in order bestie. π«Ά
An example with three expressions:
ta = a * b; tb = c + d; tc = e - f
tA = vec3f(ta, tb, tc) + A
oA = tA * B
The example just shows how temporary variables can be used to make your expressions easier to read. Please note that it's possible to have several statements in one expression. You just separate them with semicolons. π―
Here is a simple example of how an SoCalculator engine may be used in an .iv file:
DEF mycamera PerspectiveCamera {
orientation 1 0 0 1.57
}
DEF headlight DirectionalLight {
intensity 0.8
direction 0 0 1
}
Separator {
# Render a cube not affected by lighting
LightModel { model BASE_COLOR }
BaseColor { rgb = Calculator {
a = USE headlight . intensity
expression [ "oA = vec3f( a, a, a)" ]
} . oA }
Cube {}
}
In the example, the color of the Cube is a function of the intensity of the DirectionalLight, even though the Cube is rendered without lighting because of the BASE_COLOR LightModel. Not the calculator doing the most and the lighting model not even showing up. That's teamwork, that's range. π₯
π CONSTRUCTOR & DESTRUCTOR DOCUMENTATION π
SoCalculator::SoCalculator (void )
Constructor. The birth. The origin story. Main character debut. π
SoCalculator::~SoCalculator (void ) [protected], [virtual]
Destructor. We don't talk about this one. It's the sad part of the movie. π
π MEMBER FUNCTION DOCUMENTATION π
SoType SoCalculator::getTypeId (void ) const [virtual]
Returns the type identification of an object derived from a class inheriting from SoBase. This is used for run-time type checking and "downward" casting. iykyk
Usage example:
void foo(SoNode * node)
{
if (node->getTypeId() == SoFile::getClassTypeId()) {
SoFile * filenode = (SoFile *)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 information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups.
Implements SoBase. Overriding this everywhere is not optional, bestie. It's the vibe check of the type system.
const SoFieldData * SoCalculator::getFieldData (void ) const [virtual]
Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL.
Reimplemented from SoFieldContainer.
const SoEngineOutputData * SoCalculator::getOutputData (void ) const [virtual]
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Translation: not for you, bestie. Look away. π
Implements SoEngine.
void SoCalculator::inputChanged (SoField * which) [protected], [virtual]
Called when an input is changed. The default method does nothing, but subclasses may override this method to do The Right Thing when a specific field is changed. Doing The Right Thing is literally the whole assignment. β¨
Reimplemented from SoEngine.
β MEMBER DATA DOCUMENTATION β
Okay here's the whole cast of characters. Every single one of them, no skipping. π¬
SoMFFloat SoCalculator::aβ Input floating point value for the expressions.SoMFFloat SoCalculator::bβ Input floating point value for the expressions.SoMFFloat SoCalculator::cβ Input floating point value for the expressions.SoMFFloat SoCalculator::dβ Input floating point value for the expressions.SoMFFloat SoCalculator::eβ Input floating point value for the expressions.SoMFFloat SoCalculator::fβ Input floating point value for the expressions.SoMFFloat SoCalculator::gβ Input floating point value for the expressions.SoMFFloat SoCalculator::hβ Input floating point value for the expressions.SoMFVec3f SoCalculator::Aβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Bβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Cβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Dβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Eβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Fβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Gβ Input vector with three floating point values for the expressions.SoMFVec3f SoCalculator::Hβ Input vector with three floating point values for the expressions.SoMFString SoCalculator::expressionβ Mathematical expressions for the calculator. The actual brain cell of this whole operation. π§SoEngineOutput SoCalculator::oaβ (SoMFFloat) Output value with result from the calculations.SoEngineOutput SoCalculator::obβ (SoMFFloat) Output value with result from the calculations.SoEngineOutput SoCalculator::ocβ (SoMFFloat) Output value with result from the calculations.SoEngineOutput SoCalculator::odβ (SoMFFloat) Output value with result from the calculations.SoEngineOutput SoCalculator::oAβ (SoMFVec3f) Output value with result from the calculations.SoEngineOutput SoCalculator::oBβ (SoMFVec3f) Output value with result from the calculations.SoEngineOutput SoCalculator::oCβ (SoMFVec3f) Output value with result from the calculations.SoEngineOutput SoCalculator::oDβ (SoMFVec3f) Output value with result from the calculations.
πΈ AUTHOR πΈ
Generated automatically by Doxygen for Coin from the source code. Not a human, just vibes and a parser. π€β¨
And that's the whole page bestie!! This was Coin, Version 3.1.3, page SoCalculator(3) β go forth and calculate, you gorgeous genius. π¦π slay, periodt, no cap π
ππ
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.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