View Full Version : Quake3 coordinate system

02-03-2001, 02:02 AM
I have been exploring the coordinate system used in q3, and so far this is what i get.., but i think it's really strange!

To start the camera at the place we desire, i must convert the coordinates like this:


ok, now if i wanna mark a ligh effect, at the light coordinates marked in the entity light, i should do the same conversion, right? wrong! If i convert the ligth coordinates like the above, it will not be in the correct place.., so to convert the light i have to do like this:

light.x = light.x;
light.y = light.z;
light.z = -light.y;

Why ? why are they using diferent coordinates systems ? This is a problem, for example if i try to the get the distance from the player to the light source.., i must convert the coordinates again to the original coordinate system...

Is all this wrong, or is there something that i don't see ?



02-03-2001, 03:50 AM
You must have something a bit backwards along the way. In the Q3 viewer I wrote, I never had to do any of that swapping. I just make sure the world matrix is set to a Q3 world matrix rather than an identity matrix before doing any translations or rotations in OpenGL. That is, if you use the Q3 coordinate system rather than the OpenGL coordinate system, everything works perfect.
I wouldn't be surprised if you were actually seeing a mirror image of the map rather than the map itself.

02-03-2001, 04:16 AM
Can you post the Q3 world matrix , so that i can try it ?



02-03-2001, 05:26 AM
Here is what I used in place of the identity matrix for the modelview matrix:

0 -1 0 0
0 0 1 0
-1 0 0 0
0 0 0 1

[This message has been edited by DFrey (edited 02-03-2001).]

Michael Steinberg
02-03-2001, 05:57 AM
What's the sense of such a coordinate system. Can you calculate faster with it?

02-03-2001, 07:08 AM
That matrix is only used to convert Quake 3's coordinate system into OpenGL's. Quake 3 uses legacy code dating all the way back to the first program in the Quake series, which did not use OpenGL. There is nothing inherently slower about one coordinate system versus another when you are using a software rasterizer of your own design.

02-03-2001, 07:23 AM
All quake games use a coordinate system where the z-axis goes up\down and the y-axis goes into\out of the screen....
Therefore you have to do the following while reading in the vertices(If you don´t want to use quake´s coordinate system):

temp = y;
y = z;
z = -temp;

DFrey: I would either change the vertex to one´s own coordinate system before runtime or would work with the other coordinate system but why would you change the coordinates realtime which costs speed?

Greets, XBTC!

02-03-2001, 07:39 AM
No it does not cost any appreciable extra speed. All the vertices still have to be multipled by the modelview matrix regardless of what coordinate system you are using. I'm just using a different identity matrix for the modelview matrix than you are. And I'm loading it only once (to save it on the stack). And this is the way GLQuake does it (well it actually rotates the identity matrix a couple times so that it is the matrix I showed earlier).

[This message has been edited by DFrey (edited 02-03-2001).]

02-03-2001, 10:28 AM
DFrey: Sorry I just didn´t think before posting.... http://www.opengl.org/discussion_boards/ubb/wink.gif
Surely loading another identity matrix doesn´t make a speed difference....
But I think one should use only one coordinate system in one engine.
If one uses Q3´s coordinate system one should code the whole program with this coordinate system in mind....
Again sorry....

Greets, XBCT!

02-03-2001, 10:32 AM
Thanks guys http://www.opengl.org/discussion_boards/ubb/smile.gif

02-03-2001, 11:07 AM
I don't mean to beat a dead horse http://www.opengl.org/discussion_boards/ubb/biggrin.gif, but ...

... I think one should use only one coordinate system in one engine.
If one uses Q3´s coordinate system one should code the whole program with this coordinate system in mind....

Which is precisely why I use that particular 'identity' matrix. At no point do I ever have to preconvert any coordinates. I can use the raw coordinates straight from the bsp and md3 files. I would agree though, pick a coordinate system and stick to it.

02-04-2001, 02:08 AM
Yes you´re right but somehow I find it really better if you can draw the coords directly....
Perhaps I´m just a little crazy.... http://www.opengl.org/discussion_boards/ubb/smile.gif

Greets, XBTC!

[This message has been edited by XBCT (edited 02-04-2001).]