PDA

View Full Version : Relative Transfromations from Absloute Transformations


jifman
02-20-2009, 12:12 AM
Hi,

Im trying to do a simple export import animation script. I've got the script to export the world transfromation matrix for each bone for each frame, and that works fine. And i can re-import it that onto the bones to animate. Problem im having is making this offset from the where the orginal animation ended.

heres the code im useing:

fn import_animation bones_array start_frame use_relative = (
open_name = getOpenFileName caption:"*.CAF" types:"Crowdz Animation Files (*.CAF)|*.CAF|"
Lastfame_matrix = #()
Firstfame_matrix = #()
sliderTime = start_frame
--creats an output file with the varibal name
the_openfile = openFile open_name
num_bones = readLine the_openfile as number
num_frames = readLine the_openfile as number
bones_names = #()
for i =1 to num_bones do (
bones_names[i] = readLine the_openfile
Firstfame_matrix[i] = bones_array[i].transform
)
Animate On
for i = start_frame to (start_frame + num_frames) do (
sliderTime = i
if use_relative == true then (

for b = 1 to num_bones do (
if b == 1 then (
temp_num = readLine the_openfile

temp_num = readLine the_openfile
Newframe_matrix = (execute (temp_num))
bones_array[b].transform = ( Newframe_matrix + Firstfame_matrix[b])
)else(
temp_num = readLine the_openfile
Newframe_matrix = (execute (temp_num))
bones_array[b].transform = ( Newframe_matrix + Firstfame_matrix[b])
)
)
)else(
for b = 1 to num_bones do (
if b == 1 then (
temp_num = readLine the_openfile
bones_array[b].pos = (execute (temp_num))
temp_num = readLine the_openfile
(coordsys parent (bones_array[b].transform = (execute (temp_num))))
)else(
temp_num = readLine the_openfile
(coordsys parent (bones_array[b].transform =(execute (temp_num))))
)
)
)
)
close the_openfile
return bone_names
)


as you can see im making a new array to take the offset values set by the where the bones are in space at the frame the animation is supposed to be applied to as sort of an offset, and times it with the data its reading in from the file. The offset is kept, but the size doubles the bone....

any help would be fantastic

geoff

CGTalk Moderation
02-20-2009, 12:12 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.