Assigning a simple animation to a IV3D (InteractiveVisual3D) seems to be quite simple:
RotateTransform3D rotateTransform = (RotateTransform3D) _interactiveVisual3D.Transform;
Rotation3DAnimation animation = new Rotation3DAnimation(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 40), TimeSpan.FromSeconds(2));
_interactiveVisual3D.Transform = rotateTransform;
The code above performs a simple Rotation3D.
However, i would like to create a complex set of animations (in Blend). I.e. rotation and scaling, with easing concurrently.
Therefore i would probably need to use Storyboards. The problem is however, I can not seem to get this work with c#.
In Blend I can manipulate a IV3D easily using a Storyboard. In C#, VS complains that I cannot Animate a non FrameworkElement object. (Strangely it DOES works in Blend with XAML)
The code I am trying to get to work is:
Storyboard storyboard = new Storyboard();
Rotation3DAnimation rotationAnimation = (Rotation3DAnimation)floor.FindResource("someLocalAnimation -- see XAML code below");
Storyboard.SetTargetProperty(_rotationAnimation, new PropertyPath(RotateTransform3D.RotationProperty));
storyboard.Begin(_interactiveVisual3D,true); // <= here he complains!!
<AxisAngleRotation3D Axis="1,0,0" Angle="0" />
Made my object a UserControl. This simplified a lot of things.
Storyboard _storyboard = (Storyboard)FindResource("FloorActiveStory");