3D Game Development and Computer Animation Collision Detection

Slides:



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

Introduction Games have always been a fundamental part of human life. Space storm “ عاصفة الفضاء” is a 3D SCI-FI game that consists of two stages presented.
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.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
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.
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.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
Efficient Distance Computation between Non-Convex Objects by Sean Quinlan presented by Teresa Miller CS 326 – Motion Planning Class.
Oct 3, Fall 2005Game Design1 Collision Detection.
Apex Point Map for Constant-Time Bounding Plane Approximation Samuli Laine Tero Karras NVIDIA.
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.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Collision handling: detection and response
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
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.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
Collision Detection And Response Jae Chun KyungSoo Im Chau Vo Hoang Vu.
Computer Game Design and Development
11/20/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Collision Detection Overview Player-Environment handling.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
1 Sage Demo 4 Collisions SAGE Lecture Notes Ian Parberry University of North Texas.
Unit 10 Transformations. Lesson 10.1 Dilations Lesson 10.1 Objectives Define transformation (G3.1.1) Differentiate between types of transformations (G3.1.2)
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
Introduction to Game Programming & Design III Lecture III.
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,
Final Presentation CS491B ALAIN VINIOT DE LARA Spring 2007, CSULA.
Copyright © Roger Webster, Ph.D. Shooting 3D Objects Roger Webster, Ph.D. CS475 3D Game Development And Computer Animation.
Graphing in 3-D Graphing in 3-D means that we need 3 coordinates to define a point (x,y,z) These are the coordinate planes, and they divide space into.
Sound and more Animations
Computer Graphics Imaging
Buffers and texture mapping
Background Shapes & Collision Resolution (Top-down and Side-scrolling)
Gauss’s Law Chapter 24.
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
Intersecting Simple Surfaces
CS475 3D Game Development Level Of Detail Nodes (LOD)
Parts of these slides are based on
Chapter 4.2 Collision Detection and Resolution
Collision handling: detection and response
Computer Animation Texture Mapping.
Gauss’s Law Chapter 24.
Collision Detection Platforms.
What you will learn today
Computer Animation Algorithms and Techniques
Collision Detection.
CO Games Concepts Week 12 Collision Detection
Klaas Werkman Arjen Vellinga
Gauss’s Law.
GPAT – Chapter 7 Physics.
Presentation transcript:

3D Game Development and Computer Animation Collision Detection Roger Webster, Ph.D. CS 475 3D Game Development and Computer Animation Copyright © 2016 Roger Webster, Ph.D.

3D Game Development Collision Detection Lots of Collisions take place Collision Detection (CD) can be computationally expensive. Fast Efficient Collision Detection is vital. Some options exist for Collision Detection.

Collision Detection Simple Spherical collision detection Based upon positional calculations and radius simple to calculate Fastest method Not highly accurate (unless objects are pool balls!) Bounding Volumes or Box(es) computationally more expensive than spherical more accurate than spherical Polygonal collision detection most accurate Most computationally expensive (prohibitive large polys) Hierarchical Collision Detection Uses spherical, then bounding boxes, then Polys Coldet library -> most accurate, relatively fast Collision Maps (2D/3D maps based on data structure) Very fast, very efficient, accuracy based on resolution of map

Simple Spherical Collision Detection Bounding Volumes using Spheres Easiest! If anything hits sphere you assume collision. The spheres do not overlap if The separation between the two objects is greater then the sum of the 2 radii In 3D Use vectors P1 – P2 gives distance vector. Find magnitude of P1 – P2 and compare to radii sum. If distance is less then radii some, collision

Cylinderical Bounding Volumes Bounding Volume Collision Detection Cylinderical Bounding Volumes Cylinders Good for games where most objects are oriented the same way (Doom) and reduce collision detection to a 2D problem. Must check top, bottom, and radius. Pseudo Code: IF (distance between center of circles > radii sum) no collision ELSE IF (vertical distances overlap) is a collision no collision // e.g. objects on different levels

Bounding Box Collision Detection Bounding Boxes computationally more expensive than spherical more accurate than spherical

Bounding Box Collision Detection Boxes Good for 2D and 3D. Allows for another shape to choose from for a bounding region. Pseudo Code: //First box FOR (every vertex in box1) IF (box1 vertex is in box2) there is a collision, exit loop //Second box IF (there is no collision from first box) FOR (every vertex in box2) IF (box2 vertex is in box1) Check both because box1 vertex may not be in box2, but still collide.

