The Semantic Layer

The semantic layer is built on top of the IO layer. Each semantic layer class uses the data stored in the IO layer, which means that there is no redundancy of data in memory.

For example, the CSLTransform class implements the SI_Transform template. That class allows the user to set or get transformation parameters. These parameters are themselves stored internally inside a CdotXSIParams collection which belongs to a CdotXSITemplate , but accessed through the CSLTransform class methods. This means also that the same data can be accessed either using the CSLTransform class (semantic layer) or the CdotXSITemplate class (IO layer).

 

 

The Semantic Layer uses the US-ASCII standard.

Connecting the semantic layer with the IO layer

To get the IO layer handle of a semantic layer object, use the CSLTemplate::Template () method. All semantic layer objects that implement a dotXSI template are derived from the CSLTemplate class.

To properly synchronize the IO layer from a freshly created semantic layer structure, use the CSLTemplate::Synchronize () method.

At the heart of the Semantic layer are several base classes:

Scene Class

Proxy Classes

Array Classes

Utility Classes

Scene Class

The scene class (CSLScene ) is the doorway to the semantic layer. You have to instantiate a CSLScene object in order to have access to the other objects. You do not need to create any other objects directly; all objects should be created by a method either on the CSLScene object or on an object created from it. The CSLScene object allows you to create, read, and write files, access all models in the scene, and access all the top-level constructs of the dotXSI file including:

• Material Library

• Ambience

• Coordinate System

• Envelope List

• Fog

• Angle

• File Info

• Scene Info

• Image Library

Example (Scene Class)

CSLScene l_scene;
// Make sure the scene is either read in or initialized
SI_Float l_Red = l_scene->Ambience ()->GetColor()->m_fR;

Proxy Classes

The proxy classes are widely used to represent a parameter within the template itself. They provide a user-friendly format of the data. They support all the possible types supported by the semantic layer:

• Bool

• Byte

• Float, Double

• Enum,String Enum

• Long, Ulong, Int, Uint, Short, Ushort

Each proxy returns and accepts the types as expected. For example, a bool will not take a TinyVariant type parameter, but only a bool type parameter. The same is true for String Enum, such as for the Scene Info, where we can have the frames or seconds for the timing. Normally, one has to compare the values with strings. This is not the most convenient way to work, especially because only two values are possible ("SECONDS" or "FRAMES"). Now the developer can just use the following:

CSLScene l_scene;
// Make sure the scene is either read in or initialized 
l_scene->SceneInfo()->SetTimingType( CSLSceneInfo::SI_SECONDS );

This sets the proper value in the corresponding template (in this case "SECONDS").

The CSLVariantProxy class can be used for parameters with variable type. Unlike the proxy classes for the basic types, a TinyVariant value is returned.

Array Classes

Array proxies simplify the use of the various array types in the dotXSI file format, whether it is an array of vertex positions (floats), Vertex indices (int), or Joint List (string).

The array proxy allows you to work either on the 1D format or in the 2D format where you can add Rows. For example, the CSLVector2DArray class lets you get and manipulate rows of 2D entries whose types are vector2d. This makes accessing these arrays easier.

Example (Array Classes)

For example, to write all the vertices in one given shape (ordered in this case) you would write:

CSLBaseShape * l_shape;
// Make sure l_shape is set properly to a Shape;
CSLBaseShape::CSLVector3DArray * VertexList = l_shape->GetVertexList();
for (int i = 0; i < l_shape->GetVertexCount(); i++)
{
   SI_Float fX, fY, fZ;
   fX = (*VertexList)[i].GetX();
   fY = (*VertexList)[i].GetY();
   fZ = (*VertexList)[i].GetZ();
}

Utility Classes

There are also several classes that simplify access to different pieces of data (components):

• Fcurve & Keys

• Matrix 4x4

• Variant

• Color

• Connection Points & FX Connection Point

 

For more details, see Crosswalk SDK Reference.

Example (Utility Classes)

For example, to list the values at a given Fcurve:

CSLFCurve l_fcurve;
//
// Check the type
//
if (l_fcurve->Getinterpolationtype() == CSLTemplate::SI_HERMITE)
{
   CSLHermiteKey * list = l_fcurve->GetHermiteKeyListPtr();
   for (int i = 0; i < l_fcurve->GetKeyCount(); i++)
   {
       printf( "Values for Hermite keys are: [Frame=%f][Value=%f][Left Tan=%f][Right Tan=%f]\n",
          list[i].m_fTime,
          list[i].m_fValue,
          list[i].m_fInTangent,
          list[i].m_fOutTangent );
   }
}

 

Notice that this example did not use the array structure, but just the straight pointer to the list of keys. This speeds up access, but does not allow any modifications, as it is an accessor only. It is quick and simple instead of the more feature-complete CSLHermiteKeyArray that lets you add and remove keys.



Autodesk Softimage v7.5