SpriteHand
Module Border
  Silverlight 3: PlaneProjection with StoryBoard
Module Border
Location: BlogsAndy's Blog    
Posted by: host 3/18/2009 2:31 PM

Silverlight 3 introduces a little bit of 3D support out of the box.  Don’t get your hopes up, you’re not going to take what’s provided and write the next best First Person Shooter (although, using Silverlight 3’s GPU Acceleration and you just might J),  but you can do some pretty neat effects in very short order. In ScottGu's keynote at MIX, he showed a nice PlaneProjection with some Physics effects that made the projection "wobble" when clicked with the mouse.

What Silverlight 3 Beta 1 provides is a PlaneProjection, which allows you to rotate a 2D Canvas in 3D space. Here is a quick example. Suppose you have an image that looks like this:

… and then you place that image into a Canvas and add a PlaneProjection with a RotationX value of 50:

<Canvas x:Name="canvas3D" Height="400" Width="600" Background="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Center">

       <Canvas.Projection>

              <PlaneProjection RotationX="50" />

       Canvas.Projection>

       <Image Height="229" Width="234" Canvas.Left="192" Canvas.Top="171" Source="logo.png" Stretch="Fill"/>

Canvas>

This example will display the contents of “canvas3D” rotated at the X axis at 50 degrees, which will look something like this:

Not bad, but the really cool effects come from animating the PlaneProjection. We can use a StoryBoard to change any of the properties of the PlaneProjection and make some nice effects. Let’s use the projection to create a fly-in effect where the image rotates in 3D space up to the user.

We can use a DoubleAnimationUsingKeyFrames to change the RotationX of the Projection. This will make the Canvas Spin. Then we can add a second DoubleAnimation on GlobalOffsetZ, which will make the Canvas Zoom up to the user’s view.

<Storyboard x:Name="Storyboard1">

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="canvas3D" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)">

        <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>

        <EasingDoubleKeyFrame KeyTime="00:00:05" Value="360"/>

    DoubleAnimationUsingKeyFrames>

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="canvas3D" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetZ)">

        <EasingDoubleKeyFrame KeyTime="00:00:00" Value="-30000"/>

        <EasingDoubleKeyFrame KeyTime="00:00:05" Value="0"/>

    DoubleAnimationUsingKeyFrames>

Storyboard>

UserControl.Resources>

 

Here is a demo application showing this animation of PlaneProjection in action:

IMPORTANT: THE FOLLOWING IS A SILVERLIGHT 3 DEMO! SILVERLIGHT 3 IS CURRENTLY IN BETA AND YOU SHOULD ONLY INSTALL SL3 IF YOU ARE A DEVELOPER INTERESTED IN EXPERIMENTING!

[VIEW THE DEMO]  [DOWNLOAD THE SOURCE]

 

Permalink |  Trackback

Comments (2)   Add Comment
Links to Silverlight 3.0 resources    By TrackBack on 3/19/2009 3:26 AM
Links to Silverlight 3.0 resources
# Silverlight Playground

Re: Silverlight 3: PlaneProjection with StoryBoard    By Anonymous on 4/5/2009 12:09 PM
Cool


Title:
Comment:
Add Comment   Cancel 
Module Border Module Border
Module Border
  Subscribe
Module Border
RSS   Twitter
Module Border Module Border
Module Border
  Diversions
Module Border

TALKING RAGDOLL
This Windows Phone 7 App was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine. It gets interesting when you import your friends photos and have your way with them!

MORE INFO



DROPPYPOP
This Windows Phone 7 game was created using Silverlight, the  Physics Helper Library,  and the Farseer Physics Engine.
DEMO

MORE INFO



BOSS LAUNCH
This physics game won first place in the Server Quest Contest. Created using Silverlight 2, the Physics Helper Library,  and the Farseer Physics Engine.
PLAY IT

MORE INFO



DESTROY ALL INVADERS
A scrolling shooter game where the objective is to destroy the invading UFO's flying over a neighborhood of your choosing. Imagery provided by Microsoft Virtual Earth. Created using Silverlight 2.
PLAY IT

INFO AND CODE



PHYSICS HELPER DEMOS
These demos were created for the Physics Helper Library, which makes it easy to create physics games and simulations using Expression Blend, Silverlight, and the Farseer Physics Engine.
PLAY IT

INFO AND CODE



HOOK SHOT
This little basketball game took first place in the TeamZoneSports Silverlight Contest. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SORT THE FOOBARS
A game where you need to sort the good foobars from the bad ones. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



POLYGON PHYSICS DEMO
A demo showing polygon physics where the user draws physics objects with the mouse. Created using Silverlight 2 and the Farseer Physics engine.
PLAY IT

MORE INFO



SILVERLIGHT ROCKS!
Destroy the asteroids before they destroy your ship! Created using Silverlight 2.
PLAY IT

INFO AND CODE



FISH GAME
A simple game of harpoon-the-fish. Written using the AJAX Sprite Toolkit.
PLAY IT

INFO AND CODE

Module Border Module Border
Module Border
  Search_Blog
Module Border
Module Border Module Border
Module Border
  Blog_Archive
Module Border
Module Border Module Border
Copyright (c) 2013 andy.beaulieu.com - Login