We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › scale() and opengl normals
Page Index Toggle Pages: 1
scale() and opengl normals (Read 954 times)
scale() and opengl normals
Apr 23rd, 2008, 6:52pm
 
I noticed that processing's scale() command had some undesirable side effects on my gl normals. I created a obj loader and was testing it with a model I created in Maya.  When i imported the geometry it was tiny so i scaled it with processing's scale() command. here's some pertinent code:

void draw(){
 scale(100);
 pgl.beginGL();
 treeFrog.iaDraw(); // obj draw method using indexed arrays
 pgl.endGL();
}

The model loaded and scaled fine but wasn't lit correctly.  I spent a great deal of time debugging my code and found out that if i didn't scale the object it would be displayed correctly. It looks like scale() is not only scaling the geometry but also the normals. I'm not sure if this is a bug or just something i'm ignorant about. I generally stick with gl commands when working with gl geometry, but i was just running a quick test and figured it wouldn't make a difference.... wrong!  Anybody care to clarify this?
Re: scale() and native opengl normals
Reply #1 - Apr 24th, 2008, 4:02pm
 
sorry, this is the sort of thing that's covered by the "don't complain if it breaks" clause in the opengl reference.. the opengl object is available and if it works, great, but the api/environment is not designed to be a way to write opengl code.
Re: scale() and normals
Reply #2 - Apr 28th, 2008, 10:16pm
 
ok... to answer my own question, this isn't a processing issue.. gl.glScalef also scales the normals and messes up the lighting.  So if you scale an object you have to make sure to normalize the normals.  

gl.glEnable(GL.GL_NORMALIZE);

This slows things down though, so a better solution is to not use either scale() or gl.glScalef() and instead just manually scale the verticies.
Page Index Toggle Pages: 1