
<p> Self-Introduction <a href="/tags/Collision_detection/" rel="tag">Collision Detection</a></p><p>Collision Detection in Computer Games</p><p>Fangkai Yang1</p><p>1Computational Science and Technology KTH Royal Institute of Technology</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Collision Detection Outline</p><p>1 Self-Introduction Who is Fangkai?</p><p>2 Collision Detection Let’s Play a Game! Collision Detection</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Who is Fangkai? Collision Detection Outline</p><p>1 Self-Introduction Who is Fangkai?</p><p>2 Collision Detection Let’s Play a Game! Collision Detection</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Who is Fangkai? Collision Detection Who is Fangkai?</p><p>Definition Fangkai Yang is a crazy Gamer, Mathematician and Programmer.</p><p>PhD candidate in Computer Science. Research on Crowd-simulation and Game AI. Game developer: Just Cause 3 (Avalanche Studios), War Rage (NetEase Games).</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Collision Detection: A Gentle Introduction</p><p>Collision detection concerns the detection of collisions between objects in the virtual environment. Primarily employed to stop objects moving through each other and the environment.</p><p>Collision Detection is everywhere in computer games: between characters and characters, between characters and terrain, etc.</p><p>Remember: Physical laws do not exist in the virtual world by default. Must computationally model and program them.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Dayz Standalone</p><p>What my friends think I was playing:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Dayz Standalone</p><p>What I was actually playing:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Dayz Standalone</p><p>What I was actually playing:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection FIFA</p><p>What my friends think I was playing:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection FIFA</p><p>What I was actually playing:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Basic Geometry Types</p><p>Rigid-bodies Hard objects (ideal solid bodies) Constant distance between vertices in the mesh Convex vs. concave Soft-bodies Cloth, for example More complicated to simulate Soft-bodies like cloth may collide with themselves</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Basic Geometry Types</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Basic Geometry Types</p><p> https://www.youtube.com/watch?v=M5Ygpxfmcg8</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Outline</p><p>1 Self-Introduction Who is Fangkai?</p><p>2 Collision Detection Let’s Play a Game! Collision Detection</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection King of Fighter 97</p><p>I want a volunteer!</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>Question: How to test if a character has been hit?</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Outline</p><p>1 Self-Introduction Who is Fangkai?</p><p>2 Collision Detection Let’s Play a Game! Collision Detection</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Collision Detection</p><p>Definition Collision detection refers the detection of the intersection of two or more objects.</p><p>Figure: Collision detection in Street Fighter</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>Figure: Overlaps of characters.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>How about collision detection in 3D games?</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Penetration</p><p>When collision is detected, the penetration follows.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>Two forms of collision detection: Continuous: very expensive. Simulate solid objects in real life. Discrete: objects will end up with penetrating each other.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Backtracking</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Backtracking</p><p>Like Tom Cruise in Edge of Tomorrow, it turns time backwards and fix the penetration that occurred in the last frame.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection <a href="/tags/Bounding_volume/" rel="tag">Bounding Volume</a></p><p>Definition Bounding volume for a set of objects is a closed volume that completely contains the union of the objects in the set.</p><p>(a) In the game scenario. (b) In the <a href="/tags/Physics_engine/" rel="tag">physics engine</a>.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Bounding Volume types</p><p>Bounding Box: Axis Aligned Bounding Box (AABB), Oriented Bounding Box (OBB), etc. For objects that rest upon other, such as a car resting on the ground, using a bounding box is a better choice. Bounding Sphere: They are very quick to test for collision with each other.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Sphere Collision Detection</p><p>Circles are colliding if D <= (R1 + R2) d is the distance between the circle centers R1 and R2 are the radii of both circles respectively</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection AABB Collision Detection</p><p>Recall: Faces of an AABB are aligned with the coordinates axes. To see if A and B overlap, separating axes test can be used along the x,y and z axes. This is faster, as only need to search x,y and z axes.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Some Problems</p><p>Naive collision detection approaches may simply test if two objects are overlapping at every time-step. Problem: quickly moving objects can pass right through each other without detection</p><p>(b) First test. (c) Second test.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Swept Volume</p><p>The AABB in the game bounds not the object, but the Swept Volume of the object from one frame to the next.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Broad Phase and Narrow Phase</p><p>Most efficient implementations use a two-phase approach: a broad phase followed by a narrow phase. Broad phase: collision tests are based on bounding volumes only. Quickly prune away pairs of objects that do not collide with each other. The output is the potentially colliding set of pairs of objects. Narrow phase: collision tests are exact−they usually compute exact contact points and normals−thus much more costly, but performed for only the pairs of the potentially colliding set.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Broad Phase</p><p>Figure: Collision detection between AABBs (Axis Aligned Bounding Box).</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Broad Phase</p><p>The broad phase collision detection helps to filtrate the potentially colliding object sets. The brute-force way is doing collision test for all pairs of objects, and the complexity is O(n2).</p><p>(a) Sweep and prune. (b) Spatial subdivision.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Narrow Phase</p><p>Separating Axis Tests</p><p>Many <a href="/tags/Algorithm/" rel="tag">algorithms</a> are based on the separating hyperplane theorem</p><p>Figure: Two disjoint convex sets are separable by a hyperplane.</p><p>Separation w.r.t. a plane P => separation of the orthogonal projections onto any line L parallel to plane normal</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Separating Axis Tests</p><p>Think of it like this: do a twist to simplify calculations.</p><p>Separating axis is a line for which the projection intervals do not overlap.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Separating Axis Tests</p><p>Separated if Amax < Bmin or Bmax < Amin</p><p>Question: Which axes to be tested?</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Separating Axis Tests</p><p>Axes to test:</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Convex versus Convex Collision Detection</p><p>One of the most commonly used <a href="/tags/Algorithm/" rel="tag">algorithm</a> in <a href="/tags/Game_engine/" rel="tag">game engine</a> is GJK (Gilbert-Johnson-Keerthi) algorithm. This algorithm relies on a support function to iteratively get closer simplices to the solution using Minkowski difference.</p><p>(a) Two shapes collide on one vertex. (b) No collision.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection GJK</p><p>Given the two polyhedra: Computes the distance d between them Can also return the closest pair of points on each polygons</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection Support Mapping Function</p><p>Supporting point. This is an extreme point on the polygon for a given direction d. The support mapping function returns this point</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection The first simplex is built using what is called a support function. Support function returns one point inside the Minkowski difference given two sets KA and KB.</p><p>Figure: The first two vertices in the first simplex.</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Select direction d = (1, 0): p1 = (9, 9); p2 = (5, 7); p3 = p1 − p2 = (4, 2);</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Select direction d = (−1, 0): p1 = (4, 5); p2 = (12, 7); p3 = p1 − p2 = (−8, −2);</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Select direction d = (0, 1): p1 = (4, 11); p2 = (10, 2); p3 = p1 − p2 = (−6, 9);</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>The Simplex doesn’t contain the origin, but we know that the two shapes are intersecting. The problem here is that our first guess (at choosing directions) didn’t yield a Simplex that enclosed the origin. Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Select direction d = (0, −1): p1 = (4, 5); p2 = (5, 7); p3 = p1 − p2 = (−1, −2);</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Now we contain the origin and can determine that there is a collision</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection An Example</p><p>Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>(a) The first iteration. (b) New simplex does not contain the origin.</p><p>(c) The second (d) New simplex iteration. contains the origin. Fangkai Yang Collision Detection in Computer Games Self-Introduction Let’s Play a Game! Collision Detection Collision Detection</p><p>Thank you for Listening and Sleeping!</p><p>Fangkai Yang Collision Detection in Computer Games</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages0 Page
-
File Size-