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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user