Abstract base class for algebraic shapes. More...
#include <Inventor/nodes/SoAlgebraicShape.h>
Public Types | |
enum | ASWorkSpace { BOX , CAMERA , WORLD , MAX_WORK_SPACE } |
Specifies which reference frame to use inside the ray intersection shader function. More... | |
enum | ASShaderSlot { COMPUTE_COLOR , VERTEX_SHADER_ENTRY , MAX_SHADER_SLOT } |
Specifies the available slots for shader programs. More... | |
enum | ASClippingPolicy { STANDARD , FULL_SHAPE } |
Specifies how the algebraic shape should be clipped by a clipping plane. More... | |
Public Types inherited from SoShape | |
enum | ShapeType { POINTS , LINES , POLYGONS , TEXT } |
Basic type for antialiased rendering for this shape (Do not consider the SoDrawStyle property currently in the state). More... | |
Public Member Functions | |
virtual SoType | getTypeId () const |
Returns the type identifier for this specific instance. | |
Public Member Functions inherited from SoShape | |
virtual SbBool | affectsState () const |
Overrides default method on SoNode. | |
ShapeType | getShapeType () |
Gets the current shape Full Scene Antialiasing type. | |
Public Member Functions inherited from SoNode | |
virtual void | setOverride (const SbBool state) |
Turns the override flag on or off. | |
virtual SbBool | isOverride () const |
Returns the state of the override flag. | |
virtual SoNode * | copy (SbBool copyConnections=FALSE) const |
Creates and returns an exact copy of the node. | |
virtual void | touch () |
Marks an instance as modified, simulating a change to it. | |
Public Member Functions inherited from SoFieldContainer | |
void | setToDefaults () |
Sets all fields in this object to their default values. | |
SbBool | hasDefaultValues () const |
Returns TRUE if all of the object's fields have their default values. | |
SbBool | fieldsAreEqual (const SoFieldContainer *fc) const |
Returns TRUE if this object's fields are exactly equal to fc's fields. | |
void | copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE) |
Copies the contents of fc's fields into this object's fields. | |
SoNONUNICODE SbBool | set (const char *fieldDataString) |
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. | |
SbBool | set (const SbString &fieldDataString) |
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. | |
void | get (SbString &fieldDataString) |
Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
virtual int | getFields (SoFieldList &list) const |
Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
virtual int | getAllFields (SoFieldList &list) const |
Returns a list of fields, including the eventIn's and eventOut's. | |
virtual SoField * | getField (const SbName &fieldName) const |
Returns a the field of this object whose name is fieldName. | |
virtual SoField * | getEventIn (const SbName &fieldName) const |
Returns a the eventIn with the given name. | |
virtual SoField * | getEventOut (const SbName &fieldName) const |
Returns the eventOut with the given name. | |
SbBool | getFieldName (const SoField *field, SbName &fieldName) const |
Returns the name of the given field in the fieldName argument. | |
SbBool | enableNotify (SbBool flag) |
Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE). | |
SbBool | isNotifyEnabled () const |
Notification is the process of telling interested objects that this object has changed. | |
virtual void | setUserData (void *data) |
Sets application data. | |
void * | getUserData (void) const |
Gets user application data. | |
Public Member Functions inherited from SoBase | |
virtual SbName | getName () const |
Returns the name of an instance. | |
virtual void | setName (const SbName &name) |
Sets the name of an instance. | |
void | setSynchronizable (const bool b) |
Sets this to be a ScaleViz synchronizable object. | |
bool | isSynchronizable () const |
Gets the ScaleViz synchronizable state of this object. | |
Public Member Functions inherited from SoRefCounter | |
void | ref () const |
Adds a reference to an instance. | |
void | unref () const |
Removes a reference from an instance. | |
void | unrefNoDelete () const |
unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero. | |
int | getRefCount () const |
Returns current reference count. | |
void | lock () const |
lock this instance. | |
void | unlock () const |
unlock this instance. | |
Public Member Functions inherited from SoTypedObject | |
SbBool | isOfType (const SoType &type) const |
Returns TRUE if this object is of the type specified in type or is derived from that type. | |
template<typename TypedObjectClass > | |
SbBool | isOfType () const |
Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class. | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Static Public Member Functions inherited from SoShape | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SbBool | isPrimitiveRestartAvailable (SoState *state=NULL) |
Returns TRUE if the primitive restart feature is available. | |
Static Public Member Functions inherited from SoNode | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SoNode * | getByName (const SbName &name) |
A node's name can be set using SoBase::setName(). | |
static int | getByName (const SbName &name, SoNodeList &list) |
A node's name can be set using SoBase::setName(). | |
Static Public Member Functions inherited from SoFieldContainer | |
static SoType | getClassTypeId () |
Returns the type of this class. | |
Static Public Member Functions inherited from SoBase | |
static SoType | getClassTypeId () |
Returns type identifier for this class. | |
Static Public Member Functions inherited from SoTypedObject | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Public Attributes | |
SoSFNode | rayIntersection |
Field for an SoFragmentShader object that defines the GLSL ray intersection function. | |
SoSFEnum | workspace |
Field to define the workspace. | |
SoMFNode | shaderSlots |
Multi-field for Shader slots of type SoShaderObject. | |
SoSFBool | generateTransparency |
Specify if the shape generates transparent fragment. | |
SoSFEnum | clippingPolicy |
Specifies how the algebraic shape should be clipped by a clipping plane. | |
Public Attributes inherited from SoShape | |
SoSFBool | boundingBoxIgnoring |
Whether to ignore this node during bounding box traversal. | |
Abstract base class for algebraic shapes.
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 SoAlgebraicCone, SoAlgebraicCylinder and SoAlgebraicSphere. These nodes can be used in an application scene graph similar to the corresponding classic geometry nodes SoCone, SoCylinder and SoSphere. Use a transform node, e.g. SoTransform, to position the shape node in 3D space. Use an 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 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 SoFragmentShader to hold the GLSL function and set this node in the rayIntersection field.
See the GLSL include file oivAlgebraicShape.h in $OIVHOME/shaders/include/Inventor/AlgebraicShape. It declares ray, a structure that contains ray parameters:
and point, an output structure containing position, normal and color (if any) of the intersection point.
Note that ray parameters and point information are defined in the reference frame specified by the workspace field, an enum of type ASWorkSpace. 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:
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:
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:
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 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:
Limitations:
Definition at line 140 of file SoAlgebraicShape.h.
Specifies how the algebraic shape should be clipped by a clipping plane.
Enumerator | |
---|---|
STANDARD | |
FULL_SHAPE | Standard behaviour. The shape can be partially clipped by the clipping plane. |
Definition at line 252 of file SoAlgebraicShape.h.
Specifies the available slots for shader programs.
Enumerator | |
---|---|
COMPUTE_COLOR | |
VERTEX_SHADER_ENTRY | |
MAX_SHADER_SLOT |
Definition at line 196 of file SoAlgebraicShape.h.
Specifies which reference frame to use inside the ray intersection shader function.
Enumerator | |
---|---|
BOX | |
CAMERA | The normalized bounding box space. |
WORLD | The camera space (or view space) |
MAX_WORK_SPACE | The world space. |
Definition at line 171 of file SoAlgebraicShape.h.
|
static |
Returns the type identifier for this class.
|
virtual |
Returns the type identifier for this specific instance.
Reimplemented from SoShape.
Reimplemented in SoAlgebraicCone, SoAlgebraicCylinder, and SoAlgebraicSphere.
SoSFEnum SoAlgebraicShape::clippingPolicy |
Specifies how the algebraic shape should be clipped by a clipping plane.
Default value is STANDARD.
Definition at line 262 of file SoAlgebraicShape.h.
SoSFBool SoAlgebraicShape::generateTransparency |
Specify if the shape generates transparent fragment.
This field is similar to the one in SoShaderProgram. If set to true, the shape is considered as transparent. Otherwise, the shape transparency is deducted from the state. Note that this flag is useful is you want to generate transparent color from custom computer color shader slot without binding a material node.
Default value is FALSE.
Definition at line 247 of file SoAlgebraicShape.h.
SoSFNode SoAlgebraicShape::rayIntersection |
Field for an SoFragmentShader object that defines the GLSL ray intersection function.
The GLSL function must compute the intersection between a ray and the shape. Note that position and direction space is chosen according to the value of workspace. This function must be implemented as:
Definition at line 166 of file SoAlgebraicShape.h.
SoMFNode SoAlgebraicShape::shaderSlots |
Multi-field for Shader slots of type SoShaderObject.
Shader slots can contain application provided shader functions and are of the type defined in ASShaderSlot enumeration:
Definition at line 234 of file SoAlgebraicShape.h.
SoSFEnum SoAlgebraicShape::workspace |
Field to define the workspace.
Use enum ASWorkSpace. Default is BOX.
Possible choices are:
Definition at line 191 of file SoAlgebraicShape.h.