SpriteFont relies on SpriteBatch to draw and needs a font definition from the ContentManager:

SilverlightEffect

The toolkit introduces a new class called SilverlightEffect which can be used to apply .fx files.

It also support .slfx which is the default extension. There is no difference between .slfx and .fx but as XNA Effect Processor is already associated with .fx, the Silverlight Content Pipeline had to select another one.

You can now define a complete effect inside a Content project and use it for rendering your models.

To do so:

Create a .fx file with a least one technique

Shader entry points must be parameterless

Define render states

For example here is a simple .fx file:

float4x4 WorldViewProjection;

float4x4 World;

float3 LightPosition;

// Structs

struct VS_INPUT

{

float4 position : POSITION;

float3 normal : NORMAL;

float4 color : COLOR0;

};

struct VS_OUTPUT

{

float4 position : POSITION;

float3 normalWorld : TEXCOORD0;

float3 positionWorld : TEXCOORD1;

float4 color : COLOR0;

};

// Vertex Shader

VS_OUTPUT mainVS(VS_INPUT In)

{

VS_OUTPUT Out = (VS_OUTPUT)0;

// Compute projected position

Out.position = mul(In.position, WorldViewProjection);

// Compute world normal

Out.normalWorld = mul(In.normal,(float3x3) WorldViewProjection);

// Compute world position

Out.positionWorld = (mul(In.position, World)).xyz;

// Transmit vertex color

Out.color = In.color;

return Out;

}

// Pixel Shader

float4 mainPS(VS_OUTPUT In) : COLOR

{

// Light equation

float3 lightDirectionW = normalize(LightPosition - In.positionWorld);

float ndl = max(0, dot(In.normalWorld, lightDirectionW));

// Final color

returnfloat4(In.color.rgb * ndl, 1);

}

// Technique

technique MainTechnique

{

pass P0

{

VertexShader = compile vs_2_0 mainVS(); // Must be a non-parameter entry point

PixelShader = compile ps_2_0 mainPS(); // Must be a non-parameter entry point

}

}

The Toolkit will add required processors to the Content Pipeline in order to create the .xnb file for this effect:

To use this effect, you just have to instantiate a new SilverlightEffect inside your code:

Texture2D, TextureCube & SoundEffect

Silverlight 5 provides Texture2D, TextureCube and SoundEffect classes. With the Toolkit, you will be able to load them from the ContentManager:

// Load overlay textures

winOverlay = contentManager.Load<Texture2D>("Overlays/you_win");

// Music

backgroundMusic = contentManager.Load<SoundEffect>("Sounds/Music");

Mouse and Keyboard

In order to facilitate porting existing 3D applications and to accommodate polling input application models, we also added partial support for Microsoft.Xna.Framework.Input namespace.

So you will be able to request MouseState and KeyboardState everywhere you want:

public MainPage()

{

InitializeComponent();

Mouse.RootControl = this;

Keyboard.RootControl = this;

}

However, there is a slight difference from original XNA on other endpoints: you have to register the root control which will provide the events for Mouse and Keyboard. The MouseState positions will be relative to the upper left corner of this control:

Extensibility

Silverlight Content Pipeline can be extended the same way as the XNA Content Pipeline on other endpoints. You can provide your own implementation for loading assets from elsewhere than the embedded .xnb files.

For example you can write a class that will stream .xnb from the network. To do so, you have to inherit from ContentManager and provide your own implementation for OpenStream:

publicclassMyContentManager : ContentManager

{

public MyContentManager() : base(null)

{

}

protectedoverride System.IO.Stream OpenStream(string assetName)

{

returnbase.OpenStream(assetName);

}

}

You can also provide our own type reader. Here is for example the custom type reader for SilverlightEffect:

Primitives3D

Platformer

This sample is a complete game with 3 levels provided (you can easily add yours). It shows the usage of SpriteBatch, SpriteFont and SoundEffect inside a platform game. It also uses Keyboard class to control the player.

SimpleAnimation

This sample shows how to apply program controlled rigid body animation to a 3D model loaded with the ContentManager:

Skinning

This sample shows how to process and render a skinned character model using the Content Pipeline.

Conclusion

As you noticed, all these new additions to the Silverlight Toolkit are made to make it easy to get started with new Silverlight 3D features by providing developer tools to improve usability and productivity.

You can now easily start a new project that leverages both concepts of XNA and Silverlight. It becomes easy to work with 3D concepts and resources like shaders, model, sprites, effects, etc...

We also try to reduce the effort to port existing 3D applications to Silverlight.

So now it’s up to you to discover the wonderful world of 3D using Silverlight 5!

I'm a bit stumped about why you added all this 3D stuff but then disabled it from a general user's point of view? The fact that you have to jump through hoops to get the user to enable 3D for the web site means it just can't be used at all. So why go to the effort of doing all this work but then not enable it? Totally confused.