2.3. Scene Basic Types

This section discusses Inventor's Sb classes, a set of basic types that are used in many Inventor objects. Inventor includes useful methods for converting between different types and performing specific 3D operations on them.

Inventor defines the following types:

SbBool

Boolean value (TRUE or FALSE)

SbBox nx

2D or 3D box that has planes parallel to the major axes and is specified by two points on a diagonal (includes SbBox3f SbBox3f , SbBox2f SbBox2f , SbBox2s SbBox2s ); n is the number of values in the type (2 or 3), and x is the value type (f for float, s for short)

SbColor SbColor

RGB (red/green/blue) color value with conversion routines to other color spaces

SbCylinder SbCylinder

cylinder

SbLine SbLine

directed 3D line

SbMatrix SbMatrix

4×4 matrix

SbName

character string stored in a special table for fast and easy comparison, typically for identifiers

SbPList

list of generic (void *) pointers

SbPlane SbPlane

oriented 3D plane

SbRotation SbRotation

representation of a 3D rotation about an arbitrary axis

SbSphere SbSphere

sphere

SbString

“smart” character strings that have many convenience methods for easy string manipulation

SbTime SbTime

representation of time—in seconds; seconds and microseconds; or using the timeval structure

SbVec nx

2D or 3D vector, used to represent points or directions (includes SbVec2f SbVec2f , SbVec3f SbVec3f , SbVec2s SbVec2s ); n is the number of values in the type (2, 3, or 4), and x is the value type (f for float; s for short)

SbViewportRegion SbViewportRegion

active viewport region within a display window

SbViewVolume SbViewVolume

view volume (for example, see SoCamera SoCamera SoCamera 's getViewVolume() method in the Open Inventor C++ Reference Manual)

Methods

Each Sb class has useful operators associated with it. For example, you can negate a variable of typeSbVec3f SbVec3f , multiply it by a matrix, or normalize it to unit length. The following code creates a unit-length vector, based on the specified direction:

SbVec3f v(1.0, 2.0, 3.0); // declares and initializes the vector
v.normalize(); // normalizes the vector to unit length
    
SbVec3f v = new SbVec3f(1.0f, 2.0f, 3.0f); // declares and initializes the vector
v.Normalize(); // normalizes the vector to unit length
    
SbVec3f v = new SbVec3f(1.0f, 2.0f, 3.0f); // declares and initializes the vector
v.normalize(); // normalizes the vector to unit length
    

Similarly, SbMatrix SbMatrix has useful methods including multVecMatrix() , which multiplies a row vector by the matrix and returns the result, and rotate() , which sets the matrix to rotate by a given amount. See the Open Inventor C++ Reference Manual for a complete description of the available methods for each Sb class.

Types versus Fields

Chapter 3, Nodes and Groups contains a complete discussion of fields, which are the structures that store parameters for nodes. A field contains a value of a certain type. Fields are always contained within Inventor nodes. Many fields contain a corresponding Sb type. For example: