assign Storyboard to a InteractiveVisual3D

Topics: Developer Forum, Project Management Forum, User Forum
Feb 27, 2008 at 1:43 PM
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));
rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, animation);
_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.SetTargetName(_rotationAnimation, ??);
Storyboard.SetTargetProperty(_rotationAnimation, new PropertyPath(RotateTransform3D.RotationProperty));
storyboard.Children.Add(_rotationAnimation);
storyboard.Begin(_interactiveVisual3D,true); // <= here he complains!!



Resource Dictionary
-------------------------
<Rotation3DAnimation x:Key="someLocalAnimation">
<Rotation3DAnimation.To>
<AxisAngleRotation3D Axis="1,0,0" Angle="0" />
</Rotation3DAnimation.To>
</Rotation3DAnimation>





Feb 29, 2008 at 3:10 PM
Solved

Made my object a UserControl. This simplified a lot of things.

Storyboard _storyboard = (Storyboard)FindResource("FloorActiveStory");
_storyboard.Begin(this);