Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Zoom In / Zoom Out  (Read 4133 times)
0 Members and 1 Guest are viewing this topic.
Offline anil

Senior Newbie

« Posted 2008-02-13 10:45:17 »

Can any one please tell me how to implement zoom In/Out features in JOGL..
Are there any API's available.

Thanks in Advance.
Offline Cyrus

Senior Newbie

Lean Mean Programming Machine

« Reply #1 - Posted 2008-02-13 12:18:25 »

you can use glTranslate to zoom in and zoom out.

Click to Play

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 Tongue

*Always driving the Learning Car of Programming*
Online Riven
« League of Dukes »

« JGO Overlord »

Medals: 1019
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #2 - Posted 2008-02-13 13:21:31 »

Changing your position != zooming

It's all about narrowing/widening your field-of-view.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cyrus

Senior Newbie

Lean Mean Programming Machine

« Reply #3 - Posted 2008-02-13 13:40:21 »

How would you implement that in OpenGL?

*Always driving the Learning Car of Programming*
Offline Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #4 - Posted 2008-02-13 13:50:30 »


[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Cyrus

Senior Newbie

Lean Mean Programming Machine

« Reply #5 - Posted 2008-02-13 14:03:45 »

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);

then as zoom increases, the object gets further away

watch out though, anything drawn after that will be 'zoomed' as well.
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.

I found this on an other forum

*Always driving the Learning Car of Programming*
Offline anil

Senior Newbie

« Reply #6 - Posted 2008-02-14 10:09:14 »

Thanks all of you for the precious information.
Offline anil

Senior Newbie

« Reply #7 - Posted 2008-02-14 10:14:12 »

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.
Offline Cyrus

Senior Newbie

Lean Mean Programming Machine

« Reply #8 - Posted 2008-02-14 17:21:54 »

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.*Wink

you can find more info there

*Always driving the Learning Car of Programming*
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!