As it has already been said, Silverlight platform has
essential limitations on execution environment. Well, there are serious restrictions
on work with 3D in Silverlight. Unlike WPF, in Siliverlight there is work with
3D-projections of 2D-objects organized. Actually, in Silverlight 3 there are no
full 3D objects and scenes, and there are only 3D projections of 2D objects. It
means that it is impossible to load 3D objects from (for example) 3D Max Studio
in Silverlight applications. But this functionality is usually enough for most business
applications.
As well as in any other 3D system, in Silverlight 3 there
are three axes where you can rotate the two-dimensional objects. You can set
the object centre that will be the start point of rotation and bias of the
object. There are two types of object offset - local and global. Local
specifies the positioning of an object in a container. Global offsets or sets
positioning of objects on all windows.
The centre of rotation of an object is set with help of 3D-projection
parameters. It is important to indicate that the centre of an abject is set in
relative coordinates on axes X and Y (by default 0.5), and it is absolute on
axis Z (by default 0).
It is possible to set transformations on several parameters
for one object. Thus, it is possible to turn an object on coordinates X and Y
and to set any global offset. Also, it is possible to transform an object at
once on all three axes.
Figure 1: Direction of axes in Silverlight 3
Projection property is used to set 3D projections for
Silverlight control elements. In Silverlight 3 all control elements have this
property. If there is need to set a 3D projection for an object, you should
initialize this property with PlaneProjection object. In object PlaneProjection
3D, there are transformations on all axes and also local and global biases are
set.
Listing 1 - Button control with 3D-projection
<Button Content="Click me">
<Button.Projection>
<PlaneProjection RotationX="45"
RotationY="15"
RotationZ="90"/>
</Button.Projection>
</Button>
Similarly to this, you can to set transformations to all
control elements in Silverlight 3. And all control elements are still
functional, i.e. we can enter a text, click them, etc. The following example
shows the panel with several TextBox control elements. In this case, 3D
transformations are applied to the root panel, instead of child control
elements. But, if it is necessary, it is possible to apply transformations to
control elements too.
Listing 2 - 3D-projection for StackPanel control
<StackPanel Margin="15">
<StackPanel.Projection>
<PlaneProjection RotationY="-50"/>
</StackPanel.Projection>
<TextBlock Text="First name:"/>
<TextBox />
<TextBlock Text="Last name:"/>
<TextBox />
<TextBlock Text="E-mail:"/>
<TextBox />
</StackPanel>
In this case, we get the user interface as it is shown
below.
Figure 2: 3D-projection for StackPanel control
In this example it is well visible that the controls are
rotated on axis Y on 50 degrees.
PlaneProjection object can be used for appendix animation.
Thus, it is possible to change rotation coordinates on axes or to change the
rotation centre.