What you will learn today

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
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.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
Copyright  1999 by James H. Money. All rights reserved. Except as permitted under United States Copyright Act of 1976, no part of this publication may.
Computational Geometry & Collision detection
Computer Science – Game DesignUC Santa Cruz Common Bounding Volumes Most introductory game programming texts call AABBs simply “bounding boxes” Circle/SphereAxis-Aligned.
1 Terrain Following & Collision Detection. 2 Both of topics are very game-type-oriented Both of topics are very game-type-oriented Terrain Terrain For.
Computer Science – Game DesignUC Santa Cruz Today Homework Bounding Boxes Quadtrees Per-pixel collision Drawing text (if we have time)
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience Gforge SVN Collision Detection and Resolution.
Computer Graphics Recitation 6. 2 Last week - eigendecomposition A We want to learn how the transformation A works:
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.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Continuous Collision Detection David Knott COMP 259 class presentation.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Introduction to Collision Detection Lecture based on Real Time Collision Detection, Christer Ericson, Morgan Kauffman, 2005 Game Design Experience Professor.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Game Physics – Part IV Moving to 3D
CSE 381 – Advanced Game Programming Basic 3D Graphics
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
02 – Object Modeling Overview Point Selection Bounding Box Line Equation Least Square Line Equation Conclusions.
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,
Quaternions Paul Taylor Swizzle What is a swizzle?
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Collision Detection and Response. Motivation OpenGL is a rendering system OpenGL is a rendering system OpenGL has no underlying knowledge of the objects.
Speech Recognition Raymond Sastraputera.  Introduction  Frame/Buffer  Algorithm  Silent Detector  Estimate Pitch ◦ Correlation and Candidate ◦ Optimal.
Chapter 11 Collision Detection 가상현실 입문 그래픽스 연구실 민성환.
Presented by Paul Phipps
1 Sage Demo 4 Collisions SAGE Lecture Notes Ian Parberry University of North Texas.
MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing.
Ray Tracing Acceleration (1). Acceleration of Ray Tracing Goal: Reduce the number of ray/primitive intersections.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 6 Examples 1,
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.
1 Geometry for Game. Geometry Geometry –Position / vertex normals / vertex colors / texture coordinates Topology Topology –Primitive »Lines / triangles.
Determine if each is a quadratic equation or not.
Section 9.1 Parabolas.
Introduction to Collision Detection
Frustum Culling in OpenGL
3D Game Development and Computer Animation Collision Detection
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Collision Detection Box-to-Box.
Collision Detection Spring 2004.
Introduction to Coordinate Grid
Deformable Collision Detection
Parts of these slides are based on
Collision handling: detection and response
GAM 325/425: Applied 3D Geometry
2.5. Basic Primitive Intersection
Lecture 2 Announcements.
Computer Animation Algorithms and Techniques
Collision Detection.
Deformable Collision Detection
CO Games Concepts Week 12 Collision Detection
Parabolas.
Game Programming Algorithms and Techniques
David Johnson Cs6360 – Virtual Reality
T5.1d To Graph Vertical Translation
Orbitals....
Determine if each is a quadratic equation or not.
3.3: Rectangle Collisions
GPAT – Chapter 7 Physics.
Separating Axis Theorem (SAT)
Presentation transcript:

What you will learn today How to implement simple collision detection

Sphere Collisions How do we know if these have collided?

Sphere Collisions Distance!

Sphere Collisions More precisely : if( length(sphereApos - sphereBPos) < radiusA+ radiusB){ What is a potential problem with this approach? What if the spheres are moving really fast?

Activity: Are these spheres going to collide? 5 min, discuss with neighbors Are these spheres going to collide? How can you tell if they collided between frames? sphereAPos = (.4,.1, 0) sphereARadius = .5 sphereAMovementDir = (0,2,0) sphereAPos += sphereAMovementDir; sphereBPos = (.1, .6, .1) sphereBRadius= .3 sphereBMovementDir =(0,-2,0) sphereBPos += sphereBMovementDir;

‘Swept’ Sphere-Sphere Collisions http://www.gamasutra.com/view/feature/131790/simple_intersection_tests_ for_games.php?page=2

Axis Aligned Bounding Boxes(AABB) A box that is Defined by the min and max coordinates of an object Always aligned with the coordinate axes How can we tell if a point p is inside the box? Initial Airplane Orientation Airplane Orientation 2

Detecting Collisions with AABB Do a bunch of ifs if( px<= maxx && py<= maxy && pz<= maxz && px>= minx && py>= miny && pz>= minz ) then collide = true; else collide = false minx maxx maxy P miny

Detecting Collisions with AABB if mins/maxes overlap then collide = true else collide = false; Bminx Bmaxx Bmaxy Aminx Amaxx Bminy

AABB Approach Initialization: Iterate through the model’s vertices and find mins and maxes Apply Transformations and Iterate through AABB vertices to find mins and maxes

AABB Approach Initialization During runtime iterate through all vertices of your model to find the mins and maxes for x, y, and z During runtime Test if any of the AABB mins/maxes of one object overlap with another object’s AABB mins/maxes MAKE SURE THAT THE AABB VALUES ARE IN THE SAME FRAME (e.g., world coordinates)! This is equivalent to multiplying the 8 points by a matrix for each object Then make sure to recalculate your mins/maxes from the 8 transformed points! Note: it is possible to do this with only 2 points from the box: (minx,miny,minz), (maxx,maxy,maxz), but not required

Manually Transforming Objects for Collisions Manually transform all things collideable into world coordinates: mat4 trans = // object->world transformation glm::rotate(a,x,y,z)*glm::translate(p); mymesh.draw(trans); for(int i = 0; i< 8; i++) // transform BB to world worldBB[i] = trans*mymesh.BB[i]; Now recalculate mins/maxes from worldBB and use for collision detection calculations! http://www.gamasutra.com/view/feature/131790/simple_intersection_ tests_for_games.php?page=3

Review: What you learned today How to implement simple collision detection Sphere collisions Axis Aligned Bounding Boxes (AABB) REMEMBER TO TRANSFORM EVERYTHING INTO WORLD SPACE BEFORE COLLISION DETECTION