Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 3494 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.

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 Tongue

http://www.wehaveinternet.com

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

JGO Overlord


Medals: 752
Projects: 4
Exp: 16 years


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
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 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: 56
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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org 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‑gaming.org
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!