View Full Version : Render objects in bounding box

Shao tian
03-17-2011, 03:48 PM
Hey guys:
In my program, there are some spheres. User can use mouse to pick any number of these spheres. After user finished picking, the program pops up a new smaller window, and within this new window, only selected objects are rendered, and they all together should be scaled to fill the viewport, instead of keeping their original size in the original window.

firstly i planed to record each picked sphere's x and y coordinates. And compute one single max value among all x and y coordinates. This max value should be width of the bounding box surrounding the picked spheres.

After that, with in the pop up window, I use glOrtho(-max, max,-max, max,100,-100);. so that the clipping space is small enough to fix all the selected spheres, which make them scaled to fit the viewport.

The attached pdf file simply illustrates my problem(my English is not perfect, a visualized demonstration is necessary.....). My wrong result displayed in the pdf file is not the actual one, but it is close to it.

However,the result is that,the selected spheres are not scaled to fit the new viewport. Is there any wrong with my algorithm?