Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (289)
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 2601 times)
0 Members and 1 Guest are viewing this topic.
Offline anil

Senior Newbie





« Posted 2008-02-13 11: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 13:18:25 »

you can use glTranslate to zoom in and zoom out.



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

http://www.wehaveinternet.com

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

JGO Overlord


Medals: 437
Projects: 4


Hand over your head.


« Reply #2 - Posted 2008-02-13 14: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
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Cyrus

Senior Newbie




Lean Mean Programming Machine


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

How would you implement that in OpenGL?

http://www.wehaveinternet.com

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

JGO Kernel


Medals: 48
Projects: 11


Monkey for a head


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

gluPerspective

[ TriangularPixels.com - 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 15:03:45 »

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.

I found this on an other forum

http://www.wehaveinternet.com

*Always driving the Learning Car of Programming*
Offline anil

Senior Newbie





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

Thanks all of you for the precious information.
Offline anil

Senior Newbie





« Reply #7 - Posted 2008-02-14 11: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 18: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

http://java.sun.com/javase/6/docs/api/java/awt/event/MouseAdapter.html

you can find more info there

http://www.wehaveinternet.com

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

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (60 views)
2013-05-17 21:29:12

alaslipknot (69 views)
2013-05-16 21:24:48

gouessej (99 views)
2013-05-16 00:53:38

gouessej (96 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (167 views)
2013-05-12 17:10:36

kutucuk (166 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.09 seconds with 21 queries.