#include <xsi_clusterproperty.h>
An array of cluster property elements in a ClusterProperty object.
The cluster property maps the cluster element indices to property values (such as RGB vertex color). The value of the element in a cluster property element array is the cluster property value.
You can set elements using CClusterPropertyElementArray::PutItems and this is accessible from an operator. Unlike CClusterElementArray, a CClusterPropertyElementArray object allows editing of element values.
The following lists all cluster properties along with their data type values returned through CClusterPropertyElementArray::GetItem:
using namespace XSI;
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject myCube;
root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube );
// install the texture support object
CValueArray args(4);
args[0] = CValue( CString(L"Image") );
args[1] = CValue(myCube);
args[2] = CValue((short)1);
args[3] = CValue(false);
CStatus st;
CValue outArg;
st = app.ExecuteCommand( L"BlendInPresets", args, outArg );
if ( st.GetCode() != CStatus::OK )
{
app.LogMessage( L"BlendInPresets failed" );
return;
}
args[0] = CValue(myCube);
args[1] = CValue((LONG)siTxtUV);
args[2] = CValue((LONG)siTxtDefaultSpherical);
args[3] = CValue(CString(L"Texture_Support"));
st = app.ExecuteCommand( L"CreateTextureSupport", args, outArg );
if ( st.GetCode() != CStatus::OK )
{
app.LogMessage( L"CreateTextureSupport failed" );
return;
}
// get the sample point cluster and print out its UVW values
Geometry geom(myCube.GetActivePrimitive().GetGeometry());
CRefArray samplePoints;
geom.GetClusters().Filter(siSampledPointCluster, CStringArray(), L"",
samplePoints );
Cluster cluster(samplePoints.GetItem(0));
ClusterProperty UVWProp(myCube.GetMaterial().GetCurrentUV());
CClusterPropertyElementArray uvwElementArray(UVWProp.GetElements());
CDoubleArray uvwArray(uvwElementArray.GetArray());
for ( LONG i=0; i< uvwArray.GetCount(); i += uvwElementArray.GetValueSize())
{
app.LogMessage( L"UVW: " +
CValue(uvwArray[i]).GetAsText() + L"," +
CValue(uvwArray[i+1]).GetAsText() + L"," +
CValue(uvwArray[i+2]).GetAsText() );
}
Public Member Functions |
|
| CClusterPropertyElementArray () | |
| CClusterPropertyElementArray (const CClusterPropertyElementArray &in_array) | |
| virtual | ~CClusterPropertyElementArray () |
| CClusterPropertyElementArray & | operator= (const CClusterPropertyElementArray &in_array) |
| CDoubleArray | GetArray () const |
| CStatus | PutArray (const CDoubleArray &in_values) |
| LONG | GetCount () const |
| CDoubleArray | GetItem (LONG in_index) const |
| CStatus | PutItem (LONG in_index, const CDoubleArray &in_values) |
| CDoubleArray | GetItemsByIndex (const CLongArray &in_indices) const |
| CStatus | PutItemsByIndex (const CLongArray &in_indices, const CDoubleArray &in_values) |
| LONG | GetValueSize () const |
Default constructor
| CClusterPropertyElementArray | ( | const CClusterPropertyElementArray & | in_array | ) |
Copy constructor.
| in_array | constant CClusterPropertyElementArray object. |
| virtual ~CClusterPropertyElementArray | ( | ) | [virtual] |
Default destructor
| CClusterPropertyElementArray& operator= | ( | const CClusterPropertyElementArray & | in_array | ) |
Creates an array from a reference object.
| in_array | constant CClusterPropertyElementArray object. |
| CDoubleArray GetArray | ( | ) | const |
Returns an array of element values which contains CClusterPropertyElementArray::GetCount() * CClusterPropertyElementArray::GetValueSize() double values. The array is laid out so that all values for an element are contiguous.
| CStatus PutArray | ( | const CDoubleArray & | in_values | ) |
Sets the values on the underlying ClusterProperty.
| in_values | Array of element values |
| LONG GetCount | ( | ) | const |
Returns the number of cluster element values
| CDoubleArray GetItem | ( | LONG | in_index | ) | const |
Returns the cluster element values at a given index.
| in_index | Element index. |
| CStatus PutItem | ( | LONG | in_index, |
| const CDoubleArray & | in_values | ||
| ) |
Sets the cluster element values at a given index.
| in_index | Element index. |
| in_values | Array of element values. |
| CDoubleArray GetItemsByIndex | ( | const CLongArray & | in_indices | ) | const |
Returns cluster element values by indices.
| in_indices | Array of indices |
| CStatus PutItemsByIndex | ( | const CLongArray & | in_indices, |
| const CDoubleArray & | in_values | ||
| ) |
Sets cluster element values by indices.
| in_indices | Array of indices |
| in_values | Array of element values |
| LONG GetValueSize | ( | ) | const |
Returns the number of values per element in the cluster. For instance, a uvw cluster property returns 3(uvw) and in the case of a vertex color cluster property it returns 4(rgba).