Maxscript Export Help...

Started by
0 comments, last by dabx11 21 years, 8 months ago
I made a script that will export Mesh, Bones, Materials, and skin weights...Now I need to get the Animation Data. Below is a script that I wrote to do it, but it doesn''t seem to work 100% of the time...It fails when I have bones that are copied/mirrored (not a instance/ref)...Created bones come out fine. I guess i''m getting the Rotation and Position from the wrong place, but i''m not sure where else to look... I''m trying to get a Vector and Quaternion for each bone on each frame...If you could point me in the right direction, or show me a script that does it, that would be great. Thanks. Pardon the script, I just started learning it 2 days ago
  

clearlistener()
file = createfile "c:\\temp\\test.ani"

b = for i in $* collect 
	if (classof i == BoneGeometry) then i else dontcollect

print (animationRange.end - animationRange.start) to:file
print TicksPerFrame to:file
if b.count > 0 then (
coordsys parent for i = 1 to b.count do (
	print b[i].name to:file
	for t = animationRange.start to animationRange.end do (
	at time t (
	print b[i].pos to:file 
	format "[%,%,%,%]\n" b[i].rotation.x b[i].rotation.y b[i].rotation.z b[i].rotation.w to:file
	)
	)
)
)

[\source]  
Advertisement
I''m not sure what''s tripping you up, but one thing that may be causing your trouble is that by using "b.rotation" will give you the rotation in WORLD space….I believe. If you need to get the local rotation of the bone, then you want to do something like this:<br><br>( b.transform * inverse( b.transform).rotation<br><br>Just to explain this line above…By multiplying the objects transform with the inverse of it''s parent, that will give you the local transformation matrix of the object. From there, you can use the .rotation to get the rotation from that Matrix.<br><br>Another thing to be aware of, which may also be part of your problem is that every object in Max actually has TWO transformation Matrices. How do ya like that? <img src="wink.gif" width=15 height=15 align=middle> There''s the normal one, which you can get with something like "b.transform". Then there''s an offset Matrix. I''m not aware of a way to get the whole Matrix itself directly(Maybe there''s a way?), but you can access it''s parts by saying:<br><br>b.objectoffsetpos<br>b.objectoffsetrot<br>b.objectoffsetscale<br><br>Oh yeah, I almost forgot another fun aspect. I believe that different parts(or maybe it''s different ways of accessing?) the transforms give you Matrices that are of different handedness!! For fun, try selecting a single object and typing the following into the listener:<br><br>$.rotation<br>$.transform.rotation<br>$.objecttransform.rotation<br>$.objectoffsetrot<br>$.rotation.controller.value<br><br>…and notice how you get a bunch of different results back! The bottom line is that the way Max deals with transforms is a bit funky to say the least and can be terribly frustrating to figure out at times. But hopefully, even if the suggestions I gave you above don''t pan out, then by at least knowing about all of this funkiness you''ll be able to track it down. I heartily recommend reading up about the transforms in the Maxscript Help. Just do a search for "ObjectOffsetPos". That should get you to the relevant stuff.<br><br>Good luck! <img src="smile.gif" width=15 height=15 align=middle><br><br>-John
- John

This topic is closed to new replies.

Advertisement