1
尋求一個解決方案來分開所有的軸來動畫所有的對象。它也必須同時工作。不幸的是,我經過長時間的搜索發現了任何東西。 我的示例代碼不起作用,因爲我必須給所有的軸。 當我用Vector3D(0,1,-1)試用它時,他總是選擇我不想要的最短路徑。即使有兩個動畫,它也不起作用,因爲它總是執行最終的動畫。WPF 3D動畫旋轉一個物體同時分離到X軸和Y軸
我希望你能理解我的問題。如果你能幫助我,那會很好。
RotateTransform3D rotateTransform = new RotateTransform3D();
RotateTransform3D rotateTransform2 = new RotateTransform3D();
Transform3DGroup transGroup = new Transform3DGroup();
transGroup.Children.Add(rotateTransform);
transGroup.Children.Add(rotateTransform2);
// 3D Objects
wire_2.Transform = transGroup;
wire_235235235.Transform = transGroup;
wire_3.Transform = transGroup;
wire_4.Transform = transGroup;
// Set Center
rotateTransform.CenterZ = 2.33;
rotateTransform2.CenterZ = 2.33;
// Axis rotation Selection
AxisAngleRotation3D rotateAxis = new AxisAngleRotation3D(new Vector3D(0,1 ,0) , 180);
AxisAngleRotation3D rotateAxis2 = new AxisAngleRotation3D(new Vector3D(0, 0, -1), 180);
Rotation3DAnimation rotateAnimation = new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2));
Rotation3DAnimation rotateAnimation2 = new Rotation3DAnimation(rotateAxis2, TimeSpan.FromSeconds(2));
rotateAnimation.RepeatBehavior = RepeatBehavior.Forever;
rotateAnimation.IsCumulative = true;
rotateAnimation2.RepeatBehavior = RepeatBehavior.Forever;
rotateAnimation2.IsCumulative = true;
// Animation
rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, rotateAnimation2);
rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, rotateAnimation);
我很遺憾。你是對的。有時候會看到森林裏幾乎沒有樹的樹。 – HunterPanter
來自其他編碼員的新面貌,效果很好。祝你好運。 –
在旋轉過程中可以改變旋轉速度。我試圖改變它與den rotateAnimation.Duration = TimeSpan.FromSeconds(Drehzahltime/2); rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty,rotateAnimation); - 但它重置了旋轉位置,befor。 – HunterPanter