A robot which can also move after being flipped?
A possible solution might be to reset this pointer to the ground once I detect the flipped robot, but I haven't found a way to change this pointer back to the ground.
Any suggestions?
The LocalPose in the state is only used to initialize the shape. Once the entity has been initialized, you must call PhysicsEntity.SetShapeLocalPose to change the pose of a shape. Please reply and let me know if this solves your problem. We haven't done an implementation of a flipping robot, yet.
-Kyle
The Flip condition is not too nice yet, but works:
...
xna.Vector3 vector = UIMath.QuaternionToEuler(base.State.Pose.Orientation);
if(Math.Abs(vector.X) > 100 && !_isFlipped)
{
Pose leftWheelCurPos = _leftWheel.WheelShape.WheelState.LocalPose;
Pose rightWheelCurPos = _rightWheel.WheelShape.WheelState.LocalPose;
leftWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,(float) Math.PI);
rightWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f, (float) Math.PI);
PhysicsEntity.SetShapeLocalPose(_leftWheel.WheelShape, leftWheelCurPos);
PhysicsEntity.SetShapeLocalPose(_rightWheel.WheelShape, rightWheelCurPos);
_isFlipped = true;
} else if(_isFlipped && Math.Abs(vector.X) <= 100) {
Pose leftWheelCurPos = _leftWheel.WheelShape.WheelState.LocalPose;
Pose rightWheelCurPos = _rightWheel.WheelShape.WheelState.LocalPose;
leftWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,0f);
rightWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,0f);
PhysicsEntity.SetShapeLocalPose(_leftWheel.WheelShape, leftWheelCurPos);
PhysicsEntity.SetShapeLocalPose(_rightWheel.WheelShape, rightWheelCurPos);
_isFlipped = false;
}
...
}
The two conditions cover flip and backflip.
Only changing the Orientation of each wheel - not Position.
If anyone wonders why flipping a body with two wheels: the whole robot consists of two similar body parts - so there will be four wheels in total.
Thx
Tom