3DSMAX: Normals don't work in OpenGL
Hi everyone. I''m having a problem loading a 3d studio max ASE (Ascii scene export) file into my openGL program. The file is read okay, but the normals are definitely screwy.
All the normals are definitely favoring one direction because when I rotate the model, one side of it is always dark and the other side catches the light really well. Any tips on screwy normal things?
I know that the coords are in a weird order: XZY and Z is negative, so I''ve already got that covered. Please help! Thanks!
-Eric
hi,
i have the same problem ago. but i´m not sure what it was anymore.
some things to test (if you haven´t allready).
are the normals ''normalized'' by max?
let max show the normals, do they look all in one direction.
let your program show the normals, how do they look?
another thing. do you know how the animation (rotation etc.) work in ase? i don´t mean the ''mesh-animation'' with a whole new model.
greetings
i have the same problem ago. but i´m not sure what it was anymore.
some things to test (if you haven´t allready).
are the normals ''normalized'' by max?
let max show the normals, do they look all in one direction.
let your program show the normals, how do they look?
another thing. do you know how the animation (rotation etc.) work in ase? i don´t mean the ''mesh-animation'' with a whole new model.
greetings
Your point about the 3dsmax transformations is a good point. I don''t know about it really.
In 3dsmax, the normals look perfect. Everything is going in the right direction, and they are normalized.
I was thinking about showing the normals in my program, but that would take a bit of extra work :^)
-E
In 3dsmax, the normals look perfect. Everything is going in the right direction, and they are normalized.
I was thinking about showing the normals in my program, but that would take a bit of extra work :^)
-E
that´s not really alot of work. just use GL_Line(??).
the start-point is the vertex which belongs to the normal.
the end-point is the normal. just a few lines extra code.
the start-point is the vertex which belongs to the normal.
the end-point is the normal. just a few lines extra code.
*lol* Sometimes (Just SOMEtimes....) you have to do a little extra work when you''re programming :D
If you''re having problems with normals I suggest you generate them yourself if you can''t find an answer! The process really is quite simple. All you have to do is:
float oneoverdist;
float len;
len = sqrt(x * x + y * y + z * z);
if(len == 0.0f)
return;
oneoverdist = 1.0f / len;
x *= oneoverdist;
y *= oneoverdist;
z *= oneoverdist;
Where x y and z are the xyz components of the point you are generating normals for!
If you''re looking for some code, I have some working code in the Infinite.Scream engine (Available on my website) for loading Milkshape3D files and generating normals for the model.
Hope this helps!
-------- E y e .Scream Software --------
----------------------------------------
/-\
http://www.eyescream.cjb.net | * |
\-/
----------------------------------------
If you''re having problems with normals I suggest you generate them yourself if you can''t find an answer! The process really is quite simple. All you have to do is:
float oneoverdist;
float len;
len = sqrt(x * x + y * y + z * z);
if(len == 0.0f)
return;
oneoverdist = 1.0f / len;
x *= oneoverdist;
y *= oneoverdist;
z *= oneoverdist;
Where x y and z are the xyz components of the point you are generating normals for!
If you''re looking for some code, I have some working code in the Infinite.Scream engine (Available on my website) for loading Milkshape3D files and generating normals for the model.
Hope this helps!
-------- E y e .Scream Software --------
----------------------------------------
/-\
http://www.eyescream.cjb.net | * |
\-/
----------------------------------------
"*lol* Sometimes (Just SOMEtimes....) you have to do a little extra work when you're programming :D"
THIS time it IS just little work ;-)
and it is easier and faster to check the normals.
on the other hand, i haven´t big problems with max´s normals, so why calculate them new? ase-importing is slow enough :-)
greetings
Edited by - rafflesia on February 13, 2002 11:02:37 AM
THIS time it IS just little work ;-)
and it is easier and faster to check the normals.
on the other hand, i haven´t big problems with max´s normals, so why calculate them new? ase-importing is slow enough :-)
greetings
Edited by - rafflesia on February 13, 2002 11:02:37 AM
Hey guys. Thanks for all the response :^)
TheGilb: I used the exact same formula you posted for normalizing the normals. I used something else to calculate them, however. Is there a simple formula that does both automatically?
Rafflesia: I''m using face normals, not vertex normals, so what you suggested unfortunately won''t work. I didn''t even know that one could use vertex normals in OpenGL. Can you?
Thanks again, guys.
-E
TheGilb: I used the exact same formula you posted for normalizing the normals. I used something else to calculate them, however. Is there a simple formula that does both automatically?
Rafflesia: I''m using face normals, not vertex normals, so what you suggested unfortunately won''t work. I didn''t even know that one could use vertex normals in OpenGL. Can you?
Thanks again, guys.
-E
Of course you can use vertex normals instead of polygon normals.
It produces smooth shading (in opposition to flat shading) which may be enabled by glShadeModel(GL_SMOOTH);
Then the only thing you have to do is define the normals BEFORE each vertex. For instance :
glBegin(GL_TRIANGLES);
glNormal3fv(my_normal1);
glVertex3fv(my_vertex1);
glNormal3fv(my_normal2);
glVertex3fv(my_vertex2);
glNormal3fv(my_normal3);
glVertex3fv(my_vertex3);
glEnd();
If you define the normals AFTER vertices, you''ll experience problems. Be careful.
It produces smooth shading (in opposition to flat shading) which may be enabled by glShadeModel(GL_SMOOTH);
Then the only thing you have to do is define the normals BEFORE each vertex. For instance :
glBegin(GL_TRIANGLES);
glNormal3fv(my_normal1);
glVertex3fv(my_vertex1);
glNormal3fv(my_normal2);
glVertex3fv(my_vertex2);
glNormal3fv(my_normal3);
glVertex3fv(my_vertex3);
glEnd();
If you define the normals AFTER vertices, you''ll experience problems. Be careful.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement