Sign in to follow this  
Firestryke31

I need a simple 3D file format

Recommended Posts

I've been throwing together a simple iPhone game, and am at the point where I would like to display some 3D models for my characters.

Unfortunately my Google-fu is weak and I have been unable to find a simple format that meets my needs. They all either don't support skeletal animation, or are drastic overkill for my project (Shaders? We don't need no stinkin' shaders! Or tangents, or physics data, or much of anything really).

At the moment all I need are:
Vertex/Index data (duh)
Vertex Normal data
Texture coords
Skeletal animation (ideally multiple animations, and they don't need to be blendable either)
Easy to load
Relatively compact (i.e. not ASCII)

I've considered writing my own format, but then I'd have to write an exporter/converter for that format and that would be a project in and of itself.

I've also considered the MD2/MD3 formats, but having a duplicate of the entire mesh for each keyframe kind of dissuaded me from that (unless someone convinces me it is still okay for an iPhone game). If anyone has a suggestion I would love to hear it. At the moment this is basically the only thing keeping me from continuing my game.

Share this post


Link to post
Share on other sites
One option is John Ratcliff's [url="http://codesuppository.blogspot.com/2009/11/test-application-for-meshimport-library.html"]MeshImport library[/url] and its XML-based EZ-Mesh file format. It's human-readable ASCII, but you could convert it to an equivaent binary format for compactness.

Share this post


Link to post
Share on other sites
I don't think you are going to find simple and nonascii.
Maby write a blender script in python to export to your own format?
The quickest way to learn something is make it up and build on it.

If you do want simple then obj it is. However it is ASCII.

Share this post


Link to post
Share on other sites
3DS is a simple binary format, but none of the tools I use can export it with the features I need (IDK if it even supports some of them). I guess I will probably end up creating my own 3D format and Blender plugin. I just wanted to avoid reinventing the wheel.

Share this post


Link to post
Share on other sites
If you really want to make a custom format, I would suggest doing that. Writing a converter might not be so bad;
You can make a preprocessing tool using Assimp. Assimp pretty much imports any format you want, and then you can access the data directly. In general, I've had few problems. I know it supports animations, but I haven't used this part of it myself. In my projects I usually just spit out the data Assimp provides me in an easy to parse binary format that allows me to just really quickly load data to the GPU using glMapBuffer().

A link: http://assimp.sourceforge.net/

[quote name='Firestryke31' timestamp='1297913152' post='4775245']
I've been throwing together a simple iPhone game, and am at the point where I would like to display some 3D models for my characters.

Unfortunately my Google-fu is weak and I have been unable to find a simple format that meets my needs. They all either don't support skeletal animation, or are drastic overkill for my project (Shaders? We don't need no stinkin' shaders! Or tangents, or physics data, or much of anything really).

At the moment all I need are:
Vertex/Index data (duh)
Vertex Normal data
Texture coords
Skeletal animation (ideally multiple animations, and they don't need to be blendable either)
Easy to load
Relatively compact (i.e. not ASCII)

I've considered writing my own format, but then I'd have to write an exporter/converter for that format and that would be a project in and of itself.

I've also considered the MD2/MD3 formats, but having a duplicate of the entire mesh for each keyframe kind of dissuaded me from that (unless someone convinces me it is still okay for an iPhone game). If anyone has a suggestion I would love to hear it. At the moment this is basically the only thing keeping me from continuing my game.
[/quote]

Share this post


Link to post
Share on other sites
MD2 has worked fine for me on the iPhone but it doesn't support skeletal animation. You should look into PowerVR's POD format. The code to render a POD is already in the PowerVR SDK. You will also find a plugin for exporting POD format from 3DS and a tool for converting from collada to POD. POD supports skeletal animation and is optimized for the iPhone hardware.

Share this post


Link to post
Share on other sites
Cal3D format does the job for me. It saves the data in different files but you can join them together in a single file.

Share this post


Link to post
Share on other sites
[quote name='Firestryke31' timestamp='1298178936' post='4776571']
I just wanted to avoid reinventing the wheel.
[/quote]

This is one area where 'reinventing the wheel' is very common thing to do, even in the professional world.

Your final data format is going to match your data layout in memory; effectively it's nothing more than a raw dump of your vertex/index buffers with some meta data to indicate what it contains and any materials required.

While you can reuse an existing format as suggested here the simplest format is the one you can just load directly in with no messing about with parsing at runtime.

Share this post


Link to post
Share on other sites
[quote]Relatively compact (i.e. not ASCII)[/quote]
ASCII is compact!

prolly about the same size than binary (maybe slightly larger) uncompressed.
But when compressed its usually smaller than binary

So dont let file size stand in your way for not choosing ascii

Share this post


Link to post
Share on other sites
[quote name='phantom' timestamp='1298202594' post='4776638']
[quote name='Firestryke31' timestamp='1298178936' post='4776571']
I just wanted to avoid reinventing the wheel.
[/quote]

This is one area where 'reinventing the wheel' is very common thing to do, even in the professional world.

Your final data format is going to match your data layout in memory; effectively it's nothing more than a raw dump of your vertex/index buffers with some meta data to indicate what it contains and any materials required.

While you can reuse an existing format as suggested here the simplest format is the one you can just load directly in with no messing about with parsing at runtime.
[/quote]

Indeed.

As you most likely already know, the base of nearly every game game 3D file format is [url="http://en.wikipedia.org/wiki/Wavefront_.obj_file"]Wavefront .OBJ[/url]. All the file formats I have seen are nothing more than permutations of it. The only divergence is whether they combine the animation data in the same file, or do it stand-alone.

There is really not that much structure in the file format that making your own would take up a lot of time. Not a whole of wheel to reinvent, so to speak. Just follow the basics of binary file format rules and you can do it in one sitting.

If you can stand ASCII, the [url="http://www.blitzbasic.com/sdkspecs/sdkspecs/b3dfile_specs.txt"]Blitz3D[/url] file format seems to fit all of your other requirements and is widely implemented in loader libraries. (You could write the loader yourself in one sitting.)

Share this post


Link to post
Share on other sites
The key reason I don't want ASCII is because I don't want to deal with string parsing any more than I have to. Floats that I can just throw at OpenGL are always going to be faster than parsing them out first. Ideally the only string parsing I would need to do is file names and object/mesh/animation names. I may very well just go with MD2 for now, since Blender comes with an exporter and it's pretty well documented. I can write my own later when I want my own features.

Share this post


Link to post
Share on other sites
parsing an ascii md2 will take less than 1msec (Ive done it 1000s of times), creating the tangents/bitangents will take longer than the parsing
also md2 dont have skeleton info's

Share this post


Link to post
Share on other sites
I know MD2 doesn't have skeleton info, but I can start using it right now. At the moment I just want to put something animated on the screen.

Also, it's not about the speed of parsing ASCII, it's the fact that it just seems redundant if I can get the same data already in a format the processor can use. Of course, MD2 rather fails in that regard as well but like I said, Blender supports it OOB and I need something now.

Once I've got the basic logic for rendering animated models on the screen I can go and implement loading other formats and animation methods.

Share this post


Link to post
Share on other sites
Here is an example of MD2 parsing: [url="http://kode80.com/2009/09/24/iphone-md2-example/"]http://kode80.com/20...ne-md2-example/[/url]

And here is a project for loading and rendering POD format: [url="http://www.headsoft.com.au/download/code/PODTest.zip"]http://www.headsoft....ode/PODTest.zip[/url]

Share this post


Link to post
Share on other sites
As the others said, just develop your own format. Shouldn't be that hard if you've set up your memory management in the game right.

Share this post


Link to post
Share on other sites
Well it sounds interesting, listen i made an account just to reply you, cause,
i´ve had the same problem and actually have the same problem but on level, map formats, anyways,
i strongly reccomend you use wavefront object filfe format .OBJ, its normally ascii but the binary version exists, so
u should really check it out, ist really easy to read, to load and to write, its extendable so u can mix skeleton animation data there, but
if you want a file format similar, binary, and that supports skeleton animating, then milkshape 3d model format is the way to go.

The native file format for MilkShape 3D-models is the [i]ms3d[/i]-format. This file format is structured in the following way:

[list][*]Header[list][*]"MS3D000000" followed by version number (ver. 3 or 4)[/list][*]Vertex Data[list][*]Coordinates for the vertices[/list][*]Triangle Data[list][*]Pointers to vertices, as well as surface normals[/list][*]Group Data (object/mesh)[list][*]Group name and pointers to triangles[/list][*]Material Data[list][*]Color details[/list][*]Bone data[list][*]Animation data[/list][/list]

Share this post


Link to post
Share on other sites
make some kind of a converter tool, use [url="http://assimp.sourceforge.net/"]Assimp[/url] to load any file format (preferably COLLADA) , read the data and write it as ur own format
I think it's the best way, as I did with my own [url="http://hmrengine.codeplex.com"]engine[/url] . Assimp have little bugs but none of them are important and there are workarounds, overall it works really good, reads materials, animations, skinning, node transformations, everything u may need. and it's open source.
writing ur own file format is good because there is no actual file format that may be completely suitable for ur engine and data structures within it. so may be better off with ur own format and load memory chunks as fast as possible with no processing. and it's not reinventing the wheel, ur are just writing ur binary data in a file.
you can even make ur converter tool to be able to process batch of files, or output different files for each platform, do automatic texture compression of materials, and other nice stuff like that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this