SoCallbackAction Class |
Performs a generic traversal of a scene graph or path.
Namespace: OIV.Inventor.Actions
The SoCallbackAction type exposes the following members.
Name | Description | |
---|---|---|
SoCallbackAction | The constructor. |
Name | Description | |
---|---|---|
AddLineSegmentCallback | Routine to add callbacks for generated primitives (line segments) for all shapes of the given type. | |
AddPointCallback | Routine to add callbacks for generated primitives (points) for all shapes of the given type. | |
AddPostCallback | Adds a callback function to call when a node of the given type is encountered during traversal. | |
AddPreCallback | Adds a callback function to call when a node of the given type is encountered during traversal. | |
AddTriangleCallback | Routine to add callbacks for generated primitives (triangles) for all shapes of the given type. | |
Apply(SoNode) | Initiates an action on the graph defined by a node. | |
Apply(SoPath) | Initiates an action on the graph defined by a path. | |
Apply(SoPathList) | Calls Apply(pathList, false). (Inherited from SoAction.) | |
Apply(SoPathList, Boolean) | Initiates an action on the graph defined by a list of paths. | |
ClearApplyResult | When applied, an action may reference nodes or create objects (e.g. | |
EnableElement | ||
EnableElements | Obsolete.
Returns the list of enabled elements for a given action subclass.
(Inherited from SoAction.) | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
ForwardTraversal(SoNode) | Traverse a node that is not part of the current scenegraph. | |
ForwardTraversal(SoPath) | Traverse a path that is not part of the current scenegraph. | |
GetComplexity | Returns complexity information from the state. | |
GetComplexityType | Returns complexity information from the state. | |
GetContinueActionInBranchFlag | This function indicates if the action must stop in the current branch. | |
GetCoordinate3 | Returns the current coordinates from the state. | |
GetCoordinate4 | Returns the current coordinates from the state. | |
GetCreaseAngle | Returns the current shape hints from the state. | |
GetCurPath | Returns the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed. | |
GetCurrentResponse | ||
GetDecimationPercentage | Returns the current decimation percentage from the state. | |
GetDecimationType | Returns the current decimation type from the state. | |
GetDistribMode | Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only). | |
GetDrawStyle | Returns the current drawing style information from the state. | |
GetFaceType | Returns the current shape hints from the state. | |
GetFocalDistance | Returns the current camera and viewing information from the state. | |
GetFontName | Returns the current font information from the state. | |
GetFontRenderStyle | Returns the current font information from the state. | |
GetFontSize | Returns the current font information from the state. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetLightAttenuation | Returns the current lighting model information from the state. | |
GetLightModel | Returns the current lighting model information from the state. | |
GetLinePattern | Returns the current drawing style information from the state. | |
GetLinePatternScaleFactor | Returns the current drawing style information from the state. | |
GetLineWidth | Returns the current drawing style information from the state. | |
GetMaterial(SbColor, SbColor, SbColor, SbColor, Single, Single) | Calls GetMaterial(ambient, diffuse, specular, emission, shininess, transparency, System.Int32(0)). | |
GetMaterial(SbColor, SbColor, SbColor, SbColor, Single, Single, Int32) | Returns the current material information from the state. | |
GetMaterialBinding | Returns the current material information from the state. | |
GetModelMatrix | Returns the current modeling transformation from the state. | |
GetNodeAppliedTo | Returns the node the action is being applied to. | |
GetNormal | Returns the current normal information from the state. | |
GetNormalBinding | Returns the current normal information from the state. | |
GetNumCoordinates | Returns the current coordinates from the state. | |
GetNumNormals | Returns the current normal information from the state. | |
GetNumProfileCoordinates | Returns the current profiles and their coordinates from the state. | |
GetNumTextureCoordinates | Returns texture information from the state. | |
GetOriginalPathListAppliedTo | Returns the original path list the action is being applied to. | |
GetPathAppliedTo | Returns the path the action is being applied to. | |
GetPathCode | Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to. | |
GetPathListAppliedTo | Returns the path list the action is being applied to. | |
GetPickStyle | Returns the current picking style. | |
GetPipeId | Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration. | |
GetPointSize | Returns the current drawing style information from the state. | |
GetProfile | Returns the current profiles and their coordinates from the state. | |
GetProfileCoordinate2 | Returns the current profiles and their coordinates from the state. | |
GetProfileCoordinate3 | Returns the current profiles and their coordinates from the state. | |
GetProjectionMatrix | Returns the current camera and viewing information from the state. | |
GetSceneManager | Return the OIV.Inventor.SoSceneManager associated with this action. | |
GetShapeType | Returns the current shape hints from the state. | |
GetState | Gets the state from the action. | |
GetSwitch | Returns the current switch value. | |
GetTextureBlendColor | Returns texture information from the state. | |
GetTextureCoordinate2 | Returns texture information from the state. | |
GetTextureCoordinate4 | Returns texture information from the state. | |
GetTextureCoordinateBinding | Returns texture information from the state. | |
GetTextureFileName | Returns texture information from the state. | |
GetTextureImage(SbVec2i32, Int32) | Returns texture information from the state. | |
GetTextureImage(SbVec2s, Int32) | Obsolete. Returns texture information from the state. | |
GetTextureMatrix | Returns the current texture mapping information from the state. | |
GetTextureModel | Returns the current texture mapping information from the state. | |
GetTextureTransformNode | Returns the current texture mapping information from the state. | |
GetTextureWrapS | Returns the current texture mapping information from the state. | |
GetTextureWrapT | Returns the current texture mapping information from the state. | |
GetTransparencyType | Returns the current Transparency Type information from the state. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetUnits | Returns the current units from the state. | |
GetVertexOrdering | Returns the current shape hints from the state. | |
GetViewingMatrix | Returns the current camera and viewing information from the state. | |
GetViewVolume | Returns the current camera and viewing information from the state. | |
GetWhatAppliedTo | Returns code indicating what action is being applied to. | |
HasTerminated | Returns true if the traversal has reached a termination condition. | |
InvalidateState | Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied. | |
InvokePostCallbacks | ||
InvokePreCallbacks | ||
IsBeingApplied | Returns true if this action is currently being applied. | |
IsCallbackAll | Returns whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node. | |
IsLastPathListAppliedTo | Returns true if the current list is the last one from the original. | |
IsUsingAlternateRep | Returns true if current action is using alternate representations. | |
PostDelayedTraversal | Method called by SoMultiPassManager after delayed pass traversals. | |
PreDelayedTraversal | Method called by SoMultiPassManager before delayed pass traversals. | |
ResetContinueActionInBranchFlag | This function resets the continue action flag. | |
SetCallbackAll | Sets whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node. | |
SetPipeId | Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration. | |
SetSceneManager | Set the scene manager associated with this action (if any ). | |
SetUpState | Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created. | |
ShouldGeneratePrimitives | ||
StopActionInBranch | This function stops the action in the current Scene Graph branch. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Traverse | Does traversal of a graph rooted by a node. | |
UseAlternateRep | Tell the action to use alternate representations during traversal when available. |
Name | Description | |
---|---|---|
PostTailTraversal | ||
PreTailTraversal |
Performs a generic traversal of a scene graph or path. In many cases a "custom" action can be implemented using OIV.Inventor.Actions.SoCallbackAction with much less complexity than deriving a completely new action class.
The application can specify delegate methods that will be called when the action traverses a node of the specified class or a derived class. For example a callback for the OIV.Inventor.Nodes.SoCone class will only be called for OIV.Inventor.Nodes.SoCone nodes, but a callback for the OIV.Inventor.Nodes.SoShape class will be called for any type of shape node.
This makes OIV.Inventor.Actions.SoCallbackAction flexible and very convenient for "visiting" a set of nodes, especially when you only need the node itself and not a path to the node. For example, to count all the shapes in the scene graph. It is possible to get the path to the node being visited (see GetCurPath()), but OIV.Inventor.Actions.SoSearchAction may be more convenient for getting a path to one or a small number of nodes.
In addition, delegatemethods can be registered to collect the primitives (trangles, lines and points) generated by shapes in the scene graph. These primitives are the actual geometry if the shape contains triangles, lines or points, else they represent or approximate the actual geometry. NOTE: Most, but not all, shapes can generate primitives. See below for a complete list. Triangle primitives are used for all surfaces (such as cubes, face sets, or 3D text), line segment primitives are used for line shapes, and point primitives are used for point shapes. Note that the type of primitives generated for a shape is the same, regardless of drawing style or other properties.
Most of the methods on this class access information from the traversal state. They should be called only by delegatefunctions that are invoked during traversal, so there is a valid state to work with.
Apply a callback action to visit all shape nodes.
SoCallbackAction action = new SoCallbackAction(); action.AddPreCallback ( typeof(SoShape), new SoCallbackAction.CallbackActionCB(NodeCallback) ); action.AddTriangleCallback( typeof(SoShape), new SoCallbackAction.TriangleCB(TriangleCallback) ); action.Apply( root );
SoCallbackAction.Responses NodeCallback(SoCallbackAction action, SoNode node) { Console.WriteLine("Shape \"" + node.GetName() + "\": " + node.GetType()); return SoCallbackAction.Responses.CONTINUE; }
void TriangleCallback( SoCallbackAction action, ref SoPrimitiveVertex vertex1, ref SoPrimitiveVertex vertex2, ref SoPrimitiveVertex vertex3) { Console.WriteLine(" Triangle:"); printVertex( vertex1, "1" ); printVertex( vertex2, "2" ); printVertex( vertex3, "3" ); } void printVertex( SoPrimitiveVertex vertex, String label ) { SbVec3f point = vertex.Point; Console.WriteLine(" Vert{0} = ({1}, {2}, {3})", label, point[0], point[1], point[2]); }
Example output:
Shape "": SoCone Triangle: Vert1 = 0.0, -1.0, -1.0 Vert2 = 0.0, 1.0, -0.0 Vert3 = 0.38268346, -1.0, -0.9238795 Triangle: Vert1 = 0.38268346, -1.0, -0.9238795 Vert2 = 0.0, 1.0, -0.0 Vert3 = 0.0, 1.0, -0.0 . . . *