Writing model 3D Model data to a new file as a new format

Started by
11 comments, last by Ashaman73 9 years, 12 months ago

I am just wondering if its possible to write 3d model data to a file,instead of directly working with md5 files i would like to convert to my own format,the information i want to write to the file are vertices,normals,vertex weights,texture coords,so far i have written the model data to a text file but now i would like to write it to my own file format using fopen,fwrite as binary data, or should i stick to just md5 files in the game directory?

:)
Advertisement

It is possible and a lot of games, including my own, do it this way. Thought I wouldn't recommend md5 as basic format (it has its restrictions), but either FBX or Collada from which you should create your own files.

You might also want to consider using a library to save you from writing your own exporter/importer.

"I would try to find halo source code by bungie best fps engine ever created, u see why call of duty loses speed due to its detail." -- GettingNifty

It is possible and a lot of games, including my own, do it this way. Thought I wouldn't recommend md5 as basic format (it has its restrictions), but either FBX or Collada from which you should create your own files.

What are the restrictions?

:)

What are the restrictions?

The restrictions are just what the format does not provides , but what you need. MD5 was developed for id tech engines with their needs, but sometimes your engine need additional data, eg vertex color, different uv coords, multiple textures etc. which might not be covered by MD5. Collada/FBX on the other hand contains a lot of stuff, most which you dont need. It depends on what you need. If MD5 contains all data you need, than use it :D

This is probably obvious, but the md5 format itself doesn't have restrictions, but the model that is in md5 format may have restrictions. For example: You can't just grab a doom model, write it out to your new format and use it in your game that you are making money on (I doubt they'd care if it was just some open source game), and even someone's custom model may have some rights attached (though I'm a bit murky on that one)

If you want a file format for 3D models that lets you store some custom information try with PLY. You can define the name and the type of a property of the vertex in the header and then for each vertex you store the values for each property in one line. Here's an example of one file with only vertex position (x, y and z) and faces, and other example with vertex position AND colors, faces and "edges" (you can add new elements if you need too): http://www.mathworks.com/matlabcentral/fx_files/5459/1/content/ply.htm

There is also the new OpenGEX format:

http://www.opengex.org/


i would like to write it to my own file format using fopen,fwrite as binary data, or should i stick to just md5 files in the game directory?

I'd suggest using your own binary format. The first step is to determine an efficient way to load the model data which supports how your app creates the model internally, in what order you want position, normal, texcoord, blend indices, blend weights, etc., to write into your buffer or structure. Then design the file format to support that process.

Only as an example, if you have a vertex comprised of position, normal, diffuse color, 2 tex coords - read in your md5 file, setup your model with that vertex structure, open an output binary file, write a header describing the number of vertices and the format/stride, etc., and write the binary data out in vertex order. You can then read in that file by reading the header, creating a buffer of appropriate size and load data directly into the buffer. You may want to consider extras like texture names, etc.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

There is also the new OpenGEX format:

http://www.opengex.org/

Hmmm. looks really interesting, thought a few month too late for me (refactored my converter from the over-engineered collada to the proprietary FBX format), thought there is one question:

What I really miss from all this exchange formats, especially when using them to export stuff for a game engine, is the lacking support of custom attributes. You can add custom attributes in modelling tools, but you never got them exported to Collada/FBX. It is possible with OpenGex ?

This topic is closed to new replies.

Advertisement