Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  OpenGL 3D Cartesian coordinates?  (Read 1837 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid

Senior Member


Medals: 3
Projects: 1



« Posted 2012-06-15 12:25:00 »



So, I decided to move to 3D after fooling around in 2D for a while with OpenGL.

I start up the camera with gluPerspective; worked perfect as you can see above.

Now I'm wondering, how do I convert the matrix coordinate system into a Cartesian coordinate system? I messed with using glOrtho along with gluPerspective, but it was to no avail. Is there another command for it? I've googled this many times, and I find long papers that supposedly teaches me how, but instead explain vanishing point and philosophical questions on what the third dimension actually is, instead of a command to do what I need to do. Hahah.

Anyway, any insight is great. Thanks!

(Just in case it's relevant, here's gluPerspectives initialization)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public static void main(String args[]){
      try{
         Display.setTitle("I'm not an idiot!");
         Display.setDisplayMode(new DisplayMode(800, 600));
         Display.setResizable(true);
         Display.create();
      }catch(LWJGLException ex){
         ex.printStackTrace();
      }
     
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      //glOrtho(0, Display.getWidth(), Display.getHeight(), 0, -1, 1);
     Project.gluPerspective(45, (float)Display.getWidth()/(float)Display.getHeight(), 0.1f, 100f);
     
      //Main m = new Main();
     Main2 m = new Main2();
      m.loop();
   }


“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #1 - Posted 2012-06-15 15:08:30 »

I'm not sure I follow - surely you're already using a cartesian coord system (as opposed to say, radial). What are you trying to do?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline theagentd
« Reply #2 - Posted 2012-06-15 16:13:23 »

Just guessing here, but if you're not getting a good enough "3D feel", try to increase the FOV (currently at 45). For most games it's between 60 and 90. It's also somewhat hard to notice it with only a cube.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SkyAphid

Senior Member


Medals: 3
Projects: 1



« Reply #3 - Posted 2012-06-16 00:19:10 »

I'm not sure I follow - surely you're already using a cartesian coord system (as opposed to say, radial). What are you trying to do?
It uses floats, like, since the screen is 800/600. So:
1  
x = 0.5f = 400


I don't want to use floats to define places on screen, because admittedly, it's a bit hassling. glOrtho "converts" the coordinate system to a more standard "Cartesian" style. That's what I'm going for, get me? Just, I don't understand if I can use glOrtho to define 3d normally the same way as gluPerspective or if I should use them together.

I already know that I can just do division to get this too, but if there's a built in way to do this, I'd like that a lot more Azn

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #4 - Posted 2012-06-16 00:27:28 »

I'm not sure I follow - surely you're already using a cartesian coord system (as opposed to say, radial). What are you trying to do?
It uses floats, like, since the screen is 800/600. So:
1  
x = 0.5f = 400

Both of those are cartesian, just with different ranges. Cartesian is just a regular rectangular coord system with the x/y/z axies at right angles to each other.

Anyway, what you're after is just an orthographic projection. Just replace your calls to gluProjection with glOrtho or gluOrtho2d calls. All of those are just easy ways to set up the projection matrix so you only really use one at a time.

And don't forget to put your matrix mode back to MODELVIEW afterwards.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline SkyAphid

Senior Member


Medals: 3
Projects: 1



« Reply #5 - Posted 2012-06-16 07:59:08 »

I'm not sure I follow - surely you're already using a cartesian coord system (as opposed to say, radial). What are you trying to do?
It uses floats, like, since the screen is 800/600. So:
1  
x = 0.5f = 400

Both of those are cartesian, just with different ranges. Cartesian is just a regular rectangular coord system with the x/y/z axies at right angles to each other.

Anyway, what you're after is just an orthographic projection. Just replace your calls to gluProjection with glOrtho or gluOrtho2d calls. All of those are just easy ways to set up the projection matrix so you only really use one at a time.

And don't forget to put your matrix mode back to MODELVIEW afterwards.

Thanks, got it working. I was able to convert it exactly how I wanted with glOrtho and glScale and glRotate.
I know to change to modelview too, thanks Smiley

This OpenGL stuff really sparks my nerdy mathematical interests lol. It's so nifty!

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
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.

xsi3rr4x (57 views)
2014-04-15 18:08:23

BurntPizza (55 views)
2014-04-15 03:46:01

UprightPath (68 views)
2014-04-14 17:39:50

UprightPath (51 views)
2014-04-14 17:35:47

Porlus (68 views)
2014-04-14 15:48:38

tom_mai78101 (92 views)
2014-04-10 04:04:31

BurntPizza (153 views)
2014-04-08 23:06:04

tom_mai78101 (249 views)
2014-04-05 13:34:39

trollwarrior1 (205 views)
2014-04-04 12:06:45

CJLetsGame (212 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!