Jump to content
  • Advertisement
Fadey Duh

Opengl. X, Y, Z only that Y is up/down.

Recommended Posts

I've got used to the fact that in games Z coordinate has mostly been UP/DOWN dimension ( counter strike being one )
however, when I create my own opengl application from scratch, I find this really confusing why it appears to be different.
Why is Y for UP/DOWN?

How and why would I make Z as UP/DOWN?
If I should, what would be the most efficient way? ( editing default camera angle perhaps? )

 

Thank you!

Edited by Fadey Duh

Share this post


Link to post
Share on other sites
Advertisement

Here's a thread that might answer your question.  Check the replies specifically..  The thread is about DirectX but the issue seems relevant to your query.  And should point you in a good direction at least.  Happy Coding!

 

Share this post


Link to post
Share on other sites
17 minutes ago, Septopus said:

Here's a thread that might answer your question.  Check the replies specifically..  The thread is about DirectX but the issue seems relevant to your query.  And should point you in a good direction at least.  Happy Coding!

 

I still don't understand anything to be honest. It gave me a headache.
 

Share this post


Link to post
Share on other sites

Okay, here's the basics:

There are two ways to do the math.  OpenGL does it one way, other graphics systems (DirectX) do it the other way.

I would suggest you either Adapt to how OpenGL works natively, and adjust your modeling process to match the way your engine works.  Or choose a graphics system that matches your process.

If you don't, that headache you got, will only get 1000x worse. ;)

Good Luck!

And by "the other way" I'm saying, the way you are expecting it to work.

Edited by Septopus

Share this post


Link to post
Share on other sites

Now I get exactly what you saying. So directx may have their systems different thats why counter strike has z being for up/down that's the only reason, correct? Yea I just was looking for the reason why specific games used that way of coordination.


I don't see the rotation of the camera doing any harm because it will be exactly the same as 'set identity' won't perform rotation but simply setting the right numbers on the right place.

 

It's not that I favor directx ways but
I somewhat find that way more universal and common. So after I rotate the ROLL axis, it should be same.

Thanks!

Edited by Fadey Duh

Share this post


Link to post
Share on other sites

It all boils down to one of those things that Microsoft decided to do differently a long time ago to disrupt the gaming industry..  It still creates many headaches today. ;)

Share this post


Link to post
Share on other sites

I'm guessing it has little to do with right handed vs left handed corroborate systems. in both cases Z can still be in/out of the monitor.  I'm guessing it's more to do with basic graph drawing conventions. In school you typically draw graphs as +X to the right and +Y up. If you then add the Z coordinate it's naturally in and out of the page.  This is just my take on it though. I have no idea if that was the thought process when the system was designed. However for me, it does feels natural that way.

Edited by Gnollrunner

Share this post


Link to post
Share on other sites
9 minutes ago, Gnollrunner said:

I'm guessing it has little to do with right handed vs left handed corroborate systems. in both cases Z can still be in/out of the monitor.  I'm guessing it's more to do with basic graph drawing conventions. In school you typically draw graphs as +X to the right and +Y up. If you then add the Z coordinate it's naturally in and out of the page.  This is just my take on it though. I have no idea if that was the thought process when the system was designed. However for me, it does feels natural that way.

Or that.  yeah.  ;)

I should read questions more carefully I guess.

Edited by Septopus

Share this post


Link to post
Share on other sites

If you draw on graph paper, the paper usually lies flat on the table (not upright like a monitor). That means it should be natural to have x and y be used for the floor (like on a drawn map) and z going down.

It doesnt matter though, if you want a different convention you just adapt the matrix you use (for example, add some rotation). Noone will directly use clip coordinates and everything before that you program yourself in the shader.

Share this post


Link to post
Share on other sites
5 hours ago, Gnollrunner said:

I'm guessing it has little to do with right handed vs left handed corroborate systems. in both cases Z can still be in/out of the monitor.  I'm guessing it's more to do with basic graph drawing conventions. In school you typically draw graphs as +X to the right and +Y up. If you then add the Z coordinate it's naturally in and out of the page.  This is just my take on it though. I have no idea if that was the thought process when the system was designed. However for me, it does feels natural that way.

Yes this is fairly classic. At the end of the pipeline, GL/D3D are addressing pixels of  a screen. Using graphics x and y coordinates for pixels makes perfect sense for 2D and 3D graphics. In 3D you have depth as well, so we extend it with z. 

IIRC both GL and D3D address the screen with right handed coordinate systems, but one uses y=up and one uses y=down. Because they're both right-handed, this means one ends up with z=in and the other z=out. 

That's all just how they address pixels though. You're in 100% control of the world->camera->screen mapping via the matrices that you choose to use. Your projection matrix is the one that goes from a 3D world to a 2D screen,  so that it already performs that mapping. If, in your game, x=East, y=North and z=away from earth, its because you've set up that convention yourself in your matrix arrangements. You can swap around a few columns / rotate your matrices to use other conventions. I personally use x=West, y=away from earth, z=North :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!