Working with Deformers

Working with Deformers

Working with Deformers

Aspose.3D for .NET supports two deformation systems: skeletal deformation via SkinDeformer and Bone, which bind a skeleton to a mesh for character animation, and morph target deformation via MorphTargetDeformer, which blends between multiple mesh shapes.


Skeletal Deformation with SkinDeformer

A SkinDeformer attaches a set of Bone objects to a mesh. Each bone defines a weight for every vertex it influences. The mesh deforms when the bone transforms change.

using Aspose.ThreeD;
using Aspose.ThreeD.Deformers;
using Aspose.ThreeD.Entities;

var scene = new Scene();
var mesh = new Mesh("body");
Node meshNode = scene.RootNode.CreateChildNode("body", mesh);

// Create a SkinDeformer and attach it to the mesh
var skin = new SkinDeformer();
mesh.Deformers.Add(skin);

// Define a bone and assign per-vertex weights
var bone = new Bone("spine");
bone.BoneTransform = Matrix4.Identity;
bone.SetWeight(0, 1.0);
bone.SetWeight(1, 0.8);
skin.Bones.Add(bone);

Vertex indices passed to SetWeight must be valid indices in the mesh’s control-points array. Weights are typically normalized so they sum to 1.0 across all bones influencing a vertex.


Morph Target Deformation

MorphTargetDeformer blends the base mesh toward one or more target shapes. Each target is a separate mesh with the same topology but different vertex positions.

using Aspose.ThreeD;
using Aspose.ThreeD.Deformers;
using Aspose.ThreeD.Entities;

var scene = new Scene();
var baseMesh = new Mesh("face_neutral");
scene.RootNode.CreateChildNode("face", baseMesh);

// Target shape
var smileMesh = new Mesh("face_smile");

// Attach a MorphTargetDeformer
var morph = new MorphTargetDeformer();
baseMesh.Deformers.Add(morph);

// Add a morph channel targeting the smile mesh
var smileChannel = new MorphTargetChannel("smile");
smileChannel.Targets.Add(smileMesh);
morph.Channels.Add(smileChannel);

// At runtime, set the blend weight (0.0 = base, 1.0 = full target)
smileChannel.SetWeight(smileMesh, 0.75);

API Quick Reference

MemberDescription
new SkinDeformer()Create a skeletal deformer to attach to a mesh
skin.BonesIList<Bone> of bones in this deformer
new Bone(name)Create a named bone
bone.SetWeight(vertexIndex, weight)Assign a blend weight to a vertex
bone.BoneTransformBind-pose offset matrix for this bone
new MorphTargetDeformer()Create a morph target deformer
morph.ChannelsIList<MorphTargetChannel> of blend channels
new MorphTargetChannel(name)Create a named morph channel
channel.WeightBlend weight: 0.0 = base, 1.0 = target
channel.AddTarget(mesh, fullWeight)Register a target mesh for this channel
mesh.DeformersCollection of deformers on a mesh

See Also