Loading of Meshes from 3ds

Hi,

I’m currently (re)starting on OpenGL. I got some stuff working, but because watching “handmade” Pyramids and Cubes isn’t very interesting I got myself a doc on the .3ds fileformat and tried myself loading the mesh from it.
It was rather easy implementing the algorithm, however I encountered some strange problem. The mesh is loaded, however, it’s positioning is absolutely off. It’s a) lying on the side b) not even close to the origin (where I draw the mesh).
I got the LocalAxis and Center Coordinates from the 3ds file but they’re not set to any values I could use to place my mesh properly: center is (0,0,0) and Local Axis is (1,0,0),(0,1,0),(0,0,1)

My question now is: Am I screwing up or are my meshes just off? Would I need to manually calculate the meshes center and relocate it? I loaded one of the meshes in a third party mesh viewer and there it seemed to be positioned well… I’m confused.

Greets,
Daniel

PS: I’m using this mesh.

I have imported your mesh under Blender and effectively it is far from the origin. The center of the mesh is at ~ (0.0,-266,4.0). When you write it is lying on the side this is normal because by default the majority of 3d modelers have the Z axis up. The easy solution is take Blender (it’s free) and replace the mesh at the origin and rotate it to make the y axis as up vector

Remember that .3ds supports animation and is from the dos days. Back then there was discrepency between frame 0 in the keyframer and the original state in the modelor. So you may not be doing what your thing you are, when you beleive to have found the origin.

I won’t drone on about details and best practices from 3dstudio dos, but your options are to either do alot of reset xform’s in 3ds max (get the trial version if you don’t have access) or use something like lib3ds to try to get your xforms correct.

The best way to check your model is to import it into 3dsmax, export again, then reimport it…if it is changing it’s orientation your opengl 3ds parser will also be confused.

In max you can move the pivot points, … do that, then use reset xform…which is on the utility tab. This will effectively “bake” your transform to what you see. For good measure I also collapse the mesh to an editable mesh, to remove the xform modifiers.

Another opengl solution, which may or may not suit your needs would be to push matrix translate & move and popmatrix…then do all your positioning out side and before that stack.

I’m in OSX, so I haven’t looked at your model. Have a look at my website, you can see screenshots of my .3ds models in various opengl apps…some with animation some without. Lib3ds is great for animation, but did not have material support when I used it, so I wrote my own 3ds model reader and used the animation portions of lib3ds

Hope that helps