PDA

View Full Version : glOrtho, viewport for large scale objects



c0de
03-06-2008, 10:56 AM
I want to reconstruct a real object which has the dimensions (in millimeters) 500x100x50. What should be the glOrtho and viewport values in order to use these values considering that the opengl scene is displayed in a 400x400 pixels frame? I tried to modify an existing scene (where the objects were 5 x 5 x 5) but everything went crazy... especially the lights.

Zengar
03-06-2008, 12:06 PM
If I understand correctly, you want that the size of the object corresponds to its image on screen? Then you will need pixel size of your monitor (say X)... 400x400 pixels will then correspond to the 400X x 400X size; set the projection accordingly (0..400X) and it should work. You will have to recode the light positions so that it fits the new coordinate system, of course.

ZbuffeR
03-06-2008, 03:02 PM
I think the lighting problem comes from scaling the scene without renormalizing your normals, as explained here (section 1) :
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

It was written during the previous century though, so the performance advice is not relevant anymore.
Just use glEnable(GL_NORMALIZE);

c0de
03-07-2008, 07:22 AM
Thank you very much. glEnable(GL_NORMALIZE) does the trick :)
Now the scene is displayed as I wanted... even with 200x200x200 objects as in this figure:

http://rrg.utcluj.ro/~c0de/proper.jpg