#include <Inventor/nodes/SoNode.h>
Inheritance diagram for SoNode:
Public Types | |
enum | NodeType { INVENTOR = 0, VRML1 = 1 } |
Public Member Functions | |
void | setOverride (const SbBool state) |
SbBool | isOverride (void) const |
void | setNodeType (const NodeType type) |
NodeType | getNodeType (void) const |
virtual SoNode * | copy (SbBool copyconnections=FALSE) const |
virtual SbBool | affectsState (void) const |
virtual void | doAction (SoAction *action) |
virtual void | GLRender (SoGLRenderAction *action) |
virtual void | GLRenderBelowPath (SoGLRenderAction *action) |
virtual void | GLRenderInPath (SoGLRenderAction *action) |
virtual void | GLRenderOffPath (SoGLRenderAction *action) |
virtual void | callback (SoCallbackAction *action) |
virtual void | getBoundingBox (SoGetBoundingBoxAction *action) |
virtual void | getMatrix (SoGetMatrixAction *action) |
virtual void | handleEvent (SoHandleEventAction *action) |
virtual void | pick (SoPickAction *action) |
virtual void | rayPick (SoRayPickAction *action) |
virtual void | search (SoSearchAction *action) |
virtual void | write (SoWriteAction *action) |
virtual void | getPrimitiveCount (SoGetPrimitiveCountAction *action) |
virtual void | grabEventsSetup (void) |
virtual void | grabEventsCleanup (void) |
virtual void | startNotify (void) |
virtual void | notify (SoNotList *l) |
uint32_t | getNodeId (void) const |
virtual SoChildList * | getChildren (void) const |
virtual void | writeInstance (SoOutput *out) |
virtual SoNode * | addToCopyDict (void) const |
virtual void | copyContents (const SoFieldContainer *from, SbBool copyconnections) |
virtual SoFieldContainer * | copyThroughConnection (void) const |
Static Public Member Functions | |
SoType | getClassTypeId (void) |
SoNode * | getByName (const SbName &name) |
int | getByName (const SbName &name, SoNodeList &l) |
void | initClass (void) |
void | initClasses (void) |
uint32_t | getNextNodeId (void) |
int | getActionMethodIndex (const SoType type) |
void | getBoundingBoxS (SoAction *action, SoNode *node) |
void | GLRenderS (SoAction *action, SoNode *node) |
void | callbackS (SoAction *action, SoNode *node) |
void | getMatrixS (SoAction *action, SoNode *node) |
void | handleEventS (SoAction *action, SoNode *node) |
void | pickS (SoAction *action, SoNode *node) |
void | rayPickS (SoAction *action, SoNode *node) |
void | searchS (SoAction *action, SoNode *node) |
void | writeS (SoAction *action, SoNode *node) |
void | getPrimitiveCountS (SoAction *action, SoNode *node) |
Protected Member Functions | |
SoNode (void) | |
virtual | ~SoNode () |
virtual SbBool | readInstance (SoInput *in, unsigned short flags) |
Static Protected Member Functions | |
const SoFieldData ** | getFieldDataPtr (void) |
void | setNextActionMethodIndex (int index) |
int | getNextActionMethodIndex (void) |
void | incNextActionMethodIndex (void) |
Protected Attributes | |
uint32_t | uniqueId |
Static Protected Attributes | |
uint32_t | nextUniqueId = 0 |
int | nextActionMethodIndex = 0 |
Coin is a retained mode 3D visualization library (built on top of the immediate mode OpenGL library). "Retained mode" means that instead of passing commands to draw graphics primitives directly to the renderer, you build up data structures which are rendered by the library on demand.
The node classes are the main "primitive" for building these data structures. In Coin, you build tree hierarchies made up of different node types: group nodes (for the tree structure layout of the other nodes), appearance nodes (for setting up materials, textures, etc), shape nodes (for the actual geometry), and nodes for lighting and camera positioning.
One common issue with newcomers to the API is that you should not and can not use the C++ delete operator on nodes -- the destructor is protected. This is because node instances are using a common technique for memory resource handling called "reference counting". Nodes are deleted (actually, they delete themselves) when their unref() method is called and the reference count goes to zero.
Usually application programmers won't manually ref() and unref() nodes a lot, because you pass the nodes directly to SoGroup::addChild() or So*Viewer::setSceneGraph() or something similar. These functions will ref() the nodes they are passed, and unref() them when they are finished with them.
Make sure you do ref() nodes that you keep pointers to so they aren't accidentally deleted prematurely due to an unref() call from within the library itself. If you haven't manually called ref() on a top-level root node, it will then be deleted automatically. This code shows how to do it:
SoSeparator * root = new SoSeparator; // root's refcount starts out at zero root->addChild(foo_node); // foo_node refcount is increased by 1 root->addChild(bar_node); // bar_node refcount +1 // increase refcount before passing it to setScenegraph(), to avoid // premature destruction root->ref(); myviewer->setSceneGraph(root); // root's refcount +1, is now 2 // [misc visualization and processing] // myviewer will let go of it's reference to the root node, thereby // decreasing it's referencecount by 1 myviewer->setSceneGraph(NULL); // root's refcount goes from +1 to 0, and it will self-destruct controllably root->unref(); // avoid dangling pointer, in case "root" is attempted used again // (not really necessary, but good for smoking out bugs early) root = NULL;
For full information and tutorial-style introductions to all API issues, see the "Inventor Mentor: Programming Object-Oriented 3D Graphics with Open Inventor" (ISBN 0-201-62495-8). It has detailed explanations on all the basic principles involved.
See specifically the section "References and Deletion" in Chapter 3 to learn about the reference counting techniques.
Often when using the Coin library, one is interested in making extensions to it. Of particular interest is setting up extension nodes, which are then traversed, rendered and otherwise used by the rest of the library as any internal node.
The Coin header file Inventor/nodes/SoSubNode.h includes a set of convenience macros for quick and easy construction of extension nodes. Here's a complete snippet of code which shows how to set up a skeleton framework for an extension node class:
#include <Inventor/nodes/SoWWWInline.h> class MyWWWInline : public SoWWWInline { SO_NODE_HEADER(MyWWWInline); public: static void initClass(void); MyWWWInline(void); protected: virtual ~MyWWWInline(); }; SO_NODE_SOURCE(MyWWWInline); MyWWWInline::MyWWWInline(void) { SO_NODE_CONSTRUCTOR(MyWWWInline); } MyWWWInline::~MyWWWInline() { } void MyWWWInline::initClass(void) { SO_NODE_INIT_CLASS(MyWWWInline, SoWWWInline, "SoWWWInline"); } int main(int argc, char ** argv) { SoDB::init(); MyWWWInline::initClass(); // [...] return 0; }
You can then override for instance the GLRender() method to have your new class render OpenGL geometry different from it's superclass.
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, aswell 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.
|
Used to store node type. |
|
Default constructor, initializes node instance. |
|
Destructor. |
|
Set the override flag.
If this flag is A common applicaton for "override nodes" is to place them at the top of the tree as a convenient way to force e.g. a common drawstyle on the complete tree. |
|
Return status of override flag.
|
|
Sets the node type for this node to type. Since some nodes should be handled differently in VRML1 vs. Inventor, this should be used to get correct behavior for those cases. The default node type is INVENTOR. This method is an extension versus the Open Inventor API.
|
|
Returns the node type set for this node. This method is an extension versus the Open Inventor API.
|
|
Make a duplicate of this node and return a pointer to the duplicate. If this node is a group node, children are also copied and we return a pointer to the root of a full copy of the subgraph rooted here.
If copyconnections is Note that this function has been made virtual in Coin, which is not the case in the original Open Inventor API. We may change this method back into being non-virtual again for Coin version 2, as it was made virtual more or less by mistake. So please don't write application code that depends on SoNode::copy() being virtual. The reason this method should not be virtual is because this is not the function the application programmer should override if she needs some special behavior during a copy operation (like copying the value of internal data not exposed as fields). For that purpose, override the copyContents() method. Your overridden copyContents() method should then both copy internal data aswell as calling the parent superclass' copyContents() method for automatically handling of fields and other common data. |
|
Returns
If it returns
The default method returns Reimplemented in SoNodeKitListPart, SoSceneKit, SoArray, SoMultipleCopy, SoSeparator, SoShape, and SoSwitch. |
|
This function performs the typical operation of a node for any action. Reimplemented in SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoNodeKitListPart, SoAntiSquish, SoArray, SoBaseColor, SoCallback, SoCamera, SoClipPlane, SoComplexity, SoCoordinate3, SoCoordinate4, SoDrawStyle, SoFile, SoFont, SoFontStyle, SoGroup, SoLOD, SoLevelOfDetail, SoLightModel, SoMaterial, SoMaterialBinding, SoMatrixTransform, SoMultipleCopy, SoNormal, SoNormalBinding, SoPackedColor, SoPathSwitch, SoPickStyle, SoPolygonOffset, SoProfile, SoProfileCoordinate2, SoProfileCoordinate3, SoResetTransform, SoRotation, SoRotationXYZ, SoScale, SoSeparator, SoShapeHints, SoSurroundScale, SoSwitch, SoTexture2, SoTexture2Transform, SoTextureCoordinate2, SoTextureCoordinateBinding, SoTextureCoordinateDefault, SoTextureCoordinateEnvironment, SoTextureCoordinatePlane, SoTransform, SoTransformSeparator, SoTranslation, SoUnits, SoVertexProperty, and SoWWWInline. |
|
|
Implements the SoAction::BELOW_PATH traversal method for the rendering action. Reimplemented in SoAnnotation, SoExtSelection, SoLOD, SoLocateHighlight, and SoSeparator. |
|
Implements the SoAction::IN_PATH traversal method for the rendering action. Reimplemented in SoAnnotation, SoLOD, SoLocateHighlight, and SoSeparator. |
|
Implements the SoAction::OFF_PATH traversal method for the rendering action. Reimplemented in SoAnnotation, SoLOD, and SoSeparator. |
|
|
|
Action method for SoGetMatrixAction. Updates action by accumulating with the transformation matrix of this node (if any). Reimplemented in SoCenterballDragger, SoDragger, SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoNodeKitListPart, SoAntiSquish, SoArray, SoCallback, SoFile, SoGroup, SoMatrixTransform, SoMultipleCopy, SoPathSwitch, SoResetTransform, SoRotation, SoRotationXYZ, SoScale, SoSeparator, SoSurroundScale, SoSwitch, SoTexture2Transform, SoTransform, SoTransformSeparator, SoTranslation, SoUnits, and SoWWWInline. |
|
Action method for SoHandleEventAction. Inspects the event data from action, and processes it if it is something which this node should react to. Nodes influencing relevant state variables for how event handling is done also overrides this method. Reimplemented in SoDragger, SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoNodeKitListPart, SoArray, SoCallback, SoCamera, SoEventCallback, SoExtSelection, SoFile, SoGroup, SoLocateHighlight, SoMultipleCopy, SoPathSwitch, SoSelection, SoSeparator, SoSwitch, SoWWWAnchor, and SoWWWInline. |
|
Action method for SoPickAction. Does common processing for SoPickAction action instances. Reimplemented in SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoNodeKitListPart, SoAntiSquish, SoArray, SoBaseColor, SoCallback, SoClipPlane, SoComplexity, SoCoordinate3, SoCoordinate4, SoFile, SoFont, SoFontStyle, SoGroup, SoMaterialBinding, SoMatrixTransform, SoMultipleCopy, SoNormal, SoNormalBinding, SoPathSwitch, SoPickStyle, SoProfile, SoProfileCoordinate2, SoProfileCoordinate3, SoResetTransform, SoRotation, SoRotationXYZ, SoScale, SoShapeHints, SoSurroundScale, SoSwitch, SoTexture2Transform, SoTextureCoordinate2, SoTextureCoordinateBinding, SoTextureCoordinateDefault, SoTextureCoordinateEnvironment, SoTextureCoordinatePlane, SoTransform, SoTransformSeparator, SoTranslation, SoUnits, SoVertexProperty, and SoWWWInline. |
|
Action method for SoRayPickAction. Checks the ray specification of the action and tests for intersection with the data of the node. Nodes influencing relevant state variables for how picking is done also overrides this method. Reimplemented in SoDragger, SoBaseKit, SoCamera, SoCone, SoCube, SoCylinder, SoImage, SoIndexedNurbsCurve, SoIndexedNurbsSurface, SoLOD, SoLevelOfDetail, SoNurbsCurve, SoNurbsSurface, SoSeparator, SoShape, SoSphere, and SoText2. |
|
Action method for SoSearchAction. Compares the search criteria from the action to see if this node is a match. Searching is done by matching up all criteria set up in the SoSearchAction -- if any of the requested criteria is a miss, the search is not deemed successful for the node.
Reimplemented in SoDragger, SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoNodeKitListPart, SoArray, SoCallback, SoGroup, SoMultipleCopy, SoPathSwitch, SoSeparator, SoSwitch, and SoWWWInline. |
|
Action method for SoWriteAction. Writes out a node object, and any connected nodes, engines etc, if necessary. Reimplemented in SoDragger, SoBaseKit, SoBlinker, SoCallback, SoGroup, SoPendulum, SoShuttle, SoSwitch, and SoVertexShape. |
|
|
Called from SoHandleEventAction::setGrabber() to notify a node when it becomes the node where all events are sent. Reimplemented in SoDragger. |
|
Called from SoHandleEventAction to notify a node when it looses status as the node where events are sent. Reimplemented in SoDragger. |
|
This is the method which starts the notification sequence after changes. At the end of a notification sequence, all "immediate" sensors (i.e. sensors set up with a zero priority) are triggered. Reimplemented from SoBase. |
|
Notifies all auditors for this instance when changes are made. Reimplemented from SoFieldContainer. Reimplemented in SoAsciiText, SoBlinker, SoImage, SoMaterial, SoPackedColor, SoSeparator, SoText3, SoTexture2, SoVertexProperty, and SoVertexShape. |
|
This returns the node's current unique identification number. It is unlikely that application programmers will ever need use this method fom client application code, unless working with extensions to the core library (and probably not even then). The id number is only valid for as long as the node is kept unchanged -- upon any kind of change the internal id will be updated (in the notify() method), and the old id number forgotten. The technique described above plays an important role in the way internal scenegraph caches are set up and invalidated.
|
|
Returns list of children for this node. Reimplemented in SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoNodeKitListPart, SoFile, SoGroup, and SoWWWInline. |
|
This method is called from write() if the actual writing pass of the write action is taking place. It dumps the node to the given out output stream. Reimplemented from SoFieldContainer. |
|
Add a copy of this node and (recursively) all children to the copy dictionary of SoFieldContainer if this has not already been done. Used internally during copy operations. Reimplemented in SoBaseKit. |
|
Makes a deep copy of all data of from into this instance, except external scenegraph references if copyconnections is This is the method that should be overridden by subclasses which needs to account for internal data that are not handled automatically. Make sure that when you override the copyContents() method in your extension class that you also make it call upwards to it's parent superclass in the inheritance hierarchy, as copyContents() in for instance SoNode and SoFieldContainer does important work. It should go something like this:
Reimplemented from SoFieldContainer. Reimplemented in SoRotateCylindricalDragger, SoRotateSphericalDragger, SoClipPlaneManip, SoDirectionalLightManip, SoPointLightManip, SoSpotLightManip, SoTransformManip, SoBaseKit, SoInteractionKit, SoNodeKitListPart, SoCallback, SoFile, SoGroup, and SoWWWInline. |
|
Return copy of this instance.
Note: default implementation just returns Reimplemented from SoFieldContainer. |
|
This static method returns the SoType object associated with objects of this class. Reimplemented from SoFieldContainer. |
|
Returns the last node that was registered under name. |
|
Finds all nodes with name and appends them to the l nodelist. Returns the number of nodes with the specified name. |
|
|
Initialize all the node classes of Coin. Reimplemented in SoDragger. |
|
Return the next unique identification number to be assigned upon node construction or change. It is unlikely that application programmers will ever need use this method fom client application code, unless working with extensions to the core library (and probably not even then).
|
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::getBoundingBox() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::GLRender() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::callback() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::getMatrix() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::handleEvent() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::pick() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::rayPick() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::search() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::write() virtual method which does the real work. |
|
This is a static "helper" method registered with the action, and used for calling the SoNode::getPrimitiveCount() virtual method which does the real work. |
|
This method is mainly intended for internal use during file import operations. It reads a definition of an instance from the input stream in. The input stream state points to the start of a serialized / persistant representation of an instance of this class type.
flags is used internally during binary import when reading user extension nodes, group nodes or engines. Reimplemented from SoFieldContainer. Reimplemented in SoBaseKit, SoInteractionKit, SoNodeKitListPart, SoFile, SoGroup, SoImage, SoNormalBinding, SoSeparator, SoTexture2, SoTextureCoordinateBinding, and SoWWWInline. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Only in TGS Inventor on Win32 -- to avoid needing to export the nextActionMethodIndex member, see SoNode.h for more info. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Only in TGS Inventor on Win32 -- to avoid needing to export the nextActionMethodIndex member, see SoNode.h for more info. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Only in TGS Inventor on Win32 -- to avoid needing to export the nextActionMethodIndex member, see SoNode.h for more info. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |
|
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. |