5
Best of Game Programming Gems Edited by Mark DeLoura Charles River Media A part of Course Technology, Cengage Learning COURSE TECHNOLOGY CENGAGE Learning- Australia Brazil -Japan Korea 'Mexico-Singapore-Spain United Kingdom United States

Best of Game Programming Gems - GBV

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best of Game Programming Gems - GBV

Best of Game Programming Gems

Edited by Mark DeLoura

Charles River Media

A part of Course Technology, Cengage Learning

COURSE TECHNOLOGY CENGAGE Learning-

Australia • Brazil -Japan • Korea 'Mexico-Singapore-Spain • United Kingdom • United States

Page 2: Best of Game Programming Gems - GBV

Contents Acknowledgments ix

About the Authors xi

Introduction xxv

SECTION 1 GENERAL INFORMATION 1

1.1 The Science of Debugging Games 3

Steve Rabin, Nintendo of America Inc.

1.2 Finding Redeeming Value in C-Style Macros 17

Steve Rabin, Nintendo of America Inc.

1.3 Inline Functions vs. Macros 29

Peter Dalton, Smart Bomb Interactive

1.4 Squeezing More Out of Assaert 35

Steve Rabin, Nintendo of America Inc.

1.5 Programming wi th Abstract Interfaces 41

Noel Llopis, Power of Two Games

1.6 The Beauty of Weak References and Null Objects 49

Noel Llopis, Power of Two Games

1.7 Using the STL in Game Programming 57

fames Boer, ArenaNet

1.8 Custom STL Allocators 73

Pete Isensee, Microsofi Corporation

1.9 Optimization for C++ Games 83

Andrew Kirmse, Google Inc.

1.10 Real-Time Hierarchical Profiling . 95

Greg Hjelstrom, Petroglyph and Byon Garrabrant, Westwood Studios

1.11 A Generic Tree Container in C++ 103

Bill Budge, Sony Computer Entertainment America

v

Page 3: Best of Game Programming Gems - GBV

VI Contents

1.12 Lock-Free Algorithms 113

Toby Jones, Microsoft Corporation

1.13 Utilizing Multicore Processors with OpenMP 125

Pete Isensee, Microsoft Corporation

SECTION 2 MATH AND PHYSICS 133

2.1 More Approximations to Trigonometric Functions 135

Robin Green, Google Inc.

2.2 Faster Quaternion Interpolation Using Approximations 153

Andy Thomason, SN Systems

2.3 Quaternion Compression 175

Mark Zarb-Adami, Mucky Foot

2.4 Zobrist Hash Using the Mersenne Twister 181

Toby Jones, Microsoft Corporation

2.5 Solving Accuracy Problems in Large World Coordinates 187

Peter Freese, Hidden Path Entertainment

2.6 Writing a Verlet-Based Physics Engine 201

Nick Porcino, Industrial Light & Music

2.7 Constraints in Rigid Body Dynamics 211

Russ Smith, Google Inc.

2.8 The Jacobian Transpose Method for Inverse Kinematics 223

Marco Spoerl

SECTION 3 ARTIFICIAL INTELLIGENCE 235

3.1 The Basics of A* for Path Planning 237

Bryan Stout

3.2 A* Aesthetic Optimizations 247

Steve Rabin, Nintendo of America Inc.

3.3 A* Speed Optimizations 255

Steve Rabin, Nintendo of America Inc.

3.4 Tactical Path-Finding with A* 271

William van der Sterren, CGF-AI

Page 4: Best of Game Programming Gems - GBV

Contents vii

3.5 A Fast Approach to Navigation Meshes 285

Stephen White, Sucker Punch Productions; and Christopher Christensen, Naughty Dog

3.6 Flocking: A Simple Technique for Simulating Group Behavior 297

Steven Woodcock, Raytheon

3.7 A Finite-State Machine Class 311

Eric Dybsand

3.8 Implementing Practical Planning for Game Al 323

Jamie Cheng, Klei Entertainment; and Finnegan Southey, Google Inc.

SECTION 4 GRAPHICS 339

4.1 T-Junction Elimination and Retriangulation 341

Eric Lengyel, Terathon Software

4.2 Filling the Gaps: Advanced Animation Using Stitching and Skinning 347

Ryan Woodland, Zipper Interactive

4.3 Improved Skin Deformation Using Kinematic Skeletons 355

Jason P. Weber, DreamWorks Animation

4.4 Motion Capture Data Compression 363

Soren Hannibal, Shiny/Collective

4.5 Compressed Axis-Aligned Bounding Box Trees 371

Miguel Gomez, the SAAM Institute

4.6 Textures as Lookup Tables for Per-Pixel Lighting Computations . . . 377

Alex Vlachos, Valve; John Isidoro, ATI; and Chris Oat, AMD

4.7 Methods for Dynamic, Photorealistic Terrain Lighting 387

Naty Hoffman, Sony Computer Entertainment America; and Kenny Mitchell, Electronic Arts

4.8 Practical Sky Rendering for Games 399

Aurelio Reis, Firaxis Games

4.9 Powerful Explosion Effects Using Billboard Particles 411

Steve Rabin, Nintendo of America Inc.

4.10 Rendering with Handcrafted Shading Models 421

Jan Kautz, University College London

Page 5: Best of Game Programming Gems - GBV

viii Contents

SECTION 5 NETWORKING 427

5.1 Overcoming Network Address Translation in Peer-to-Peer Communications 429

Jon Watte, Forterra Systems

5.2 Minimizing Latency in Real-Time Strategy Games 451

Jim Greer, Kongregate and Zachary Booth Simpson, Mine Control

5.3 Real-Time Strategy Network Protocol 459

Jan Svarovsky, Svarovsky Productions Ltd.

5.4 Secure Sockets 469

Pete Isensee, Microsoft Corporation

5.5 Bit Packing: A Network Compression Technique 481

Pete Isensee, Microsoft Corporation

SECTION 6 AUDIO 489

6.1 A Basic Music Sequencer for Games 491

Scott Patterson, Electronic Arts—Blackbox

6.2 Audio Compression wi th Ogg Vorbis 503

Jack Moffitt, Chesspark

6.3 Using 3D Surfaces as Audio Emitters 511

Sami Hamlaoui, Double Helix Games

6.4 Introduction to Single-Speaker Speech Recognition 521

Julien Hamaide, lOTacle Studios Belgium

6.5 A Technique to Instantaneously Reuse Voices in a Sample-Based Synthesizer 531

Thomas Engel, Factor 5 Inc.

Index 535