万本电子书0元读

万本电子书0元读

顶部广告

Adobe Flash 11 Stage3D (Molehill) Game Programming Beginner’s Guide电子书

售       价:¥

45人正在读 | 0人评论 9.8

作       者:Christer Kaitila

出  版  社:Packt Publishing

出版时间:2011-11-25

字       数:139.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:此类商品不支持退换货,不支持下载打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Written in an informal and friendly manner, the style and approach of this book will take you on an exciting adventure. Piece by piece, detailed examples help you along the way by providing real-world game code required to make a complete 3D video game. Each chapter builds upon the experience and achievements earned in the last, culminating in the ultimate prize – your game! If you ever wanted to make your own 3D game in Flash, then this book is for you. This book is a perfect introduction to 3D game programming in Adobe Molehill for complete beginners. You do not need to know anything about Stage3D/Molehill or Flash 11 in order to take advantage of the examples in this book. This book assumes that you have programming experience in AS3 (Action* 3).
目录展开

Adobe Flash 11 Stage3D (Molehill) Game Programming

Table of Contents

Adobe Flash 11 Stage3D (Molehill) Game Programming

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers and more

Why Subscribe?

Free Access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code for this book

Errata

Piracy

Questions

1. Let's Make a Game Using Molehill!

Your epic adventure awaits!

What is Molehill?

What Molehill is NOT

What you need to know already

Basic 3D terminology

Common 3D content terms

Mesh

Polygon

Vertex

Texture

Shaders

Vertex program

Fragment program

3D Content level one achieved!

Common 3D coding terms

Vectors

Normals

Matrices

3D Coding level one achieved!

Pop quiz – earn some experience points

Have a go hero – your first side quest

Summary

Level 1 achieved!

2. Blueprint of a Molehill

The old fashioned way

The Molehill way: Stage3D

Using 2D Flash text and sprites

Why is Stage3D so fast?

The structure of a Molehill application

Stage

Stage3D

Context3D

VertexBuffer3D

IndexBuffer3D

Program3D

Flowchart of a Molehill program

Time for action – things we do once, during the setup

What just happened?

Time for action – things we do over and over again

What just happened?

Pop quiz – earn some experience points

Summary

Level 2 achieved!

3. Fire up the Engines!

Step 1: Downloading Flash 11 (Molehill) from Adobe

Time for action – getting the plugin

Time for action - getting the Flash 11 profile for CS5

Time for action – upgrading Flex

Time for action – upgrading the Flex playerglobal.swc

Time for action – using SWF Version 13 when compiling in Flex

Time for action – updating your template HTML file

Stage3D is now set up!

Step 2: Start coding

Time for action – creating an empty project

What just happened?

Time for action – importing Stage3D-specific classes

What just happened?

Time for action – initializing Molehill

What just happened?

Time for action – defining some variables

What just happened?

Time for action – embedding a texture

What just happened?

Time for action – defining the geometry of your 3D mesh

What just happened?

Time for action – starting your engines

What just happened?

Time for action – adding to the onContext3DCreate function

What just happened?

Time for action – uploading our data

What just happened?

Time for action – setting up the camera

What just happened?

Time for action – let's animate

What just happened?

Time for action – setting the render state and drawing the mesh

What just happened?

Quest complete – time to reap the rewards

Congratulations!

The entire source code

Pop quiz – earn some experience points

Have a go hero – a fun side quest

Summary

Level 3 achieved!

4. Basic Shaders: I can see Something!

AGAL: Adobe Graphics Assembly Language

What does one line of AGAL look like?

What is a register?

What is a component?

Working with four components at the same time

Different registers for different jobs

Vertex attribute registers: va0..va7

Constant registers: vc0..vc127 and fc0..fc27

Temporary registers: vt0..vt7 and ft0..ft7

Output registers: op and oc

Varying registers: v0..v7

Texture samplers: fs0..fs7

A basic AGAL shader example

The vertex program

Time for action – writing your first vertex program

What just happened?

The fragment program

Time for action – writing your first fragment program

What just happened?

Compiling the AGAL source code

Time for action – compiling AGAL

What just happened?

Time to Render!

Time for action – rendering

What just happened?

Creating a shader demo

Adding an FPS counter

Time for action – creating the FPS GUI

What just happened?

Time for action – adding the GUI to our inits

What just happened?

Time for action – adding multiple shaders to the demo

What just happened?

Time for action – initializing the shaders

What just happened?

Time for action – animating the shaders

What just happened?

Time for action – uploading data to Stage3D

What just happened?

Quest complete—time to reap the rewards

Congratulations!

Pop quiz – earn some experience points

Have a go hero – shader experiments

Summary

Level 4 achieved!

5. Building a 3D World

Creating vertex buffers

Importing 3D models into Flash

Time for action – coding the Stage3dObjParser class

What just happened?

Time for action – creating the class constructor function

What just happened?

Time for action – coding the parsing functions

What just happened?

Time for action – processing the data

What just happened?

Time for action – coding some handy utility functions

What just happened?

Our mesh parsing class is complete!

The render loop

Time for action – starting the render loop

