Marioko
17-07-2006 22:35:58
Hi..
I am very newbie in Ogre and OgreDotNet, at last i could make a scene with a robot. When i press the arrows keys up, down, right, left, the robot walk very nice, the problem is in the rotation, i want that if i press right then the robot rotate to east, and if i press right and up (for example) the robot rotate to north-east..
I am using this code to try perform the rotation:
Only the first time that i run the app works nice, but later the robot fuck it.. o rotate very ugly.. somebody can help me??
I am very newbie in Ogre and OgreDotNet, at last i could make a scene with a robot. When i press the arrows keys up, down, right, left, the robot walk very nice, the problem is in the rotation, i want that if i press right then the robot rotate to east, and if i press right and up (for example) the robot rotate to north-east..
I am using this code to try perform the rotation:
private void performRobotRotation()
{
Vector3 src = robotNode.GetOrientation() * Vector3.UnitX;
Vector3 dest = robotNode.GetPosition();
//mMoveRobot bits: 1=adelante, 2=atras, 4=izquierda, 8=derecha
if ((mMoveRobot & 1) > 0)
dest *= Vector3.NegativeUnitZ;
if ((mMoveRobot & 2) > 0)
dest *= Vector3.UnitZ;
if ((mMoveRobot & 4) > 0)
dest *= Vector3.NegativeUnitX;
if ((mMoveRobot & 8) > 0)
dest *= Vector3.UnitX;
Quaternion rotation = src.GetRotationTo(dest);
robotNode.Rotate(rotation);
}
Only the first time that i run the app works nice, but later the robot fuck it.. o rotate very ugly.. somebody can help me??