Base Classes

The Crosswalk SDK uses platform-independent data structures to represent basic types. They are C++ classes that encapsulate the following types of data:

Category | Class Name
Vectors and Matrices | CSIBCMatrix4x4 CSIBCQuaternion CSIBCVector2D CSIBCVector3D CSIBCVector4D CSIBCMatrix33d CSIBCMatrix44d CSIBCMatrixMNd CSIBCQuaterniond CSIBCRotationd CSIBCRotMatd CSIBCTransfod CSIBCVector2Dd CSIBCVector3Dd CSIBCVector4Dd CSIBCVectorwd CSIBCXfoMatd
Colors | CSIBCColorf CSIBCColorb
Character strings | CSIBCString
Collections (Arrays) | CSIBCArray
Utilities | CSIBCUtil
Images | CSIBCPixMap CSIBCPixMapDriver
Networking | SIBCNetworkLayer
File I/O | CSIBSearchPath
Objects | CSIBCNode CSIBCUserData

Vectors and Matrices

The Crosswalk SDK has base classes that implement 2D, 3D and 4D vectors. It also provides classes that implement 4 x 4 matrices and quaternions. These classes implement the most widely-used operations on vectors and matrices, such as the basic operators (+, -, dot product, cross product). Some useful methods are also implemented for matrices to extract scaling, rotation and translation information from a transformation matrix:

Floating point vector and matrix classes | Double floating point vector and matrix classes
CSIBCVector2D CSIBCVector3D CSIBCVector4D CSIBCMatrix4x4 CSIBCQuaternion | CSIBCMatrix33d CSIBCMatrix44d CSIBCMatrixMNd CSIBCQuaterniond CSIBCRotationd CSIBCRotMatd CSIBCTransfod CSIBCVector2Dd CSIBCVector3Dd d CSIBCVector4Dd CSIBCVectorwd CSIBCXfoMatd

| For more information on vectors and matrices, see the Crosswalk SDK Reference.

Colors

The Crosswalk SDK has base classes that implement colors. There are two classes that implement the same thing:

• CSIBCColorb

• CSIBCColorf

The only difference is that CSIBCColorb represents color components as byte values (0-255) and CSIBCColorf represents color components as float values (0.0 - 1.0).

| For more information on colors, see the Crosswalk SDK Reference.

Character strings

Normal strings are implemented by the CSIBCString class. Several functions and methods are also provided to manipulate these strings (concatenation, duplication, copy etc.).

| For more information on character strings, see the Crosswalk SDK Reference.

Collections (Arrays)

Most arrays in the Crosswalk SDK are implemented using the CSIBCArray class template. This class implements functions that are important for arrays, such as getting the number of components, dynamically allocating the array, resizing, etc.

| For more information on arrays, see the Crosswalk SDK Reference.

Images

Pixel maps are images used by textures. Pixel maps have basic image manipulation functions. They are implemented by the CSIBCPixMap class. Several image loaders can also be implemented and plugged in. Image loaders are implemented by subclassing the CSIBCPixMapDriver class. Additionally, search paths can be added to give multiple paths for loading images. Here are some useful loading functions:

Functions | Description
CSIBCSearchPath *CSIBCPixMap::GetSearchPath() | Gets the search path for textures
SI_Error CSIBCPixMap::AddDriver( CSIBCPixMapDriver * ) | Registers a map driver
SI_Error CSIBCPixMap::Load( CSIBCString &, CSIBCPixMap &, SI_Bool in_ResizeToPowerOfTwo = TRUE ) SI_Error CSIBCPixMap::Load( const SI_Char *, CSIBCPixMap &, SI_Bool in_ResizeToPowerOfTwo = TRUE ) SI_Error CSIBCPixMap::Load( CSIBCString &, void *, SI_Int, CSIBCPixMap & ) SI_Error CSIBCPixMap::Load( const SI_Char *, void *, SI_Int, CSIBCPixMap & ) | Loads an image into a pixmap
SI_Error CSIBCPixMap::Cleanup() | Clears the list of registered map drivers

Example (Image Classes)

This is an example of adding a new image loader in the host application:

    // Load the Image File format drivers

    #include <CSIILPPMFileDriver.h>
    #include <CSIILPICFileDriver.h>

    // Add ppm drivers
    CSIBCPixMap::AddDriver( CSIILPPMFileDriver::Driver() );

    // Add Softimage pic drivers
    CSIBCPixMap::AddDriver( CSIILPICFileDriver::Driver() );

    //Here is an example of how to load an image in a CSIBCPixMap:

    //Allocate a new map
    _SI_NEW( pPixMap, CSIBCPixMap() );

    //Load it from file
    CSIBCPixMap::Load( _SI_TEXT("image.ppm"), *pPixMap );

File I/O

You use search paths to locate specific files in various directories. For example, the application can suppose that a file called foo.txt can be located under c:\dira, c:\dirb and c:\dirc. The CSIBSearchPath class provides a way to store the possible paths where the file may be located and then search for that file in those paths.

Objects

CSIBCNode is the base class for most of the classes of the Crosswalk SDK. The CSIBCNode class has the following properties:

• a name

• a general purpose flag

• an array of user data

Since a lot of classes need to be aggregated in a collection and also have an identification, they should all inherit from the CSIBCNode class. User data can be attached to CSIBCNode so that it can extend the class.

User data is implemented by the CSIBCUserData class. It comprises a tag name and a pointer to data. When the CSIBCNode is destroyed, its array of user data is also destroyed. However, it is possible to assign a release function so that each user data item is cleaned properly prior to releasing the memory for the CSIBCNode.

The release function must have the following prototype:

    void ReleaseMethod (void *in_pObjectToDelete);

| If you don’t need a release method for the user data, you can use the CSIBCNode::AttachUserData function with the tag name and the data pointer.

Example (Object Classes)

    void ReleaseString(void *in_pObjectToDelete)
    {
       CSIBCString* pStr = (CSIBCString *) in_pObjectToDelete;

       delete pStr;
    }

    void foo()
    {
       CSIBCNode node;
       CSIBCUserData userData;

       // initialize the user data tag name
       userData.Name().SetText(_SI_TEXT(“userdata_tag’));

       // initialize the user data’s data pointer
       userData.SetData((void *) new CSIBCString(_SI_TEXT(“User data content”)));

       // set the user data’s data release function
       userData.SetReleaseMethod(ReleaseString);

       // attach the user data to the CSIBCNode
       node.UserDataList().Add(&userData);
    }

Autodesk Softimage v7.5