What just happened?

Time for action – adding the score to the GUI

What just happened?

Time for action – upgrading your init routines

What just happened?

Time for action – parsing our mesh data

What just happened?

Time for action – animating the scene

What just happened?

Quest complete—time to reap the rewards

Folder structure

Pop quiz – earn some experience points

Have a go hero – a fun side-quest: make some more models!

Summary

Level 5 achieved!

6. Textures: Making Things Look Pretty

Time for a plan: creating a "real" game

Using textures in Stage3D

Power-of-two

UV coordinates

Transparent textures

Animating UV coordinates in a shader

Time for action – updating UV coordinates each frame

What just happened?

Texture atlases

Animated textures

Manipulating texture data

Render states

Backface culling

Time for action – rendering a mesh's backfaces

What just happened?

Depth testing

Time for action – making a mesh not affect the zbuffer

What just happened?

Blend modes

Time for action – rendering an opaque mesh

What just happened?

Time for action – rendering a mesh with transparent regions

What just happened?

Time for action – rendering a mesh so it lightens the scene

What just happened?

Increasing your performance

Opaque is faster

Avoiding overdraw

Avoiding state changes

Use simple shaders

Draw fewer meshes

Adding texture effects to our demo

Time for action – embedding the new art

What just happened?

Time for action – adding the variables we need

What just happened?

Time for action – upgrading the GUI

What just happened?

Time for action – listening for key presses

Time for action – upgrading our render loop

What just happened?

Time for action – upgrading the renderTerrain function

What just happened?

Time for action – upgrading our Stage3D inits

What just happened?

Time for action – simplifying the initShaders function

What just happened?

Time for action – parsing the new meshes

What just happened?

Time for action – rendering different meshes as appropriate

What just happened?

Time for action – switching textures

What just happened?

Time for action – switching blend modes

What just happened?

Your demo has been upgraded!

Pop quiz – earn some experience points

Summary

Level 6 achieved!

7. Timers, Inputs, and Entities: Gameplay Goodness!

Our current quest

Keeping it simple

Making it reusable

Making our game more interactive

Adding a HUD overlay graphic

Time for action – adding a GUI overlay

What just happened?

Keeping track of time: a game timer class

Time for action – creating the game timer class

What just happened?

Time for action – adding the GameTimer class constructor

What just happened?

Time for action – implementing the tick function

What just happened?

A game input class

Time for action – creating the GameInput class

What just happened?

Time for action – coding the GameInput class constructor

What just happened?

Time for action – detecting mouse movement

What just happened?

Time for action – detecting the keyboard input

What just happened?

Time for action – detecting key release events

What just happened?

Time for action – detecting the input focus

What just happened?

An abstract entity class

Time for action – creating the Stage3dEntity class

What just happened?

Time for action – creating the Stage3dEntity class constructor

What just happened?

Hiding complex code by using get and set functions

Time for action – getting and setting the transform

What just happened?

Time for action – getting and setting the entity position

What just happened?

Time for action – getting and setting the entity rotation

Time for action – getting and setting the entity's scale

What just happened?

Time for action – updating the transform or values on demand

What just happened?

Time for action – creating the movement utility functions

What just happened?

Time for action – implementing vector utility functions

Time for action – adding some handy entity utility functions

What just happened?

Time for action – cloning an entity

What just happened?

Time for action – rendering an entity

What just happened?

Design art for our new improved game world

Upgrading our game

Time for action – importing our new classes

What just happened?

Time for action – adding new variables to our game

What just happened?

Time for action – embedding the new art

Time for action – upgrading the game inits

What just happened?

Time for action – upgrading the GUI

Time for action – simplifying the shaders

Time for action – using the new textures

What just happened?

Time for action – spawning some game entities

What just happened?

Time for action – upgrading the render function

What just happened?

Time for action – creating a simulation step function

What just happened?

Time for action – creating a heartbeat function

Time for action – upgrading the enterFrame function

What just happened?

Let's see all this in action!

Pop quiz – earn some experience points

Have a go hero – a fun side-quest: engage the afterburners!

Summary

Level 7 achieved!

8. Eye-Candy Aplenty!

Our current quest

Designing for performance

Designing for reusability

Animating using AGAL

A basic particle entity class

Time for action – extending the entity class for particles

What just happened?

Time for action – adding particle properties

What just happened?

Time for action – coding the particle class constructor

What just happened?

Time for action – cloning particles

What just happened?

Time for action – generating numbers used for animation

What just happened?

Time for action – simulating the particles

What just happened?

Time for action – respawning particles

What just happened?

Time for action – rendering particles

What just happened?

Keyframed vertex animation shader

Time for action – creating a keyframed particle vertex program

What just happened?

Time for action – creating a static particle vertex program

What just happened?

Time for action – creating a particle fragment program

What just happened?

Time for action – compiling the particle shader

A particle system manager class

Time for action – coding a particle system manager class

What just happened?

Time for action – defining a type of particle

What just happened?

Time for action – simulating all particles at once

What just happened?

Time for action – rendering all particles at once

What just happened?

Time for action – spawning particles on demand

