Game Development Community

Weird rotation

by Mikkel Hempel · in Torque Game Engine · 08/07/2002 (5:50 pm) · 0 replies

Im currently coding a turret. It consists of two parts TurretBody and TurretHead. I've mounted the TurretHead onto TurretBody and now I want to rotate the TurretHead according to the mouse-movement.

To do this I've worked with the TurretHead::processTick() function.

After Parent::processTick(move) is called I've coded the following (mRot is a public member of TurretHead of type Point4F):

-----------------------------------------------------

Point3F pos;
getTransform().getColumn(3,&pos);

QuatF rot;

mRot.x += dAtof(Con::getVariable("$mvYaw"));
mRot.y += dAtof(Con::getVariable("$mvPitch"));
mRot.z += dAtof(Con::getVariable("$mvRoll"));

rot.set(0, 0, mRot.y, 1) // only rotate around z-axis

setPosition(pos,rot);
setRenderPosition(pos,rot);

-----------------------------------------------------

If I run the game with this code the "rendered" model of TurretHead isent rotating when moving the mouse but the "inner structure" is rotated because the cannon shoots in the direction I move the mouse!!!? but the weird part is if I hardcode the "rot" to example:

rot.set(0, 0, M_PI, 1) // only rotate around z-axis

then the TurretHead is rotated 180deg. = PI around the z-axis.

So my conclusion is that the "rendered" model only gets rotated by the initial value (in this example: PI).

I have no idea how to fix the bug, but any help would be apriciated very much!!!

Best regards
-Roquqkie-

btw. I've been "forced" by the #GarageGames chan. to make a tutorial out of my project...Maybe I'll do so IF I get the rendered rotation to work! :D