Hello everyone,
I have achieved with Maya / Esenthel something that you might wanna use too : transforming an animated mesh using nCloth technology in Maya so that it is successfully imported in Esenthel Editor, which handles skeleton animation only.
I needed it to have a convincing flag animation
The main trick, and you have to keep that in mind is to create a joint for each vertex of your mesh, and bake the physic animation into keyframes.
So... The more vertices you will use ... the more bones Esenthel will have to handle.
Workflow:
- Creating your physics animation into Maya
- Open the script editor and copy this MEL script into the field :
Code:
string $sel[] = `ls -sl`;
float $selPos[3] = `xform -ws -q -t $sel`;
PolySelectConvert 3;
string $verts[] = `ls -sl -fl`;
select -clear;
//string $jParent = `joint -name "jParent" -p $selPos[0] $selPos[1] $selPos[2]`;
for ($v in $verts)
{
float $pos[3] = `xform -ws -q -t $v`;
//select $jParent;
joint -p $pos[0] $pos[1] $pos[2];
}
SelectAllJoints;
group -n BoneGroup; xform -os -piv 0 0 0;
float $rMin = `playbackOptions -q -min`;
float $rMax = `playbackOptions -q -max`;
int $frame;
for ($frame = $rMin; $frame <= $rMax; $frame++)
{
int $vjCounter = 0;
currentTime -e $frame;
for ($v in $verts)
{
// --get it's position..
float $vpos[3] = `xform -q -ws -t $v`;
// --get the name of the appropriate joint incremented by 1.
string $jName = "|BoneGroup|joint" + ++$vjCounter;
// --set the pos of the joint to the pos of the vertex..
move $vpos[0] $vpos[1] $vpos[2] $jName;
// --set keyframe
setKeyframe -at translate -t $frame $jName;
}
}
- Click the blue PLAY button to execute it : a joint will be automatically created at each vertex, and a keyframe will be created for each frame of your animation, following the simulation that has run.
- Select the joints and mesh to Bind Skin (smooth will be fine). If an error message occurs, you might delete the nCloth and constraints from your scene and try again
- If you play, you can now see your joints playing the same result of your physics simulation.
You might wanna try to clean a bit your timeline and delete some keyframes... You can trust the interpolation to have a good result, and it would be easier for you to edit the animation if you want to (for example : make it "loopable")
Now you can export you scene into .FBX, and load it in Esenthel Editor.
Here is a result of an animated flag :
https://www.youtube.com/watch?v=-BkmBdS3...e=youtu.be
Hope this will help someone else out there !