Sign in to follow this  
werbfred

Screen Coordinates and World Coordinates

Recommended Posts

werbfred    122
Hi evrybody, I tried to find a similar thread in the history, but I was unable to find my luck... I would like to know what is the relation between the screen coordinates and the world coordinates. Especially, I would like to know the relation between my camera distance and the size of the object I'm looking at? An example will be easier to understand what I looking for. Having a screen width of 800 and height of 600, so if I draw a square in the middle of the screen with an edge of 1.0f. Now If I'm situated at (0.0f, 0.0f, -1.0f) would this mean that the cube has an edge of 600 pixels on the screen ? In fact I'm looking for a mathematical equation helping me to define the object size depending on my distance from the origin. Thx.

Share this post


Link to post
Share on other sites
mjs1    122
I think you're looking for gluProject() and gluUnProject(). GluProject() takes x, y, z world coordinates and converts them into x, y screen coordinates. GluUnproject does the opposite, where it takes x, y screen coordinates plus a depth value and converts them into into x, y, z world coordinates. Try doing a search for gluUnproject/gluUnProject and see if this is what you're after.

The amount of space a fixed-size object will take up in screen coordinates also depends on your viewing angle. If you have a tight view angle a small object could take up the entire viewing area, while if you have a wide view angle a very large object could take up a very small amount of viewing area.

Hope this helps!

Share this post


Link to post
Share on other sites
werbfred    122
In fact your answer was in some way helpfull. I was able to find some information that might help me to move any further...

I try not to use any glu functions for the moment. It would be nice if some simple gl function I could set or determine the values for the focus and/or viewing angle values. This way I should be able to establish some equation to determine what position and size my object should have to be at a precise size on the screen.

To be more precise, I'm working on a GUI with some buttons (radio, checkbox, etc.), textboxes and so on. And I would like to know how to set their world coordinates in order to be sure they will be at the right place and have the right size and shape.

Thx.

Share this post


Link to post
Share on other sites
compie    122
Quote:
Original post by werbfred
To be more precise, I'm working on a GUI with some buttons (radio, checkbox, etc.), textboxes and so on. And I would like to know how to set their world coordinates in order to be sure they will be at the right place and have the right size and shape.

Thx.


Use an orthogonal projection for that!

Share this post


Link to post
Share on other sites
compie    122
Quote:
Original post by mjs1
I think you're looking for gluProject() and gluUnProject(). GluProject() takes x, y, z world coordinates and converts them into x, y screen coordinates.


Into object space! Not world space.

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

Sign in to follow this