Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience Gforge SVN Collision Detection and Resolution.

Slides:



Advertisements
Similar presentations
Computational Geometry
Advertisements

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.
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.
CSE 380 – Computer Game Programming Collision Detection & Response Erin Catto’s Box2D.
CSE 381 – Advanced Game Programming Scene Management
Computational Geometry & Collision detection
Each pixel is 0 or 1, background or foreground Image processing to
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Space Partitioning for Broad Sweep Collision Detection Part 2 - Quadtrees Game Design Experience Professor Jim Whitehead February 13, 2009 Creative Commons.
Computer Science – Game DesignUC Santa Cruz Common Bounding Volumes Most introductory game programming texts call AABBs simply “bounding boxes” Circle/SphereAxis-Aligned.
Computer Science – Game DesignUC Santa Cruz Today Homework Bounding Boxes Quadtrees Per-pixel collision Drawing text (if we have time)
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.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Continuous Collision Detection David Knott COMP 259 class presentation.
Space Partitioning for Broad Sweep Collision Detection Part 1 - Grids Game Design Experience Professor Jim Whitehead February 11, 2009 Creative Commons.
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.
Efficient Distance Computation between Non-Convex Objects by Sean Quinlan presented by Teresa Miller CS 326 – Motion Planning Class.
Introduction to Collision Detection Lecture based on Real Time Collision Detection, Christer Ericson, Morgan Kauffman, 2005 Game Design Experience Professor.
Apex Point Map for Constant-Time Bounding Plane Approximation Samuli Laine Tero Karras NVIDIA.
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 Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
Physics Simple – Pong Medium – Rigid bodies F = ma Circles, spheres, rectangles for collisions Complex – Fluids, clothings, explosions, hair.
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.
V part 2 Obtained from a Guildford County workshop- Summer, 2014.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
CSE 381 – Advanced Game Programming Quickhull and GJK.
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.
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.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
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.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
ONLINE CONFERENCE DESIGN.BUILD.DELIVE R with WINDOWS PHONE THURSDAY 24 MARCH 2011.
Computer Game Design and Development
Chapter 11 Collision Detection 가상현실 입문 그래픽스 연구실 민성환.
11/20/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Collision Detection Overview Player-Environment handling.
1 Sage Demo 4 Collisions SAGE Lecture Notes Ian Parberry University of North Texas.
Computer Game Design and Development Collision Detection Havok Destruction.
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
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”
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.
Bounding Volume Hierarchies and Spatial Partitioning
Introduction to Collision Detection
3D Game Development and Computer Animation Collision Detection
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
Bounding Volume Hierarchies and Spatial Partitioning
Parts of these slides are based on
What you will learn today
Computer Animation Algorithms and Techniques
Collision Detection.
Game Programming Algorithms and Techniques
GPAT – Chapter 7 Physics.
Presentation transcript:

Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience Gforge SVN Collision Detection and Resolution

Computer Science – Game DesignUC Santa Cruz Imagine Cup Registration My username: arnavjhala (add as faculty mentor) Clarification: – Imagine cup theme is REQUIRED for all projects Even if you don’t sign up for Imagine Cup

Computer Science – Game DesignUC Santa Cruz Gforge Create an account for your team Add me (User: Nurb) Will be used for all project deliverables

Computer Science – Game DesignUC Santa Cruz SVN Subversion Tool – Used for version control – Collaboration (dev log, merging conflicts, reverting versions, tagging milestones) – Tracking (files changed, commits per person, etc.) –

Computer Science – Game DesignUC Santa Cruz Collision Detection Collision detection – Determining if two objects intersect (true or false) – Example: did bullet hit opponent? Collision resolution (collision determination) – Determining when two objects came into contact At what point during their motion did they intersect? Example: Two balls needing to bounce off each other – Determining where two objects intersect Which points on the objects touch during a collision? Example: Pong: where ball hits paddle is important Complexity of answering these questions increases in order given – If < when < where

Computer Science – Game DesignUC Santa Cruz Key to collision detection: scaling Key constraint: only ms per clock tick – Limited time to perform collision detection Object shapes in 2D games can be quite complex – Naïve: check two objects pixel-by-pixel for collisions Many objects can potentially collide – Naïve: check every object pair for collisions Drawback of naïve approach – Takes too long – Doesn’t scale to large numbers of objects Approaches for scaling – Reduce # of collision pairs – Reduce cost of each collision check Chu Chu Rocket, Dreamcast

Computer Science – Game DesignUC Santa Cruz Naïve Collision Detection: n x n checking Assume – n objects in game – All n objects can potentially intersect with each other Conceptually easiest approach – Check each object against every other object for intersections – Leads to (n-1) + (n-2) + … + 1 = n(n-1)/2 = O(n 2 ) checks – Done poorly, can be exactly n 2 checks – Example: 420 objects leads to 87,990 checks, per clock tick

