Check out the relevant function:
function write_bones mesh file =-- writes bone related data to a file( if mesh.modifiers[#skin] != undefined then -- if there is a skin modifier ( -- selecting the mesh and going into modify mode -- is necessary for some of the following commands select mesh max modify mode -- write out total bone count for the mesh total_bone_count = skinops.getnumberbones mesh.modifiers[#skin] writelong file total_bone_count #unsigned for bone = 1 to total_bone_count do -- loop through all the bones in this mesh ( -- write out the name of this bone bone_name = skinops.getbonename mesh.modifiers[#skin] bone 0 writestring file bone_name -- retrieve the bone node by the name bone_node = getnodebyname bone_name controller = bone_node.position.controller; for index = 1 to 2 do ( -- write out keyframe count keyframe_count = numkeys controller; writelong file keyframe_count #unsigned for keyframe = 1 to keyframe_count do -- loop through all keyframes ( -- get the time for this keyframe keyframe_time = ( getkeytime controller keyframe ).frame as integer -- write it to the file writelong file keyframe_time #unsigned -- retrieve the proper transform matrix for the bone transform = bone_node.transform if ( bone_node.parent != undefined ) then -- if this isn't the root bone -- apply the parent's transform on top transform = transform * ( inverse ( bone_node.parent.transform ) ) if index == 1 then -- if we are dealing with a positional keyframe ( -- retrieve the translation (point) translation = transform.translationpart -- write out translation at time keyframe_time writefloat file translation.x at time keyframe_time writefloat file translation.y at time keyframe_time writefloat file translation.z ) else -- we are dealing with a rotational keyframe ( -- retrieve the rotation (quaternion) rotation = transform.rotationpart; -- write out rotation at time keyframe_time writefloat file rotation.x at time keyframe_time writefloat file rotation.y at time keyframe_time writefloat file rotation.z at time keyframe_time writefloat file rotation.w ) ) controller = bone_node.rotation.controller; ) ) for vertex = 1 to getnumverts mesh do -- loop through all mesh vertices in this mesh ( -- write out number of bones affecting this mesh vertex vertex_bone_count = skinops.getvertexweightcount mesh.modifiers[#skin] vertex writelong file vertex_bone_count #unsigned for bone = 1 to vertex_bone_count do -- loop through all the bones that affect this mesh vertex ( -- write out the bone id for this mesh vertex bone_id = skinops.getvertexweightboneid mesh.modifiers[#skin] vertex bone writelong file bone_id #unsigned -- write out the bone weight for this mesh vertex weight = skinops.getvertexweight mesh.modifiers[#skin] vertex bone writefloat file weight ) ) ) else -- there is no skin modifier -- we have no bones writelong file 0 #unsigned )
It exports the proper timings and everything but for some reason all the actual transformation data (all the lines with "at time ...") contain the exact same values for a mesh that is animated.
What could cause this behavior? I've spend a day and haven't been able to find anything, I'm very new to Maxscript however, maybe somebody can point me in the right direction. I'm using 3ds Max 9 if that matters.
Thanks ahead of time.
[Edited by - d h k on June 8, 2010 12:37:34 PM]