Free 3dof rotation
by Jake · in Technical Issues · 03/01/2001 (11:16 pm) · 4 replies
I've been playing tank-turret rotation games(i.e.Quake) for a long time now, I would like to try having some more rotational freedom. I've already added a third rotation input into Quake1, however, I want roll to appropiately affect yaw/pitch directions(i.e. rolled 90deg to the side pitch becomes yaw relative to the world.) My mathematical comprehension on the subject is severly lacking, however. I've looked over a few websites on the matter, and even looked over the sourcecode for the game 'Descent'. I am still stumped. I have posted my best meager attempt thus far, in hopes that someone can put me on the right track.
void Rotate (float dangles[3])
{
//edited out clueless code
}
The converting to orientation angles is probably just wishfull thinking. Borrowing from Zoid's spectator functions I can get yaw/pitch, but I've yet to figure how to get roll
//edited out clueless code
void Rotate (float dangles[3])
{
//edited out clueless code
}
The converting to orientation angles is probably just wishfull thinking. Borrowing from Zoid's spectator functions I can get yaw/pitch, but I've yet to figure how to get roll
//edited out clueless code
#2
03/03/2001 (2:24 am)
Sorry!! I hope you havn't tried to implement it yet (I hate late night 3D maths). I think that instead of rotating the model coordinates, you just add the rotation to the pitch, yaw or roll of the reference point, and then when moving the model to world space it should be right :). I've not had a chance to try it yet, but I will and I'll tell you if I get it working.
#3
cl.old is a matrix holding the old viewpoint in terms of any of the 2 vectors: up, right, forward. rot is a rotation matrix holding how much and in what direction to spin around the viewpoint's vectors. newm holds the result, the new viewpoint.
I don't really understand how the matrix math works, but it does seem to be the only way. You can't do the roll then do the yaw then do the pitch, when you apply another it is not onto the original orientation thereby being incorrect, they all have to be done at the same time. I suppose you could minimize that error by breaking it up into many small movements, but that doesn't seem pratical.
03/03/2001 (11:45 am)
Well, at the moment I am just trying to find out how to rotate a viewpoint in totally free 6dof space(as opposed to constricted movement like a turret of a tank.) For example, an invisible camera, like a spectator in Quake. There are no verticies at all involved, just a viewpoint.cl.old is a matrix holding the old viewpoint in terms of any of the 2 vectors: up, right, forward. rot is a rotation matrix holding how much and in what direction to spin around the viewpoint's vectors. newm holds the result, the new viewpoint.
I don't really understand how the matrix math works, but it does seem to be the only way. You can't do the roll then do the yaw then do the pitch, when you apply another it is not onto the original orientation thereby being incorrect, they all have to be done at the same time. I suppose you could minimize that error by breaking it up into many small movements, but that doesn't seem pratical.
#4
03/03/2001 (12:29 pm)
I you just want to apply multiple transforamtions/rotations at the same time then that should eb pretty easy. ou just have to multiply the matrices together to make a single matrix which contains all the rotations. Go to gamedev.net and into the developers resources->programming-> and then its 3D and theory or something and you'll find plenty tutorials on matrix maths that will explain it better then I can.
William Finlayson
Store all the vertices in your model relative to 0,0,0 giving you model coordinates. this point (0,0,0 to the model), would be a point in world space (the model's reference point), storing the x,y,z as well as the pitch, yaw, and roll. When rotating the model, the rotations will occur in model space as all the coordinates will be in model space.
When you want to draw the model, you need to translate the model coordinates from model space to world space, do that by rotating the coordinates by the same rotation that is stored in the model reference point, and then add the reference point's x,y and z.
I hope this is what you were needing :) If my explanation is a bit rough then just ask and i'll be happy to (attempt to) clarify anything.