Navigation
API > API/Plugins > API/Plugins/SkeletalMeshModifiers
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- USkinWeightModifier
References
| Module | SkeletalMeshModifiers |
| Header | /Engine/Plugins/Experimental/MeshModelingToolsetExp/Source/SkeletalMeshModifiers/Public/SkinWeightModifier.h |
| Include | #include "SkinWeightModifier.h" |
Syntax
UCLASS&40;BlueprintType&41;
class USkinWeightModifier : public UObject
Remarks
API used to modify skin weights on a Skeletal Mesh asset.
To use:
Instantiate an instance of USkinWeightModifier
Call "SetSkeletalMesh(MyMeshAsset)", passing in the skeletal mesh you want to edit weights on
Use Get/Set weights functions, and Normalize/Prune to edit the weights as desired
When ready to commit to the asset, call CommitWeightsToSkeletalMesh() and save the asset if desired
This API can be used from C++, Blueprint or Python. Here is a sample usage of the API in Python:
import unreal
create a weight modifier for a given skeletal mesh
skel_mesh = unreal.EditorAssetLibrary().load_asset("/Game/Characters/Wolf/Meshes/SK_Wolf") weight_modifier = unreal.SkinWeightModifier() weight_modifier.set_skeletal_mesh(skel_mesh)
get weight of vertex 1234
vertex_weights = weight_modifier.get_vertex_weights(1234) print(vertex_weights)
remove neck2 as an influence on this vertex
vertex_weights.pop("neck2") weight_modifier.set_vertex_weights(vertex_weights, True) print(vertex_weights)
commit change to the skeletal mesh
weight_modifier.commit_weights_to_skeletal_mesh()
OUTPUT: {"head": 0.6, "neck1": 0.3, "neck2": 0.1} {"head": 0.6, "neck1": 0.3}
In Python, the per-vertex weights are stored as a dictionary mapping Bone Names to float weight values.
The "SetVertexWeights()" function expects the same data structure. You can add/remove/edit influences as needed. The SetVertexWeights() function does not normalize the weights. So you can make multiple modifications and call NormalizeVertexWeights() or NormalizeAllWeights() as desired.
The PruneVertexWeights() and EnforceMaxInfluences() functions can be used to trim small influences and clamp the total number of influences per vertex as needed.
Note that it is not required to normalize the weights by calling any of the normalize functions. Or manually before calling SetVertexWeights(). Committing the weights to the skeletal mesh will always enforce normalization.
Though it may be useful to normalize while editing.
Functions
| Type | Name | Description | |
|---|---|---|---|
| bool | Actually applies the weight modifications to the skeletal mesh. | ||
| bool | EnforceMaxInfluences
(
const int32 MaxInfluences |
Strips out smallest influences to ensure each vertex does not have weight on more influences than MaxInfluences. | |
| TArray< FName > | Get an array of all bone names in the skeletal mesh. | ||
| int32 | Get the total number of vertices in the skeletal mesh. | ||
| USkeletalMesh * | Get a reference to the skeletal mesh that was loaded | ||
| TMap< FName, float > | GetVertexWeights
(
const int32 VertexID |
Get all bone weights for a single vertex. | |
| bool | Normalize weights on all vertices in the mesh. | ||
| bool | NormalizeVertexWeights
(
const int32 VertexID |
Normalize weights on the specified vertex. | |
| bool | PruneAllWeights
(
const float WeightThreshold |
Remove all weights below the given threshold value, on all vertices. | |
| bool | PruneVertexWeights
(
const int32 VertexID, |
Remove all weights below the given threshold value, on the given vertex. | |
| bool | SetSkeletalMesh
(
USkeletalMesh* InMesh |
Call this first to load the weights for a skeletal mesh for fast editing. | |
| bool | SetVertexWeights
(
const int32 VertexID, |
Set bone weights for a single vertex. |
Constants
| Name | Description |
|---|---|
| LODIndex |