Adobe Flash 11 Stage3D (Molehill) Game Programming Beginners Guide Table of Contents


Table of Contents

Preface
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
Chapter 10: 3... 2... 1... ACTION!
Appendix A: AGAL Operand Reference
Appendix B: Pop Quiz Answers
Index

  • Chapter 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!
    • Summary
    • Level 1 achieved!
    • Chapter 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
      • Time for action – things we do over and over again
      • Summary
      • Level 2 achieved!
      • Chapter 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
        • Time for action – importing Stage3D-specific classes
        • Time for action – initializing Molehill
        • Time for action – defining some variables
        • Time for action – embedding a texture
        • Time for action – defining the geometry of your 3D mesh
        • Time for action – starting your engines
        • Time for action – adding to the onContext3DCreate function
        • Time for action – uploading our data
        • Time for action – setting up the camera
        • Time for action – let's animate
        • Time for action – setting the render state and drawing the mesh
          • Quest complete – time to reap the rewards
          • Congratulations!
        • The entire source code
        • Summary
        • Level 3 achieved!
        • Chapter 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
            • The fragment program
          • Time for action – writing your first fragment program
          • Compiling the AGAL source code
          • Time for action – compiling AGAL
          • Time to Render!
          • Time for action – rendering
          • Creating a shader demo
          • Adding an FPS counter
          • Time for action – creating the FPS GUI
          • Time for action – adding the GUI to our inits
          • Time for action – adding multiple shaders to the demo
          • Time for action – initializing the shaders
          • Time for action – animating the shaders
          • Time for action – uploading data to Stage3D
            • Quest complete—time to reap the rewards
            • Congratulations!
          • Summary
          • Level 4 achieved!
          • Chapter 5: Building a 3D World
            • Creating vertex buffers
              • Importing 3D models into Flash
            • Time for action – coding the Stage3dObjParser class
            • Time for action – creating the class constructor function
            • Time for action – coding the parsing functions
            • Time for action – processing the data
            • Time for action – coding some handy utility functions
              • Our mesh parsing class is complete!
            • The render loop
            • Time for action – starting the render loop
            • Time for action – adding the score to the GUI
            • Time for action – upgrading your init routines
            • Time for action – parsing our mesh data
            • Time for action – animating the scene
              • Quest complete—time to reap the rewards
            • Folder structure
            • Summary
            • Level 5 achieved!
            • Chapter 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
                • Texture atlases
                • Animated textures
                • Manipulating texture data
              • Render states
                • Backface culling
              • Time for action – rendering a mesh's backfaces
                • Depth testing
              • Time for action – making a mesh not affect the zbuffer
                • Blend modes
              • Time for action – rendering an opaque mesh
              • Time for action – rendering a mesh with transparent regions
              • Time for action – rendering a mesh so it lightens the scene
              • 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
              • Time for action – adding the variables we need
              • Time for action – upgrading the GUI
              • Time for action – listening for key presses
              • Time for action – upgrading our render loop
              • Time for action – upgrading the renderTerrain function
              • Time for action – upgrading our Stage3D inits
              • Time for action – simplifying the initShaders function
              • Time for action – parsing the new meshes
              • Time for action – rendering different meshes as appropriate
              • Time for action – switching textures
              • Time for action – switching blend modes
              • Your demo has been upgraded!
              • Summary
              • Level 6 achieved!
              • Chapter 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
                  • Keeping track of time: a game timer class
                • Time for action – creating the game timer class
                • Time for action – adding the GameTimer class constructor
                • Time for action – implementing the tick function
                  • A game input class
                • Time for action – creating the GameInput class
                • Time for action – coding the GameInput class constructor
                • Time for action – detecting mouse movement
                • Time for action – detecting the keyboard input
                • Time for action – detecting key release events
                • Time for action – detecting the input focus
                  • An abstract entity class
                • Time for action – creating the Stage3dEntity class
                • Time for action – creating the Stage3dEntity class constructor
                • Hiding complex code by using get and set functions
                • Time for action – getting and setting the transform
                • Time for action – getting and setting the entity position
                • Time for action – getting and setting the entity rotation
                • Time for action – getting and setting the entity's scale
                • Time for action – updating the transform or values on demand
                • Time for action – creating the movement utility functions
                • Time for action – implementing vector utility functions
                • Time for action – adding some handy entity utility functions
                • Time for action – cloning an entity
                • Time for action – rendering an entity
                • Design art for our new improved game world
                • Upgrading our game
                • Time for action – importing our new classes
                • Time for action – adding new variables to our game
                • Time for action – embedding the new art
                • Time for action – upgrading the game inits
                • Time for action – upgrading the GUI
                • Time for action – simplifying the shaders
                • Time for action – using the new textures
                • Time for action – spawning some game entities
                • Time for action – upgrading the render function
                • Time for action – creating a simulation step function
                • Time for action – creating a heartbeat function
                • Time for action – upgrading the enterFrame function
                • Let's see all this in action!
                • Summary
                • Level 7 achieved!
                • Chapter 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
                  • Time for action – adding particle properties
                  • Time for action – coding the particle class constructor
                  • Time for action – cloning particles
                  • Time for action – generating numbers used for animation
                  • Time for action – simulating the particles
                  • Time for action – respawning particles
                  • Time for action – rendering particles
                  • Keyframed vertex animation shader
                  • Time for action – creating a keyframed particle vertex program
                  • Time for action – creating a static particle vertex program
                  • Time for action – creating a particle fragment program
                  • Time for action – compiling the particle shader
                  • A particle system manager class
                  • Time for action – coding a particle system manager class
                  • Time for action – defining a type of particle
                  • Time for action – simulating all particles at once
                  • Time for action – rendering all particles at once
                  • Time for action – spawning particles on demand
                  • Time for action – creating new particles if needed
                  • 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
                  • 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
                  • Time for action – upgrading the renderScene function
                  • Time for action – adding particles to the gameStep function
                  • Time for action – keeping track of particle statistics
                  • Let's see the new particle system in action!
                  • Summary
                  • Level 8 achieved!
                  • Chapter 9: A World Filled with Action
                    • Extending the entity class for "actors"
                    • Time for action – creating a game actor class
                    • Time for action – extending the actor's properties
                    • Time for action – coding the GameActor class constructor
                    • Time for action – creating a step animation function
                    • Time for action – animating actors
                      • Implementing artificial intelligence (AI)
                    • Time for action – using timers
                    • Time for action – shooting at enemies
                    • 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
                    • 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
                    • Time for action – destroying every actor in the pool
                    • Easy world creation using a map image
                    • Time for action – implementing a level parser class
                    • Time for action – spawning actors based on a map image
                    • Time for action – parsing the map image pixels
                    • 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
                    • Summary
                    • Level 9 achieved!
                    • Chapter 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
                      • Adding new variables to our game
                      • Time for action – tracking the game state
                      • Time for action – adding variables for timer-based events
                      • Time for action – adding movement related variables
                      • Time for action – keeping track of all entities
                      • Time for action – upgrading the HUD
                      • Time for action – defining variables used by Stage3D
                      • Adding art to our game
                      • Time for action – embedding our new art assets (AS3 version)
                      • Time for action – embedding our new art assets (CS5 version)
                      • Time for action – embedding all the meshes
                      • Time for action – keeping track of art assets
                      • Upgrading the final game source code
                      • Time for action – upgrading the inits
                      • Time for action – initializing Stage3D
                      • Time for action – upgrading the initGUI function
                      • Time for action – upgrading the texture inits
                      • Time for action – upgrading the shaders
                      • Time for action – defining new actor types and behaviors
                      • Time for action – initializing the terrain meshes
                      • Time for action – initializing the enemies
                      • Time for action – initializing the bullets
                      • Time for action – initializing the asteroids
                      • Time for action – initializing the space stations
                      • Time for action – initializing the particle models
                      • Time for action – creating the game level
                      • Time for action – upgrading the render loop
                      • Defining gameplay-specific events
                      • Time for action – tracking game events
                      • Time for action – handling game over
                      • Time for action – updating the score display
                      • Time for action – updating the FPS display
                      • Time for action – handling collision events
                      • Time for action – handling the player input
                      • Time for action – upgrading the gameStep function
                      • Time for action – upgrading the heartbeat function
                      • Time for action – upgrading the enterFrame function
                      • Publish... distribute... profit!
                      • Summary
                      • Level 10 achieved. Universe saved!
                      • Where to go from here?
                      • A note from the author
                      • Appendix 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

                        Code Download and Errata
                        Packt Anytime, Anywhere
                        Register Books
                        Print Upgrades
                        eBook Downloads
                        Video Support
                        Contact Us
                        Awards Voting Nominations Previous Winners
                        Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                        Resources
                        Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software