Working In Screen Coordinates

Started by
1 comment, last by Tachikoma 12 years, 10 months ago
Hello all:

New here and new to game development in general. This is a graphics API agnostic question but specifically I am working in WebGL.

I come from a UI design background and have done quite a bit of development in Flash. What I always found nice about working in this environment was its psuedo-3d API. I could still working in screen coordinates but at the same time, the object could be made to appear with perspective.

For example, I could animate an object's x,y, and z properties and rotate on any axis giving a 3d like effect all in screen coordinates.

Now coming to the OpenGL / WebGL world should I throw out this concept and worry about world space coordinates only?

Sorry for the what may seem like an idiotic question.

I guess what I am really trying to ask is how do other people tackle a project such as building a complex user interface which has to be pixel precise but contains 3d effects.

Thanks for your help.

- john
Advertisement
If you want to make a pixel perfect HUD, you should change to an orthogonal projection matrix and maybe disable the depth test, while painting the UI.
You should first draw your scene in perspective, and afterwards switch to orthogonal.

This thread explains it :) http://www.gamedev.net/topic/389503-opengl-hud/
The screen coordinate system and the world coordinate system are two distinct spaces, and you need to transform data from space to the other via the matrices mentioned by VildNinja.

For instance, you may wish to display 3D world data with a HUD on top. Both of these rendering steps would require their own transformation steps. One could use perspective transformation to emulate a camera for rendering scene geometry (defined in metres). Meanwhile, the HUD assets, defined in pixel units, would need an orthographic transform for rendering. Note, these units are examples, you could use furlongs and yards if you are so inclined, it doesn't really matter.

Here is a crappy, oversimplified visual example how GL works:

3D World Space (Metres) ------> Perspective Transform -> |
HUD Assets (Pixels) ----------> Othrographic Transform -> | -> Normalised Device Coordinates -> Viewport
Other Stuff (Whatever Units) -> Other Stuff Transform --> |
Latest project: Sideways Racing on the iPad

This topic is closed to new replies.

Advertisement