UVProperty is a kind of ClusterProperty object used for storing and accessing the UV information of a cluster.
UVProperty supports a special API for pinning and unpinning UV components. Pinning acts like a lock. When UV components are pinned, they are not affected by operations performed on them. For instance, pinned UVs cannot be rotated or scaled in the Texture Editor.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( "Cube", "MeshSurface", "", myCube ); // install the texture support object CValueArray args(4); args[0] = CValue( CString("Image") ); args[1] = CValue(myCube); args[2] = CValue((short)1); args[3] = CValue(false); CStatus st; CValue outArg; st = app.ExecuteCommand( "BlendInPresets", args, outArg ); if ( st.GetCode() != CStatus::OK ) { app.LogMessage( "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( "CreateTextureSupport", args, outArg ); if ( st.GetCode() != CStatus::OK ) { app.LogMessage( "CreateTextureSupport failed" ); return; } // Get the uv property on the cube and set some components as pinned or unpinned PolygonMesh pm = myCube.GetActivePrimitive().GetGeometry(); CGeometryAccessor ga = pm.GetGeometryAccessor(); CRefArray uvs = ga.GetUVs(); UVProperty uvprop( uvs[0] ); // Pin some components CLongArray toPin(5); toPin[0] = 0; toPin[1] = 5; toPin[2] = 10; toPin[3] = 15; toPin[4] = 20; uvprop.PinComponents( toPin ) // Use a CBitArray for a fast access to the pinned components XSI::CBitArray baComponents; uvprop.GetPinComponentArray( baComponents ); LONG it = baComponents.GetIterator(); LONG i = 0; while (baComponents.GetNextTrueBit(it)) { app.LogMessage( "Pinned component index = " + CString( it ) ); } // Unpin all uvprop.UnPinAllComponents(); uvprop.GetPinComponentArray( baComponents ); app.LogMessage( "Number of Pinned components = " + CString( baComponents.GetTrueCount() ) ); \code
#include <xsi_uvproperty.h>
Public Member Functions |
|
UVProperty () | |
~UVProperty () | |
UVProperty (const CRef &in_ref) | |
UVProperty (const UVProperty &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
UVProperty & | operator= (const UVProperty &in_obj) |
UVProperty & | operator= (const CRef &in_ref) |
CStatus | PinAllComponents () |
CStatus | PinComponents (const CLongArray &in_componentArray) |
CStatus | UnPinAllComponents () |
CStatus | UnPinComponents (const CLongArray &in_componentArray) |
CStatus | GetPinComponentArray (CLongArray &out_componentArray) const |
CStatus | GetPinComponentArray (CBitArray &out_baComponents) const |
UVProperty | ( | ) |
Default constructor.
~UVProperty | ( | ) |
Default destructor.
UVProperty | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
UVProperty | ( | const UVProperty & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from ClusterProperty.
siClassID GetClassID | ( | ) | const [virtual] |
UVProperty& operator= | ( | const UVProperty & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
UVProperty& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from ClusterProperty.
CStatus PinAllComponents | ( | ) |
Mark all components referenced by this UV property as pinned.
CStatus PinComponents | ( | const CLongArray & | in_componentArray | ) |
Mark specific components referenced by this UV property as pinned.
in_componentArray | Array of indices identifying the components to pin. |
CStatus UnPinAllComponents | ( | ) |
Mark all components referenced by this UV property as unpinned.
CStatus UnPinComponents | ( | const CLongArray & | in_componentArray | ) |
Mark specific components referenced by this UV property as unpinned.
in_componentArray | Array of indices identifying the components to unpin. |
CStatus GetPinComponentArray | ( | CLongArray & | out_componentArray | ) | const |
Returns an array of indices to identify the pinned components referenced by this UV property.
Returns a bit array of indices to identify the pinned components referenced by this UV property. This is the preferred method for accessing the pin component indices of a UV property.