i i i i Game Physics Pearls i i i i i i i i Game Physics Pearls Edited by Gino van den Bergen and Dirk Gregorius A K Peters, Ltd. Natick, Massachusetts i i i i i i i i Editorial, Sales, and Customer Service Office A K Peters, Ltd. 5 Commonwealth Road, Suite 2C Natick, MA 01760 www.akpeters.com Copyright ⃝c 2010 by A K Peters, Ltd. All rights reserved. No part of the material protected by this copyright notice may be reproduced or utilized in any form, electronic or mechanical, including photo- copying, recording, or by any information storage and retrieval system, without written permission from the copyright owner. Background cover image ⃝c YKh, 2010. Used under license from Shutterstock.com. Library of Congress Cataloging-in-Publication Data Game physics pearls / edited by Gino van den Bergen and Dirk Gregorius. p. cm. ISBN 978-1-56881-474-2 (alk. paper) 1. Computer games–Programming. 2. Physics–Programming. I. Bergen, Gino van den. II. Gregorius, Dirk. QA76.76.C672G359 2010 794.8’1526–dc22 2010021721 Source code and demos that accompany this book will be made available at http://www.gamephysicspearls.com. Printed in the United States of America 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1 i i i i i i i i Contents Foreword xi Preface xiii I Game Physics 101 1 1 Mathematical Background 3 1.1 Introduction . ....................... 3 1.2VectorsandPoints........................ 3 1.3LinesandPlanes........................ 8 1.4MatricesandTransformations................. 9 1.5Quaternions........................... 13 1.6Rigid-BodyDynamics..................... 15 1.7NumericalIntegration...................... 22 1.8FurtherReading......................... 26 Bibliography............................. 27 2 Understanding Game Physics Artifacts 29 2.1 Introduction . ....................... 29 2.2DiscretizationandLinearization................ 29 2.3TimeSteppingandtheWellofDespair............. 31 2.4TheCurseofRotations..................... 32 2.5Solver.............................. 32 2.6 Collision Detection ....................... 36 2.7Joints.............................. 40 2.8DirectAnimation........................ 42 2.9ArtifactReference........................ 43 II Collision Detection 45 3 Broad Phase and Constraint Optimization for PlayStationR 347 3.1 Introduction . ....................... 47 3.2 Overview of Cell/BE . ................... 47 v i i i i i i i i vi Contents 3.3OptimizationoftheBroadPhase................ 51 3.4OptimizationoftheConstraintSolver............. 57 3.5Conclusion........................... 60 Bibliography............................. 61 4 SAT in Narrow Phase and Contact-Manifold Generation 63 4.1 Introduction ........................... 63 4.2ContactManifold........................ 63 4.3PhysicsEnginePipeline..................... 65 4.4SATBasics........................... 69 4.5IntuitiveGaussMap....................... 75 4.6ComputingFullContactManifolds............... 77 4.7SATOptimizations....................... 89 4.8Acknowledgments....................... 96 Bibliography............................. 97 5 Smooth Mesh Contacts with GJK 99 5.1 Introduction ........................... 99 5.2ConfigurationSpace....................... 101 5.3 Support Mappings . ....................... 103 5.4OverviewofGJK........................ 105 5.5 Johnson’s Algorithm . ................... 106 5.6 Continuous Collision Detection . ............ 110 5.7Contacts............................. 115 5.8Conclusion........................... 121 Bibliography............................. 121 III Particles 125 6 Optimized SPH 127 6.1 Introduction ........................... 127 6.2TheSPHEquations....................... 128 6.3AnAlgorithmforSPHSimulation............... 131 6.4TheChoiceofDataStructure.................. 132 6.5CollapsingtheSPHAlgorithm................. 139 6.6 Stability and Behavior . ................... 143 6.7Performance........................... 147 6.8Conclusion........................... 150 6.9Appendix:ScalingthePressureForce............. 150 Bibliography............................. 151 i i i i i i i i Contents vii 7 Parallelizing Particle-Based Simulation on Multiple Processors 155 7.1 Introduction . ....................... 155 7.2DividingComputation..................... 156 7.3 Data Management without Duplication . ........... 159 7.4 Choosing an Acceleration Structure . ........... 162 7.5DataTransferUsingGrids................... 173 7.6Results.............................. 174 7.7Conclusion........................... 175 Bibliography............................. 175 IV Constraint Solving 177 8 Ropes as Constraints 179 8.1 Introduction . ....................... 179 8.2Free-HangingRopes...................... 181 8.3StrainedRopes......................... 184 Bibliography............................. 193 9 Quaternion-Based Constraints 195 9.1 Introduction . ....................... 195 9.2NotationandDefinitions.................... 195 9.3TheProblem........................... 196 9.4ConstraintDefinitions...................... 198 9.5Matrix-BasedQuaternionAlgebra............... 201 9.6ANewTakeonQuaternion-BasedConstraints......... 203 9.7WhyItWorks.......................... 203 9.8MoreGeneralFrames...................... 204 9.9LimitsandDrivers....................... 206 9.10Examples............................ 207 9.11Conclusion........................... 213 9.12Acknowledgments....................... 213 Bibliography............................. 213 V Soft Body 215 10 Soft Bodies Using Finite Elements 217 10.1 Introduction . ....................... 217 10.2 Continuum Mechanics . ................... 218 10.3LinearFEM........................... 223 i i i i i i i i viii Contents 10.4SolvingtheLinearSystem................... 241 10.5 Surface-Mesh Update . ................... 246 Bibliography............................. 248 11 Particle-Based Simulation Using Verlet Integration 251 11.1 Introduction ........................... 251 11.2TechniquesforNumericalIntegration............. 252 11.3UsingRelaxationtoSolveSystemsofEquations........ 256 11.4RigidBodies.......................... 261 11.5ArticulatedBodies....................... 264 11.6Miscellaneous.......................... 266 11.7Conclusion........................... 268 Bibliography............................. 269 12 Keep Yer Shirt On 271 12.1 Introduction ........................... 271 12.2StableReal-TimeCloth..................... 271 12.3ModelingRealFabrics..................... 273 12.4Performance........................... 276 12.5OrderofClothUpdateStages.................. 278 12.6Conclusion,Results,andFuture................ 279 Bibliography............................. 279 VI Skinning 281 13 Layered Skin Simulation 283 13.1 Introduction ........................... 283 13.2LayeredDeformationArchitecture............... 283 13.3SmoothSkinning........................ 287 13.4 Anatomical Collisions . ................... 291 13.5Relaxation............................ 295 13.6Jiggle.............................. 299 13.7Conclusion........................... 301 Bibliography............................. 303 14 Dynamic Secondary Skin Deformations 305 14.1 Introduction ........................... 305 14.2TheInteractionModel..................... 307 14.3 Neighborhood Interaction . ................... 311 14.4VolumetricEffects....................... 318 i i i i i i i i Contents ix 14.5FinalRemarks.......................... 327 Bibliography............................. 331 Index 341 i i i i i i i i Foreword I am not a fan of gems-style books. Typically, they are assembled and glued together as a collection of loosely related articles, and no attempt is made to unify them by emphasizing common themes and ideas. When I was asked to write the foreword for this book, my initial reaction was to decline politely, thinking this was yet another such book. However, knowing the editors and their reputations in the physics engine industry, I agreed to read the book in hopes that there might be a few articles that make the book a worthwhile purchase. I am delighted to say that this book is much more than I imagined. Those few articles I hoped to find interesting turned out to be all the articles! I congratulate the editors and the authors for producing the finest collection of game physics articles I have seen to date. The common theme is experience. Each author de- scribes not only a topic of interest, but provides an in-the-trenches discussion of the practical problems and solutions when implementing the algorithms, whether for a physics engine or game application. Moreover, I found it comforting that the authors were consistent in their findings, giving me hope that writing a fast and robust physics engine actually can be a scientific process rather than an en- deavor that combines art, hacks, and voodoo. Also of importance is that several of the topics are about nonsequential programming, whether multicore or for game consoles, which is important given the evolution of modern computing hardware towards multiprocessing and multithreading. This book is a must-have if you plan on exploring the world of physics pro- gramming. And I hope the editors and authors have plans on producing more books of the same great quality. —Dave Eberly xi i i i i i i i i Preface It took some time before I considered myself a physics programmer. Like most game programmers, I started out toying with physics in hobby game projects. These early attempts at getting physical behavior out of an 8-bit home computer did involve concepts such as velocity, mass, and force, but in my head they were far from “real” physics.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages338 Page
-
File Size-