Hello everybody!
I'm a little confused about screen dimensions in ZGE.
When I moved a 2d bitmap (so, I changed the Position.X and Y of this model) in my first test program with the default settings, the left and right edge of the screen can be found at -5 and 5 values, while top and bottom are at -3 and 3.
But why? Why not 0 and 800, and 0 and 600? Is there a function to get the screen coordinates? And what if I set a smaller or greater screen resolution? The -5,5 and -3,3 values are constant even in this case?
Confusion with screen coordinates
Moderator: Moderators
Re: Confusion with screen coordinates
Hi Tomi,
When using a 3D / perspective camera the edge of the screen is dependent on how far your object is away from the camera.
K
By default ZGameEditor uses a camera with a perspective projection and a vertical field-of-view of 45 degrees positioned at coordinate 0,0,10.
When using a 3D / perspective camera the edge of the screen is dependent on how far your object is away from the camera.
If you want to have a coordinate system that matches your viewport, i'd recommend using a camera with a orthographic projection instead. Attached is a basic example.
K
- Attachments
-
- Ortho.zgeproj
- (2.34 KiB) Downloaded 118 times
Re: Confusion with screen coordinates
A-ha! Thanks, Kjell; so is ZGE basically uses 3D projection, even in the case of a 2d program? But I will look your attached example program...
Re: Confusion with screen coordinates
Hi Tomi,
K
No, you don't have to use a 3D projection if you don't want to. Simply add a Camera component to your project and configure it to your needs .. below is the exact same scene viewed using 3 different camera configurations.
K
Re: Confusion with screen coordinates
Thanks again, Kjell!
I started to understand it based on your attached images.
But returning to your previous words:
"When using a 3D / perspective camera the edge of the screen is dependent on how far your object is away from the camera."
Okay, but in this case how can I get the exact screen dimensions? Is there such a function that give those values in different distances from the camera? App.ViewportWidth and App.ViewportHeight?
I started to understand it based on your attached images.
But returning to your previous words:
"When using a 3D / perspective camera the edge of the screen is dependent on how far your object is away from the camera."
Okay, but in this case how can I get the exact screen dimensions? Is there such a function that give those values in different distances from the camera? App.ViewportWidth and App.ViewportHeight?
Re: Confusion with screen coordinates
Hi Tomi,
It's simple Pythagoras theorem
So .. by default the camera is positioned at 0,0,10 and uses a perspective projection with a FOV of 45. When you create a diagram of that situation viewed from the side ( over the x-axis ) it looks something like this:
You can find the vertical "screen edge" for z-coordinate = 0 using the following calculation:
K
It's simple Pythagoras theorem
So .. by default the camera is positioned at 0,0,10 and uses a perspective projection with a FOV of 45. When you create a diagram of that situation viewed from the side ( over the x-axis ) it looks something like this:
You can find the vertical "screen edge" for z-coordinate = 0 using the following calculation:
K
Re: Confusion with screen coordinates
Hi LsJack,
K
Sure, i swapped out the model & textures with procedural alternatives for filesize & copyright reasons ( and added a bit of movement ) .. but aside from that it's the same thing.
K
- Attachments
-
- Isometric.zgeproj
- (5.46 KiB) Downloaded 123 times