Advertisement

Slight 3DS related problem.

Started by March 18, 2005 01:46 AM
9 comments, last by V-man 19 years, 10 months ago
Hi, Not sure what would have been the best place to post this. When I export some mesh as a 3DS file, and then open it in my program, it loads fine. I have this one object, when I open it in my program, the position is not the same as in 3DS. It's been a long time since I looked at how to load a 3DS file. Is there anything about a transform matrix in there? I'm not bothering with transform matrices, if 3DS does indeed support them. Thanks V-man
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Yes, 3ds files support a transform matrix. I don't know which chunk (I'd have to look it up). I believe 3ds files also contain meshes in left handed coordinate systems, and that can throw off the transform matrix.
Advertisement
It looks like there is a translation matrix chunk.
OK, so why does 3DStudio load some models with no translation (I think)
and some models that require the translation matrix.
This seems inconsistent.

I want it to export it in such a way that that tranlation is {0, 0, 0}

I have 3DS max 4

Thanks








Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Check to make sure your pivot is centered to the world(0,0,0), otherwise it'll throw the entire object off.
"Check to make sure your pivot is centered to the world(0,0,0), otherwise it'll throw the entire object off."

How do I make sure of that?

The transform chunk or local as they call it contains 3 pairs of 3D vector for rotation of XYZ, then translation.

I made a 4x4 matrix,

X1 Y1 Z1 trans1
X2 Y2 Z2 trans2
X3 Y3 Z3 trans3
0 0 0 1

but the objects that were in place are all distant from each other now.
I only have the problem with one object, that doesn't seem to be in place, else all other objects are fine without me bothering with this matrix.








Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
In max, use the keyboard transform to move the model to 0,0,0. If the model is not where it should be, you know the pivot isn't centered.

If this is the problem and you need help with it, let me know. Unfortunately I can't post the answer right now as I don't have max on this system, and I'd probably get the menu names all mixed up :P

Advertisement
What I as trying to do was setup a scene in 3DS max, then export as 3DS file.
Like I said, everything is fine except for one object which is weird.
My sceneisn't complex at this point.
The object in question, I made it out of Text. I extruded it. All others are actual 3d stuff like sphered and cubes.
For single objects, yes, I could put them at 0, 0, 0 and export but this is suppose to be a scene.



Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I have expereinced a similr problem to this, when i export a model of a medieval building one of the building pillars is moved to the far right of the model for no aparant reason. Interestingly enough this pillar is also extruded although so are all the others so i do not see why this would happen to just one.

It may actually be a completely new pillar as i have not yet found a missing one in the model but either way it souldnt be there and isnt there in MAX.

Maybe one of your pillars is actually 2 copies at the same location, and 3DMax gives an offset. Just a wild guess. Or 3DS export feature is weird.

I wish I knew how to apply the transform matrix.

Thanks for the replies so far.



Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Some weird things can happen with 3ds when exporting from Max... here's a few things that I've come up with due to some recent experience:

1) NEVER EVER EVER export a mesh to 3ds, reimport to Max, and then re-export. It will invariably mess a lot of things up (normals, smoothing groups, transforms, coordinates, etc). ALWAYS keep the original .max file and export directly from that.

2) Don't worry too much about the pivot location, but there is one thing that you must do before exporting: reset the transforms! Select everything, choose the Utilities on the right panel of Max, and choose "Reset XForm" (then hit Reset Selected). As well if your meshes are not yet collapsed, you can do that using the Collapse utility here.

If you do the above, your model should import correctly, even if you ignore the coordinate system and pivot information, providing that the import code is correct of course. Hope that helps :)

PS: Overall, 3ds is a really dated and crappy format though... try to move away from it if you can!







This topic is closed to new replies.

Advertisement