CSE 381 – Advanced Game Programming Quickhull and GJK.

Slides:



Advertisements
Similar presentations
The Gilbert-Johnson-Keerthi (GJK) Algorithm
Advertisements

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
CSE 380 – Computer Game Programming Collision Detection & Response Erin Catto’s Box2D.
CSE 381 – Advanced Game Programming Scene Management
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
Oct 3, Fall 2005Game Design1 Collision Detection.
1 Advanced Scene Management System. 2 A tree-based or graph-based representation is good for 3D data management A tree-based or graph-based representation.
Collision Detection David Johnson Cs6360 – Virtual Reality.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
INTERACTION TECHNIQUES Collision Detection and Other Interactions Collision Detection and Other Interactions.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
CSE 381 – Advanced Game Programming GJK. GJK Gilbert – Johnson – Keerthi distance algorithm Used to determine the minimum distance between convex sets.
Collision handling: detection and response
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Collision/Acceleration University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Collaborative Visual Computing Lab Department of Computer Science University of Cape Town Graphics Topics in VR By Shaun Nirenstein.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
CSE 381 – Advanced Game Programming Collision Detection.
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
Computer Game Design and Development
CSE 380 – Advanced Game Programming Sweep & Prune.
Chapter 11 Collision Detection 가상현실 입문 그래픽스 연구실 민성환.
11/20/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Collision Detection Overview Player-Environment handling.
Presented by Paul Phipps
Maths & Technologies for Games Spatial Partitioning 2
3D Object Representations 2011, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9.
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Minkowski Sums and Distance Computation Eric Larsen COMP
Bounding Volume Hierarchies and Spatial Partitioning
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
3D Object Representations
2.1. Collision Detection Overview.
Parts of these slides are based on
Chapter 4.2 Collision Detection and Resolution
Collision handling: detection and response
Computer Animation Algorithms and Techniques
Collision Detection.
CO Games Concepts Week 12 Collision Detection
David Johnson Cs6360 – Virtual Reality
GPAT – Chapter 7 Physics.
Presentation transcript:

CSE 381 – Advanced Game Programming Quickhull and GJK

What is collision detection? Determining if, when, & where two objects intersect What objects? Linear components, planes, triangles, rectangles, oriented boxes, spheres, capsules, lozenges, cylinders, ellipsoids, etc. Hugely important part of a 3D game engine. Why? done continuously every frame involves huge amounts of computations Entire textbooks are written on this subject alone Real-Time Collision Detection by Christer Ericson Collision Detection in Interactive 3D Environments by Gino van den Bergen

Collision Detection & Graphics Work together in a game engine Should be developed together Both share: geometric data timing elements So, pool resources for their algorithms e.g., scene graphs, spatial partitioning (octrees, bsps…)

Game Engine Collision Detection 2 phases Broad phase: determine which pairs of shapes need to be tested for collision Narrow phase: determine collision results for each pair identified in broad phase All game objects maintain collision sets data for collisions calculations i.e., bounding volumes

Types of Collisions Object versus plane (navigation or culling) Object versus object (general collision) Linear component versus object (picking)

Imagine a complex world Hundreds of interior structures, each with rooms Complex external terrain environment Water with underwater structures (interiors) Rather than testing these items serially, we can do so hierarchically much faster continuously reduce the problem

How should collision data be organized? One of the most important questions in designing a collision system Game world might contain a large number of interacting objects an exhaustive comparison is too exhaustive Objects should be organized into collision groups e.g., rooms, partitions, etc.

Rooms as collision groups Scene graphs & collision sets are not static, they change with the game as players, NPCs, or other game objects move/change When a player enters a room, the scene graph is reconfigured player is now part of room collision group Only objects moving within a room are tested against one another for collisions

Collision Detection Game Physics This is a huge topic Game physics is rapidly changing

Collision Detection & Response Collision Detection detecting what game objects are colliding with each other Collision Response providing a programmed response to collisions that fits with the game’s design & custom laws of physics

Static vs. Dynamic Objects Static objects never move Dynamic objects move Collisions may be between: Static objects & dynamic objects (fast & easy) Dynamic objects & dynamic objects (harder)

What types of collisions might we care about? Main character and static objects: terrain, floor, tiles, walls, furniture, buildings, game objects (i.e. power-ups, ammo), etc. Main character & dynamic objects: enemies, projectiles (i.e. bullets, arrows, etc.), particles (expensive), etc. Other dynamic objects and: other static objects other dynamic objects

