Can any one please tell me how to implement zoom In/Out features in JOGL…
Are there any API’s available.
Thanks in Advance.
Can any one please tell me how to implement zoom In/Out features in JOGL…
Are there any API’s available.
Thanks in Advance.
you can use glTranslate to zoom in and zoom out.
http://www.restena.lu/convict/Jeunes/5%20DOF%20Robot-arm-Dateien/cartesian.gif
As you can see on this image, you see the x,y,z-axis
using glTranslatef(0.0f, 0.0f, positionZ); you can “move” an object on the z-axis, thus making the object appear nearer or farther away.
If you need more help on this, just tell me
Changing your position != zooming
It’s all about narrowing/widening your field-of-view.
How would you implement that in OpenGL?
[quote]baldurk
02-09-2003, 02:43 AM
there is no way to really ‘zoom’ in OpenGL. The camera stays at 0, 0, 0 looking along the z axis. Everything else moves around it. The best way to zoom out object a is to translate it further away, eg.
glTranslatef(APosX, APosY, APosZ);
glTranslatef(0.0f, 0.0f, -Zoom);
DrawObjectA();
then as zoom increases, the object gets further away
watch out though, anything drawn after that will be ‘zoomed’ as well.
Yau
02-09-2003, 04:00 AM
Actually u can zoom with OpenGL by altering ur viewing matrix using the gluPerspective(…) function.
The actuall function parameter is as follows:
void gluPerspective(
float angle, // the viewable anlge infront of the camera/eye
float aspect, // typically width/height of window or screen
float near, // min distance from camera that is renderable
float far, // max distance from camera that is renderable
)
To do zooming the first parameter is the one u wnat to alter. The smaller the angle u specify the greater the zoom. Try experimenting and u’ll see this in action.
The advantage of using this technique over the one above is that u won’t get into a situation where u zoom past an object because u aren’t actually repositioning any objects.
The disadvantage is that everytime u want to zoom or animate zooming and zooming out u have to recreate ur perspective viewing transformation. Well this isn’t too bad.
[/quote]
I found this on an other forum
Thanks all of you for the precious information.
Cyrus thanks a lot for the information.
Cyrus can u explain in some detail how I can implement the Zoom In/Out using JOGL.
What I am trying to do is load .stl file and implement the Zoom In/Out functionality on mouse scroll button.
I m able to load the .stl file but not finding the way how to implemement Zoom In/Out on mouse scroll button.
Can u plz provide me some example with Zoom In/out features.
I m very much new to JOGL.
Thanks in advance.
gluPerspective(zoom, ratio, zNear, zFar);
you must make zoom a variable, to implement mousescrolling is not a JOGL feature.
But it’s an AWT event feature. (import java.awt.event.*
http://java.sun.com/javase/6/docs/api/java/awt/event/MouseAdapter.html
you can find more info there