我有ModelVisual3D的立方體。我想同時翻譯和旋轉它。我希望旋轉中心位於立方體的中間(立方體圍繞其自身的軸旋轉)。 但是,當我嘗試應用這兩個轉換時,效果不是你所期望的。由於物體正在平移,所以旋轉的中心是不同的,從而使它以奇怪的方式移動和旋轉。我如何獲得理想的效果?3D動畫在WPF中同時旋轉和翻譯
Transform3DGroup transGroup = new Transform3DGroup();
DoubleAnimation cardAnimation = new DoubleAnimation();
cardAnimation.From = 0;
cardAnimation.To = 3;
cardAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));
Transform3D transform = new TranslateTransform3D(0,0,0);
transGroup.Children.Add(transform);
RotateTransform3D rotateTransform = new RotateTransform3D();
AxisAngleRotation3D rotateAxis =
new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180);
Rotation3DAnimation rotateAnimation =
new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2));
rotateAnimation.DecelerationRatio = 0.8;
transGroup.Children.Add(rotateTransform);
Model.Transform = transGroup;
transform.BeginAnimation(TranslateTransform3D.OffsetXProperty,
cardAnimation);
rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty,
rotateAnimation);
您的意思是將立方體旋轉到位然後翻譯?因爲這不是我想要的,所以我希望它能夠在地球移動並圍繞其軸旋轉時進行平移和旋轉...... – synepis 2010-01-13 08:39:14
謝謝您的回答!這正是我所期待的。 – synepis 2010-01-14 11:51:56