views:

589

answers:

1

I'm working on a WPF 3D project where I can have multiple (1 - 20'ish) ModelVisual3D objects being moved around the scene via animation. Each ModelVisual3D has both a RotateTransform3D and a TranslateTransform3D applied to it each move. And each ModelVisual3D object moves independently of each other.

So right now in order to do this, each time I want to move objects around, I spin through each ModelVisual3D and setup a double animation for both its rotation and its translate transform movement. Then call the BeginAnimation() on both transforms (for each object).

So that means, if I have 20 ModelVisual3D objects, I'll end up calling BeginAnimation() on 40 different transform objects...each time I need to move them.

This performs ok, but it seems like there should be a better way. Is there something where I can group multiple transforms together for multiple ModelVisual3D objects, into one "transform group" object, and then call Begin on that?

Also, I looked at using the storyboard object, but I'm doing this all in C# (very little static xaml going on here, most of the UI is dynamically created). The storyboard object seems to be able to only be used for a single ModelVisual3D object. So best case, I would be down to 20 storyboard objects that I call BeginAnimation on.

Or is what I'm doing the best thing to do?

A: 

You can store both the RotateTransform3D and the TranslateTransform3D in a Transform3DGroup. That should cut you down to 20'ish BeiginAnimation calls.

Charlie
That really doesnt work, because the Transform3DGroup.BeginAnimation() call takes a single DependencyProperty. And I'm doing a translate transform on the OffsetX property, and a rotation transform on the Angle property. So its still two calls
Turbo