Hierarchical Collision Detection Use a Library Uses spherical, then hierarchical bounding boxes, then Polygons Highly accurate Relatively efficient and fast (because it is hierarchical) Some models are computationally expensive (ex. F15 plane). Returns the Collision Point (x,y,z) on the polygon and the Surface Normal (x1,y1,z1) normalized (unit vector).

Hierarchical Collision Detection using XNAEngine; using CollisionDetection; CollidableModel gzMissile; CollidableModel target; protected override void LoadContent () { Model tModel = Content.Load<Model>("bomb"); target = new CollidableModel(tModel); Model mModel = Content.Load<Model>(“missile"); gzMissile = new CollidableModel(mModel); } protected void UpdateMissileMovements() if (target.checkRayCollision(gzMissile.Position, dir, LengthofRay*5.0f, out cp, out surfaceNormal)) {//do something}

Hierarchical Collision Detection using XNAEngine; using CollisionDetection; CollidableModel gzMissile; CollidableModel target; protected override void LoadContent () { Model tModel = Content.Load<Model>("bomb"); target = new CollidableModel(tModel); Model mModel = Content.Load<Model>(“missile"); gzMissile = new CollidableModel(mModel); } protected void UpdateMissileMovements() if (target.checkCollision(gzMissile, out cp, out surfaceNormal)) {//do something}

2D Collision Maps MyModel.LoadObject(city.3ds) Very fast, very efficient, accuracy based on resolution of map Essentially you are pre-computing all the collisions MyModel.LoadObject(city.3ds) Calculate total distance across X,Z For every N points across X,Z check collisions Put x,y collision point in data structure Write collision map out to file Load collision map file in Myinit();

2D Collision Maps Very fast, very efficient, accuracy based on resolution of map Essentially you are pre-computing all the collisions

3D Collision Maps Spatial Partitioning Divide your universe into cells. Check collisions in regions near object in question This will greatly reduce the number of collision calculation that must be performed. Results are only as good as the resolution.

Calculate Your Own We know Maxx, Minx, Maxz, Minz We know each object’s position and radius

Calculate Your Own void myUpdate(void) { spd = speedMultiplier * normalizeSpeed(); // speed is a function of fps for each tank { speed = tank[i].getSpeed() * spd; tank[i].MoveForward(speed); dirVec.x = curpos[i].x - prevpos[i].x; // set direction vector dirVec.y = curpos[i].y - prevpos[i].y; dirVec.z = curpos[i].z - prevpos[i].z; getWallCollision(tank[i], dirVec, i); prevpos[i] = curpos[i]; tank[i].Draw(camera) tank[i].getPosition(&curpos[i].x, &curpos[i].y, &curpos[i].z); }

// determine if tank hit a wall, and if so, bounce off of it void getWallCollision(MUnode & t, const LVector4 & dirVec, const int & tankNum) { …….//continued if (hitWall) // rotate tank object float theta, costheta, reflect; float lenTankVec = sqrt(dirVec.x * dirVec.x + dirVec.y * dirVec.y + dirVec.z * dirVec.z); costheta = (dirVec.x * wallVec.x + dirVec.z * wallVec.z) / lenTankVec; theta = acos(costheta); theta = muopengl_radians2degrees(theta); reflect = 180 + (dir * theta * 2); t.Yaw(reflect); if (tankView && tankNum == camTank) myCamera.Yaw(reflect); //printf("angle %f, reflect %f\n", theta, reflect); }

// heading of tank we're going to attach the camera to float getHeading(const int & i) { LVector3 dirVec; dirVec.x = curpos[i].x - prevpos[i].x; dirVec.y = curpos[i].y - prevpos[i].y; dirVec.z = curpos[i].z - prevpos[i].z; float theta, costheta; float lenTankVec = sqrt(dirVec.x * dirVec.x + dirVec.y * dirVec.y + dirVec.z * dirVec.z); costheta = (dirVec.z) / lenTankVec; theta = acos(costheta); theta = muopengl_radians2degrees(theta); if (dirVec.x < 0) theta = -theta; } return theta;

Computer Animation areas of CD research: Self collision Detection of objects colliding with itself.