Hey, I'm getting further in OpenGL, and I want to write my own code for loading models. I think i'm to the point where I can do this, however, I can't decide on the model format I want to use for the engine. My artist uses Maya, and we want the game to support skeletal animation, the mesh itself, and the texture data from the model. Is there an industry standard? What are your thoughts on the easiest file format to understand and work with while including these features?
Thanks in advance!
Thoughts on the best model format?
Moderator: Coders of Rage
-
- Chaos Rift Regular
- Posts: 101
- Joined: Thu Dec 09, 2010 2:13 am
- MadPumpkin
- Chaos Rift Maniac
- Posts: 484
- Joined: Fri Feb 13, 2009 4:48 pm
- Current Project: Octopia
- Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
- Programming Language of Choice: C/++,Java,Py,LUA,XML
- Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk
Re: Thoughts on the best model format?
I had the exact same question around 2 months ago. I eventually found out about COLLADA or *.DAE which is supported by blender, maya, max, lightwave, XSI, and cinema4D to name a few. Definitely the best, format for general use. They save in an XML format and they're damn easy to parse (besides animation obviously). They also have 2 other things that make them amazing:
EDIT:*My honest recommendation is to do exactly what I did, and many other people have done. Use COLLADA files as middleware where you can convert it to your own binary 3D model type that is more straight to the point. My 3D model format allows bone animation with each vertice to 1 bone (working on 2 bones), it allows different normals and materials per mesh, with any number of meshes. (Within reason) I wrote a simple c++ converter that takes a COLLADA and rips necessary data from it (not physics for me) and writes it to a binary .LWM file... (Light Weight Model, my binary model format)
CUBE.dae (for your viewing pleasure) ps it also contains a camera and a light, I just exported it from blender real quick to show.
- They support physics in the file, so any physics that you apply to an object in a program such as blender, then export the .dae. It is then simply applied to the object if you use certain physics engines (Bullet, ODE, and PhysX, and I think one or two others). If you're building your own physics, you could add support yourself if you're coding the parser.
- Because it's XML, you can also add your own features to the files. For example my .dae's that I was using in my model viewer also had a texture and a normal map right in the xml code.
- COLLADA files parse slower than other files because of the text format instead of binary. It's not a big enough difference that it would make a huge deal for a single player game containing 30 or so models (or less). I honestly can't say how much more than that would be noticeable, most I've ever done with COLLADA files was 11.
- Animation is not fun at all to customize when it comes to collada
EDIT:*My honest recommendation is to do exactly what I did, and many other people have done. Use COLLADA files as middleware where you can convert it to your own binary 3D model type that is more straight to the point. My 3D model format allows bone animation with each vertice to 1 bone (working on 2 bones), it allows different normals and materials per mesh, with any number of meshes. (Within reason) I wrote a simple c++ converter that takes a COLLADA and rips necessary data from it (not physics for me) and writes it to a binary .LWM file... (Light Weight Model, my binary model format)
CUBE.dae (for your viewing pleasure) ps it also contains a camera and a light, I just exported it from blender real quick to show.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Blender User</author>
<authoring_tool>Blender 2.54.0 r31878</authoring_tool>
</contributor>
<created>2011-03-02T22:34:03</created>
<modified>2011-03-02T22:34:03</modified>
<unit name="decimetre" meter="0.1"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_cameras>
<camera id="Camera-camera" name="Camera">
<optics>
<technique_common>
<perspective>
<xfov>1</xfov>
<aspect_ratio>0.1</aspect_ratio>
<znear>0.1</znear>
<zfar>100</zfar>
</perspective>
</technique_common>
</optics>
</camera>
</library_cameras>
<library_lights>
<light id="Lamp-light" name="Lamp">
<technique_common>
<point>
<color>1 1 1</color>
<constant_attenuation>1</constant_attenuation>
<linear_attenuation>0</linear_attenuation>
<quadratic_attenuation>1</quadratic_attenuation>
</point>
</technique_common>
</light>
</library_lights>
<library_images/>
<library_effects>
<effect id="Material-effect">
<profile_COMMON>
<technique sid="common">
<lambert>
<emission>
<color>0 0 0 1</color>
</emission>
<ambient>
<color>0 0 0 1</color>
</ambient>
<diffuse>
<color>0.8 0.8 0.8 1</color>
</diffuse>
<reflective>
<color>1 1 1 1</color>
</reflective>
<reflectivity>
<float>0.5</float>
</reflectivity>
<transparent>
<color>0 0 0 1</color>
</transparent>
<transparency>
<float>1</float>
</transparency>
<index_of_refraction>
<float>1</float>
</index_of_refraction>
</lambert>
<extra/>
</technique>
<extra>
<technique profile="GOOGLEEARTH">
<show_double_sided>1</show_double_sided>
</technique>
</extra>
</profile_COMMON>
<extra><technique profile="MAX3D"><double_sided>1</double_sided></technique></extra>
</effect>
</library_effects>
<library_materials>
<material id="Material" name="Material">
<instance_effect url="#Material-effect"/>
</material>
</library_materials>
<library_geometries>
<geometry id="Cube-mesh">
<mesh>
<source id="Cube-mesh-positions">
<float_array id="Cube-mesh-positions-array" count="24">1 1 -1 1 -1 -1 -1 -0.9999998 -1 -0.9999997 1 -1 1 0.9999995 1 0.9999994 -1.000001 1 -1 -0.9999997 1 -1 1 1</float_array>
<technique_common>
<accessor source="#Cube-mesh-positions-array" count="8" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Cube-mesh-normals">
<float_array id="Cube-mesh-normals-array" count="18">0 0 -1 0 0 1 1 -2.83122e-7 0 -2.83122e-7 -1 0 -1 2.23517e-7 -1.3411e-7 2.38419e-7 1 2.08616e-7</float_array>
<technique_common>
<accessor source="#Cube-mesh-normals-array" count="6" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Cube-mesh-vertices">
<input semantic="POSITION" source="#Cube-mesh-positions"/>
</vertices>
<polylist material="Material" count="6">
<input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/>
<input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/>
<vcount>4 4 4 4 4 4 </vcount>
<p>0 0 1 0 2 0 3 0 4 1 7 1 6 1 5 1 0 2 4 2 5 2 1 2 1 3 5 3 6 3 2 3 2 4 6 4 7 4 3 4 4 5 0 5 3 5 7 5</p>
</polylist>
</mesh>
</geometry>
</library_geometries>
<library_animations/>
<library_controllers/>
<library_visual_scenes>
<visual_scene id="Scene" name="Scene">
<node id="Cube" type="NODE">
<translate sid="location">0 0 0</translate>
<rotate sid="rotationZ">0 0 1 0</rotate>
<rotate sid="rotationY">0 1 0 0</rotate>
<rotate sid="rotationX">1 0 0 0</rotate>
<scale sid="scale">1 1 1</scale>
<instance_geometry url="#Cube-mesh">
<bind_material>
<technique_common>
<instance_material symbol="Material" target="#Material"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Lamp" type="NODE">
<translate sid="location">4.076245 1.005454 5.903862</translate>
<rotate sid="rotationZ">0 0 1 106.9363</rotate>
<rotate sid="rotationY">0 1 0 3.163707</rotate>
<rotate sid="rotationX">1 0 0 37.26105</rotate>
<scale sid="scale">1 1 1</scale>
<instance_light url="#Lamp-light"/>
</node>
<node id="Camera" type="NODE">
<translate sid="location">7.481132 -6.50764 5.343665</translate>
<rotate sid="rotationZ">0 0 1 46.69194</rotate>
<rotate sid="rotationY">0 1 0 0.6197679</rotate>
<rotate sid="rotationX">1 0 0 63.55929</rotate>
<scale sid="scale">1 1 1</scale>
<instance_camera url="#Camera-camera"/>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#Scene"/>
</scene>
</COLLADA>
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
For God so loved the world that he blessed the thugs with rock
- MadPumpkin
- Chaos Rift Maniac
- Posts: 484
- Joined: Fri Feb 13, 2009 4:48 pm
- Current Project: Octopia
- Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
- Programming Language of Choice: C/++,Java,Py,LUA,XML
- Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk
Re: Thoughts on the best model format?
I forgot to add, if you need help with writing your own model format I can help you out with that and format and what not.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
For God so loved the world that he blessed the thugs with rock