Collisions in Pairs In collision detection, we always compare pairs of objects. Easier to: understand design & implement solutions A naïve approach: one pair at a time, compare all game objects in a game world against all other game objects in a game world

Collision Detection Calculations What data are we looking for? 1.Do these two objects potentially collide? 2.Do these two objects collide? 3.When did these two objects collide? 4.Where did these two objects collide? where on geometry of objects, points of impact These 4 questions get progressively: more computationally expensive to implement more complex to implement (more math)

Phases of Collision Detection Spatial Partitioning Algorithms problem reduction only perform additional phases on pairs of object on same “islands” Broad Phase – early rejection tests Do the coarse Bounding Volumes of two objects collide? Narrow Phase What are the contact points on object geometries? Done down to the last triangle in 3D games

Bounding Volumes The base geometry used for all collision tests instead of the shape’s geometry, which is too expensive Properties of desirable BVs: inexpensive intersection tests tight fitting inexpensive to compute easy to rotate and transform use little memory Ref: [1]

Assumptions you might make All collideable game objects: have rectangular Bounding Volumes don’t rotate, or if they do rotate, we don’t care about them colliding with stuff Thus: no polytope collision detection equations no rotation equations this makes life much easier (no narrow phase)

Common Bounding Volumes Note that the space craft has been rotated Ref: [1], Figure 4.2 This semester, we like AABBs and/or Spheres axis-aligned bounding boxes

Spatial Partitioning First, reduce the problem only perform additional phases on pairs of object on same “islands” Common Solutions: Octree Algorithms (quadtrees for 2D) also: Portals (ala Quake), BSP trees (Binary Space Partitions), Spatial Hashing, etc.

Octrees Used to divide a 3D world into “islands” 2D divided via Quadtrees Why? to make rendering more efficient to make collision detection more efficient What would be the data for these nodes? region coordinates for cell though a smart implementation might eliminate this too AABBs

Octree Source:

Octree Drawbacks Objects cross islands octree has to be constantly updated not so bad Objects straddle islands collision detection may involve objects from multiple islands can be a headache

Broad Phase Do the coarse AABBs of two objects collide? Common solution: separating axis algorithms including temporal coherence For efficiencies use: Sweep & Prune an extension of separating axis, more efficient for many elements

Narrow Phase What are the contact points on object geometries? for 3D might be convex hulls Two Steps 1.determine potentially colliding primitives (ex: triangles) of a pair of objects AABB tree algorithms 2.determine contact between primitives GJK algorithms Ref[3]

What’s a convex set? What does convex mean? Convex Test: –For all the shape’s vertices: Make a line between each pair Is entire line inside object? –If yes, it is convex –If no, it is not (i.e., has dent)

Convex Set vs. Hull Convex Set –a set of points representing a convex shape Convex Hull –a minimal convex set –minimally snugly fits points (rubber band analogy)

Quickhull Algorithm for making a convex hull from a points set 1)Find min and max points on all axes to form minimal bounding box 2)Min/Max points represent first approximation 3)Exclude all points within the hull 4)For each line in approximation, find point furthest outside polytope 5)Add those points to hull in between the points that formed the line 6)If any points remain to consider, go back to step 3

GJK Gilbert – Johnson – Keerthi distance algorithm Used to determine the minimum distance between convex sets Why? –to see if they are colliding –to see where they are colliding

Minkowski Sum What’s that? –A mathematical operation performed on 2 shapes A B = All Points in A + All Points in B How many points do we end up with? –A * B

Visualizing Minkowski Sums Results in swept shapes A B A B

Minkowski Difference The Opposite of a Minkowski Sum A B = All Points in A – All Points in B How many points do we end up with? –A * B

Visualizing Minkowski Differences Results in swept shapes A B A B

An Interesting Detail For Minkowski Difference A B If A and B are intersecting, A B contains origin A B A B

Now Let’s Get Back To GJK Assume we have two shapes, A & B We want to know if A & B intersect

GJK for A & B Collision Test 1.Calculate Minkowski Difference 2.Select any Minkowski Difference point 3.Start at that point, and try to get to origin by visiting other points. –remember, this is a convex set 4.Build polytope using 4 points –iteratively update to find next one 5.If any polytope along way contains origin, no collision 6.If polytope never contains origin, no collision

Visualizing GJK Miss (no collision) Note: I’ve simplified things a bit for rendering

Visualizing GJK Hit (collision)