After writing a simple maxscript for exporting physics data into physx, and working for hours with the .x format trying to get animations and meshes together (at the same time!) I decided the format itself was just too complicated and not even worth debugging so I came up with this
Code: Select all
<mesh numverts="3" numtris="1" material="material.material">
x y z
x y z
x y z
0 1 2
</mesh>
<bone name="parent" position="x,y,z" rotation="w,x,y,z">
<bone name="child" position="x,y,z" rotation="w,x,y,z">
</bone>
</bone>
<skinweights bone="bone name" numweights="1">
vertexnumber weight
</skinweights>
<animation name="animation">
<joint name="joint name" numkeys="1">
time w x y z//quaternion
</joint>
</animation>
you might notice the vertices dont even have uvs, normals or anything, but that can easily be added, with a flag for vertex type(its just not my top priority right now)
currently the material loading is not working either(see my thread in advanced help)
if anyone is interested in using it I could post the irrlicht meshloader
but its still a work in progress(every thing but animations works)
heres the maxscript code that generates the text(into the maxscript listener) which I paste into files (.mesh,.skeleton,.animation no .material yet) I could easily write a function to save all to file but anyways
Code: Select all
utility util "animation"
(
button saveskeleton "save skeleton"
button saveskinnedmesh "save skinned mesh"
button saveskinweights "save skin weights"
button saveanimation "save animation"
function addBone b tab =
(
if (classOf b == BoneGeometry or classOf b == Biped_Object or classOf b == dummy) then
(
pos = (getNodeTM b).translationpart
rot = (getNodeTM b).rotationpart
bname = substituteString b.name " " "_"
format "%<bone name=\"%\" position=\"%,%,%\" rotation=\"%,%,%,%\">\n" tab bname pos.x pos.z pos.y rot.w rot.x rot.z rot.y
for i in b.children do
(
addBone i (tab+" ")
)
format "%</bone>\n" tab
)
)
on saveskeleton pressed do
(
for i in geometry do
(
if(i.parent==undefined and ((classOf i)==BoneGeometry or (classOf i)==Biped_Object)) then
(
addBone i ""
)
)
)
on saveskinnedmesh pressed do
(
for i in geometry do
(
if ((classOf i)==Editable_mesh) then
(
for m in i.modifiers do
(
if((classOf m)==Skin) then
(
format "<mesh numverts=\"%\" numtris=\"%\">\n" i.numverts i.numfaces
for v=1 to i.numverts do
(
vert = getVert i v
format "% % %\n" vert.x vert.z vert.y
)
for f=1 to i.numfaces do
(
face = getFace i f
format "% % %\n" (face.x as Integer-1) (face.z as Integer-1) (face.y as Integer-1)
)
format "</mesh>\n"
)
)
)
)
)
on saveskinweights pressed do
(
for i in geometry do
(
if ((classOf i)==Editable_mesh) then
(
for m in i.modifiers do
(
if((classOf m)==Skin) then
(
max modify mode
modPanel.setCurrentObject m
BoneWeights = #()
BoneIndex = #()
for n=1 to skinOps.getNumberBones m do
(
BoneWeights[n] = #()
BoneIndex[n] = #()
)
for v=1 to skinOps.GetNumberVertices m do
(
index = 1
for n=1 to skinOps.GetVertexWeightCount m v do
(
append BoneWeights[skinOps.GetVertexWeightBoneID m v n] v
append BoneIndex[skinOps.GetVertexWeightBoneID m v n] index
index+=1
)
)
for n=1 to BoneWeights.count do
(
bname = substituteString (skinOps.getBoneName m n 1) " " "_"
format "<skinweights bone=\"%\" numweights=\"%\">\n" bname BoneWeights[n].count
for v=1 to BoneWeights[n].count do
(
format "% %\n" (BoneWeights[n][v]-1) (skinOps.GetVertexWeight m BoneWeights[n][v] BoneIndex[n][v])
)
format "</skinweights>\n"
)
)
)
)
)
)
on saveanimation pressed do
(
format "<animation name=\"%\">\n" "..."
for i in geometry do
(
if((classOf i)==BoneGeometry) then
(
if(i.rotation.isAnimated) then
(
bname = substituteString i.name " " "_"
format " <bone name=\"%\" numkeys=\"%\">\n" bname i.rotation.controller.keys.count
for k in i.rotation.controller.keys do
(
rot = k.value as quat
format " % % % % %\n" (k.time as float/4800) rot.w rot.x rot.z rot.y
)
format " </bone>\n"
)
)
)
format "</animation>\n"
)
)
any suggestions?