Gildor's Forums

Author Topic: Animation Export  (Read 3667 times)
warrantyvoider
Full Member
***
Posts: 109


View Profile
Animation Export
« on: March 03, 2013, 18:24 »

Hi,
I currently try to redo your psa exporter. So far I found out that I start from an AnimSet object, find all bones from the BioAnimSetData and then "lerp" from keyframe to keyframe. lets say I have 3 frames, so I calc the lerp values from 1 to 2, 2 to 3, but then to what do I lerp frame 3 to?


greetz WV
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7971



View Profile WWW
Re: Animation Export
« Reply #1 on: March 03, 2013, 18:27 »

Hi.
That depends on "looping" state of animation playback. When the animation is looped, you should lerp last frame against the first one. When animation is not looped, you'll freeze mesh at the last frame.
When you're exporting animations you shouldn't lerp last frames. You'll always have a last frame for exact export.
Logged
warrantyvoider
Full Member
***
Posts: 109


View Profile
Re: Animation Export
« Reply #2 on: March 03, 2013, 19:58 »

yeah, you were right, as always :p here I just want to share my method (the last sequence will be slerped against first or itself, depending on loop) because directx has functions for this built in:

Code:
for (int j = 0; j < inf.NumRawFrames; j++)
                    for (int k = 0; k < inf.TotalBones; k++)
                    {
                        Vector3 fromV = seq.CompressedTrackOffsets[k].Trans;
                        Vector3 toV = seqn.CompressedTrackOffsets[k].Trans;
                        Vector4 srotQ = seq.CompressedTrackOffsets[k].Rot;
                        Vector4 erotQ = seqn.CompressedTrackOffsets[k].Rot;
                        Quaternion q1 = Vec4ToQ(srotQ);
                        Quaternion q2 = Vec4ToQ(erotQ);
                        float t = (float)j / (float)(inf.NumRawFrames - 1);
                        Vector3 currV = Vector3.Lerp(fromV, toV, t);
                        Quaternion qc = Quaternion.Slerp(q1, q2, t);
                        PSAFile.PSAAnimKeys key = new PSAFile.PSAAnimKeys();
                        key.location = new PSAFile.PSAPoint(currV);
                        key.rotation = new PSAFile.PSAQuad(QToVec4(qc));
                        key.time = 1;
                        d.Keys.Add(key);
                    }
greetz WV
Logged
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS