Is there a BeforeRendering event or similar, where I can modify my objects before each frame?

Nov 5, 2010 at 8:15 AM
Edited Nov 5, 2010 at 8:15 AM

I'd like to apply a custom world matrix to some objects before rendering each frame, as part of an animation. However, I cannot find an appropriate event exposed for this. What would be the best way to approach this scenario?

Nov 5, 2010 at 8:27 AM
Edited Nov 5, 2010 at 8:27 AM

There is an event called Update on the Game  that you can hook into.

Nov 5, 2010 at 9:02 AM
Edited Nov 5, 2010 at 9:03 AM

If you want to animate things like Position, Rotation or Scale or any of the other properties of an object, you can use Storyboards as well. There is a Storyboard extension that allows you to easily animate the Position, Rotation and Scale types, which are of type Coordinate.

E.g. : 


<Grid x:Name="LayoutRoot">
		<EventTrigger RoutedEvent="Grid.Loaded">
				<Storyboard RepeatBehavior="Forever">
						<Animation:CoordinateAnimation From="0,0,0" To="0,359,0" Duration="00:00:10" TargetName="Box" TargetProperty="(Node.Rotation)"/>


And just add the namespace at the top : 



Nov 5, 2010 at 1:23 PM

Thanks, Update covers my needs nicely.

I'm not able to use the built-in properties, since my animation involves multiplying multiple rotation matrices. Hmm... I wonder if it would be possible to create an animation type for something like that. For example, make World also take a MultiplyingMAtrix that has multiple child matrices, which can be animated. Might work...

But it's actually simpler for me to use the Update method, so I'm not sure how useful that scenario would be.