3D Graphics with XNA Game Studio 4.0 pptx

292 2K 0
3D Graphics with XNA Game Studio 4.0 pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... Called when the game should update itself protected override void Update(GameTime gameTime) { base.Update(gameTime); } // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); } } [] Download from Wow! eBook Getting Started with 3D The 3D coordinate system One thing that all 3D systems... 267 268 Preface XNA is a very powerful API using which it's easy to make great games, especially when you have dazzling 3D effects This book will show you how to implement the same 3D graphics used in professional games to make your games shine, and get those gamers addicted! This book will show you, step-by-step, how to implement the effects used in professional 3D games in your XNA games Upon reaching... code for the Game1 class is now as follows: public class Game1 : Microsoft .Xna. Framework .Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Model model; Matrix[] modelTransforms; public Game1 () { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics. PreferredBackBufferWidth = 1280; graphics. PreferredBackBufferHeight = 800; } // Called when the game should... generated Game1 class contains a lot of excess comments and code, so once you have familiarized yourself with the class and its functions, simplify it to the following: public class Game1 : Microsoft .Xna. Framework .Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; public Game1 () { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } // Called when the game should... may encounter while building games Next, we will look at a way to improve performance with a "view frustum culling" system, and finally, we'll build a small game that allows the player to fly a spaceship using keyboard controls Setting up a new project The first step in any game is to set up the XNA game project in Visual Studio 1 To begin with, ensure that XNA and Visual Studio are installed by following... version was XNA 3.1 From the box on the right, specify that you want to create a Windows Game, and give it a name: 3 Click on OK, and you will be taken to the main file of the game project called Game1 .cs XNA will have created this file and added it to your project automatically The Game1 class is the main class in an XNA game By default, this class is automatically instantiated when the game is loaded,... SpriteBatch(GraphicsDevice); model = Content.Load("ship"); modelTransforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(modelTransforms); [ 16 ] Chapter 1 } // Called when the game should update itself protected override void Update(GameTime gameTime) { base.Update(gameTime); } // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue);... Vector3.Zero, GraphicsDevice); We need to update the camera in the Update() method: // Called when the game should update itself protected override void Update(GameTime gameTime) { camera.Update(); base.Update(gameTime); } Finally, we can use the View and Projection properties of camera in the Draw() method: // Called when the game should draw itself protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue);... best to address it [] Getting Started with 3D This chapter will provide you with a brief overview of the fundamentals of 3D graphics We will create a number of useful classes and systems that will make work easier later on and provide us with a flexible framework for building games This chapter will focus mainly on models, how they work, and how to view them with cameras We will build a number of... guide available at creators .xna. com and launch Visual Studio Once it has loaded, create a new project: Getting Started with 3D 2 From the left-hand side, choose the version of XNA you want to work with Generally, you should pick the most recent version available, unless you are specifically targeting an older version If you've just installed XNA, there will be only one version of XNA to choose from At the .

Ngày đăng: 14/03/2014, 21:20

Từ khóa liên quan

Mục lục

  • Cover

  • Copyright

  • Credits

  • About the Author

  • About the Reviewers

  • www.PacktPub.com

  • Table of Contents

  • Preface

  • Chapter 1: Getting Started with 3D

    • Setting up a new project

    • The 3D coordinate system

    • Matrices

    • Loading a model

    • Drawing a model

    • Creating a Custom Model class

    • Creating a Camera class

      • Creating a target camera

      • Upgrading the camera to a free camera

      • Calculating bounding spheres for models

      • View frustum culling

      • Additional camera types: Arc-Ball

      • Additional camera types: chase camera

Tài liệu cùng người dùng

Tài liệu liên quan