elements(3)
π elements(3) π
okay bestie, welcome to the manual page for elements β part of the Library Functions Manual, section 3 (that's the "these are library functions, go write some code" section, iykyk π«Ά).
This is a long one, so it's coming at you in three parts. You're reading part 1 right now. Buckle up, hydrate, and let's get into it. β¨
πΈ NAME πΈ
elementsβ Element Classes π
that's the whole vibe of this page: it's about Element Classes. Element classes. Classes for elements. The way that naming is so straightforward, honestly iconic of them. π</pinky>
no cap, that's literally it for this bit β the rest of the good stuff is coming in the next parts, so keep scrolling when they arrive. π¦
β¨ SYNOPSIS β¨
π Classes π
okay bestie, buckle up, this is the full roster of element classes and it's a lot π
class SoGLClipPlaneElementβ soooo this one is yet to be documented, we literally have nothing else, it's giving mysterious π«Άclass SoGLColorIndexElementβ this one sets the current OpenGL color, slay β¨class SoGLCoordinateElementβ yet to be documented, no cap πclass SoGLDepthBufferElementβ controls the OpenGL depth buffer πclass SoGLDisplayListβ stores and manages OpenGL display lists, iconic behavior πclass SoGLDrawStyleElementβ updates the current draw style in OpenGL πclass SoGLEnvironmentElementβ this one's for setting GL fog etc., lowkey atmospheric πΈclass SoGLLazyElementβ meant to optimize GL rendering, the efficiency queen β¨class SoGLLightIdElementβ yet to be documented πclass SoGLLinePatternElementβ yet to be documented π¦class SoGLLineWidthElementβ changes the linewidth setting of the OpenGL render state πclass SoGLModelMatrixElementβ yet to be documented πclass SoGLMultiTextureCoordinateElementβ stores the current gltexture coordinates for several units, multi-tasking main character πclass SoGLTextureEnabledElementβ an element which controls whether texturing is enabled or not πclass SoGLMultiTextureImageElementβ used to control the current GL texture for texture units πΌοΈclass SoGLMultiTextureMatrixElementβ used to update the OpenGL texture matrix π₯class SoGLNormalElementβ yet to be documented πclass SoGLPointSizeElementβ changes the pointsize setting of the OpenGL render state βclass SoGLPolygonOffsetElementβ yet to be documented π¦class SoGLProjectionMatrixElementβ yet to be documented πclass SoGLRenderPassElementβ yet to be documented πclass SoGLShapeHintsElementβ yet to be documented πΈclass SoGLTexture3EnabledElementβ an element which controls whether 3D texturing is enabled or not πclass SoGLTextureCoordinateElementβ stores the current gltexture coordinates πclass SoGLTextureImageElementβ used to control the current GL texture πΌοΈclass SoGLTextureMatrixElementβ used to update the OpenGL texture matrix π₯class SoGLUpdateAreaElementβ yet to be documented πclass SoGLVBOElementβ used to store VBO state π¦class SoGLViewingMatrixElementβ used to store the current viewing matrix πclass SoGLViewportRegionElementβ yet to be documented π¦class SoAccumulatedElementβ an abstract class for storing accumulated state, the blueprint vibes πclass SoAmbientColorElementβ yet to be documented πclass SoAnnoText3CharOrientElementβ yet to be documented πclass SoAnnoText3FontSizeHintElementβ yet to be documented πΈclass SoAnnoText3RenderPrintElementβ yet to be documented πclass SoBBoxModelMatrixElementβ keeps track of the current model matrix during a scene graph traversal. It is used by amongst others theSoGetBoundingBoxActionclass, bestie's little helper π«Άclass SoBumpMapCoordinateElementβ yet to be documented πclass SoTextureImageElementβ yet to be documented π¦class SoBumpMapMatrixElementβ used to manage the bump map matrix stack πclass SoCacheElementβ stores and manages the open caches π¦class SoClipPlaneElementβ used to manage the clip plane stack βοΈclass SoComplexityElementβ contains the current shape complexity for a graph traverser πclass SoComplexityTypeElementβ yet to be documented πclass SoCoordinateElementβ yet to be documented πclass SoCreaseAngleElementβ stores the crease angle during a scene graph traversal πclass SoCullElementβ used internally for render and pick culling πclass SoDecimationPercentageElementβ yet to be documented πclass SoDecimationTypeElementβ yet to be documented π¦class SoDepthBufferElementβ controls the depth buffer settings πclass SoDiffuseColorElementβ yet to be documented πclass SoDrawStyleElementβ yet to be documented πΈclass SoElementβSoElementis the abstract base class for all elements, the literal mother of them all πclass SoEmissiveColorElementβ yet to be documented πclass SoEnvironmentElementβ yet to be documented πclass SoFloatElementβSoFloatElementis an abstract base class for elements that consists of a single float value πclass SoFocalDistanceElementβ yet to be documented πclass SoFontNameElementβ yet to be documented π¦class SoFontSizeElementβ yet to be documented πΈclass SoInt32Elementβ the base class for elements that simply store a 32-bit integer π’class SoLazyElementβ used to handle material and shape properties β¨class SoLightAttenuationElementβ yet to be documented πclass SoLightElementβ manages the currently active light sources π‘class SoLightModelElementβ yet to be documented πclass SoLinePatternElementβ yet to be documented π¦class SoLineWidthElementβ changes the linewidth setting of the render state πclass SoListenerDopplerElementβ holds the doppler velocity and factor of the current listener π§class SoListenerGainElementβ stores theSoListenergain during a scene graph traversal πclass SoListenerOrientationElementβ holds the orientation of the current listener π§class SoListenerPositionElementβ holds the position of the current listener πclass SoLocalBBoxMatrixElementβ yet to be documented πclass SoMaterialBindingElementβ yet to be documented π¦class SoModelMatrixElementβ used to manage the current transformation πclass SoTextureCoordinateElementβ yet to be documented πclass SoMultiTextureEnabledElementβ an element which stores whether texturing is enabled or not πΈclass SoMultiTextureImageElementβ yet to be documented πclass SoMultiTextureMatrixElementβ used to manage the texture matrix stack for texture units > 0 π₯class SoNormalBindingElementβ yet to be documented πclass SoNormalElementβ yet to be documented πclass SoOverrideElementβ maintains a list of overridable elements and a list over which elements should be overridden, the bossy one πclass SoPickRayElementβ yet to be documented π¦class SoPickStyleElementβ yet to be documented πclass SoPointSizeElementβ changes the pointsize setting of the render state βclass SoPolygonOffsetElementβ yet to be documented πΈclass SoProfileCoordinateElementβ yet to be documented πclass SoProfileElementβ yet to be documented πclass SoReplacedElementβ an abstract element superclass πclass SoShapeStyleElementβ yet to be documented πclass SoShininessElementβ yet to be documented β¨class SoSoundElementβ used for optimizing audio rendering and for turning off inactiveSoVRMLSoundnodes πclass SoSpecularColorElementβ yet to be documented πclass SoSwitchElementβ yet to be documented π¦class SoTextOutlineEnabledElementβ yet to be documented πΈclass SoTextureCombineElementβ yet to be documented πclass SoTextureCoordinateBindingElementβ yet to be documented πclass SoTextureEnabledElementβ an element which stores whether texturing is enabled or not πclass SoTextureMatrixElementβ used to manage the texture matrix stack π₯class SoTextureOverrideElementβ makes it possible to override texture elements πclass SoTextureQualityElementβ yet to be documented πclass SoTextureUnitElementβ yet to be documented π¦class SoTransparencyElementβ yet to be documented πclass SoUnitsElementβSoUnitsElementβ bestie, this class is yet to be documented π (yes, really, that's the whole tea)SoVertexAttributeBindingElementβ also yet to be documented πSoViewVolumeElementβ yet to be documented, we stay guessing πSoViewingMatrixElementβ ok this one actually has lore: it stores the world-to-camera transformation β¨SoViewportRegionElementβ yet to be documented π¦SoWindowElementβ this icon is used to store the current window attributes πSoGeoElementβ yet to be documented πΈSoGLShadowCullingElementβ yet to be documented π«ΆSoShadowStyleElementβ yet to be documented π
π DETAILED DESCRIPTION π
okay so here's the vibe: the element classes in Coin are the containers of state information during action traversals of scene graphs. One element usually corresponds to one item of information, or sometimes a whole group of related information values. The elements work like a stack that gets pushed and popped as the action traverses in and out of SoSeparator nodes, and the action will always just inspect the top of the stack when it needs to know a value. no cap. π
Elements are internal implementation details of the workings of nodes and actions, and it's not something one needs to worry about before writing one's own extension nodes. Writing extension elements is even more removed from plain Open Inventor usage, but it is fully possible for the experienced Open Inventor developer. π
The Element Classes β¨
Elements are mostly internal to Coin, unless you create new extension nodes over Coin. Then you will probably need to know about them. π
Elements are part of the design for scenegraph traversal in Coin.
It works like this, bestie: any traversal action instantiates and keeps a single SoState instance during traversal. The SoState instance uses SoElement objects as "memory units" to keep track of the current state for any feature of the scenegraph nodes. π§
As an example, consider the SoPointSize node: when the SoPointSize node is traversed by, for instance, a SoGLRenderAction, it will itself push a SoPointSizeElement onto the SoGLRenderAction's SoState stack. Later, when a SoPointSet node occurs in the scenegraph, it will request the current pointsize value from the SoState by reading off the value of its SoPointSizeElement. the way that just works is so satisfying fr fr π
SoSeparator nodes will push and pop elements on and off the state stack, so anything that changes state below a SoSeparator node will not influence anything above the SoSeparator. it's giving boundaries. π§
For more information on the theoretical underpinnings of this traversal design, you should consider reading available literature on the so-called "Visitor pattern". We recommend "Design Patterns", by Gamma, Helm, Johnson, Vlissides (aka the "Gang Of Four"). This book actually uses the Inventor API traversal mechanism as the case study for explaining the Visitor pattern. π
For extending the Coin library with your own classes, we strongly recommend that you make yourself acquainted with the excellent Β«The Inventor ToolmakerΒ» book (ISBN 0-201-62493-1), which describes the tasks involved in detail. This book was written by the original SGI Inventor designers and explains many of the underlying design ideas, as well as having lots of hands-on examples on how to extend the Coin toolkit in ways that are true to the fundamental design ideas. (Β«The Inventor ToolmakerΒ» is also available at SGI's online library, at no cost. See Download The Inventor Toolmaker.) Reading the sourcecode of the built-in classes in Coin should also provide very helpful. π οΈβ¨
The following is a complete example on how to extend Coin with your own traversal elements. First, the class declaration of the new element (ie the header include file):
// [texturefilenameelement.h]
#ifndef TEXTUREFILENAMEELEMENT_H
#define TEXTUREFILENAMEELEMENT_H
#include <Inventor/elements/SoReplacedElement.h>
#include <Inventor/SbString.h>
class TextureFilenameElement : public SoReplacedElement {
typedef SoReplacedElement inherited;
SO_ELEMENT_HEADER(TextureFilenameElement);
public:
static void initClass(void);
virtual void init(SoState * state);
static void set(SoState * const state, SoNode * const node,
const SbString & filename);
static const SbString & get(SoState * const state);
static const TextureFilenameElement * getInstance(SoState * state);
protected:
virtual ~TextureFilenameElement();
virtual void setElt(const SbString & filename);
private:
SbString filename;
};
#endif // !TEXTUREFILENAMEELEMENT_H
The implementation of the element:
// [texturefilenameelement.cpp]
//
// The purpose of the code in this file is to demonstrate how you can
// make your own elements for scene graph traversals.
//
// Code by Peder Blekken <pederb@sim.no>, 1999-12-09. Copyright
// Kongsberg Oil & Gas Technologies.
#include "texturefilenameelement.h"
SO_ELEMENT_SOURCE(TextureFilenameElement);
void
TextureFilenameElement::initClass(void)
{
SO_ELEMENT_INIT_CLASS(TextureFilenameElement, inherited);
}
void
TextureFilenameElement::init(SoState * state)
{
this->filename = "<none>";
}
TextureFilenameElement::~TextureFilenameElement()
{
}
void
TextureFilenameElement::set(SoState * const state, SoNode * const node,
const SbString & filename)
{
TextureFilenameElement * elem = (TextureFilenameElement *)
SoReplacedElement::getElement(state, classStackIndex, node);
elem->setElt(filename);
}
const SbString &
TextureFilenameElement::get(SoState * const state)
{
return TextureFilenameElement::getInstance(state)->filename;
}
void
TextureFilenameElement::setElt(const SbString & filename)
{
this->filename = filename;
}
const TextureFilenameElement *
TextureFilenameElement::getInstance(SoState * state)
{
return (const TextureFilenameElement *)
SoElement::getConstElement(state, classStackIndex);
}
And a small, stand-alone test application putting the new element to use:
// [lstextures.cpp]
//
// The purpose of this file is to make a small wrapper "tool" around
// the TextureFilenameElement extension element, just for showing
// example code on how to make use of a user-defined custom element.
//
// The code goes like this:
//
// We initialize the element, enable it for the SoCallbackAction, read
// a scene graph file, set callbacks on SoTexture2 and all shape nodes
// and applies the SoCallbackAction. The callbacks will then print out
// the texture filename information from the TextureFilenameElement
// each time an interesting node is hit.
//
//
// Code by Peder Blekken <pederb@sim.no>. Cleaned up, integrated in
// Coin distribution and commented by Morten Eriksen
// <mortene@sim.no>. 1999-12-09. Copyright Kongsberg Oil & Gas Technologies.
#include <Inventor/SoDB.h>
#include <Inventor/SoInput.h>
#include <Inventor/actions/SoCallbackAction.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTexture2.h>
#include <Inventor/nodes/SoShape.h>
#include <Inventor/misc/SoState.h>
#include <cstdio>
#include "texturefilenameelement.h"
SoCallbackAction::Response
pre_tex2_cb(void * data, SoCallbackAction * action, const SoNode * node)
{
const SbString & filename = ((SoTexture2 *)node)->filename.getValue();
TextureFilenameElement::set(action->getState(), (SoNode *)node, filename);
(void)fprintf(stdout, "=> New texture: %s\n",
filename.getLength() == 0 ?
"<inlined>" : filename.getString());
return SoCallbackAction::CONTINUE;
}
SoCallbackAction::Response
pre_shape_cb(void * data, SoCallbackAction * action, const SoNode * node)
{
const SbString & filename =
TextureFilenameElement::get(action->getState());
(void)fprintf(stdout, " Texturemap on %s: %s\n",
node->getTypeId().getName().getString(),
filename.getLength() == 0 ?
"<inlined>" : filename.getString());
return SoCallbackAction::CONTINUE;
}
void
usage(const char * appname)
{
(void)fprintf(stderr, "\n\\tUsage: %s <modelfile.iv>\n\n", appname);
(void)fprintf(stderr,
"\\tLists all texture filenames in the model file,\n"
"\\tand on which shape nodes they are used.\n\n"
"\\tThe purpose of this example utility is simply to\n"
"\\tshow how to create and use an extension element for\n"
"\\tscene graph traversal.\n\n");
}
int
main(int argc, char ** argv)
{
if (argc != 2) {
usage(argv[0]);
exit(1);
}
SoDB::init();
TextureFilenameElement::initClass();
SO_ENABLE(SoCallbackAction, TextureFilenameElement);
SoInput input;
if (!input.openFile(argv[1])) {
(void)fprintf(stderr, "ERROR: couldn't open file ``%s''.\n", argv[1]);
exit(1);
}
SoSeparator * root = SoDB::readAll(&input);
if (root) {
root->ref();
SoCallbackAction cbaction;
cbaction.addPreCallback(SoTexture2::getClassTypeId(), pre_tex2_cb, NULL);
cbaction.addPreCallback(SoShape::getClassTypeId(), pre_shape_cb, NULL);
cbaction.apply(root);
root->unref();
return 0;
}
return 1;
}
π«Ά AUTHOR π«Ά
Generated automatically by Doxygen for Coin from the source code. π€β¨
and that's a wrap on part 3, bestie π this page was served up by Coin Version 3.1.3, page elements(3), and yeah the author line is literally Doxygen auto-generating the whole thing from the source code β iconic behavior tbh πβ¨ slay, go write your extension elements, ily π¦
π¦ 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