Skinned animation now works, although there are still some optimizations

to be made.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4027 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2006-04-18 01:36:19 +00:00
parent fdf0fa27d3
commit a0ff0d1457
15 changed files with 504 additions and 236 deletions
+9 -7
View File
@@ -37,18 +37,20 @@ macroScript TRAnimationExporter category:"File" \
-- Writes a single node transform
fn writeTransform node outFile = (
format " <transform name=\"%\"" node.name to:outFile
writePoint3Attr " translation" node.transform.translationPart outFile
writeQuatAttr " rotation" (inverse node.transform.rotationPart) outFile
writePoint3Attr " scale" node.transform.scalePart outFile
xform = node.transform
if node.parent != undefined do (
xform = xform * (inverse node.parent.transform)
)
writePoint3Attr " translation" xform.translationPart outFile
writeQuatAttr " rotation" (inverse xform.rotationPart) outFile
writePoint3Attr " scale" xform.scalePart outFile
format "/>\n" to:outFile
)
-- Writes a single animation frame
fn writeFrame nodes outFile = (
format " <frame>\n" to:outFile
for node in nodes do in coordsys parent (
writeTransform node outFile
)
writeTransform node outFile
format " </frame>\n\n" to:outFile
)
@@ -57,7 +59,7 @@ macroScript TRAnimationExporter category:"File" \
(
outFile = createfile fileName
format "<?xml version=\"1.0\" standalone=\"yes\"?>\n\n" to:outFile
format "<animation>\n\n" to:outFile
format "<animation frameRate=\"%\">\n\n" frameRate to:outFile
local nodes
if selection.count > 0 then (
nodes = selection
+9 -9
View File
@@ -103,22 +103,20 @@ macroScript TRModelExporter category:"File" \
) else (
kind = "triMesh"
)
) else if node.boneEnable then (
kind = "boneNode"
) else (
kind = "node"
)
format " <% name=\"%\"" kind node.name to:outFile
xform = node.transform
if node.parent != undefined do (
xform = xform * (inverse node.parent.transform)
format " parent=\"%\"" node.parent.name to:outFile
)
in coordsys parent (
writePoint3Attr " translation" node.transform.translationPart \
outFile
writeQuatAttr " rotation" (inverse node.transform.rotationPart) \
outFile
writePoint3Attr " scale" node.transform.scalePart outFile
)
writePoint3Attr " translation" xform.translationPart \
outFile
writeQuatAttr " rotation" (inverse xform.rotationPart) \
outFile
writePoint3Attr " scale" xform.scalePart outFile
if isMesh then (
format ">\n" to:outFile
if isProperty node #skin do (
@@ -140,6 +138,7 @@ macroScript TRModelExporter category:"File" \
format "<?xml version=\"1.0\" standalone=\"yes\"?>\n\n" to:outFile
format "<model>\n\n" to:outFile
local nodes
oldsel = selection as array
if selection.count > 0 then (
nodes = selection
) else (
@@ -148,6 +147,7 @@ macroScript TRModelExporter category:"File" \
for node in nodes do (
writeNode node outFile
)
select oldsel
format "</model>\n" to:outFile
close outFile
)