HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Milkshape3d ASCII format

12-29-2005, 12:37 AM#1
StealthFox
I found this in one of the CharacterFX folders and I thought it would help somehow.

// MilkShape 3D ASCII File Format Specification: 1 box, 1 material, a simple animation

// total frames
Frames: 30

// current frame
Frame: 1

// number of meshes
Meshes: 1

// mesh: name, flags, material index
"Box01" 0 0

// number of vertices
20

// vertex: flags, x, y, z, u, v, bone index
0 -10.375000 10.500000 13.750000 0.000000 0.000000 -1
0 -10.375000 -10.250000 13.750000 0.000000 1.000000 -1
0 10.375000 10.500000 13.750000 1.000000 0.000000 -1
0 10.375000 -10.250000 13.750000 1.000000 1.000000 -1
0 10.375000 10.500000 13.750000 0.000000 0.000000 -1
0 10.375000 -10.250000 13.750000 0.000000 1.000000 -1
0 10.375000 10.500000 -4.500000 1.000000 0.000000 -1
0 10.375000 -10.250000 -4.500000 1.000000 1.000000 -1
0 10.375000 10.500000 -4.500000 0.000000 0.000000 -1
0 10.375000 -10.250000 -4.500000 0.000000 1.000000 -1
0 -10.375000 10.500000 -4.500000 1.000000 0.000000 -1
0 -10.375000 -10.250000 -4.500000 1.000000 1.000000 -1
0 -10.375000 10.500000 -4.500000 0.000000 0.000000 -1
0 -10.375000 -10.250000 -4.500000 0.000000 1.000000 -1
0 -10.375000 10.500000 13.750000 1.000000 0.000000 -1
0 -10.375000 -10.250000 13.750000 1.000000 1.000000 -1
0 -10.375000 10.500000 13.750000 0.000000 1.000000 -1
0 10.375000 10.500000 13.750000 1.000000 1.000000 -1
0 -10.375000 -10.250000 13.750000 0.000000 0.000000 -1
0 10.375000 -10.250000 13.750000 1.000000 0.000000 -1

// number of normals
6

// normal: x, y, z
0.000000 0.000000 1.000000
1.000000 0.000000 0.000000
0.000000 0.000000 -1.000000
-1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 -1.000000 0.000000

// number of triangles
12

// triangle: flags, vertex index1, vertex index2, vertex index3, normal index1, normal index 2, normal index 3, smoothing group
0 0 1 2 0 0 0 1
0 1 3 2 0 0 0 1
0 4 5 6 1 1 1 2
0 5 7 6 1 1 1 2
0 8 9 10 2 2 2 1
0 9 11 10 2 2 2 1
0 12 13 14 3 3 3 2
0 13 15 14 3 3 3 2
0 12 16 6 4 4 4 3
0 16 17 6 4 4 4 3
0 18 13 19 5 5 5 3
0 13 7 19 5 5 5 3

// number of materials
Materials: 1

// material: name
"Material01"

// ambient
0.200000 0.200000 0.200000 0.800000

// diffuse
0.000000 0.501961 0.752941 0.800000

// specular
0.752941 0.752941 0.752941 0.800000

// emissive
0.000000 0.000000 0.000000 0.800000

// shininess
63.000000

// transparency
0.800000

// color map
"D:\Eigene Dateien\Image2.tga"

// alphamap
"D:\Eigene Dateien\Image1.tga"

// number of joints
Bones: 3

// name
"joint1"

// parent name
""

// joint: flags, posx, posy, posz, rotx, roty, rotz
0 0.250000 0.000000 0.000000 0.224024 1.570796 0.000000

// number of position keys
2

// position key: time, posx, posy, posz
1.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000

// number of rotation keys
2

// rotation key: time, rotx, roty, rotz
1.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000

"joint2"
"joint1"
5 0.000000 0.000000 20.256172 -1.015218 0.000362 3.141593
3
1.000000 0.000000 0.000000 0.000000
15.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
3
1.000000 0.000000 0.000000 0.000000
15.000000 2.286381 -0.000548 -0.000365
30.000000 0.000000 0.000000 0.000000
"joint3"
"joint2"
4 0.000000 0.000000 16.128391 0.000000 0.000000 0.000000
2
1.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000
2
1.000000 0.000000 0.000000 0.000000
30.000000 0.000000 0.000000 0.000000


// you can build the joint matrix:
// - rotate an identity matrix by the rotation values of the joint
// - set the translation of the matrix to the position values.

// the same for key matrices

// the key matrices animate the reference matrices, so you have to multiply them,
// to get the final local joint matrix. The get the final global joint matrix,
// you have to multiply them by their parents.
12-29-2005, 07:44 PM#2
StealthFox
I found out that Milkshape3d ASCII bone rotations are saved in radians and in euler form.

Here is the euler to quaternion formula also:

c1 = cos(rotation around y-axis/2)
s1 = sin(rotation around y-axis/2)
c2 = cos(rotation around z-axis/2)
s2 = sin(rotation around z-axis/2)
c3 = cos(rotation around x-axis/2)
s3 = sin(rotation around x-axis/2)
c1c2 = c1*c2
s1s2 = s1*s2
w = c1c2*c3 - s1s2*s3
x = c1c2*s3+ s1s2*c3
y = s1*c2*c3 + c2*s2*s3
z = c1*s2*c3 - s1*c2*s3

So Euler(x, y, z) becomes Quaternion(w, x, y, z); Rotation around y-axis is Heading, Rotation around z-axis is Banking, and Rotation aound x-axis is Attitude.
12-29-2005, 10:20 PM#3
Starcraftfreak
Since this is not a tool, but a format spec, I've moved this thread to the Programming forum. It's appreciated though, that you want to contribute. Keep that up man.