PDA

View Full Version : dynamically resizing viewport according to 3d drawing



holyburak
10-02-2003, 03:23 AM
hi guys! http://www.opengl.org/discussion_boards/ubb/smile.gif

suppose i have a cube, look it at the front, so i see a rectangle. Then i glRotate it in order to have an isometric view. What happened? some of the drawing went out of my viewport.
Question :
How can i automate resizing of the viewport to make all of the scene in the viewport?

(was it silly?)
Thanks.

V-man
10-02-2003, 08:51 AM
See if all objects are within the viewing frustum.

You can either project vertices with gluProject (or bounding box)and see if they all lie inside the viewport. The problem here is what to do next if object is outside. You can move back or rotate to look at the object. Depends on you!

The second way is to test if all vertices (or bounding box) are inside the frustum volume.

roffe
10-02-2003, 09:20 PM
Originally posted by holyburak:
suppose i have a cube, look it at the front, so i see a rectangle. Then i glRotate it in order to have an isometric view. What happened?

What projection are you using? Remember, perspective projections don't preserve line lenghts. Maybe you want an isometric projection? Where all lines that are equal in world space are equal in 2d(I think this was isometric).