我有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