What just happened?

Time for action – creating new particles if needed

What just happened?

Keyframed particle meshes

Selecting a particle texture

Time for action – sculpting a single particle

Time for action – sculpting a group of particles

Time for action – sculpting the second keyframe

What just happened?

Incorporating the particle system class in our game

Time for action – adding particles to your game

Time for action – preparing a type of particle for use

What just happened?

Time for action – upgrading the renderScene function

What just happened?

Time for action – adding particles to the gameStep function

What just happened?

Time for action – keeping track of particle statistics

What just happened?

Let's see the new particle system in action!

Pop quiz – earn some experience points

Have a go hero –inventing some cool particle effects

Summary

Level 8 achieved!

9. A World Filled with Action

Extending the entity class for "actors"

Time for action – creating a game actor class

What just happened?

Time for action – extending the actor's properties

What just happened?

Time for action – coding the GameActor class constructor

What just happened?

Time for action – creating a step animation function

What just happened?

Time for action – animating actors

Implementing artificial intelligence (AI)

Time for action – using timers

Time for action – shooting at enemies

What just happened?

Time for action – cloning an actor

Time for action – handling an actor's death

Time for action – respawning an actor

Collision detection

Time for action – detecting collisions

Time for action – detecting sphere-to-sphere collisions

Time for action – detecting bounding-box collisions

An "actor reuse pool" system

Time for action – creating an actor pool

Time for action – defining a clone parent

Time for action – animating the entire actor pool

What just happened?

Time for action – rendering an actor pool

Time for action – spawning an actor

Time for action – checking for collisions between actors

Restricting display to nearby actors for better framerate

Time for action – hiding actors that are far away

What just happened?

Time for action – destroying every actor in the pool

What just happened?

Easy world creation using a map image

Time for action – implementing a level parser class

What just happened?

Time for action – spawning actors based on a map image

What just happened?

Time for action – parsing the map image pixels

What just happened?

Upgrading the input routines

Time for action – adding more properties to the input class

Time for action – handling click events

Time for action – upgrading the key events

What just happened?

Pop quiz – earn some experience points

Have a go hero – a fun side-quest: art attack!

Summary

Level 9 achieved!

10. 3... 2... 1... ACTION!

Our final quest

Getting to the finish line

Time for action – drawing a title screen

Time for action – importing required classes

What just happened?

Adding new variables to our game

Time for action – tracking the game state

What just happened?

Time for action – adding variables for timer-based events

What just happened?

Time for action – adding movement related variables

What just happened?

Time for action – keeping track of all entities

What just happened?

Time for action – upgrading the HUD

What just happened?

Time for action – defining variables used by Stage3D

What just happened?

Adding art to our game

Time for action – embedding our new art assets (AS3 version)

What just happened?

Time for action – embedding our new art assets (CS5 version)

What just happened?

Time for action – embedding all the meshes

Time for action – keeping track of art assets

What just happened?

Upgrading the final game source code

Time for action – upgrading the inits

What just happened?

Time for action – initializing Stage3D

What just happened?

Time for action – upgrading the initGUI function

What just happened?

Time for action – upgrading the texture inits

What just happened?

Time for action – upgrading the shaders

What just happened?

Time for action – defining new actor types and behaviors

What just happened?

Time for action – initializing the terrain meshes

What just happened?

Time for action – initializing the enemies

What just happened?

Time for action – initializing the bullets

What just happened?

Time for action – initializing the asteroids

What just happened?

Time for action – initializing the space stations

What just happened?

Time for action – initializing the particle models

What just happened?

Time for action – creating the game level

What just happened?

Time for action – upgrading the render loop

What just happened?

Defining gameplay-specific events

Time for action – tracking game events

What just happened?

Time for action – handling game over

What just happened?

Time for action – updating the score display

What just happened?

Time for action – updating the FPS display

What just happened?

Time for action – handling collision events

What just happened?

Time for action – handling the player input

What just happened?

Time for action – upgrading the gameStep function

What just happened?

Time for action – upgrading the heartbeat function

What just happened?

Time for action – upgrading the enterFrame function

What just happened?

Publish... distribute... profit!

Have a go hero – a fun side quest

Summary

Level 10 achieved. Universe saved!

Where to go from here?

A note from the author

A. AGAL Operand Reference

What does one line of AGAL look like?

Registers available for AGAL programs

COPYING DATA

ALGEBRAIC OPERANDS

MATH OPERANDS

TRIGONOMETRY OPERANDS

CONDITIONAL OPERANDS

VECTOR and MATRIX OPERANDS

TEXTURE SAMPLING OPERAND

B. Pop Quiz Answers

Chapter 1

Let's Make a Game Using Molehill!

Chapter 2

Blueprint of a Molehill

Chapter 3

Fire up the Engines

Chapter 4

Basic Shaders: I can see something!

Chapter 5

Building a 3D World

Chapter 6

Textures: Making Things Look Pretty

Chapter 7

Timers, Inputs, and Entities: Gameplay Goodness!

Chapter 8

Eye-Candy Aplenty!

Chapter 9

A World Filled with Action

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部