3D Game Development with Microsoft Silverlight 3

3D Game Development with Microsoft Silverlight 3

Most online interactive content uses 2D graphics. To represent real-life situations, Rich
Internet Applications (RIAs) need to show real-time 3D scenes. This book will let you
add a new dimension to your Silverlight applications using C# and XAML. The book
covers the various tools and libraries needed for giving life to 3D models in a Silverlight
viewport—right from editing, exporting, loading, and controlling 3D models up to
specific 3D algorithms. It will help you learn to develop 3D games and interactive 3D
scenes for a web site with animated models, with numerous examples and clear
explanations packed with screenshots to aid your understanding of every process. After
all of the code is written and the additional art assets edited, they are all compressed into
.zip files for easy availability and use.

What This Book Covers

Chapter 1: Lights, Camera, and Action!: In this chapter, we will cover many topics that
will help us to understand the new tools and techniques involved in preparing 2D
graphics to be used in Silverlight games. This chapter is all about tools and graphics.

Chapter 2: Working with 2D Characters: In this chapter, we will begin creating 2D
characters that move on the screen and we will learn to control their behavior in the 2D
space. We will learn about GPU hardware acceleration, 2D vectors, resolutions, sprites,
and animation.

Chapter 3: Combining Sprites with Backgrounds: In this chapter, we will control
multiple sprites created on demand. We will animate several independent sprites at the
same time, while responding to the keys pressed by the player to control characters and
some game logic.

Chapter 4: Working with 3D Characters: In this chapter, we will take 3D elements from
popular and professional 3D DCC tools and we will show them rendered in real-time on
the screen. We will learn a lot about 3D models, meshes, and 3D engines.

Chapter 5: Controlling the Cameras: Giving Life to Lights and Actions: In this chapter,
we will learn everything we need to know about 3D cameras to be able to render our
models in real-time on a 2D screen from different angles. We will change the values
for their most important properties and we will be able to watch their effects in a
rendered 3D view.

Chapter 6: Controlling Input Devices to Provide Great Feedback: In this chapter, we will
learn everything we need to know about the most widely used gaming input devices. We
will be able to read values from them in order to control many aspects of our games.

Chapter 7: Using Effects and Textures to Amaze: In this chapter, we will learn everything
we need to know about the process of enveloping a 3D model using textures. We will
be able to take 3D elements from popular and professional 3D DCC tools and we will
show them rendered in real-time on the screen with different textures and enlightened
by many lights.

Chapter 8: Animating 3D Characters: In this chapter, we will learn how to move, rotate,
and scale the 3D models in the 3D scenes. We will use object-oriented capabilities to
define independent behaviors for simple and complex 3D characters.

Chapter 9: Adding Realistic Motions Using a Physics Engine: In this chapter, we will
simulate some laws of 2D and 3D physics. We will learn to define gravity force, mass,
drag coefficients, and moment of inertia to represent the physical properties of the bodies
that define a model.

Chapter 10: Applying Artificial Intelligence: In this chapter, we will detect collisions
between 3D characters and we will define specific behaviors using artificial intelligence,
persecution, and evasion algorithms

Chapter 11: Applying Special Effects: In this chapter, we will use advanced physics and
special effects. We will generate gravity effects, we will add fluids with movements, and
we will use transitions to determine different states in a game.

Chapter 12: Controlling Statistics and Scoring: In this chapter, we will create gadgets to
display different kinds of information to the player on the screen. We will also calculate
different kinds of information in order to update the gauges. Also, we will measure and
improve the game’s overall performance.

Chapter 13: Adding Environments and Scenarios: In this chapter, we will create menus
and attractive transitions. We will add configuration options and we will save them using
an isolated storage.

Chapter 14: Adding Sound, Music, and Video: In this chapter, we will generate sounds
associated to game events. We will also add presentation videos and background music.

Appendix: Pop Quiz Answers: This appendix will include answers to all the pop quiz
questions chapter-wise.

Adding Sound, Music, and Video

	A game needs sound, music and video. It has to off er the player att ractive
	background music. It must also generate sounds associated with certain game
	events. When a spaceship shoots a laser beam, a sound must accompany
	this action. Reproducing videos showing high-quality previously rendered
	animations is a good idea during transitions between one stage and the next.

In this chapter we will add sounds, music and videos to the game. By reading this chapter
and following the exercises we will learn how to:

  • Add background music to the game
  • Generate sounds associated to the game events
  • Take advantage of multiple channel audio
  • Control the reproduction of concurrent sounds
  • Organize the media elements for the game
  • Prepare our media elements for their use in Silverlight applications
  • Take advantage of Silverlight 3 performance enhancements for videos
  • Reproduce videos combined with animated projections

Hear the UFOs coming

So far, we have worked with 3D scenes showing 3D models with textures and different
kinds of lights. We took advantage of C# object-oriented capabilities and we animated 3D
models and moved the cameras. We have read values from many different input devices
and we added physics, artificial intelligence, amazing effects, gauges, statistics, skill levels,
environments, and stages. However, the game does not use the speakers at all because there
is no background music and there are no in-game sounds. Thus, we have to sort this issue
out. Modern games use videos to dazzle the player before starting each new stage. They use
amazing sound effects and music custom prepared for the game by renowned artists. How
can we add videos, music, and sounds in Silverlight?

	We can do this by taking advantage of the powerful multimedia classes off ered
	by Silverlight 3. However, as a game uses more multimedia resources than
	other simpler applications, we must be careful to avoid including unnecessary
	resources in the files that must be downloaded before starting the application.

Time for action – installing tools to manipulate videos

The 3D digital artists used Blender to create an introductory video showing a high quality
rendered animation for five seconds. They took advantage of Blender’s animation creation
features, as shown in the following screenshot:

A spaceship flies in a starry universe for a few seconds. Then, the camera navigates through
the stars.

Your project manager wants you to add this video as an introduction to the game. However,
as the video file is in AVI (Audio Video Interleave) format and Silverlight 3 does not support
this format, you have to convert the video to an appropriate format.

	The creation of video animations for a game is very complex and
	requires specialist skills. We are going to simplify this process by
	using an existing video.

First, we must download and install an additional tool that will help us in converting an
existing video to the most appropriate file formats used in Silverlight 3:

	The necessary tools will depend on the applications the digital
	artists use to create the videos. However, we will be using some
	tools that will work fine with our examples.

  1. Download one of the following files:
  2. Run the installers and follow the steps to complete the installation wizards.
  3. If you installed Expression Encoder 2, download and install its Service Pack 1.
    The download link for it is http://www.microsoft.com/expression/tryit/
    try-it-v2.aspx#encodersp1 file name—EncoderV2SP1_en.exe.
  4. Once you have installed one of the versions of Expression Encoder, you will
    be able to load and encode many video files in different file formats, as shown in
    the following screenshot:

What just happened?

We installed Expression Encoder. Now we have the necessary tool to convert existing video
clipart to the most appropriate file formats to use in Silverlight 3.

Pages: 1 2 3 4 5

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!