View Full Version : Reverse rotation
01-18-2009, 05:11 PM
Hi, I've been having a little problem with a program I'm working on.
I have made the foundation for a multiplayer game, in which you fly around in space, using a dedicated server.
My problem is that if a player sees another player, he also needs to know how much he is rotated. And as such, an easy way would be for players to send their total rotation-data to the server each time it changes. (e.g. the players turns around)
I have the matrix (I think) that all the scaling, position and rotations are performed on, but I cannot find a way to get the four values that the other players need to apply to the "other-player" object's matrix to locally rotate it. (using glrotatef)
In short, with the modelview matrix (I think its that one), how do I figure out what four values to pass to glrotatef to make another object, using a clean identity matrix, be oriented the same way? (if this is possible in this way at all)
01-18-2009, 06:51 PM
I'm not sure I understand you completely, but if you have the matrix for the scale position and rotation of the object you wish to orientate something else to, why not just use glLoadMatrixf(); instead of glRotatef?
01-18-2009, 07:51 PM
You're not the first victim of my lacking ability to explain myself, sorry about that.
Here's an example of what happens, and when I get a problem:
Player A rotates alot.
Player B moves within visual range of Player A.
Player A sends his rotation information to the server.
(that is, his absolute rotation, from not rotated at all, to his present rotation)
The server sends information about Player A (including rotation information) to player B.
Player B uses one glrotate to set the object representing player A correctly. (when next he recieves new rotation information, he reset the matrix, and then applies the new absolute rotation)
The problem comes when I want player A to send his rotation information to the server.
From Player A's matrix, I dont know how to find out what values Player B would have to send to his glrotatef.
01-19-2009, 01:26 AM
You have to use the same world coordinates (GL_MODELVIEW)for all players. In this case there is no special cases, everyone has to transform world coordinates to its own for the rendering, and everyone sends worlds coordinates to the server.
01-19-2009, 03:47 PM
Is the problem that you don't want to send a 9 or 16 floats as a matrix, but would rather send 3 floats for roll,pitch and yaw and have the guy at the other end reconstruct the matrix?
if so this link might be useful:
but as it states, their may be issues.
01-20-2009, 03:53 AM
-> James A.
Exactly, that's it.
I looked a little at the page you pointed to, and I guess once I get that to work, I have to find a way to avoid the singularities in a simple way, but that is probably doable :)
btw, I implemented sending the whole 16-value array when I thought the rotation-problem might take a long time to figure out. (which worked quite well, despite wasting bandwidth)
I have to admit I don't really understand what you mean, but if you mean that every player will need to have an identical copy of the modelview matrix of the other players to render place/orient/scale them correctly, then I suppose that is correct.
But my need is such that if any player at any times only performs a rotation, it would be better if that update sent to the server contained only data regarding the rotation, instead of sending the whole modelview matrix.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.