Arrange Shape
Clusters are how you arrange shapes on a avatar.
Use the Cluster API to create a cluster, add shapes to a cluster, remove a cluster and so on.
For more information about the feature, please visit here.
To learn more about the rest of the API, please refer to Cluster in the repository.
Sample Plugin
Sample plugin for garment creation is available here.
Sample plugin for cluster arragement is available here.
Creating a Cluster
Code Snippet
Python C++ C#
Python
# Create new cluster (Front Torso)
clusterId = BwApi.ClusterCreate(garmentId,
BwApi.BW_API_CLUSTER_SILHOUETTE_VIEW_FRONT,
BwApi.BW_API_CLUSTER_SILHOUETTE_LOCATION_TORSO)C++
// Create new cluster (Front Torso)
int clusterId = 0;
BwApiClusterCreate(garmentId,
BW_API_CLUSTER_SILHOUETTE_VIEW_FRONT,
BW_API_CLUSTER_SILHOUETTE_LOCATION_TORSO,
&clusterId);C#
// Create new cluster (Front Torso)
int clusterId = 0;
BwApi.ClusterCreate(garmentId,
ClusterSilhouetteView.BW_API_CLUSTER_SILHOUETTE_VIEW_FRONT,
ClusterSilhouetteLocation.BW_API_CLUSTER_SILHOUETTE_LOCATION_TORSO,
&clusterId);Result
New cluster ID.
Note: Creating a cluster without any shape doesn't do anything.
Adding Shape to a Cluster
A cluster may have more than one shape associated with it.
Code Snippet
Python C++ C#
Python
# Add existing shape to an existing cluster BwApi.ClusterShapeAdd(garmentId, clusterId, shapeId)
C++
// Add existing shape to an existing cluster
result = BwApiClusterShapeAdd(garmentId,
clusterId,
shapeId);C#
// Add existing shape to an existing cluster
BwApi.ClusterShapeAdd(garmentId,
clusterId,
shapeId);Result
Setting Shape Offset on a Cluster
Code Snippet
The code snippet below shows how to set the shape offset from the cluster hanging point.
Python C++ C#
Python
# Get the current shape offset offset = BwApi.ClusterShapeOffsetGet(garmentId, clusterId, shapeId)# Move the shape a little bit offset.x = offset.x + 5 offset.y = offset.y + 2# Update the shape offset BwApi.ClusterShapeOffsetSet(garmentId, clusterId, shapeId, offset)
C++
// Get the current shape offset BwApiCoodinatesXY offset; BwApiClusterShapeOffsetGet(garmentId, clusterId, shapeId, &offset);// Move the shape a little bit offset.x = offset.x + 5; offset.y = offset.y + 2;// Update the shape offset BwApiClusterShapeOffsetSet(garmentId, clusterId, shapeId, offset);
C#
// Get the current shape offset CoordinatesXY offset = new CoordinatesXY(); BwApi.ClusterShapeOffsetGet(garmentId, clusterId, shapeId, out offset);// Move the shape a little bit offset.x = offset.x + 5; offset.y = offset.y + 2;// Update the shape offset BwApi.ClusterShapeOffsetSet(garmentId, clusterId, shapeId, offset);
Result
Removing a Shape from a Cluster
Code Snippet
Python C++ C#
Python
# remove the shape from the cluster BwApi.ClusterShapeRemove(garmentId, clusterId, shapeId)
C++
// remove the shape from the cluster BwApiClusterShapeRemove(garmentId, clusterId, shapeId);
C#
// remove the shape from the cluster BwApi.ClusterShapeRemove(garmentId, clusterId, shapeId);
Result
Deleting a Cluster
Code Snippet
Python C++ C#
Python
# delete a cluster BwApi.ClusterDelete(garmentId, clusterId)
C++
// delete a cluster BwApiClusterDelete(garmentId, clusterId);
C#
// delete a cluster BwApi.ClusterDelete(garmentId, clusterId);
Result
Note: Shapes associated with the cluster have no cluster after this action completes.