English | MP4 | AVC 1920×1080 | AAC 44KHz 2ch | 191 Lessons (35h 7m) | 7.16 GB
Learn all the theory and the math behind 2D game physics and create a simple rigid-body physics engine from scratch with C++.
This course is a gentle introduction into the world of 2D game physics! We’ll review all the beautiful math that provides the foundation for most physics engines, starting with a strong review of vectors, matrices, basic trigonometry, rigid-body collision, and touching a little bit of calculus as well.
The lectures are designed to teach all concepts from first principles. In our journey, we’ll review several topics from physics, like velocity, acceleration, integration, mass, forces, gravity, drag, friction, rigid body dynamics, collision detection, constraints, etc.
We’ll also put theory into practice by coding a very simple 2D physics engine from scratch using the C++ programming language.
We’ll start by writing a simulation of particle physics, which is a good start for us to address concepts like movement, forces, displacement, and integration.
We’ll then proceed to work with rigid bodies by adding shapes to our objects, like circles, rectangles, and polygons. We’ll also learn how to code the collision detection and collision resolution between these rigid bodies.
We’ll conclude our C++ implementation by adding constraints to our physics engine, which will help us add different types of objects to our engine, like joints and ragdolls. Ultimately, constraints will help us improve the stability of our engine, and they are a great opportunity for us to discuss some interesting ideas from calculus.
The tools you’ll need
All you really need is a simple code editor and a C++ compiler. We’ll use a cross-platform library called SDL to display our graphics, and since we can find a C++ compiler for virtually any operating system, you can follow along on either Windows, macOS, or Linux!
Also, make sure you have pen and paper ready for the lectures. This course will probably be a little bit different than other programming courses you took before. We will take our sweet time and make sure we understand every formula we find along the way!
Table of Contents
1 Introduction & Learning Outcomes
2 How to Take this Course
3 What is Game Physics
4 A Quick Review of Vector Math
5 Vector & Scalar Quantities
6 Using the P5js Web Editor
7 Visualizing Errors in the Web Editor
8 Coding a Vec2 Class
9 Vector Magnitude
10 Vector Addition & Subtraction
11 Methods for Vector Addition & Subtraction
12 Vector Equality
13 Scaling Vectors
14 Static Methods
15 Applications of Vector Addition & Subtraction
16 Dot Product
17 Is the Dot Product Commutative
18 Cross Product
19 Coding the Cross Product Method
20 Exercise Perpendicular 2D Vector
21 Perpendicular 2D Vector
22 Exercise Vec3 Methods
23 Vec3 Methods
24 Vector Normalization
25 Coding the Normalization Method
26 Scaling, Translating, and Rotating Vectors
27 Quick Review of Sine & Cosine
28 Vector Rotation Proof (x-component)
29 Vector Rotation Proof (y-component)
30 Coding the Vec2 Rotate Method
31 Concluding our JavaScript Vector Class
32 Vec2 C++ Header File
33 A Quick Look at C++ Vec2 Syntax
34 Vec2 Operator Overloading
35 Technologies & Dependencies
36 Folder Structure
37 Initial Project Files
38 Compiling using GCC & Linux
39 Makefile
40 Configuring Visual Studio on Windows
41 Introduction to Particle Physics
42 Particle Class
43 Particle Velocity
44 Using the + Operator to Add Vectors
45 Controlling our Framerate
46 Framerate Independent Movement
47 Clamping Invalid DeltaTime Values
48 Moving in a Constant Velocity
49 Changing the Particle’s Velocity
50 Keeping the Particle Inside the Window
51 Constant Acceleration
52 Discrete vs. Continuous
53 Integration & Movement Simulation
54 Different Integration Methods
55 Particle Integrate Function
56 Applying Forces to Particles
57 Function to Add Force
58 Particles with Different Mass
59 The Weight Force
60 Inverse of the Mass
61 Applying Forces with the Keyboard
62 Drag Force
63 Drag Force Function
64 Handling Mouse Clicks with SDL
65 Unexpected Drag Behavior
66 Friction Force
67 Friction Force Function
68 Gravitational Attraction Force
69 Gravitational Attraction Force Function
70 Spring Force
71 Spring Force Function
72 Exercise Spring Forces
73 Multiple Particles Chain
74 Multiple Particles Soft body
75 Soft Bodies & Verlet Integration
76 Rigid-Bodies
77 Shapes
78 Shape Class
79 Shape Class Implementation
80 Circle Shape
81 Angular Velocity & Angular Acceleration
82 Torque & Moment of Inertia
83 Circle Shape Angular Motion
84 Box Vertices
85 Local Space vs. World Space
86 Body Update Function
87 Why Not a Shape Draw Function
88 No Draw Method in the Shape Class
89 Circle-Circle Collision Detection
90 Circle-Circle Collision Class
91 Circle-Circle Collision Implementation
92 Collision Contact Information
93 Collision Information Code
94 Broad Phase & Narrow Phase
95 The Projection Method
96 Objects with Infinite Mass
97 Impulse Method & Momentum
98 Impulse
99 Deriving the Linear Impulse Formula
100 Simplifying the Impulse Method Formula
101 Coding the Linear Impulse Method
102 Is Linear Collision Response Enough
103 AABB Collision Detection
104 SAT Separating Axis Theorem
105 Finding Minimum Separation with SAT
106 Polygon-Polygon Collision Code
107 Code to Find SAT Minimum Separation
108 Refactoring the SAT Separation Function
109 Finding Extra Collision Information with SAT
110 Polygon-Polygon Collision Information
111 Linear & Angular Velocity At Point
112 Post-Collision Velocity At Point
113 Computing Linear & Angular Impulse
114 Collision Distance Vectors Ra-Rb
115 D Cross Product Simplification
116 Coding the Impulse Along Normal
117 Exercise Impulse Along Tangent
118 Friction Impulse Along Tangent
119 Removing Window Boundaries Check
120 Circle-Polygon Collision Detection
121 Finding Polygon’s Nearest Edge with Circle
122 Exercise Circle-Polygon Edge Regions
123 Circle-Polygon Collision Information
124 Circle-Polygon Collision Resolution
125 Exercise Polygons with Multiple Vertices
126 Polygon with Multiple Vertices
127 Loading SDL Textures
128 Rendering Circle Texture
129 World Class
130 Implementing World Functions
131 Refactoring Function to Update Vertices
132 Local Solvers vs. Global Solvers
133 A Naive Iterative Positional Correction
134 Constrained Rigid-Body Physics
135 Position vs. Velocity Constraints
136 Example Velocity Constraint & Bias Factor
137 Example Distance Constraint & Bias Factor
138 Constraint Forces & Constrained Movement
139 Force-Based vs. Impulse-Based Constraints
140 The Constraint Class
141 VecN Class
142 Implementing VecN Functions
143 VecN Operator Overloading
144 Matrices
145 MatMN Class
146 Matrix Transpose
147 Matrix Multiplication
148 Matrix Multiplication Function
149 Seeing Beyond the Matrix
150 Generalized Velocity Constraint
151 Solving Violated Velocity Constraints
152 Constraint Class Inheritance
153 Distance Constraint
154 Joint Constraint Class
155 Converting World Space to Local Space
156 World List of Constraints
157 Refactoring Body Update
158 Deriving the Distance Jacobian
159 Populating the Distance Jacobian
160 Solving System of Equations (Ax=b)
161 Gauss-Seidel Method
162 Constrained Pendulum
163 Solving System of Constraints Iteratively
164 Warm Starting
165 Adding the Bias Term
166 Ragdoll with Joint Constraints
167 Preventing NaN Errors
168 Penetration Constraint
169 Deriving the Penetration Jacobian
170 Penetration Constraint Class
171 Solving Penetration Constraints
172 Penetration Warm Starting
173 Penetration Constraint Friction
174 Clamping Friction Magnitude Values
175 Penetration Constraint Bounciness
176 Unstable Stack of Boxes
177 Allowing for Multiple Contact Points
178 Reference & Incident Edges
179 Finding Incident Edge
180 Getting Ready for Clipping
181 Clipping Function
182 Testing Multi-Contact Boxes
183 Testing Multiple Objects & Constraints
184 Contact Caching
185 Continuous Collision Detection
186 Broad & Narrow Split
187 Euler Integration Review
188 MidPoint & RK4 Integrators
189 Verlet Integration
190 Stick Constraints
191 Conclusion & Next Steps
Resolve the captcha to access the links!