Readjusting the rotation axis
by Dracola · in Torque Game Engine · 05/22/2006 (6:53 pm) · 1 replies
I inserted a little piece of code to make my sphereical player roll around, pretty much when he moves in the Y he rotates in the Y, when he moves in the X he rotates in the X. The problem with this is when he rotates 90 degrees on the X then the Y is pointing up and down, like the Z axis used to. Then when he moves on the Y he spins in what wouold normally be the Z axis. So what I need to do is find a way to have the Axis be constant while he rolls around. Or if anybody knows another way to fix this that would work also.
Here's the code if it might help. I took the xrot part out of the wheel code(there it is called arot) and made a new yrot which is bassicaly the same thing.
in Player.cc, Player::updatePos
in Player::renderImage under dglMultMatrix(&getRenderTransform());
that is pretty much it, thanks.
Here's the code if it might help. I took the xrot part out of the wheel code(there it is called arot) and made a new yrot which is bassicaly the same thing.
in Player.cc, Player::updatePos
xrot += mAbs(mVelocity.x)*time/scale.z / M_2PI;
yrot+=mAbs(mVelocity.y)*time/scale.z / M_2PI;
xrot -= mFloor(xrot);
if (xrot < 0)
xrot = 1 - xrot;
yrot -= mFloor(yrot);
if (yrot < 0)
yrot = 1 - yrot;in Player::renderImage under dglMultMatrix(&getRenderTransform());
MatrixF rot(EulerF(xrot * M_2PI,0,0));
dglMultMatrix(&rot);
MatrixF myrot(EulerF(0,0,yrot));
dglMultMatrix(&myrot);that is pretty much it, thanks.
About the author
Torque Owner Dracola