University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Picking II, Collision.

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
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.
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.
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.
CSE 381 – Advanced Game Programming Scene Management
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Picking Week 10, Mon Mar.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Picking, Collision Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Collision Detection Week.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
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.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Better Interactive Programs Ed Angel Professor of Computer Science, Electrical and Computer.
Projections and Picking Wed 24 Sep 2003
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
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.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Picking and Lighting Week 4, Fri 26 Sep 2003 recap: viewports and picking.
Collision Detection David Johnson Cs6360 – Virtual Reality.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
Computer Graphics Mirror and Shadows
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
COMP 175: Computer Graphics March 24, 2015
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
CSE 381 – Advanced Game Programming Basic 3D Graphics
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
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.
1 Better Interactive Programs. 2 Objectives Learn to build more sophisticated interactive programs using ­Picking Select objects from the display Three.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Procedural Approaches.
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Implementation II.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Procedural II, Collision.
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.
Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Collision II, Antialiasing.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Computer Graphics I, Fall 2010 Implementation II.
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
1 Geometry for Game. Geometry Geometry –Position / vertex normals / vertex colors / texture coordinates Topology Topology –Primitive »Lines / triangles.
Bounding Volume Hierarchies and Spatial Partitioning
CS679 - Fall Copyright Univ. of Wisconsin
Procedural, Collision University of British Columbia
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
Parts of these slides are based on
Computer Animation Algorithms and Techniques
Collision Detection.
David Johnson Cs6360 – Virtual Reality
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Picking II, Collision and Accelleration Week 10, Fri Mar 23

2 News showing up for your project grading slot is not optional 2% penalty for noshows signing up for your project grading slot is not optional 2% penalty for nosignups within two days of due date your responsibility to sign up for slot not ours to hunt you down if you chose to skip class on signup day we do make best effort to accomodate change requests via to grader for that project

3 News project 4 proposals due today 3pm handin cs314 proj3.prop or on paper in box proposal: your chance to get feedback from me don’t wait to hear back from me to get started you’ll hear from me soon if I see something dubious not a contract, can change as you go

4 Midterm 2: Wed Mar 26 covering through Homework 3 material MT1: transformations, some viewing MT2 emphasis some viewing projections color rasterization lighting/shading advanced rendering (incl raytracing) graded H3 + solutions out Monday

5 Midterm 2: Wed Mar 26 closed book allowed to have calculator one side of 8.5”x11” paper, handwritten write your name on it turn it in with exam, you’ll get it back have ID out and face up

6 Review: Language-Based Generation L-Systems F: forward, R: right, L: left Koch snowflake: F = FLFRRFLF Mariano’s Bush: F=FF-[-F+F+F]+[+F-F-F] angle 16

7 Review: Fractal Terrain 1D: midpoint displacement divide in half, randomly displace scale variance by half 2D: diamond-square generate new value at midpoint average corner values + random displacement scale variance by half each time

8 Review: Particle Systems changeable/fluid stuff fire, steam, smoke, water, grass, hair, dust, waterfalls, fireworks, explosions, flocks life cycle generation, dynamics, death rendering tricks avoid hidden surface computations

9 Review: Picking Methods manual ray intersection bounding extents backbuffer coding x VCS y

10 Picking II

11 Select/Hit use small region around cursor for viewport assign per-object integer keys (names) redraw in special mode store hit list of objects in region examine hit list OpenGL support

12 Viewport small rectangle around cursor change coord sys so fills viewport why rectangle instead of point? people aren’t great at positioning mouse Fitts’ Law: time to acquire a target is function of the distance to and size of the target allow several pixels of slop

13 nontrivial to compute invert viewport matrix, set up new orthogonal projection simple utility command gluPickMatrix(x,y,w,h,viewport) x,y: cursor point w,h: sensitivity/slop (in pixels) push old setup first, so can pop it later Viewport

14 Render Modes glRenderMode(mode) GL_RENDER: normal color buffer default GL_SELECT: selection mode for picking (GL_FEEDBACK: report objects drawn)

15 Name Stack again, "names" are just integers glInitNames() flat list glLoadName(name) or hierarchy supported by stack glPushName(name), glPopName can have multiple names per object

16 for(int i = 0; i < 2; i++) { glPushName(i); for(int j = 0; j < 2; j++) { glPushMatrix(); glPushName(j); glTranslatef(i*10.0,0,j * 10.0); glPushName(HEAD); glCallList(snowManHeadDL); glLoadName(BODY); glCallList(snowManBodyDL); glPopName(); glPopName(); glPopMatrix(); } glPopName(); } Hierarchical Names Example

17 Hit List glSelectBuffer(buffersize, *buffer) where to store hit list data on hit, copy entire contents of name stack to output buffer. hit record number of names on stack minimum and minimum depth of object vertices depth lies in the z-buffer range [0,1] multiplied by 2^32 -1 then rounded to nearest int

18 Integrated vs. Separate Pick Function integrate: use same function to draw and pick simpler to code name stack commands ignored in render mode separate: customize functions for each potentially more efficient can avoid drawing unpickable objects

