Skip to main content
GameDev.net gamedev.net
🔒 Locked

3DS File Loading

Started by StiNKy Dec 22, 2005 at 2:00 AM 1 replies 1.1k views
Original Post
StiNKy
StiNKy
I've been having some small problems writing my own 3DS file loader. I have all the basics down, vertices, faces, texture co-ordinates. But my problem arises when I have multiple objects. Basically it seems like most of the objects are out of alignment with each other. See screenshot here: http://img476.imageshack.us/img476/6531/3dsshot6vb.jpg (Please ignore the dodgy texturing, the model came from a "free 3ds models" site) What I think the correct fix is the 0x4160 chunk, the local axis chunk: 4 x 3D float vectors. Of which I have absolutely no idea how to properly parse to the renderer. I've tried mapping it to a matrix like so (OpenGL btw): [ 0] [ 3] [ 6] [ 9] [ 1] [ 4] [ 7] [10] [ 2] [ 5] [ 8] [11] 0.0f 0.0f 0.0f 1.0f But obviously with little success. So my question is this: Is it indeed the 0x4160 chunk which can fix this? Or am I totally of course? Or am I just parsing the 0x4160 chunk incorrectly? Thanks in advance.
vicviper
vicviper

As you say, that chunk is quite dodgy.

In theory, this chunk represents the local matrix relative to the parent, but I've seen a lot of 3DS files that interpret that matrix as a world matrix, or 3DS files that do not have matrix chunk at all (assume identity matrix?) , so many format conversion programs usually ask you how you want to interpret it.

My suggestions are:

Do not use a "free" 3ds model... if you have access to 3dsmax, just make a simple scene and export an "correct" 3ds file, so you will be sure that the problems are not related to a bad written 3ds file.

Remember that the matrix is in "3d studio axis alignment", that means that you can't simply copy the matrix to an opengl one, you have to properly translate the axes.

And try to interpret the matrix in several different ways, you'll probably find a way that fits
StiNKy
StiNKy
Ah, thanks for that, although I have a few follow up questions:
I downloaded quite a few "free 3ds models" and they all pretty much had multiple objects out of alignment, it became so frequent it's obviously caused this thread!
I actually don't have access to any version of 3d studio max, so is there any chance you can describe "3d studio axis alignment"?

I've been toying with it for quite a while now, and have found that if I scrapped most of the vectors except the last one, the translation vector, and if I inverse it, I get some pretty interesting results:
1.0f 0.0f 0.0f -[ 9]
0.0f 1.0f 0.0f -[10]
0.0f 0.0f 1.0f -[11]
0.0f 0.0f 0.0f 1.0f
It tends to fix quite a lot of the issues I have with some 3ds models, but definatly not all of them. But I still don't have a clue what to do with the first three vectors...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.