SoAlgebraicShape Class |
Abstract base class for algebraic shapes.
Namespace: OIV.Inventor.Nodes
The SoAlgebraicShape type exposes the following members.
Name | Description | |
---|---|---|
AffectsState | Overrides default method on OIV.Inventor.Nodes.SoNode. | |
BeginShape(SoAction, SoShapeTriangleShapes) | Calls BeginShape(action, shapeType, (OIV.Inventor.Details.SoFaceDetail ^)nullptr). (Inherited from SoShape.) | |
BeginShape(SoAction, SoShapeTriangleShapes, SoFaceDetail) | These methods can be used by subclasses to generate triangles more easily when those triangles are part of a larger structure, such as a triangle strip, triangle fan, or triangulated polygon, according to the TriangleShape enumerated type. | |
Callback | Implements primitive generation for all shapes. | |
ComputeBBox(SoAction, SbBox3f, SbVec3f) | OIV actions. | |
ComputeBBox(SoAction, SbXfBox3d, SbVec3d) | Compute object oriented bounding box (OOB) for subclass using information in the given action (which may not necessarily be an OIV.Inventor.Actions.SoGetBoundingBoxAction). | |
Copy | Calls Copy(false). (Inherited from SoNode.) | |
Copy(Boolean) | Creates and returns an exact copy of the node. | |
CopyFieldValues(SoFieldContainer) | Calls CopyFieldValues(fc, false). (Inherited from SoFieldContainer.) | |
CopyFieldValues(SoFieldContainer, Boolean) | Copies the contents of fc's fields into this object's fields. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Distribute | (Inherited from SoNode.) | |
DoAction | (Inherited from SoNode.) | |
EnableNotify | Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false). | |
EndShape | end shape previously started with OIV.Inventor.Nodes.SoShape.BeginShape(OIV.Inventor.Actions.SoAction, OIV.Inventor.Nodes.SoShape.TriangleShapes, OIV.Inventor.Details.SoFaceDetail). | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FieldsAreEqual | Returns true if this object's fields are exactly equal to fc's fields. | |
Get | Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
GetAllFields | Returns a list of fields, including the eventIn's and eventOut's. | |
GetAlternateRep | This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type). | |
GetBoundingBox | Implements bounding box method using virtual OIV.Inventor.Nodes.SoShape.ComputeBBox(OIV.Inventor.Actions.SoAction, OIV.Inventor.SbBox3f@, OIV.Inventor.SbVec3f@) method. | |
GetEventIn | Returns a the eventIn with the given name. | |
GetEventOut | Returns the eventOut with the given name. | |
GetField | Returns a the field of this object whose name is fieldName. | |
GetFieldName | Returns the name of the given field in the fieldName argument. | |
GetFields | Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetMatrix | (Inherited from SoNode.) | |
GetName | Returns the name of an instance. | |
GetPrimitiveCount | Counts number of primitives produced by this shape. | |
GetRenderEngineMode | Returns the supported Render engine mode. | |
GetRenderUnitID | (Inherited from SoNode.) | |
GetShapeType | Gets the current shape Full Scene Antialiasing type. | |
GetStringName | (Inherited from SoBase.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GLRender | OIV actions. | |
GLRenderBelowPath | (Inherited from SoNode.) | |
GLRenderInPath | (Inherited from SoNode.) | |
GLRenderOffPath | (Inherited from SoNode.) | |
GrabEventsCleanup | (Inherited from SoNode.) | |
GrabEventsSetup | (Inherited from SoNode.) | |
HandleEvent | (Inherited from SoNode.) | |
HasDefaultValues | Returns true if all of the object's fields have their default values. | |
IsBoundingBoxIgnoring | Used by BoundingBoxAction to know if bounding box computation should be ignored or not. | |
IsNotifyEnabled | Notification is the process of telling interested objects that this object has changed. | |
IsOverride | Returns the state of the override flag. | |
IsSynchronizable | Gets the ScaleViz synchronizable state of this object. | |
Pick | (Inherited from SoNode.) | |
RayPick | Implements picking along a ray by intersecting the ray with each primitive generated by subclass. | |
Search | (Inherited from SoNode.) | |
Set | Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
SetName | (Inherited from SoBase.) | |
SetOverride | Turns the override flag on or off. | |
SetShapeType | set the antialiasing type for this shape. | |
SetSynchronizable | Sets this to be a ScaleViz synchronizable object. | |
SetToDefaults | Sets all fields in this object to their default values. | |
ShapeVertex | add a primitive vertex to the shape prevously started with OIV.Inventor.Nodes.SoShape.BeginShape(OIV.Inventor.Actions.SoAction, OIV.Inventor.Nodes.SoShape.TriangleShapes, OIV.Inventor.Details.SoFaceDetail). | |
ToString |
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.) | |
Touch | Marks an instance as modified, simulating a change to it. | |
Write | (Inherited from SoNode.) |
Name | Description | |
---|---|---|
boundingBoxIgnoring | Whether to ignore this node during bounding box traversal. | |
generateTransparency | Specify if the shape generates transparent fragment. | |
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) | |
rayIntersection | Field for an OIV.Inventor.Nodes.SoFragmentShader object that defines the GLSL ray intersection function. | |
shaderSlots | Multi-field for Shader slots of type OIV.Inventor.Nodes.SoShaderObject. | |
UserData |
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.) | |
workspace | Field to define the workspace. |
An implicit surface is a 2-dimensional surface in 3-dimensional space defined as the locus of zeros of a given function. Many useful shapes such as sphere, cylinder or cone can be expressed using this approach, known as a quadric surfaces.
Sub-classes of this node compute and render an implicit surface on the GPU using a GLSL shader function. A screen-aligned quad is drawn, representing the screen space bounding box of the algebraic shape. Then, this quad is ray-casted and a ray/shape intersection is applied per fragment to draw the final shape.
Several predefined sub-classes are provided for convenience, including OIV.Inventor.Nodes.SoAlgebraicCone, OIV.Inventor.Nodes.SoAlgebraicCylinder and OIV.Inventor.Nodes.SoAlgebraicSphere. These nodes can be used in an application scene graph similar to the corresponding classic geometry nodes OIV.Inventor.Nodes.SoCone, OIV.Inventor.Nodes.SoCylinder and OIV.Inventor.Nodes.SoSphere. Use a transform node, e.g. OIV.Inventor.Nodes.SoTransform, to position the shape node in 3D space. Use an OIV.Inventor.Nodes.SoMaterial node to assign material properties. See the notes and limitations section on this page for some important differences between algebraic and geometric shapes.
Extending OIV.Inventor.Nodes.SoAlgebraicShape:
Derived classes must implement the bounding box computation function computeBBox() in C#.And also implement the ray/shape intersection function OivASRayIntersection() in GLSL. This function returns true if there is an intersection between the ray and the shape, false otherwise. Create an OIV.Inventor.Nodes.SoFragmentShader to hold the GLSL function and set this node in the rayIntersection field.
bool OivASRayIntersection ( in OivASRay ray, inout OivASPoint point ) { DO SOMETHING return [ true | false ]; }
See the GLSL include file oivAlgebraicShape.h in $OIVHOME/shaders/include/Inventor/AlgebraicShape. It declares ray, a structure that contains ray parameters:
struct OivASRay { vec3 rs; // ray start vec3 re; // ray end vec3 rd; // ray direction };
struct OivASPoint {
vec3 position;
vec3 normal;
vec4 color;
};
Note that ray parameters and point information are defined in the reference frame specified by the workspace field, an enum of type OIV.Inventor.Nodes.SoAlgebraicShape.ASWorkSpaces. This frame can be the camera space, the world space or the normalized space of the bounding box of the shape. By default, the bounding box space is used.
A GLSL helper function for solving quadratic functions (i.e. a*x^2 + b*x + c = 0) is provided:
bool OivASSolveQuadric ( in vec3 abc, inout vec2 roots );
with abc, a vector containing the coefficients {a, b, c} of the polynomial. A quadratic equation has zero, one or two solutions, called roots. It returns true if there are solutions, false otherwise. Note that only helper function for quadric surfaces are provided but higher order surface such as Torus (i.e. degree 4) may be implemented using user-defined polynomial solver.
All quadric shape equations can be solved using this function. For instance, the equation of a sphere centered at the origin with a radius of 1 is defined by: x^2 + y^2 + z^2 - 1 = 0 To find the intersection point between such a sphere with a ray as defined above, we have to solve the quadric sphere equation such as: (rs + t*rd)^2 - 1 = 0 which leads to, rd^2 . t^2 + 2 . rs . rd . t + rs^2 - 1 = 0 It means solving a quadratic equation with:
a = 1 (i.e. dot(rd, rd) = 1),
b = 2 * dot(rs, rd),
c = dot(rs, rs) - 1.0.
If a solution exists (1 or 2), the OivASSolveQuadric function returns true and roots are stored in the parameter roots. The roots (i.e. t1 and t2) represent the solution for the parameter t such as solutions are:
p1 = rs + t1*rd
p2 = rs + t2*rd
The smallest positive root is the first intersection point along the ray direction rd. If there are two positive roots, the larger one is the intersection point with the back face. If a root is negative, it means that there is an intersection in the opposite ray direction.
While this node is designed to address algebraic surfaces, the ray intersection function could be used with other types of surfaces to find the intersection between the ray and the shape (e.g. distance functions).
Note that this node supports instancing using OIV.Inventor.Nodes.SoMultipleInstance to render millions of algebraic shapes in a more efficient way than than using geometric shapes.
The application can also provide custom color shaders to shade the surface or use built-in shading based on light model and material properties (transparency is supported as well).
Notes:
Shape hints (OIV.Inventor.Nodes.SoShapeHints) do not affect rendering. Algebraic shapes are always rendered as if "two-sided lighting" is enabled.
Complexity (OIV.Inventor.Nodes.SoComplexity) does not affect rendering. Algebraic shapes are not tessellated, so are always "full resolution".
Material binding (OIV.Inventor.Nodes.SoMaterialBinding) does not affect rendering. (You can't color the caps differently like you can with OIV.Inventor.Nodes.SoCylinder, etc.)
Algebraic shapes can be picked, but no OIV.Inventor.Details.SoDetail is available.
Wireframe rendering is not supported since this node does not generate real geometry.
Limitations:
Texturing (OIV.Inventor.Nodes.SoTexture2) does not affect rendering.
Projection (OIV.Inventor.Nodes.SoProjection) does not affect rendering.
Draw style (OIV.Inventor.Nodes.SoDrawStyle) does affect rendering, but the result is a single line segment, not a wire frame shape.