List Of Figures |
|
xix | |
Preface To The Second Edition |
|
xxiii | |
Preface To The First Edition |
|
xxv | |
Acknowledgments |
|
xxvii | |
About The Author |
|
xxix | |
|
|
1 | (14) |
|
1.1 What Is Game Physics? |
|
|
2 | (1) |
|
1.2 What Is A Physics Engine? |
|
|
2 | (3) |
|
1.2.1 Advantages Of A Physics Engine |
|
|
3 | (1) |
|
1.2.2 Weaknesses Of A Physics Engine |
|
|
4 | (1) |
|
1.3 Approaches To Physics Engines |
|
|
5 | (3) |
|
|
5 | (1) |
|
|
6 | (1) |
|
1.3.3 Impulses And Forces |
|
|
6 | (1) |
|
1.3.4 What We're Building |
|
|
7 | (1) |
|
1.4 The Mathematics Of Physics Engines |
|
|
8 | (2) |
|
1.4.1 The Math You Need To Know |
|
|
8 | (1) |
|
1.4.2 The Math We'll Review |
|
|
9 | (1) |
|
1.4.3 The Math I'll Introduce |
|
|
10 | (1) |
|
1.5 The Source Code In The Book |
|
|
10 | (1) |
|
1.6 How The Book Is Structured |
|
|
11 | (6) |
|
1.6.1 Exercises And Projects |
|
|
12 | (3) |
Part I Particle Physics |
|
15 | (60) |
|
Chapter 2 The Mathematics Of Particles |
|
|
17 | (30) |
|
|
17 | (21) |
|
2.1.1 The Handedness Of Space |
|
|
21 | (2) |
|
2.1.2 Vectors And Directions |
|
|
23 | (2) |
|
2.1.3 Scalar And Vector Multiplication |
|
|
25 | (2) |
|
2.1.4 Vector Addition And Subtraction |
|
|
27 | (2) |
|
2.1.5 Multiplying Vectors |
|
|
29 | (1) |
|
2.1.6 The Component Product |
|
|
30 | (1) |
|
|
31 | (2) |
|
|
33 | (4) |
|
2.1.9 The Orthonormal Basis |
|
|
37 | (1) |
|
|
38 | (6) |
|
2.2.1 Differential Calculus |
|
|
38 | (5) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (2) |
|
Chapter 3 The Laws Of Motion |
|
|
47 | (14) |
|
|
48 | (1) |
|
|
49 | (6) |
|
3.2.1 The Force Equations |
|
|
50 | (1) |
|
3.2.2 Adding Mass To Particles |
|
|
51 | (1) |
|
3.2.3 Momentum And Velocity |
|
|
52 | (1) |
|
3.2.4 The Force Of Gravity |
|
|
53 | (2) |
|
|
55 | (3) |
|
3.3.1 The Update Equations |
|
|
55 | (2) |
|
3.3.2 The Complete Integrator |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
59 | (2) |
|
Chapter 4 The Particle Physics Engine |
|
|
61 | (14) |
|
|
61 | (5) |
|
4.1.1 Setting Projectile Properties |
|
|
62 | (1) |
|
|
63 | (3) |
|
|
66 | (7) |
|
|
66 | (1) |
|
|
67 | (2) |
|
|
69 | (4) |
|
|
73 | (1) |
|
|
73 | (2) |
Part II Mass Aggregate Physics |
|
75 | (80) |
|
Chapter 5 Adding General Forces |
|
|
77 | (12) |
|
5.1 D'alembert's Principle |
|
|
77 | (3) |
|
|
80 | (7) |
|
5.2.1 Interfaces And Polymorphism |
|
|
81 | (1) |
|
|
81 | (3) |
|
5.2.3 A Gravity Force Generator |
|
|
84 | (1) |
|
5.2.4 A Drag Force Generator |
|
|
85 | (2) |
|
5.3 Built-In Gravity And Damping |
|
|
87 | (1) |
|
|
87 | (1) |
|
|
88 | (1) |
|
Chapter 6 Springs And Spring-Like Things |
|
|
89 | (24) |
|
|
89 | (3) |
|
6.2 Spring-Like Force Generators |
|
|
92 | (9) |
|
6.2.1 A Basic Spring Force Generator |
|
|
92 | (2) |
|
6.2.2 An Anchored Spring Generator |
|
|
94 | (2) |
|
6.2.3 An Elastic Bungee Generator |
|
|
96 | (2) |
|
6.2.4 A Buoyancy Force Generator |
|
|
98 | (3) |
|
|
101 | (9) |
|
6.3.1 The Stiff Springs Problem |
|
|
102 | (2) |
|
6.3.2 Faking Stiff Springs |
|
|
104 | (6) |
|
|
110 | (1) |
|
|
110 | (3) |
|
Chapter 7 Hard Constraints |
|
|
113 | (32) |
|
7.1 Simple Collision Resolution |
|
|
113 | (5) |
|
7.1.1 The Closing Velocity |
|
|
114 | (1) |
|
7.1.2 The Coefficient Of Restitution |
|
|
115 | (1) |
|
7.1.3 The Collision Direction And The Contact Normal |
|
|
115 | (2) |
|
|
117 | (1) |
|
|
118 | (12) |
|
7.2.1 Collision Detection |
|
|
121 | (2) |
|
7.2.2 Resolving Interpenetration |
|
|
123 | (3) |
|
|
126 | (4) |
|
7.3 The Contact Resolver Algorithm |
|
|
130 | (6) |
|
|
131 | (4) |
|
7.3.2 Time-Division Engines |
|
|
135 | (1) |
|
7.4 Collision-Like Things |
|
|
136 | (6) |
|
|
137 | (3) |
|
|
140 | (2) |
|
|
142 | (1) |
|
|
142 | (3) |
|
Chapter 8 The Mass Aggregate Physics Engine |
|
|
145 | (10) |
|
8.1 Overview Of The Engine |
|
|
145 | (6) |
|
8.2 Using The Physics Engine |
|
|
151 | (2) |
|
8.2.1 Rope Bridges And Cables |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
153 | (1) |
|
|
153 | (1) |
|
|
154 | (1) |
Part III Rigid-Body Physics |
|
155 | (96) |
|
Chapter 9 The Mathematics Of Rotations |
|
|
157 | (50) |
|
9.1 Rotating Objects In 2d |
|
|
158 | (7) |
|
9.1.1 The Mathematics Of Angles |
|
|
158 | (1) |
|
|
159 | (1) |
|
9.1.3 The Origin And The Center Of Mass |
|
|
160 | (5) |
|
|
165 | (7) |
|
|
165 | (2) |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
169 | (3) |
|
9.3 Angular Velocity And Acceleration |
|
|
172 | (1) |
|
9.3.1 Velocity Of A Point |
|
|
173 | (1) |
|
9.3.2 Angular Acceleration |
|
|
173 | (1) |
|
9.4 Implementing The Mathematics |
|
|
173 | (30) |
|
|
174 | (1) |
|
9.4.2 Matrix Multiplication |
|
|
175 | (9) |
|
9.4.3 Matrix Inverse And Transpose |
|
|
184 | (7) |
|
9.4.4 Converting A Quaternion To A Matrix |
|
|
191 | (2) |
|
9.4.5 Transforming Vectors |
|
|
193 | (4) |
|
9.4.6 Changing The Basis Of A Matrix |
|
|
197 | (1) |
|
9.4.7 The Quaternion Class |
|
|
198 | (2) |
|
9.4.8 Normalizing Quaternions |
|
|
200 | (1) |
|
9.4.9 Combining Quaternions |
|
|
200 | (1) |
|
|
201 | (1) |
|
9.4.11 Updating By The Angular Velocity |
|
|
202 | (1) |
|
|
203 | (1) |
|
|
203 | (4) |
|
Chapter 10 Laws Of Motion For Rigid Bodies |
|
|
207 | (24) |
|
|
207 | (4) |
|
10.2 Newton-2 For Rotation |
|
|
211 | (9) |
|
|
211 | (2) |
|
10.2.2 The Moment Of Inertia |
|
|
213 | (3) |
|
10.2.3 Inertia Tensor In World Coordinates |
|
|
216 | (4) |
|
10.3 D'alembert For Rotation |
|
|
220 | (6) |
|
|
223 | (3) |
|
10.4 The Rigid-Body Integration |
|
|
226 | (2) |
|
|
228 | (1) |
|
|
228 | (3) |
|
Chapter 11 The Rigid-Body Physics Engine |
|
|
231 | (20) |
|
11.1 Overview Of The Engine |
|
|
231 | (3) |
|
11.2 Using The Physics Engine |
|
|
234 | (13) |
|
11.2.1 A Flight Simulator |
|
|
234 | (8) |
|
11.2.2 A Sailing Simulator |
|
|
242 | (5) |
|
|
247 | (1) |
|
|
248 | (3) |
Part IV Collision Detection |
|
251 | (82) |
|
Chapter 12 Collision Detection |
|
|
253 | (38) |
|
12.1 The Collision Detection Pipeline |
|
|
254 | (1) |
|
12.2 Broad-Phase Collision Detection |
|
|
255 | (2) |
|
|
256 | (1) |
|
12.3 Bounding Volume Hierarchies |
|
|
257 | (19) |
|
|
259 | (7) |
|
12.3.2 Building The Hierarchy |
|
|
266 | (9) |
|
12.3.3 Subobject Hierarchies |
|
|
275 | (1) |
|
12.4 Spatial Partitioning |
|
|
276 | (12) |
|
12.4.1 Binary Space Partitioning |
|
|
276 | (5) |
|
12.4.2 Oct-Trees And Quad-Trees |
|
|
281 | (2) |
|
|
283 | (4) |
|
12.4.4 Multiresolution Maps |
|
|
287 | (1) |
|
|
288 | (1) |
|
|
288 | (3) |
|
Chapter 13 Generating Contacts |
|
|
291 | (42) |
|
|
292 | (2) |
|
13.1.1 Primitive Assemblies |
|
|
293 | (1) |
|
|
294 | (10) |
|
|
295 | (3) |
|
|
298 | (2) |
|
13.2.3 Vertex—face Contacts |
|
|
300 | (1) |
|
13.2.4 Edge -Edge Contacts |
|
|
301 | (1) |
|
13.2.5 Edge–face Contacts |
|
|
301 | (1) |
|
13.2.6 Face–face Contacts |
|
|
302 | (1) |
|
13.2.7 Testing Before Generating Contacts |
|
|
303 | (1) |
|
13.3 Simple Collision Algorithms |
|
|
304 | (15) |
|
13.3.1 Colliding Two Spheres |
|
|
305 | (2) |
|
13.3.2 Colliding A Sphere And A Plane |
|
|
307 | (3) |
|
13.3.3 Colliding A Box And A Plane |
|
|
310 | (5) |
|
13.3.4 Colliding A Box And A Sphere |
|
|
315 | (4) |
|
13.4 Separating Axis Tests |
|
|
319 | (9) |
|
13.4.1 Generating Contact Data With SATS |
|
|
320 | (2) |
|
13.4.2 Colliding Two Boxes |
|
|
322 | (4) |
|
13.4.3 Colliding Convex Polyhedra |
|
|
326 | (2) |
|
|
328 | (3) |
|
|
331 | (1) |
|
|
331 | (2) |
Part V Contact Physics |
|
333 | (128) |
|
Chapter 14 Collision Resolution |
|
|
335 | (52) |
|
14.1 Impulse And Impulsive Torque |
|
|
335 | (5) |
|
|
336 | (2) |
|
14.1.2 Rotating Collisions |
|
|
338 | (1) |
|
14.1.3 Handling Rotating Collisions |
|
|
339 | (1) |
|
|
340 | (15) |
|
14.2.1 Change To Contact Coordinates |
|
|
340 | (7) |
|
14.2.2 Velocity Change By Impulse |
|
|
347 | (4) |
|
14.2.3 Impulse Change By Velocity |
|
|
351 | (1) |
|
14.2.4 Calculating The Desired Velocity Change |
|
|
351 | (2) |
|
14.2.5 Calculating The Impulse |
|
|
353 | (1) |
|
14.2.6 Applying The Impulse |
|
|
353 | (2) |
|
14.3 Resolving Interpenetration |
|
|
355 | (9) |
|
14.3.1 Choosing A Resolution Method |
|
|
355 | (4) |
|
14.3.2 Implementing Nonlinear Projection |
|
|
359 | (3) |
|
14.3.3 Avoiding Overrotation |
|
|
362 | (2) |
|
14.4 The Collision Resolution Process |
|
|
364 | (20) |
|
14.4.1 The Collision Resolution Pipeline |
|
|
365 | (2) |
|
14.4.2 Preparing Contact Data |
|
|
367 | (5) |
|
14.4.3 Resolving Penetration |
|
|
372 | (7) |
|
14.4.4 Resolving Velocity |
|
|
379 | (2) |
|
14.4.5 Alternative Update Algorithms |
|
|
381 | (3) |
|
|
384 | (1) |
|
|
385 | (2) |
|
Chapter 15 Resting Contacts And Friction |
|
|
387 | (26) |
|
|
388 | (2) |
|
15.1.1 Force Calculations |
|
|
389 | (1) |
|
|
390 | (5) |
|
15.2.1 Removing Accelerated Velocity |
|
|
392 | (1) |
|
15.2.2 Lowering The Restitution |
|
|
393 | (1) |
|
15.2.3 The New Velocity Calculation |
|
|
394 | (1) |
|
|
395 | (4) |
|
15.3.1 Static And Dynamic Friction |
|
|
395 | (3) |
|
15.3.2 Isotropic And Anisotropic Friction |
|
|
398 | (1) |
|
15.4 Implementing Friction |
|
|
399 | (11) |
|
15.4.1 Friction As Impulses |
|
|
400 | (2) |
|
15.4.2 Modifying The Velocity Resolution Algorithm |
|
|
402 | (5) |
|
15.4.3 Putting It All Together |
|
|
407 | (3) |
|
15.5 Friction And Sequential Contact Resolution |
|
|
410 | (1) |
|
|
411 | (1) |
|
|
412 | (1) |
|
Chapter 16 Stability And Optimization |
|
|
413 | (24) |
|
|
413 | (8) |
|
|
414 | (1) |
|
16.1.2 Interpenetration On Slopes |
|
|
415 | (2) |
|
16.1.3 Integration Stability |
|
|
417 | (2) |
|
16.1.4 The Benefit Of Pessimistic Collision Detection |
|
|
419 | (1) |
|
16.1.5 Changing Mathematical Accuracy |
|
|
420 | (1) |
|
|
421 | (15) |
|
|
422 | (8) |
|
16.2.2 Margins Of Error For Penetration And Velocity |
|
|
430 | (2) |
|
|
432 | (2) |
|
16.2.4 Code Optimizations |
|
|
434 | (2) |
|
|
436 | (1) |
|
Chapter 17 Putting It All Together |
|
|
437 | (24) |
|
17.1 Overview Of The Engine |
|
|
437 | (2) |
|
17.2 Using The Physics Engine |
|
|
439 | (19) |
|
|
440 | (5) |
|
|
445 | (6) |
|
|
451 | (7) |
|
17.3 Limitations Of The Engine |
|
|
458 | (1) |
|
|
458 | (1) |
|
17.3.2 Reaction Force Friction |
|
|
458 | (1) |
|
|
459 | (1) |
|
|
459 | (1) |
|
|
459 | (1) |
|
|
459 | (2) |
Part VI Further Topics In Physics |
|
461 | (30) |
|
Chapter 18 Physics In Two Dimensions |
|
|
463 | (12) |
|
|
463 | (2) |
|
|
465 | (2) |
|
18.3 Particle And Mass Aggregate Physics |
|
|
467 | (1) |
|
18.4 The Mathematics Of Rotation |
|
|
467 | (2) |
|
18.4.1 Representing Rotation |
|
|
467 | (2) |
|
|
469 | (1) |
|
|
469 | (2) |
|
|
471 | (2) |
|
18.6.1 Vertex—edge Contacts |
|
|
472 | (1) |
|
18.6.2 Edge—edge Contacts |
|
|
472 | (1) |
|
18.6.3 Contact Generation |
|
|
472 | (1) |
|
|
473 | (1) |
|
|
473 | (1) |
|
|
474 | (1) |
|
Chapter 19 Other Programming Languages |
|
|
475 | (8) |
|
|
475 | (4) |
|
|
479 | (1) |
|
|
480 | (1) |
|
|
481 | (1) |
|
19.5 Other Scripting Languages |
|
|
482 | (1) |
|
Chapter 20 Other Types Of Physics |
|
|
483 | (8) |
|
20.1 Simultaneous Contact Resolution |
|
|
483 | (5) |
|
|
484 | (1) |
|
20.1.2 The Linear-Complementarity Problem |
|
|
485 | (3) |
|
20.2 Reduced Coordinate Approaches |
|
|
488 | (1) |
|
|
489 | (2) |
Appendix A Useful Inertia Tensors |
|
491 | (6) |
|
|
492 | (1) |
|
|
492 | (1) |
|
|
493 | (2) |
|
|
493 | (1) |
|
|
493 | (1) |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
495 | (1) |
|
A.4 Moments Of Inertia In 2d |
|
|
495 | (4) |
|
|
495 | (2) |
Appendix B Useful Friction Coefficients |
|
497 | (2) |
Appendix C Mathematics Summary |
|
499 | (6) |
|
|
499 | (1) |
|
|
500 | (1) |
|
|
501 | (1) |
|
|
502 | (1) |
|
|
503 | (1) |
|
|
504 | (1) |
Glossary |
|
505 | (4) |
Bibliography |
|
509 | (2) |
Index |
|
511 | |