Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mesh loader

Started by Javelin Jan 26, 2003 at 6:37 AM 4 replies 300+ views
Original Post
Javelin
Javelin
Hi What do you people use to load meshes into your 3D engines? Basicly I want to write my own functions for loading meshes but I cant seem to find an easy format to decode. I have searched for the "scene description format" (SDF), since it looked very simple, but with little progress. So if you have a link to or a name of a simple format, I would be grateful. I do not want to start with 3DS, LWO and things like that... Thanks // Javelin -- Why do something today when you can do it tomorrow... --
// Javelin// Assumption is the mother of all fuckups...
timmay
timmay
Try MilkShape, it is an easy to use low poly editor and it has an ascii export option that exports meshes in a readable format.
You can get it at: http://www.swissquake.ch/chumbalum-soft/
Javelin
Javelin
Well... I already have got milkshape and it looks quite nice...
But what I want is a description of some easy mesh format. SDF is quite readable but a text file that describes the format would be most welcome anyway...

Thanks

// Javelin
-- Why do something today when you can do it tomorrow... --
// Javelin// Assumption is the mother of all fuckups...
timmay
timmay
Ah, I see. A few weeks ago I was looking for the same thing that you are looking for. Then I found the following specification in the milkshape SDK (seperate download). Using this as a reference I wrote the code that read and rendered the exported model in no-time. If you''d like to see my code (it''s c++) let me know.


  
// 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.


// 360 = 6.28

//

Javelin
Javelin
Thanks m8... that was the typy of info I wanted.

I also checked the 3DS format and it did look far less complicated than I thought it to be so maybe I try that one right away.



// Javelin
-- Why do something today when you can do it tomorrow... --
// Javelin// Assumption is the mother of all fuckups...
timmay
timmay
You''re welcome. I''d like to note one more thing, it''s just my opinion though. The reason I''ve never looked further than Milkshape is that it might be brilliant when you''re working with different artists that use different modelers. Milkshape has the ability to import 37 different formats (includeing 3DS) and export it into one uniform format. This also means you could use a whole range of existing (free) content already available without the need of adding support for different formats.
Again, this is just my opinion. You should use whatever suits you best.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.