world coordinates -> screen coordinates
for the longest time i had no clue how to do this. then yesterday late at night (early morning today) i was reading gamedev''s resources section, specifically the series on the quake engine and something by seumas mcnally, an had an epiphany.. all it is is a transformation from one coordinate system to another. i learned this in pre-calculus a long time ago.
so all i gotta do is setup a matrix that rotates the world axes into the view axes. add some translation and scaling to that matrix and its all good.
but, here is my question though. do i build that matrix and set that as opengl''s modelview (projection?) matrix, or do i apply the matrix myself before passing points to opengl?
Im assuming the former. then instead of glLoadIdentity() every time i apply rotations and whatnot, i can push the matrix, do my thing, and pop it.
is this how its done in say quake3?
You firstly build orientation matrix using objects position and orientatio and then use it on each vertex. This will apply one transformation to entire object or world(depends how u use it).
To move various parts of object in different directions you need a bit complicated system - skeletal animation.
Beware that building orientation matrix isn''t such an easy process an it can give u great deal of troubles. Be sure to study matrix calculations as much as u can. Helps a lot.
Happyface
To move various parts of object in different directions you need a bit complicated system - skeletal animation.
Beware that building orientation matrix isn''t such an easy process an it can give u great deal of troubles. Be sure to study matrix calculations as much as u can. Helps a lot.
Happyface

im not so much intrested in moving objects just yet. all im trying to do right now is have my world defined by its own coordinate system, where Z is up.
Say I have a box centered at the origin of the world. now im at 0,4,0 looking at the box which is right infront of me. in opengl''s coordinates, the box isnt at the origin, its maybe at 0,0,-4, but as far as my world is concerened, the box is still at the origin.
Now i rotate my view 45 degrees to the right. the box is still at the origin but in opengl''s coordinates, its something like cos(45)*4,0,sin(45)*4.
Im still not completely sure how that transformation takes place. I could use glTranslatef and glRotatef ofcourse but thats not what im getting at. im past that. i know quake and whatnot dont do it this way.
Ive been studying quake''s source to see how it projects stuff to the screen, but theres way too much going on to really make sense of it.
I guess what im getting at is how do others do this? whats the standard way of doing it?
Say I have a box centered at the origin of the world. now im at 0,4,0 looking at the box which is right infront of me. in opengl''s coordinates, the box isnt at the origin, its maybe at 0,0,-4, but as far as my world is concerened, the box is still at the origin.
Now i rotate my view 45 degrees to the right. the box is still at the origin but in opengl''s coordinates, its something like cos(45)*4,0,sin(45)*4.
Im still not completely sure how that transformation takes place. I could use glTranslatef and glRotatef ofcourse but thats not what im getting at. im past that. i know quake and whatnot dont do it this way.
Ive been studying quake''s source to see how it projects stuff to the screen, but theres way too much going on to really make sense of it.
I guess what im getting at is how do others do this? whats the standard way of doing it?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement