You are previewing 3D Game Development with Microsoft Silverlight 3 Beginner's Guide.
O'Reilly logo
3D Game Development with Microsoft Silverlight 3 Beginner's Guide

Book Description

A practical guide to creating real-time responsive online 3D games in Silverlight 3 using C#, XBAP WPF, XAML, Balder, and Farseer Physics Engine

  • Develop online interactive 3D games and scenes in Microsoft Silverlight 3 and XBAP WPF

  • Integrate Balder 3D engine 1.0, Farseer Physics Engine 2.1, and advanced object-oriented techniques to simplify the game development process

  • Enhance development with animated 3D characters, sounds, music, physics, stages, gauges, and backgrounds

  • Packed with inspiring, realistic examples offering impressive graphics, strong performance, and a rich interactive experience

In Detail

Microsoft Silverlight is a programmable web browser plug-in that enables the animation, vector graphics, and audio-video playback features that characterize Rich Internet Applications. Silverlight is a great (and growing) RIA platform and games are the next level to exploit in it. But it doesn't offer 3D capabilities out of the box and integrating a 3D engine can involve lot of complex mathematics and matrix algebra. This book will help C# developers to get their fingers on the pulse of 3D in Silverlight.

This book uses Balder, an open source 3D engine offering 3D capabilities for Silverlight 3. It leaves out boring matrix algebra and complex 3D mathematics. By the end of the book you will have explored the entire engine, and will be able to design and program your own 3D games with ease!

The book begins by introducing you to the fundamental concepts of 2D games and then drives you into the 3D world, using easy-to-follow, step-by-step examples. The book employs amazing graphics and impressive performance, and increasingly adds more features to a 3D game giving you a rich interactive experience.

By following the practical examples in this book, you will learn the important concepts, from the creation of the initial models, up to the addition of physics and artificial intelligence.

The book helps you to provide realistic behaviors for 3D characters by enveloping models with different textures, using lights to create effects, animating multiple 3D characters using a physics engine (Farseer Physics Engine), and simulating real-life physics. Videos, music, and sounds associated with specific events offer the final touches to the 3D game development learning experience.