Computer Science – Game DesignUC Santa Cruz Broad vs Narrow Sweep With many small objects in large playfield – Each object only has the potential to collide with nearby objects Broad sweep – Perform a quick pass over n objects to determine which pairs have potential to intersect, p Narrow sweep – Perform p x p check of object pairs that have potential to intersect Dramatically reduces # of checks Mushihimesama

Computer Science – Game DesignUC Santa Cruz Broad sweep approaches Grid – Divide playfield into a grid of squares – Place each object in its square – Only need to check contents of square against itself and neighboring squares – See for example Space partitioning tree – Subdivide space as needed into rectangles – Use tree data structure to point to objects in space – Only need to check tree leaves – Quadtree, Binary Space Partition (BSP) tree Application-specific – 2D-shooter: only need to check for collision against ship – Do quick y check for broad sweep Point Quadtree (Wikipedia)

Computer Science – Game DesignUC Santa Cruz Reducing Cost of Checking Two Objects for Collision General approach is to substitute a bounding volume for a more complex object Desirable properties of bounding volumes: – Inexpensive intersection tests – Tight fitting – Inexpensive to compute – Easy to rotate and transform – Low memory use Megaman X1 (Capcom). White boxes represent bounding volumes.

Computer Science – Game DesignUC Santa Cruz Common Bounding Volumes Most introductory game programming texts call AABBs simply “bounding boxes” Circle/SphereAxis-Aligned Bounding Box (AABB) Oriented Bounding Box (OBB) Convex Hull Better bounds, better culling Faster test, less memory

Computer Science – Game DesignUC Santa Cruz Circle Bounding Box Simple storage, easy intersection test Rotationally invariant struct Point { int x; int y; } struct circle { Point c; // center int r; // radius } r c bool circle_intersect(circle a, circle b) { Point d; // d = b.c – a.c d.x = a.c.x – b.c.x; d.y = a.c.y – b.c.y; int dist2 = d.x*d.x + d.y*d.y; // d dot d int radiusSum = a.r + b.r; if (dist2 < = radiusSum * radiusSum) { return true; } else { return false; } Compare Euclidean distance between circle centers against sum of circle radii.

Computer Science – Game DesignUC Santa Cruz Axis-Aligned Bounding Boxes (AABBs) Three common representations – Min-max – Min-widths – Center-radius // min.x < =x < =max.x // min.y < =y < =max.y struct AABB { Point min; Point max; } // min.x < =x < =min.x+dx // min.y < =y < =min.y+dy struct AABB { Point min; int dx; // x width int dy; // y width } // | c.x-x | < = rx | c.y-y | < = ry struct AABB { Point c; int rx; // x radius int ry; // y radius } min max min c dx dy ry rx struct Point { int x; int y; } Can easily be extended to 3D

Computer Science – Game DesignUC Santa Cruz Axis Aligned Bounding Box Intersection (min-max) Two AABBs intersect only if they overlap on both axes a.max.x<b.min.x a.min.x>b.max.xa.min.x=b.min.x a.max.y<b.min.y a.min.y>b.max.y a.min.y=b.min.y bool IntersectAABB(AABB a, AABB b) { { if (a.max.x < b.min.x || a.min.x < b.max.x) return false; if (a.max.y < b.min.y || a.min.y < b.max.y) return false; return true; }

Computer Science – Game DesignUC Santa Cruz Axis Aligned Bounding Box Intersection (min-width) Two AABBs intersect only if they overlap on both axes -(a.min.x- b.min.x)>a.dx (a.min.x- b.min.x)>b.dx a.min.x=b.min.x -(a.min.y- b.min.y)>a.dy (a.min.y- b.min.y)>b.dy a.min.y=b.min.y bool IntersectAABB(AABB a, AABB b) { { int t; t=a.min.x-b.min.x; if (t > b.dx || -t > a.dx) return false; t=a.min.y-b.min.y; if (t > b.dy || -t > a.dy) return false; return true; } // Note: requires more operations than // min-max case (2 more subtractions, 2 more negations)

Computer Science – Game DesignUC Santa Cruz AABB Intersection (center-radius) Two AABBs intersect only if they overlap on both axes b.c.x-a.c.x > a.rx+b.ry a.c.x-b.c.x > a.rx+b.rx a.c.x=b.c.x b.c.y-a.c.y > a.ry+b.ry a.c.y-b.c.y > a.ry+b.ry a.c.y=b.c.y bool IntersectAABB(AABB a, AABB b) { { if (Abs(a.c.x – b.c.x) > (a.r.dx + b.r.dx)) return false; if (Abs(a.c.y – b.c.y) > (a.r.dy + b.r.dy)) ) return false; return true; } // Note: Abs() typically single instruction on modern processors

Computer Science – Game DesignUC Santa Cruz There’s more … Per-pixel collision Per-pixel with transformed objects