View Full Version : Does 3DSMAX export conveniently normal vectors to .ASE ?
08-21-2001, 04:55 AM
i'm experimenting my ASE loader and I've met the following problem :
When I look at my model's most lighted face, some of its meshes are very dark, whereas the other meshes are very well lighted. And when I look at the opposite face, these meshes which were dark are now well lighted. My conclusion is that these meshes have their normal vectors in the wrong sense. Enabling two-sided lighting has not worked. Do you have any idea ?
Did you convert the vertices from 3DSMAX format to OpenGL format, but forgot to convert the normals?
08-21-2001, 11:27 PM
I load directly the normals from the file, without doing any conversion (they are already normalized in the file). Why, should I make some kind of conversion ???
OpenGL and 3DSMAX uses different coordinate system. If you convert vertices, but not normals, it will fail. If you don't do any conversion at all, no problems should occur with wrong normals.
An I see no reason why the normals should be wrong. I suppose 3DSMAX knows how to calculate them correctly.
My guess is that your code to either load or display the objects is wrong.
I have just checked my ASE loader and I think the problem Morglum might have is that, in an ASE file, the vertices that are exported are ALREADY transformed by the given transformation matrix while the normals ARE NOT.
So, when you load an ASE file, you should either do:
1) Load vertices/normals, transform the vertices with the invert of the transformation matrix.
2) Load vertices/normals, transform the normals with the transformation matrix.
I personally do 1) because I keep the transformation matrix for each object.
Hope this helps (and is not completely wrong ! http://www.opengl.org/discussion_boards/ubb/wink.gif).
08-22-2001, 04:44 AM
oh, that sounds interresting.... But I don't understand : by the "transformation matrix", do you mean the matrix found in *NODE_TM ? In my ASE file it looks like
*TM_ROW0 1.000000 0.000000 0.000000
*TM_ROW1 0.000000 0.000000 1.000000
*TM_ROW2 0.000000 -1.000000 0.000000
*TM_ROW3 70.867462 44.356461 7.246377
But, as you see, there are only 4x3 numbers. How should I fill the last column ?
And once I've got this matrix, do I simply have to multiply my normals by it ? Thanks for explaining !
oh , by the way, I've said the normals were normalized... That's not always true ! My question is : will multiplication by the transformation matrix normalize them ?
[This message has been edited by Morglum (edited 08-22-2001).]
Yes, the transformation matrix is given by the "TM_ROW" entries.
Say, your GL matrix is define as GLfloat, then you should read the coefficients as follows:
*TM_ROW0 0 1 2
*TM_ROW1 4 5 6
*TM_ROW2 8 9 10
*TM_ROW3 12 13 14
Then, for the other coefficients, you should put in the following values:
If you take the usual maths notation, those coefficients are not the last column but the last line of the matrix.
Now, I have a doubt regarding how to use this matrix to get your normals. I can't remember if you must multiply the normals with the this matrix or with the transpose of this matrix... Try and see what happens (I'd say use the matrix itself)... The other solution, as I previously said, is to invert the matrix and transform back the vertices.
Now, when you multiply the normals by the matrix, you may introduce a scaling factor so you HAVE TO NORMALIZE the normals after multiplying.
You should also pay attention to your rendering code: let's get back to the two methods:
1) I have transformed the vertices back with the invert of my Matrix. The rendering code is:
2) I have transformed AND normalized my normals.
Although 2) seems better, you lose all the hierarchy when doing this... It's really up to you !
08-22-2001, 08:45 AM
Thank yo very much, Eric ! I really could not have guessed all that alone.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.