Dot Net Solutions
George V Place,
4 Thames Avenue
Windsor
Berkshire
SL4 1QP
Great Britain
0845 402 1752
GEO: -0.606174, 51.4843
 
 
 
 

Animated 3D Panels in Silverlight 3 

Along with using the out of the box Grid, StackPanel, Canvas etc. in Silverlight 2 you could create your own custom panel types to perform arbitrary layout. With Silverlight 3 you can combine custom panels together with the PlaneProjection to layout elements in 3D space. I’ll show you how.

First, having 3D elements jump from position to position is incredibly disconcerting. Its difficult to track the objects and so destroys the 3D illusion being created.

AnimatingProjectionPanelBase is the start point for understanding this – it uses similar techniques to animated 2D panels (here and here), but applies them to a Silverlight 3 PlaneProjection.

To make use of it, create a new panel deriving from this type e.g.

public class ProjectionOffsetPanel : AnimatingProjectionPanelBase

then in the ArrangeOverride(Size finalSize) function, call the provided SetLocation method on each child.

protected override Size ArrangeOverride(Size finalSize)
{
    foreach (UIElement child in Children)
    {
        PlaneProjection projection = CreateYourPlaneProjection(…);
        base.SetLocation(child, yourDefaultProjection, projection);
    }
    return finalSize;
}

The sample code includes two panels that make use of this.

ProjectionOffsetPanel allows you to layout elements by setting a start projection that is applied to the first element, and adding an offset to each each subsequent element.

<three:ProjectionOffsetPanel> 
    <
three:ProjectionOffsetPanel.ProjectionZero>
        <
PlaneProjection
            
RotationY="37"
            
GlobalOffsetY="208"
            
GlobalOffsetX="236"
            
RotationX="-28"
            
RotationZ="-3" />
    </
three:ProjectionOffsetPanel.ProjectionZero>
    <
three:ProjectionOffsetPanel.ProjectionOffset>
        <
PlaneProjection
            
RotationY="0.5"
            
GlobalOffsetY="-20"
            
GlobalOffsetZ="-20" />
    </
three:ProjectionOffsetPanel.ProjectionOffset>

this gives an effect similar to the Windows Vista Flip3D feature

ProjectionOffsetExample

ProjectionPathPanel arranges elements along a path in 3D space that is defined by fixed points along this path, each point can be set up from xaml

<three:ProjectionPathPoint Position="0" > 
    <
three:ProjectionPathPoint.Projection>
        <
PlaneProjection
            
GlobalOffsetX="236"
            
GlobalOffsetY="208"
            
GlobalOffsetZ="25"
            
RotationX="-28"
            
RotationY="37"
            
RotationZ="-3" />
    </
three:ProjectionPathPoint.Projection>
</
three:ProjectionPathPoint>

This allows arbitrary 3D paths to be laid out on screen

ProjectionPath 

As these present as Silverlight Panels, both can be used in Expression Blend and support use either to hold static content but they really light up when used with a databound  ObservableCollection into which you are adding and removing content.

Download the sample.

Published: 22 Jul 2009  05:27
0  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:        

Links to this post

No linkbacks added

Comments

No comments added yet

 
 
 
 

Post comment

Name *:
URL:
Email:
Comments:


CAPTCHA Image Validation