XNA 3D Model Viewer

Version: 1.0.0

Description

The new Shared Graphics model in Windows Phone codenamed “Mango” allows an application to seamlessly integrate Silverlight and XNA graphics in a single application. This hands-on-lab will show you how to leverage the SharedGraphicsDeviceManager APIs to display 3D models in a Silverlight application. The lab will also use the new BackgroundTransferService APIs to download the models in the background.

Overview

Windows Phone offers two distinct programming models for user interfaces: Silverlight and XNA. Silverlight is most commonly used for applications that have a lot of controls, display a lot of data, or do a lot of textual data entry. XNA is most commonly used for 2D and 3D games. Though you can certainly write games with Silverlight and you can write data-centric applications with XNA, each framework is optimized for its respective scenarios; leveraging the right model for your app should provide you with the most productivity and improved time to market.

In the Windows Phone 7 release, you had to choose a framework for your application and stick within that model. The Windows® Phone Codenamed Mango release significantly improves the integration between the two frameworks. In Windows® Phone Codenamed Mango, Silverlight applications can embed XNA models and XNA applications can embed Silverlight elements. In both cases, a great effort was made to preserve the advantages of each framework to get the best of both worlds. For example, before Windows Phone Codenamed Mango, application developers had difficulty rendering fonts with XNA, especially in different sizes or using non-Latin alphabets. The UIElementRenderer, discussed in this lab, offers a compelling solution to this problem. You can use a UIElementRenderer to render Silverlight TextBlock elements (or other elements with text) in any shape or size. The text will be rendered as an XNA texture with Silverlight’s advanced typography features and vector graphics.

Windows Phone Codenamed Mango also supports a new background transfer service that runs independently of your application. Transfers can continue while your application is inactive or when users navigate between different pages.

This lab shows how to use the background transfer service to downloaded embedded XNA models.

Objectives

This lab provides instructions to help you achieve the following:

  • Write an application that uses the background transfer service
  • Embed a 3D XNA model in a Silverlight application

Prerequisites

The following prerequisites ensure you get the best results possible from this hands-on lab:

Lab Structure

This lab includes a single exercise with the following tasks:

  1. Use the background transfer service.
  2. Embed a 3D XNA model into a Silverlight application.

Estimated completion time

Completing this lab should take from 15 to 30 minutes.