19 Select/Hit advantages faster OpenGL support means hardware acceleration avoid shading overhead flexible precision size of region controllable flexible architecture custom code possible, e.g. guaranteed frame rate disadvantages more complex

20 Hybrid Picking select/hit approach: fast, coarse object-level granularity manual ray intersection: slow, precise exact intersection point hybrid: both speed and precision use select/hit to find object then intersect ray with that object

21 OpenGL Precision Picking Hints gluUnproject transform window coordinates to object coordinates given current projection and modelview matrices use to create ray into scene from cursor location call gluUnProject twice with same (x,y) mouse location z = near: (x,y,0) z = far: (x,y,1) subtract near result from far result to get direction vector for ray use this ray for line/polygon intersection

22 Picking and P4 you must implement true 3D picking! you will not get credit if you just use 2D information

23 Collision/Acceleration

24 Collision Detection do objects collide/intersect? static, dynamic picking is simple special case of general collision detection problem check if ray cast from cursor position collides with any object in scene simple shooting projectile arrives instantly, zero travel time better: projectile and target move over time see if collides with object during trajectory

25 Collision Detection Applications determining if player hit wall/floor/obstacle terrain following (floor), maze games (walls) stop them walking through it determining if projectile has hit target determining if player has hit target punch/kick (desired), car crash (not desired) detecting points at which behavior should change car in the air returning to the ground cleaning up animation making sure a motion-captured character’s feet do not pass through the floor simulating motion physics, or cloth, or something else

26 From Simple to Complex boundary check perimeter of world vs. viewpoint or objects 2D/3D absolute coordinates for bounds simple point in space for viewpoint/objects set of fixed barriers walls in maze game 2D/3D absolute coordinate system set of moveable objects one object against set of items missile vs. several tanks multiple objects against each other punching game: arms and legs of players room of bouncing balls

27 Naive General Collision Detection for each object i containing polygons p test for intersection with object j containing polygons q for polyhedral objects, test if object i penetrates surface of j test if vertices of i straddle polygon q of j if straddle, then test intersection of polygon q with polygon p of object i very expensive! O(n 2 )

28 Fundamental Design Principles fast simple tests first, eliminate many potential collisions test bounding volumes before testing individual triangles exploit locality, eliminate many potential collisions use cell structures to avoid considering distant objects use as much information as possible about geometry spheres have special properties that speed collision testing exploit coherence between successive tests things don’t typically change much between two frames

29 Example: Player-Wall Collisions first person games must prevent the player from walking through walls and other obstacles most general case: player and walls are polygonal meshes each frame, player moves along path not known in advance assume piecewise linear: straight steps on each frame assume player’s motion could be fast

30 Stupid Algorithm on each step, do a general mesh-to-mesh intersection test to find out if the player intersects the wall if they do, refuse to allow the player to move problems with this approach? how can we improve: in response? in speed?

31 Collision Response frustrating to just stop for player motions, often best thing to do is move player tangentially to obstacle do recursively to ensure all collisions caught find time and place of collision adjust velocity of player repeat with new velocity, start time, start position (reduced time interval) handling multiple contacts at same time find a direction that is tangential to all contacts

32 Accelerating Collision Detection two kinds of approaches (many others also) collision proxies / bounding volumes spatial data structures to localize used for both 2D and 3D used to accelerate many things, not just collision detection raytracing culling geometry before using standard rendering pipeline

33 Collision Proxies proxy: something that takes place of real object cheaper than general mesh-mesh intersections collision proxy (bounding volume) is piece of geometry used to represent complex object for purposes of finding collision if proxy collides, object is said to collide collision points mapped back onto original object good proxy: cheap to compute collisions for, tight fit to the real geometry common proxies: sphere, cylinder, box, ellipsoid consider: fat player, thin player, rocket, car …

34 Trade-off in Choosing Proxies increasing complexity & tightness of fit decreasing cost of (overlap tests + proxy update) AABB OBB Sphere Convex Hull 6-dop AABB: axis aligned bounding box OBB: oriented bounding box, arbitrary alignment k-dops – shapes bounded by planes at fixed orientations discrete orientation polytope

35 Pair Reduction want proxy for any moving object requiring collision detection before pair of objects tested in any detail, quickly test if proxies intersect when lots of moving objects, even this quick bounding sphere test can take too long: N 2 times if there are N objects reducing this N 2 problem is called pair reduction pair testing isn’t a big issue until N>50 or so…

36 Spatial Data Structures can only hit something that is close spatial data structures tell you what is close to object uniform grid, octrees, kd-trees, BSP trees bounding volume hierarchies OBB trees for player-wall problem, typically use same spatial data structure as for rendering BSP trees most common

37 Uniform Grids axis-aligned divide space uniformly

38 Quadtrees/Octrees axis-aligned subdivide until no points in cell

39 KD Trees axis-aligned subdivide in alternating dimensions

40 BSP Trees planes at arbitrary orientation

41 Bounding Volume Hierarchies

42 OBB Trees

43 Related Reading Real-Time Rendering Tomas Moller and Eric Haines on reserve in CICSR reading room

44 Acknowledgement slides borrow heavily from Stephen Chenney, (UWisc CS679) slides borrow lightly from Steve Rotenberg, (UCSD CSE169)