Rotating a full 360 degrees in WPF 3D

Posted by sklitzz on Stack Overflow See other posts from Stack Overflow or by sklitzz
Published on 2010-01-14T12:04:04Z Indexed on 2010/04/07 19:33 UTC
Read the original article Hit count: 590

Filed under:
|
|
|
|

Hi,

I have a ModelVisual3D of a cube and I want to animate it to rotate around its axis for 360 degrees. I make a RoationTransform3D which I tell to rotate 360 but it doesn't rotate at all, also if you say 270 degrees it rotates only 90 degrees but in the opposite direction. I guess he computer calculates the "shortest path" of the rotation. The best solution I have come up with is to make one animation turn 180 and after it finishes call another 180 to complete the full rotation. Is there a way to do it in one animation?

RotateTransform3D rotateTransform = new RotateTransform3D();
myCube.Model.Transform = rotateTransform;

AxisAngleRotation3D rotateAxis =
      new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180/*or 360*/);
Rotation3DAnimation rotateAnimation =
      new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2));

rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty,
      rotateAnimation);

© Stack Overflow or respective owner

Related posts about c#

Related posts about 3d