View Full Version : glOrtho, viewport for large scale objects
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.
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.
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) :
It was written during the previous century though, so the performance advice is not relevant anymore.
Just use glEnable(GL_NORMALIZE);
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:
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.