Deformers

Overview

A Deformer modifies a Mesh (or other Geometry) beyond its raw control_points — the two concrete kinds exposed by this fork are SkinDeformer (bone-driven skinning) and MorphTargetDeformer (blend-shape style targets). Deformer data most commonly arrives already attached to a Mesh after loading a rigged or blend-shape model from a file; the workflow documented here is reading that data back out.


Reading every deformer on a mesh

Mesh.deformers lists every Deformer attached to the mesh; get_deformers(deformer_type) filters to one kind:

from aspose.threed.entities import Mesh

mesh = Mesh("Character")
for deformer in mesh.deformers:
    print(f"{type(deformer).__name__}: owner={deformer.owner}")

Each Deformer’s owner property points back at the Geometry it modifies, and name identifies it like any other named object in the scene.

SkinDeformer: bone-driven skinning

SkinDeformer.bones is a list of Bone objects, each linking a scene Node (the bone) to per-vertex weights:

for deformer in mesh.get_deformers(SkinDeformer):
    for bone in deformer.bones:
        print(f"Bone node: {bone.node.name}, weight_count: {bone.weight_count}")

Bone.get_weight(index) returns the influence weight of that bone on a specific control point; Bone.transform and Bone.bone_transform expose the bone’s bind-pose matrices.

MorphTargetDeformer: blend shapes

MorphTargetDeformer.channels is a list of MorphTargetChannel objects, each holding one or more target Shapes and a weight per target:

for deformer in mesh.get_deformers(MorphTargetDeformer):
    for channel in deformer.channels:
        print(f"Channel weight: {channel.channel_weight}, targets: {len(channel.targets)}")

MorphTargetChannel.get_weight(index) and set_weight(index, weight) read and adjust an individual target’s influence within the channel.


Tips and Best Practices

  • Always filter with get_deformers(deformer_type) rather than scanning mesh.deformers by hand when you only care about one kind — SkinDeformer or MorphTargetDeformer.
  • Check bone.node is not None before reading bone.node.name — a bone’s node reference depends on the source file having linked it correctly.
  • Treat deformer weights as read-only inspection data unless you have specifically validated that the exporter you are targeting writes modified weights back out.
  • Remember that a mesh with no rigging or blend shapes simply has an empty deformers list — this is normal, not an error.

Common Issues

IssueCauseFix
mesh.deformers is always emptyThe source file has no skinning or morph-target data, or it was not loaded with a format/options combination that preserves itConfirm the source format and file actually contain deformer data before assuming a bug
AttributeError reading bone.node.namebone.node is NoneCheck bone.node is not None before accessing its name
get_deformers(SkinDeformer) returns nothing but deformers is non-emptyThe mesh’s deformers are MorphTargetDeformer instances, not SkinDeformerCheck type(deformer).name for each entry in mesh.deformers to see what kinds are actually present

FAQ

Can I attach a brand-new SkinDeformer to a mesh I built from scratch?

The public API surface exposes SkinDeformer’s properties and methods for reading an existing deformer; building full bone-weight rigging from scratch in application code is a much larger task than this page covers — start from a file that already contains the rigging you need.

What is the difference between SkinDeformer and MorphTargetDeformer?

SkinDeformer drives mesh deformation from bone transforms and per-vertex weights (classic skeletal skinning). MorphTargetDeformer blends between alternate target Shapes using per-channel weights (blend-shape / morph-target animation).

Does a Deformer modify control_points directly?

No — a Deformer is read as auxiliary data alongside the mesh’s own control_points and polygons; it describes how the mesh would be deformed, rather than rewriting the base geometry itself.


API Reference Summary

Class/MethodDescription
Mesh.deformersEvery Deformer attached to the mesh
Mesh.get_deformers(deformer_type)Deformers of one specific kind
SkinDeformer.bonesList of Bone objects for skeletal skinning
Bone.node / Bone.get_weight(index)The bone’s scene Node and its per-vertex weight
MorphTargetDeformer.channelsList of MorphTargetChannel objects
MorphTargetChannel.targets / .channel_weightTarget shapes and the channel’s overall weight

See Also