This class is used to reference Softimage objects. Each instance of an CRef maintains a link with only one single object at a time, it cannot refer to multiple objects. CRef has no base or derived class hierarchy and only contains methods for accessing the type of the underlying Softimage object.
CRef provides the core of the RTTI system to determine if an object is of a specific type; for example, to ensure that the compatibility between the reference and a given API class is valid by checking it against the siClassID enum. CRef instances are typically attached to API classes for manipulating Softimage objects.
A CRef object can be converted to its corresponding Softimage Object Model interface, and the resulting object can be used with the Softimage object model. The inverse is also possible: you can create a CRef object from an existing Softimage object model interface. See the XSI::ConvertObject function for more details.
- See also:
- CRefArray, CBase
- Example:
- Demonstrates how to use the work with CRefs
using namespace XSI;
void GetSomeObjects( CRefArray& io_array, const Application& in_app );
Application app;
CRefArray array;
GetSomeObjects( array, app );
CStringArray emptyArray;
Model root( app.GetActiveSceneRoot() );
array += root.FindChildren( L"", L"", emptyArray, true );
X3DObject grid;
root.AddGeometry( L"Grid", L"MeshSurface", L"", grid );
array += grid.GetParameters();
for (LONG i=0; i<array.GetCount(); ++i )
{
app.LogMessage(L"");
CRef ref(array[i]);
app.LogMessage( CString(L">>Reference object class type: ") + ref.GetClassIDName() );
if ( ref.IsA( siSIObjectID ) )
{
SIObject siobj(ref);
app.LogMessage( CString(L"\tObject name: ") + siobj.GetName() );
}
if ( ref.IsA( siX3DObjectID ) )
{
X3DObject xobj(ref);
app.LogMessage( CString(L"\tNumber of children : ") +
CValue(xobj.GetChildren().GetCount()).GetAsText() );
}
if ( ref.IsA( siParameterID ) )
{
Parameter param(ref);
app.LogMessage( CString(L"\tParameter's value : ") +
param.GetValue().GetAsText() );
}
}
void GetSomeObjects( CRefArray& io_array, const Application& in_app )
{
X3DObject myCube;
X3DObject myCone;
Material myPhong;
Model root = in_app.GetActiveSceneRoot();
root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube );
root.AddGeometry( L"Cone", L"MeshSurface", L"", myCone );
myCone.AddMaterial( L"Phong", false, L"", myPhong );
io_array.Add( myCube.GetActivePrimitive().GetRef() );
io_array.Add( myCone.GetActivePrimitive().GetRef() );
io_array.Add( myPhong.GetRef() );
}