I have created a model in Blender. Now i want to read that 3D model in my c++ program. I figured that a model can be exported to various file formats e.g. .obj, .3ds or COLLADA and then can be read in a c++ program. I have been searching web for doing that for quite a while and found many tutorials. But i ran into issues with most of them. For example, IN the Nehe tutorial they are using glaux which I don't want to use in my program. And the remaining tutorials use md2 which is not supported by Blender.
So can anyone guide me which file format to use for exporting 3D model and how to load that in my OpenGL program? Also how can I animate that model? Is it possible to add extra effects like tone mapping after it has been loaded in the c++ program using OpenGL? if yes then how?
P.S. I am using Linux for game developement
3 Answers
I'd go for OBJ format. As you have already probably realised, there's hundreds of OBJ loaders for C++ out there. I believe one of the most mature ones is Assimp, it supports many different formats and it is pretty well documented. Here you have an example where they use it.
-
-
\$\begingroup\$ It works for me in all my browsers... Try this link x90.es/1CC \$\endgroup\$– DanOct 13, 2011 at 10:21
-
2\$\begingroup\$ Obj doesnt have support for animated meshes though does it? just google "Blender opengl skinned mesh" and i expect you will find a format that suits what you want edit: couldnt delete my post, was meant to be a reply to a previous post reccomending the obj format \$\endgroup\$– StowellyOct 13, 2011 at 10:24
-
1\$\begingroup\$ .obj does not support animation, and this answer is wrong. stackoverflow.com/questions/757145/… \$\endgroup\$ Aug 9, 2012 at 21:49
Blender 2.60 has fixed COLLADA animation support, it was more or less broken in earlier versions. However, if you haven't loaded any model formats yet in your own code, I'd suggest learning to load .obj first. It's in ASCII so it's human readable and easy to read without external loader libraries.
3ds isn't containing any animation data so that one won't work. Collada I don't know much about but when I decided on which format to use in my game I searched and compared a lot and finally I went with the B3D format, it supports skeletal animation and is loadable from Irrlicht (it also contains lighting values).
I use the 'b3d pipeline' exporter from 3dsMax and I have coded my own hlsl shader to animate and light the meshes, it works really well.
You can check out how Irrlicht does it (ie. loading and animating), it does the animation in software though but there are examples if you search a bit on how to do it with a shader (if you want that). A nice thing is that Irrlicht supports both OpenGL and Linux.
Another format that is quite straight forward is the .X format, there must be tons of examples out there on how to export, load, parse and set up the skeleton and animating with it. It is a Microsof format though so maybe you won't want to use it :-)
Tone mapping and such has absolutely nothing to do with animating so yeah if you know how to use that technique you can do that with animated meshes.