Table of Contents

  1. 3D Game Development with Microsoft Silverlight 3 Beginner's Guide
    1. 3D Game Development with Microsoft Silverlight 3 Beginner's Guide
    2. Credits
    3. About the Author
    4. Acknowledgement
    5. About the Reviewer
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code for the book
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Lights, Camera, and Action!
      1. UFOs in the sky!: Invaders
      2. Time for action—preparing the development environment
        1. What just happened?
      3. Time for action—recognizing digital art assets
        1. What just happened?
      4. Time for action—creating the raster digital content
        1. What just happened?
        2. Digital Content Creation tools
        3. Basic elements of a 2D and/or 3D real-time game
        4. Programming responsibilities
      5. Time for action—installing tools to manipulate scalable digital content
        1. What just happened?
        2. XAML works fine with Silverlight 3
      6. Time for action—creating the scalable digital content in XAML
        1. What just happened?
        2. Previewing and scaling XAML vector graphics
      7. Time for action—testing the scalable digital content using XamlPad
        1. What just happened?
        2. Editing vector illustrations using Expression Design
        3. Have a go hero—preparing scalable digital content for a new remake
      8. Preparing a gaming framework
      9. Time for action—creating Silverlight applications
        1. What just happened?
      10. Time for action—building and running Silverlight applications
        1. What just happened?
        2. Programming event handlers in the main page
      11. Time for action—creating XBAP WPF applications
        1. What just happened?
      12. Time for action—building and running the XBAP WPF applications
        1. What just happened?
        2. Have a go hero—creating a prototype for the remake
        3. Pop quiz—preparing the digital content
      13. Summary
    8. 2. Working with 2D Characters
      1. Creating an accelerated graphics viewport
      2. Time for action—enabling hardware acceleration
        1. What just happened?
      3. Time for action—transforming media using the GPU
        1. What just happened?
        2. Caching rendered content
        3. Scaling and rotating a vector-based illustration
      4. Time for action—shaking many illustrations at the same time
        1. What just happened?
        2. Running loops faster
        3. Accelerating transforms and blends
        4. Using 2D vectors
      5. Time for action—detecting GPU-acceleration problems
        1. What just happened?
        2. Understanding GPU acceleration limitations
      6. Creating encapsulated object-oriented characters
      7. Time for action—creating User Control classes to hold images
        1. What just happened?
      8. Time for action—displaying images and sprites
        1. What just happened?
        2. Showing a sprite on the screen
        3. Defining the behavior
        4. Understanding dimensions
        5. Managing resolutions
        6. Screen resolutions
        7. Have a go hero—completing the animation
        8. Pop quiz—working with sprites and the GPU
      9. Summary
    9. 3. Combining Sprites with Backgrounds
      1. The first remake assignment
      2. Time for action—creating sprites based on XAML vector-based graphics
        1. What just happened?
        2. Defining the relative center point
      3. Time for action—creating a specialized sprite management class
        1. What just happened?
        2. Taking full advantage of object-oriented capabilities
        3. Preparing the classes for inheritance
        4. Wrapping a UserControl to manage it
      4. Time for action—creating a superclass for some characters
        1. What just happened?
      5. Time for action—creating the subclasses for the characters
        1. What just happened?
      6. Time for action—creating methods for the game loop
        1. What just happened?
        2. Creating objects on the fly
        3. Managing dynamic objects
      7. Time for action—writing the game loop
        1. What just happened?
        2. Animating multiple sprites
        3. Managing a complex game loop
      8. Time for action—detecting collisions between 2D characters
        1. What just happened?
        2. Using colors to paint sprites
        3. Have a go hero—using backgrounds
        4. Have a go hero—preparing Invaders 3000
        5. Pop quiz—simplifying game loops
      9. Summary
    10. 4. Working with 3D Characters
      1. The second remake assignment
      2. Time for action—exporting a 3D model without considering textures
        1. What just happened?
        2. XAML 3D models
      3. Time for action—from DCC tools to WPF
        1. What just happened?
        2. XBAP WPF applications with 3D content
      4. Time for action—displaying a 3D model in a 2D screen with WPF
        1. What just happened?
        2. Understanding the 3D world
        3. X, Y, and Z in practice
        4. GPU 3D acceleration
        5. Understanding meshes
      5. Time for action—using other XAML exporter for DCC tools
        1. What just happened?
      6. Time for action—adding 3D elements and interacting with them using Expression Blend
        1. What just happened?
        2. Interacting with 3D elements using Expression Blend
      7. Silverlight and the 3D world
      8. Time for action—exporting a 3D model to ASE
        1. What just happened?
      9. Time for action—installing Balder 3D engine
        1. What just happened?
      10. Time for action—from DCC tools to Silverlight
        1. What just happened?
        2. Displaying a 3D model in a 2D screen with Silverlight
        3. Using 3D vectors
        4. Have a go hero—working with multiple 3D characters
        5. Pop quiz—3D models and real-time rendering
      11. Summary
    11. 5. Controlling the Cameras: Giving Life to Lights and Actions
      1. Understanding 3D cameras
      2. Time for action—when seeing is believing
        1. What just happened?
        2. Controlling the position, the direction, and the up vector
      3. Time for action—performing transformations
        1. What just happened?
        2. Defining and applying transformations
      4. Time for action—zooming in and out
        1. What just happened?
        2. Controlling the perspective field of view
        3. Controlling the clipping planes
      5. Time for action—understanding perspective and orthographic cameras
        1. What just happened?
        2. Have a go hero—rotating cameras around a 3D model
      6. Silverlight and the cameras
      7. Time for action—controlling cameras on the fly
        1. What just happened?
        2. Understanding cameras related to matrixes
        3. Have a go hero—working with many cameras
        4. Pop quiz—working with cameras in a 3D world
      8. Summary
    12. 6. Controlling Input Devices to Provide Great Feedback
      1. Giving life to the game!
      2. Time for action—creating a keyboard manager class
        1. What just happened?
        2. Using the keyboard
      3. Time for action—programming the input control in the game loop
        1. What just happened?
      4. Time for action—mapping a gamepad to the keyboard
        1. What just happened?
        2. Understanding the gamepad as an input device
      5. Time for action—using the gamepad
        1. What just happened?
      6. Time for action—creating a mouse manager class
        1. What just happened?
        2. Using the mouse
      7. Time for action—using the mouse manager in the game loop
        1. What just happened?
      8. Time for action—using the gamepad as a mouse
        1. What just happened?
      9. Time for action—rotating cameras using input devices
        1. What just happened?
        2. Have a go hero—taking full advantage of the gamepad
      10. Bridging with DirectInput capabilities
      11. Time for action—installing the necessary SDKs
        1. What just happened?
        2. Considering deployment's additional requirements
      12. Time for action—understanding sticks and buttons
        1. What just happened?
        2. Understanding the steering wheel as an input device
      13. Time for action—testing the input devices with a DirectInput wrapper
        1. What just happened?
        2. Understanding the analog axis for a steering wheel
        3. Understanding the analog axis for a gamepad
      14. Time for action—adapting a joystick manager class
        1. What just happened?
      15. Time for action—using the steering wheel in the game loop
        1. What just happened?
        2. Using the joystick manager
        3. Working with many input devices
        4. Using other input devices
        5. Have a go hero—using the Wiimote
        6. Have a go hero—working with time, analog and digital values
        7. Pop quiz—working with gaming input devices
      16. Summary
    13. 7. Using Effects and Textures to Amaze
      1. Dressing characters using textures
      2. Time for action—adding textures in DCC tools
        1. What just happened?
      3. Time for action—exporting 3D models from DCC tools to Silverlight
        1. What just happened?
        2. Displaying a 3D model using textures in a 2D screen with Silverlight
      4. Time for action—enveloping 3D models
        1. What just happened?
        2. Understanding textures
        3. Repeating textures as tiles
      5. Time for action—replacing textures
        1. What just happened?
        2. Have a go hero—playing with textures
      6. Displaying lights, shadows, materials, and textures
      7. Time for action—working with lights and understanding shadows
        1. What just happened?
        2. Understanding different kinds of lights
        3. Have a go hero—creating effects using lights
        4. Pop quiz—working with textures, materials, and lights
      8. Summary
    14. 8. Animating 3D Characters
      1. Invaders 3D
      2. Time for action—adding a UFO
        1. What just happened?
      3. Time for action—creating a new game superclass to generalize time management capabilities
        1. What just happened?
      4. Time for action—specializing a game superclass
        1. What just happened?
      5. Time for action—creating a subclass for a 3D character
        1. What just happened?
        2. Using an Actor to represent a 3D character
      6. Time for action—adding an Actor to the game
        1. What just happened?
        2. Moving 3D characters as Actors
      7. Time for action—rotating 3D characters
        1. What just happened?
        2. Using the World matrix in order to perform transformations to meshes
        3. Performing compound transformations
      8. Time for action—scaling 3D characters
        1. What just happened?
        2. Using the World matrix in order to scale meshes
        3. Have a go hero—creating a specialized XAML 3D character wrapper class
      9. Using bones and skeletons
      10. Time for action—animating models with skeletons and bones
        1. What just happened?
        2. Using skeletons and bones
      11. Time for action—adding an Actor with skeletons and bones to the game
        1. What just happened?
        2. Understanding complex 3D animation techniques
        3. Have a go hero—aliens walking
        4. Pop quiz—animating 3D characters in a scene
      12. Summary
    15. 9. Adding Realistic Motions Using a Physics Engine
      1. Using physical principles in games to beat invaders
      2. Time for action—installing Farseer Physics Engine
        1. What just happened?
      3. Time for action—adding parallel physics bodies and geometries to 3D characters
        1. What just happened?
        2. Creating bodies
        3. Creating geometries
        4. Updating a 3D model according to the associated body's properties
      4. Time for action—working with forces, impulses, acceleration and speed
        1. What just happened?
        2. Specifying the gravitational force
        3. Applying forces
        4. Applying impulses
        5. Working with a 2D physics simulator in the game loop
      5. Time for action—working with torques and rotations
        1. What just happened?
        2. Applying torques
        3. Translating 2D physics to a 3D world
        4. Working with Farseer Physics Engine in XBAP WPF applications
        5. Have a go hero—circles are not rectangles
        6. Have a go hero—applying particle systems
        7. Pop quiz—working with bodies, geometries, and physics
      6. Summary
    16. 10. Applying Artificial Intelligence
      1. Detecting collisions between 3D characters
      2. Time for action—adding a second UFO
        1. What just happened?
      3. Time for action—detecting collisions between 3D characters
        1. What just happened?
        2. Working with advanced responses to collisions
        3. Controlling collision moments using events
        4. Working with collision categories
        5. Using engines to improve collision detection precision
        6. Have a go hero—3D Moon Lander
      4. Using artificial intelligence in games to control 3D characters
      5. Time for action—using chasing algorithms
        1. What just happened?
        2. Working with states for the characters
        3. Pursuing an enemy
        4. Generating and controlling random situations
      6. Time for action—using evasion algorithms
        1. What just happened?
        2. Evading an enemy
        3. The advantages of using an AI engine
        4. Have a go hero—adding complex AI algorithms
        5. Pop quiz—working with collision detection and artificial intelligence
      7. Summary
    17. 11. Applying Special Effects
      1. Working with 3D characters in the background
      2. Time for action—adding a transition to start the game
        1. What just happened?
      3. Time for action—creating a low polygon count meteor model
        1. What just happened?
      4. Time for action—from 3D Studio Max to Silverlight
        1. What just happened?
      5. Time for action—creating a subclass for a 3D meteor
        1. What just happened?
      6. Time for action—creating and controlling a meteor rain
        1. What just happened?
        2. Advantages of using multiple physics engines
      7. Time for action—simulating fluids with movement
        1. What just happened?
        2. Simulating waves
      8. Time for action—creating a subclass for a complex asteroid belt
        1. What just happened?
        2. Using an Actor to represent a wave in the background
      9. Time for action—adding an asteroid belt background to the game
        1. What just happened?
        2. Working with encapsulated physics controllers
        3. Have a go hero—adding dissolutions, fire, smoke, and explosions
        4. Pop quiz—working with special effects
      10. Summary
    18. 12. Controlling Statistics and Scoring
      1. Showing gauges and scorecards
      2. Time for action—using special fonts
        1. What just happened?
        2. Embedding fonts in the project
      3. Time for action—creating a score gauge showing text
        1. What just happened?
        2. Using Expression Blend to create 2D gauges
      4. Time for action—showing a score gauge
        1. What just happened?
        2. Calculating, saving, and showing statistics
      5. Time for action—creating a bonus gauge showing text
        1. What just happened?
      6. Time for action—creating a fuel gauge
        1. What just happened?
      7. Time for action—creating a remaining lives gauge
        1. What just happened?
        2. Using a panel to show many aligned user controls
      8. Time for action—showing and updating multiple gauges
        1. What just happened?
        2. Working with multiple gauges
        3. Have a go hero—adding gauges for multiplayer games
        4. Pop quiz—working with special fonts and gauges
      9. Summary
    19. 13. Adding Environments and Scenarios
      1. Working with levels and stages
      2. Time for action—installing Windows Presentation Foundation Pixel Shader Effects Library
        1. What just happened?
      3. Time for action—adding screens to organize the game
        1. What just happened?
      4. Time for action—applying transition effects
        1. What just happened?
        2. Rendering a WriteableBitmap and using it as an ImageBrush
        3. Creating a StoryBoard
        4. Working with a StoryBoard to animate an effect
      5. Time for action—changing the transition effect
        1. What just happened?
        2. Exploring transition effects
        3. Working with multiple transition effects
      6. Time for action—using skill levels
        1. What just happened?
      7. Time for action—changing and improving the environments according to the skill level
        1. What just happened?
        2. Retrieving values for parameters using LINQ to XML
      8. Time for action—saving configurations
        1. What just happened?
        2. Have a go hero—displaying amazing menus with configuration options
        3. Have a go hero—showing stages
        4. Pop quiz—avoiding the GAME OVER screen
      9. Summary
    20. 14. Adding Sound, Music, and Video
      1. Hear the UFOs coming
      2. Time for action—installing tools to manipulate videos
        1. What just happened?
      3. Time for action—preparing a video to use it in Silverlight
        1. What just happened?
        2. Video formats supported in Silverlight 3
        3. Using free applications to convert video formats
      4. Time for action—reproducing videos
        1. What just happened?
        2. Locating videos in a related web site
        3. Stretching videos
        4. Taking advantage of GPU acceleration to scale videos
      5. Time for action—applying projections
        1. What just happened?
      6. Time for action—animating projections
        1. What just happened?
        2. Working with a StoryBoard in XAML to animate a projection
      7. Time for action—solving navigation problems
        1. What just happened?
      8. Time for action—reproducing music
        1. What just happened?
      9. Time for action—preparing audio files to use them in Silverlight
        1. What just happened?
        2. Audio formats supported in Silverlight 3
        3. Using free applications to convert audio formats
      10. Time for action—creating a class to handle audio concurrency
        1. What just happened?
        2. Using a round robin algorithm to work with concurrent sounds
      11. Time for action—generating sounds associated to game events
        1. What just happened?
        2. Have a go hero—animating the game over scene
        3. Have a go hero—configuring sounds and music
        4. Pop quiz—working with audio and video in Silverlight 3
      12. Summary
    21. A. Pop quiz—Answers