[Closed] Help: Exporting Animation Data
Hey guys, Im currently trying to write an exporter that can export meshes, animations and textures to a text file. Everything is going well except for the animation export.
Basically what I want to do is to use any type of IK and still be able to export the final bone data. I realize that to do this I need to select all bones in my file and create a key frame for them where I have used controllers like IK or whatever – basically when the bone itself is not moved but through another means like an IK System or Wire Parameters.
This works great with HI IK but for some reason starts to stuff up when using Spline IK.
What happens is that it exports all the animation correctly for all the bones in the chain except for the root. (btw, this is a stretchy spline IK system).
For some reason it will get the position but not the rotation or vice versa. There are pos and rot keys for the Spline IK bones, but both will not export.
Script Process: Firstly I collect the bones in the model:
gBoneList = #() ;
select $* ;
selection = getCurrentSelection() ;
for i = 1 to selection.count do
(
if ( canConvertTo selection[i] BoneGeometry ) then
(
append gBoneList selection[i] ;
)
)
I then go through the list of bones created using the following loop:
for bone in gBoneList do
(
)
I then look at the key frames for each individual bone’s rotations and position. I get these keys using:
local rkeys, tkeys ;
rkeys = GetUniqueTimes(bone.rotation.controller.keys) ;
tkeys = GetUniqueTimes(bone.pos.controller.keys) ;
– GetUniqueTimes is defined latter
Most of the time this works. But occasionally there are times when rkeys.count is greater than zero while tkeys.count equals zero. Sometimes it’s the other way around.
What’s confusing is that the key frame count for rotations and translations are ocasionally zero. It happens about 1 in 20 times. However it’s not random, and the faults are repeatable.
In the above, the GetUniqueTimes function is defined by:
function GetUniqueTimes keyarray =
(
local times, out;
times = #() ;
out = #() ;
for key in keyarray do
(
append times (key.time as float) ;
)
sort times ;
last_tm = undefined ;
for tm in times do
(
if (last_tm != tm) then
(
append out tm ;
)
last_tm = tm ;
)
out ;
)
Thanks in advance for your help.