About Store Forum Documentation Contact



Post Reply 
Importing Maya nCloth animation
Author Message
LDA Offline
Member

Post: #1
Importing Maya nCloth animation
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 smile

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") smile
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 !
(This post was last modified: 10-09-2015 09:54 AM by LDA.)
10-08-2015 02:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Importing Maya nCloth animation
That's cool effect, thanks for sharing smile

(10-08-2015 02:24 PM)LDA Wrote:  You might wanna try to clean a bit your timeline and delete some keyframes...
Please keep in mind that in EE Editor, once you open an Animation, and go to "Edit" mode, there's an option at the top menu (near edit button) to "Reduce Keyframes" which can automatically remove keyframes for you based on chosen aggressiveness.
10-08-2015 09:21 PM
Find all posts by this user Quote this message in a reply
LDA Offline
Member

Post: #3
RE: Importing Maya nCloth animation
Nice, I haven't noticed that tool smile
10-09-2015 09:54 AM
Find all posts by this user Quote this message in a reply
Post Reply