Jump to content
  • Advertisement
Sign in to follow this  
Citizen Erased

Saving in game geometry to a common file format

This topic is 4078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to add a feature to an application I'm working that will allow me to save an in game model's geometry to a common file format such as .3DS. Now, I can quite easily export the vertex / index / normal data into a text file with ostream but i'm not sure what exactly is required in order to format it to something like a .3DS file. How would I go about doing this or go about finding out how to do this?

Share this post


Link to post
Share on other sites
Advertisement
3DS is, as far as I know, a proprietary format, although its internals have been documented partially by various volunteers. If I were you, I'd go for a different format based on your needs. But if you absolutely must go with 3DS, you can find documentation of the reverse-engineering results, for instance here. I'm not aware of what potential legal issues you are exposing yourself to by implementing something like that.

If your models are static, you can dump them to Wavefront OBJ format. If you have keyframe animations, something like MD2 to MD5 might be useful. Then there's also Collada.

Share this post


Link to post
Share on other sites
Saving to .OBJ would do the job, how would I go about making an exporter for that format? As I say, saving the data to a text document is easy enough but I'm not sure what kind of formatting would be needed to create something like an OBJ.

Share this post


Link to post
Share on other sites
Well, you need to read the format specification. In case of Wavefront OBJ, it's publicly available. As it's a text format, you can find plenty of documentation for it. You can read the spec here, but it contains a lot of things that you won't need (the Bezier stuff). The basic format is very simple, it contains rows of data starting with an identifier and followed by a bunch of numbers. The vertex rows are implicitly indexed in order of appearance, and the face data references that row index. This page describes all the basic entries you need to write.

Share this post


Link to post
Share on other sites
First, you should find documentation on the format you wanna export to.
Then, I'd suggest you to code an importer first. As you see onscreen that what you loaded is what was expected, you'll know you've done things right. Then, you could attempt to inverse the logic and export you own model into that format.

Share this post


Link to post
Share on other sites
Hmm, I'm not sure OBJ would be ideal. I need a format that will store vertex data, index data, vertex normals and UV texture data (and can be loaded into 3DStudioMax but that is not essential). Anyone know of a good, easy to use format that fits that bill? I'm not entirely sure .OBJ does...

Share this post


Link to post
Share on other sites
OBJ stores all of those, yes. Did you look at those links? Here's another that explains it slightly better.

Keep in mind with the face index you can store nine numbers, representing three vertices, three normals, and three texture coordinates, so with those you're all set.

On another note, OBJ can also reference material data in a material library file, for which it presents another format, MTL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!