Logo
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
EPL Standings
 
 
Windows Phone

Developing for Windows Phone and Xbox Live : Custom Avatar Animations (part 3)

8/18/2011 5:07:21 PM

Adding the Custom Animation to Your Game

Now that the processor is done, add a reference to the CustomAvatarAnimationPipelineExtension project to the content project. Expand the AvatarCustomAnimationSampleContent project. Right-click the References list and select Add Reference. Select the Projects tab and select the CustomAvatarAnimationPipelineExtension project. Next, add the animation you built to the content project. Right-click the AvatarCustomAnimationSampleConent project and select Add -> Existing Item. Locate the animation fbx file that you created in your 3D content creation package and click the Add button.

With the new content item added to the content project, we n change the processor to use when building the content item. Click the animation fbx file in the content project and locate the properties panel. Under the properties panel, in Content Processor, click the drop-down and select CustomAvatarAnimationProcessor as shown in Figure 7.

Figure 7. Selecting the CustomAvatarAnimationProcessor content processor

The sample project, AvatarCustomAnimationSample, is an Xbox 360 project, but it should use the types you created previously in the CustomAvatarAnimationWindows project. To use these types, build them as a library for the Xbox 360. Fortunately, this is a common scenario and an easy way to create the Xbox 360 version of the library. Right-click the CustomAvatarAnimationWindows project and select the Create Copy of Project for Xbox 360 menu option as shown in Figure 8.

Figure 8. Creating copy of a project for Xbox 360

After the new project is created, rename the project CustomAvatarAnimationXbox. Your AvatarCustomAnimationSample project now needs a reference to the new project, so expand the AvatarCustomAnimationSample project and right-click the Reference list. Select the Add Reference menu item. Click the Projects tab and select the CustomAvatarAnimationXbox project.

Updating Your Game to Use the Custom Animation

You need to make only a few minor updates to use the new custom animation type.

First, add the namespace you used for the custom animation types by adding the following line to your game class file:

using CustomAvatarAnimation;

Next, you need a member variable to store the custom animation. Add the following member variable to your Game class:

AvatarCustomAnimation customAvatarAnimation;

To load the AvatarCustomAnimation, add the following lines to your LoadContent method:

// Load the custom animation
CustomAvatarAnimationData animationData =
Content.Load<CustomAvatarAnimationData>("CustomAnimation");
customAvatarAnimation = new AvatarCustomAnimation(animationData);

The fbx file is converted into a CustomAvatarAnimationData using the custom content pipeline processor. Then, use the ContentManager to load the file. You can then create a AvatarCustomAnimation instance using the CustomAvatarAnimationData.

Now, you can use the AvatarCustomAnimation just like you use an AvatarAnimation. In the game’s Update method, call the animations Update method. Add the following to your game’s Update method:

customAvatarAnimation.Update(gameTime.ElapsedGameTime, true);

The final step is to use the animation with the AvatarRenderer Draw method. Add the following to your game’s Draw method.

avatarRenderer.Draw(customAvatarAnimation);

Running the sample now shows a random avatar playing back your custom animation. Figure 9 shows the avatar playing the custom animation created for this sample.

Figure 9. Custom animation playing on the avatar

Top Search -----------------
- Windows Server 2008 R2 : Work with RAID Volumes - Understand RAID Levels & Implement RAID
- Windows Server 2008 R2 Administration : Managing Printers with the Print Management Console
- Configuring Email Settings in Windows Small Business Server 2011
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Implement Permissions
- Monitoring Exchange Server 2010 : Monitoring Mail Flow
- Windows Server 2008 R2 :Task Scheduler
- Windows Server 2008 R2 : File Server Resource Manager
- Windows Server 2008 R2 : Installing DFS
- Exchange Server 2010 : Managing Anti-Spam and Antivirus Countermeasures
- Windows Server 2008 R2 : Configuring Folder Security, Access, and Replication - Share Folders
Other -----------------
- Windows Phone 7 : Sensors - Displaying Sunset and Sunrise
- Windows Phone 7 : Sensors - Indicating the User's Position?
- Windows Phone 7 : Sensors - Creating a Seismograph
- Developing for Windows Phone and Xbox Live : Avatars Using Render Targets
- Developing for Windows Phone and Xbox Live : Interacting with Objects
- Windows Phone 7 : Resetting a form by shaking the phone!
- Developing for Windows Phone and Xbox Live : Blending Between Animations
- Managing Gestures from the Silverlight for Windows Phone 7 Toolkit
- Windows Phone 7 : Handling Gestures in a Graphical Context Such as a Game Menu
- Developing for Windows Phone and Xbox Live : Modifying Avatar Lighting & Playing Multiple Animations
 
 
Most view of day
- Microsoft Exchange Server 2010 : Setting Up Transport Rules (part 3) - Selecting Actions
- Microsoft Dynamics CRM 4 : Digital Phone Integration (part 2) - Cisco Unified CallConnector for Microsoft Dynamics CRM
- What's new and improved in SharePoint 2013 : Creating a new site
- Preparing and Configuring Boot Images (part 2) - Adding Drivers to a Boot Image
- Microsoft Dynamics CRM 4.0 : Infrastructure Design Considerations - Windows SharePoint Integration
- Working with the Windows Home Server Registry : Finding Registry Entries
- Duplicating and Copying DVDs (part 2) - Ripping DVDs to the PC
Top 10
- Windows Server 2012 : Managing networking using Windows PowerShell (part 2) - Examples of network-administration tasks
- Windows Server 2012 : Managing networking using Windows PowerShell (part 1) - Identifying networking cmdlets
- Sharepoint 2013 : Managing Site Security - Create Permission Levels for a Site
- Sharepoint 2013 : Managing Site Security - Edit a SharePoint Group’s Settings
- Sharepoint 2013 : Managing Site Security - Create a SharePoint Group for a Site
- Sharepoint 2013 : Assign Users’ Permissions on a Site
- Sharepoint 2013 : Get to a Site’s Permission Management Page (part 2) - Check What Permissions a User or a Group Has on a Site
- Sharepoint 2013 : Get to a Site’s Permission Management Page (part 1)
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 4) - Automating mailbox settings,Ready-to-go custom attributes
- Microsoft Exchange Server 2013 : Creating new mailboxes (part 3) - Default folders, Manipulating mailbox settings
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
Cars Review