jimwalks
08-16-2011, 02:30 PM
Hi Everyone,
I'm currently writing a program to visualize STL files using OpenGL. The problem I face is that the STL objects are dynamic in size and therefore I need to initialize my camera settings dynamically.
From what I have researched, so far I have computed a bounding box by finding the minimum and maximum x,y and z points in the scene. From this I have tried to input these coordinates into glOrtho and aimed the camera to the center of the scene using gluLookAt. However, this gives incorrect results and often the model is outside of the scope of the window.
Could anyone tell me if I am going about this correctly? Or have any example code of how to set up an opengl scene using a bounding box.
Thanks so much,
Jim
I'm currently writing a program to visualize STL files using OpenGL. The problem I face is that the STL objects are dynamic in size and therefore I need to initialize my camera settings dynamically.
From what I have researched, so far I have computed a bounding box by finding the minimum and maximum x,y and z points in the scene. From this I have tried to input these coordinates into glOrtho and aimed the camera to the center of the scene using gluLookAt. However, this gives incorrect results and often the model is outside of the scope of the window.
Could anyone tell me if I am going about this correctly? Or have any example code of how to set up an opengl scene using a bounding box.
Thanks so much,
Jim