GPAT – Chapter 7 Physics.

Slides:



Advertisements
Similar presentations
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Advertisements

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
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.
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.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
고려대학교 그래픽스 연구실 Chapter 6 Collision Detection 6.1~6.4 고려대학교 그래픽스연구실 민성환.
Computational Geometry & Collision detection
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
1Notes. 2Heightfields  Especially good for terrain - just need a 2d array of heights (maybe stored as an image)  Displacement map from a plane  Split.
1Notes. 2 Triangle intersection  Many, many ways to do this  Most robust (and one of the fastest) is to do it based on determinants  For vectors a,b,c.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1cs533d-winter-2005 Notes  More optional reading on web 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.
Ch. 7: Dynamics.
Game Physics Chris Miles. The Goal To learn how to create game objects with realistic physics models To learn how to simulate aspects of reality in order.
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.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
1cs533d-term Notes  list Even if you’re just auditing!
Semester Physics 1901 (Advanced) A/Prof Geraint F. Lewis Rm 560, A29
Collision Detection CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Rigid Body Simulation.
Computer graphics & visualization Collision Detection – Narrow Phase.
Week 13 - Wednesday CS361.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Game Physics – Part IV Moving to 3D
Erin Catto Blizzard Entertainment Numerical Integration.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
Rotation Rotational Variables Angular Vectors Linear and Angular Variables Rotational Kinetic Energy Rotational Inertia Parallel Axis Theorem Newton’s.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
Computer Game Design and Development
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Two-Dimensional Rotational Dynamics W09D2. Young and Freedman: 1
Havok Xtra Training
1 6. Center of mass, Collisions 6.1. The center of mass To describe the motion of a system of particles (also for their continuous distribution – a solid.
Fundamentals of Computer Animation Collision Detection and Response.
Advanced Computer Graphics Rigid Body Simulation
Physically Based Simulations For Games
Manipulator Dynamics 1 Instructor: Jacob Rosen
Lecture 16 Newton Mechanics Inertial properties,Generalized Coordinates Ruzena Bajcsy EE
Intersecting Simple Surfaces
s= mt+constant where m=Ds/Dt i.e., speed
Parts of these slides are based on
© University of Wisconsin, CS559 Fall 2004
Chapter 4.2 Collision Detection and Resolution
Collision handling: detection and response
Devil physics The baddest class on campus Pre-IB Physics
2.5. Basic Primitive Intersection
Manipulator Dynamics 2 Instructor: Jacob Rosen
Motion in Real and Virtual Worlds
Computer Animation Algorithms and Techniques
Collision Detection.
Advanced Games Development Game Physics
Physics 319 Classical Mechanics
Game Programming Algorithms and Techniques
Presentation transcript:

GPAT – Chapter 7 Physics

Physics Overview Physics in games involves these two basic elements: Object-object interaction (Geometry) Collision detection Collision response Mechanics (Calculus) Object movement Also can be used to simulate Visual effects such as water dynamics More realistic sound and light effects However, these are often too slow for gaming

Collision Detection

Basic Geometry 𝑛 A B C 𝑅 0 𝑣 𝑅 0 𝑅 1 Planes Rays Line segments Point 𝑝 , normal 𝑛 𝑝 ⋅ 𝑛 +𝑑=0 Easy to derive from triangle Rays Point 𝑅 0 , direction 𝑣 , parametric value 𝑡∈ 0,∞ 𝑅 0 + 𝑣 𝑡 Line segments Same as ray except 𝑡∈ 0,1 (i.e., two endpoints) A ray cast involves extending a ray into the scene to determine interaction with objects, e.g., ballistics in FPS games. Often computed by line segments and not actual rays 𝑅 0 𝑣 𝑅 0 𝑅 1

Collision Geometries A separate geometric representation of objects is used instead of the real mesh geometry for collision detection Compare a box (12 triangles) to a complex model for an avatar (>15,000 triangles) Leads to false positives

Collision Geometries Bounding Spheres (BSs) Center Radius Axis-Aligned Bounding Boxes (AABBs) Min/Max in each dimension (2 points) Oriented Bounding Boxes (OBBs) 8 vertices or 6 planes

Collision Geometries Capsules Convex Polyhedrons (Convex Hulls) 2 points Radius Convex Polyhedrons (Convex Hulls) Mesh List of Geometries

BS-BS collision Detection A 𝑟 𝑎 𝑟 𝑏 B Collision if 𝐴−𝐵 2 < 𝑟 𝑎 + 𝑟 𝑏 2 Collision A 𝑟 𝑎 𝑟 𝑏 B Non-collision

AABB-AABB Collision Detection For 2D-boxes A and B: 𝐴.𝑚𝑎𝑥.𝑥>𝐵.𝑚𝑖𝑛.𝑥∧ 𝐵.𝑚𝑎𝑥.𝑥>𝐴.𝑚𝑖𝑛.𝑥∧ 𝐴.𝑚𝑎𝑥.𝑦>𝐵.𝑚𝑖𝑛.𝑦∧ 𝐵.𝑚𝑎𝑥.𝑦>𝐴.𝑚𝑖𝑛.𝑌 𝐴.𝑚𝑖𝑛 𝐴.𝑚𝑎𝑥 𝐴 𝐵 𝐵.𝑚𝑖𝑛 𝐵.𝑚𝑎𝑥 Collision 𝐴.𝑚𝑖𝑛 𝐴.𝑚𝑎𝑥 𝐴 𝐵 𝐵.𝑚𝑖𝑛 𝐵.𝑚𝑎𝑥 Non-collision

Line Segment-plane Collision Detection Given the two equations: 𝑅 0 + 𝑣 𝑡 𝑝 ⋅ 𝑛 +𝑑=0 We solve for their intersection (a point on that plane): 𝑅 0 + 𝑣 𝑡 ⋅ 𝑛 +𝑑=0 𝑅 0 ⋅ 𝑛 + 𝑣 ⋅ 𝑛 𝑡+𝑑=0 𝑡= − 𝑅 0 ⋅ 𝑛 +𝑑 𝑣 ⋅ 𝑛 If 𝑡∈ 0,1 then there is a collision, else non-collision Plug back in if you need the point 𝑛 𝑝 𝑅 0 𝑣

Line Segment-Triangle Collision Detection First figure out the point hits the plane that the triangle lies in Next we determine if that point lies in the triangle Key idea is to determine if the point is on the same side of each edge of the triangle: 𝐴𝐵 × 𝐴𝑃 ⋅ 𝑛 >0 Can be more efficient with Barycentric coordinates A C B P

BS-Plane Collision Detection 𝑟 𝑏 B Essentially, find a hypothetical plane parallel to the first plane and through the center of the sphere Compare the difference of the plane's 𝑑 values to the spheres radius Intersection if: 𝑑 𝐵 =−𝐵⋅ 𝑛 𝑑− 𝑑 𝐵 < 𝑟 𝑏 𝑛 𝑝 𝑂 𝑑 𝐵 𝑑 Non-collision

Swept BS Collision Detection 𝑡=1 𝑡=0 Essentially, a version of continuous collision detection (or collision detection for capsules) Again, construct parametric equations and solve Specifically, construct rays for the motion of the object centers and find the point where the distance between the rays is the same as the sum of the radii B A 𝑡=1 𝑡=0 A B

Swept BS Collision Detection 𝑡=1 𝑡=0 Center motion: 𝐴 t = 𝐴 0 + 𝑣 𝐴 𝑡 𝐵 t = 𝐵 0 + 𝑣 𝐵 𝑡 Solve for 𝑡 in: 𝐴 𝑡 − 𝐵 𝑡 = 𝑟 𝐴 + 𝑟 𝐵 𝐴 𝑡 − 𝐵 𝑡 ⋅ 𝐴 𝑡 − 𝐵 𝑡 = 𝑟 𝐴 + 𝑟 𝐵 2 B A 𝑡=1 𝑡=0 A B

Swept BS Collision Detection 𝑡=1 𝑡=0 𝐴 𝑡 − 𝐵 𝑡 ⋅ 𝐴 𝑡 − 𝐵 𝑡 = 𝑟 𝐴 + 𝑟 𝐵 2 Looking at 𝐴 𝑡 − 𝐵 𝑡 : 𝐴 0 + 𝑣 𝐴 𝑡− 𝐵 0 − 𝑣 𝐵 𝑡 𝐴 0 − 𝐵 0 + 𝑣 𝐴 − 𝑣 𝐵 𝑡 Let 𝐶 = 𝐴 0 − 𝐵 0 , 𝐷 = 𝑣 𝐴 − 𝑣 𝐵 so: 𝐶 + 𝐷 𝑡 ⋅ 𝐶 + 𝐷 𝑡 = 𝑟 𝐴 + 𝑟 𝐵 2 B A 𝑡=1 𝑡=0 A B

Swept BS Collision Detection 𝑡=1 𝑡=0 Expanding the dot product: 𝐶 ⋅ 𝐶 +2 𝐶 ⋅ 𝐷 𝑡+ 𝐷 ⋅ 𝐷 𝑡 2 = 𝑟 𝐴 + 𝑟 𝐵 2 Let 𝑎= 𝐷 ⋅ 𝐷 ,𝑏= 𝐶 ⋅ 𝐷 , 𝑐= 𝐶 ⋅ 𝐶 − 𝑟 𝐴 + 𝑟 𝐵 2 , so: 𝑎 𝑡 2 +𝑏𝑡+𝑐=0 Solve with quadratic equation, and if the discriminant is greater than 0 and further 𝑡∈ 0,1 , then there is a collision. Otherwise no collision (or tangent) B A 𝑡=1 𝑡=0 A B

Collision Response Simple examples Complex interactions Objects "die" One object loses health Complex interactions Need to determine exact point of collision (LERP) Need to determine normals at point of collision Reflect and scale velocities about normals depending on elasticity of collision A B

Optimizing Collision Detection Often use a hierarchy of collision geometries (e.g., sphere/box then convex hull) Use of spatial trees, e.g., quadtree to limit which objects collision is performed against (~logarithmic time and ~constant number of triangles to collision check)

Physics-based movement

Review of Linear (Newtonian) Mechanics Newton's second law of motion – force is mass by acceleration 𝐹 =𝑚 𝑎 For position 𝑥 : Velocity 𝑣 = 𝑥 (first derivative with respect to time) Acceleration 𝑎 = 𝑣 = 𝑥 (second derivative with respect to time) In games however, we are trying to compute the next time steps position 𝑥 ′ , thus, we need the anti-derivative, i.e., integration Further we need to use numerical integration, after all we don't even have a symbolic representation of our motion Essentially cannot use variable time step Accuracy is related to the magnitude of the time step Begin by calculating the force, e.g., gravity, wind resistance, impulses, etc Next compute acceleration 𝑎 = 𝐹 𝑚

Euler and Semi-Implicit Euler Integration Euler integration – use current velocity to alter position 𝑥 ′ = 𝑥 + 𝑣 Δt 𝑣 ′ = 𝑣 + 𝑎 Δt Semi-implicit Euler integration – use next velocity to alter position 𝑣 ′ = 𝑣 + 𝑎 Δt 𝑥 ′ = 𝑥 + 𝑣 ′ Δt

Advanced Considerations Can use Velocity Verlet integration (essentially the trapezoid rule) Could use Taylor series expansions, e.g., Fourth Order Runge-Kutta All about how much error you can handle For angular considerations – torque is moment of inertia by angular accelaration 𝜏 =𝐼 𝛼 then use integration to get angular velocity 𝜔 and angle 𝑞 Complicated as moment of interia is a matrix Typically utilize existing libraries PhysX Bullet etc

Summary In this chapter we delved into the basics elements of emulating physics Collision detection Collision response Physics-based movement through numerical integration