Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.

Slides:



Advertisements
Similar presentations
Real-Time Game Physics
Advertisements

2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
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.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
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.
Motivation Hair animation used in movies, games, virtual reality, etc. Problem due to complexity –Human head has over 100,000 strands of hair –Computation.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
Continuous Collision Detection: Progress and Challenges Gino van den Bergen dtecta
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
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.
Particle Systems Final Exam Study Guide Game Design Experience Professor Jim Whitehead March 16, 2009 Creative Commons Attribution 3.0 (Except copyrighted.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
CSCE 590E Spring 2007 Graphics I By Jijun Tang. Announcements Second presentation will be held on April 16 th and 18 th  April 16 th : Space Banditos,
CS 326 A: Motion Planning robotics.stanford.edu/~latombe/cs326/2004/index.htm Collision Detection and Distance Computation.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
CSCE 590E Spring 2007 Collision Detection By Jijun Tang.
Mechanics, Dynamics & Aesthetics The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object.
Collision Detection Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
Efficient Distance Computation between Non-Convex Objects By Sean Quinlan Presented by Sean Augenstein and Nicolas Lee.
Collision Detection David Johnson Cs6360 – Virtual Reality.
CIS 487/587 Bruce R. Maxim UM-Dearborn
Game Physics What is meant by Physics in games (old)? –Collision Detection (testing) But want the physical effect of hitting an immovable object. Also.
Computer graphics & visualization Collision Detection – Narrow Phase.
CS 4730 Collision Detection CS 4730 – Computer Game Design.
INTERACTION TECHNIQUES Collision Detection and Other Interactions Collision Detection and Other Interactions.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Collision and Animation Systems in Games Jani Kajala Lead Programmer / Chief Technology Officer, Pixelgene Ltd (0)
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
CSCE 552 Spring 2009 Math, Physics and Collision Detection By Jijun Tang.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
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.
Computer Game Design and Development Mathematics, Collision, and Physics Havok Destruction.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
A Computationally Efficient Framework for Modeling Soft Body Impact Sarah F. Frisken and Ronald N. Perry Mitsubishi Electric Research Laboratories.
Controlling a Virtual Camera Ross Ptacek University of Alabama Birmingham.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Computer Game Design and Development
CSE 380 – Advanced Game Programming Sweep & Prune.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9.
Computer Game Design and Development Collision Detection Havok Destruction.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Introduction to Game Programming & Design III Lecture III.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
Review IMGD Engine Architecture Types Broadly, what are the two architecture types discussed for game engines? What are the differences?
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Collision Detection Spring 2004.
Parts of these slides are based on
Math, Physics and Collision Detection
Chapter 4.2 Collision Detection and Resolution
Mechanics, Dynamics & Aesthetics
Motion in Real and Virtual Worlds
Computer Animation Algorithms and Techniques
Collision Detection.
CO Games Concepts Week 12 Collision Detection
GPAT – Chapter 7 Physics.
Presentation transcript:

Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공

Topics Introduction Point Masses –Projectile motion –Collision response Rigid-Bodies –Numerical simulation –Controlling truncation error –Generalized translation motion Soft Body Dynamic System Collision Detection (today)

Collision Detection Determining when objects collide not as easy as it seems –Geometry can be complex (beyond spheres) –Objects can move fast –Can be many objects (say, n ) Naïve solution is O(n 2 ) time complexity, since every object can potentially collide with every other object Two basic techniques –Overlap testing Detects whether a collision has already occurred –Intersection testing Predicts whether a collision will occur in the future

Overlap Testing Facts –Most common technique used in games –Exhibits more error than intersection testing Concept –For every simulation step, test every pair of objects to see if overlap –Easy for simple volumes like spheres, harder for polygonal models Useful results of detected collision –Collision normal vector (needed for physics actions, as seen earlier) –Time collision took place

Overlap Testing: Collision Time Collision time calculated by moving object back in time until right before collision –Move forward or backward ½ step, called bisection Get within a delta (close enough) –With distance moved in first step, can know “how close” In practice, usually 5 iterations is pretty close

Overlap Testing: Limitations Fails with objects that move too fast –Unlikely to catch time slice during overlap Possible solutions –Design constraint on speed of objects (fastest object moves smaller distance than thinnest object) May not be practical for all games –Reduce simulation step size Adds overhead since more computation Note, can try different step size for different objects

Intersection Testing Predict future collisions Extrude geometry in direction of movement –Ex: swept sphere turns into a “capsule” shape Then, see if overlap When predicted: –Move simulation to time of collision –Resolve collision –Simulate remaining time step

Intersection Testing: Sphere-Sphere Collision Or, simpler: If distance large enough, no collision: If t is in [0..1] then collide

Dealing with Complexity Complex geometry must be simplified –Complex object can have 100’s or 1000’s of polygons –Testing intersection of each costly Reduce number of object pair tests –There can be 100’s or 1000’s of objects –If test all, O(n 2 ) time complexity

Complex Geometry – Bounding Volume (1 of 3) Bounding volume is simple geometric shape that completely encapsulates object –Ex: approximate spiky object with ellipsoid Note, does not need to encompass, but might mean some contact not detected –May be ok for some games

Complex Geometry – Bounding Volume (2 of 3) Testing cheaper –If no collision with bounding volume, no more testing is required –If there is a collision, then there could be a collision More refined testing can be used Commonly used bounding volumes –Sphere – if distance between centers less than sum of Radii then no collision –Box – axis-aligned (lose fit) or oriented (tighter fit)

Complex Geometry – Bounding Volume (3 of 3) For complex object, can fit several bounding volumes around unique parts –Ex: For a human character, boxes around torso and limbs, sphere around head Can use hierarchical bounding volume –Ex: large sphere around whole avatar If collide, refine with more refined bounding boxes Movie: Bounded Deformation Tree

Complex Geometry – Minkowski Sum (1 of 2) Take sum of two convex volumes to create new volume –Sweep origin (center) of X all over Y +=

Complex Geometry – Minkowski Sum (2 of 2) Test if single point in X in new volume, then collide –Take center of sphere at t 0 to center at t 1 –If line intersects new volume, then collision

Reduced Collision Tests - Partitioning Partition space so only test objects in same cell –If N objects, then sqrt(N) x sqrt(N) cells to get linear complexity But what if objects don’t align nicely? What if all objects in same cell? (same as no cells)

Reduced Collision Tests – Plane Sweep Objects tend to stay in same place –So, don’t need to test all pairs Record bounds of objects along axes Any objects with overlap on all axes should be tested further Time consuming part is sorting bounds –Quicksort O(nlog(n)) –But, since objects don’t move, can do better if use Bubblesort to repair – nearly O(n)

Collision Resolution (1 of 2) Once detected, must take action to resolve –But effects on trajectories and objects can differ Ex: Two billiard balls strike –Calculate ball positions at time of impact –Impart new velocities on balls –Play “clinking” sound effect Ex: Rocket slams into wall –Rocket disappears –Explosion spawned and explosion sound effect –Wall charred and area damage inflicted on nearby characters Ex: Character walks through invisible wall –Magical sound effect triggered –No trajectories or velocities affected

Collision Resolution (2 of 2) Prologue –Collision known to have occurred –Check if collision should be ignored –Other events might be triggered Sound effects Send collision notification messages (OO) Collision –Place objects at point of impact –Assign new velocities Using physics or Using some other decision logic Epilog –Propagate post-collision effects –Possible effects Destroy one or both objects Play sound effect Inflict damage Many effects can be done either in the prologue or epilogue

Collision Resolution – Collision Step For overlap testing, four steps –Extract collision normal –Extract penetration depth –Move the two objects apart –Compute new velocities (previous stuff) For intersection testing, two steps –Extract collision normal –Compute new velocities (previous stuff)

Collision Resolution – Collision Normal Find position of objects before impact –Use bisection Use two closest points to construct the collision normal vector (Case A) For spheres, normal is line connecting centers (Case B) A B

Collision Resolution – Intersection Testing Simpler than resolving overlap testing –No need to find penetration depth or move objects apart Simply 1. Extract collision normal 2. Compute new velocities

Collision Detection Summary Test via overlap or intersection (prediction) Control complexity –Shape with bounding volume –Number with cells or sweeping When collision: prolog, collision, epilog

Game Programming 더 알아야 할 것들 : –ODE, OgreODE –Shader, GPU programming, Deferred Rendering –Particle System, Fluid Simulation (smoke, water)