Principles of Computer Game Design and Implementation. Lecture 13

Similar documents
Spatial Data Structures

Computer Graphics Ray Casting. Matthias Teschner

Spatial Data Structures

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5.

Spatial Data Structures

Intersection Acceleration

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

Hashing Techniques. Material based on slides by George Bebis

Specialized Acceleration Structures for Ray-Tracing. Warren Hunt

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Spatial Data Structures

Spatial Data Structures

Parallel Physically Based Path-tracing and Shading Part 3 of 2. CIS565 Fall 2012 University of Pennsylvania by Yining Karl Li

Logistics. CS 586/480 Computer Graphics II. Questions from Last Week? Slide Credits

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

11 - Spatial Data Structures

Questions from Last Week? Extra rays needed for these effects. Shadows Motivation

CS 431/636 Advanced Rendering Techniques

Speeding up your game

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

ICS RESEARCH TECHNICAL TALK DRAKE TETREAULT, ICS H197 FALL 2013

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Acceleration Data Structures

Computer Graphics. Bing-Yu Chen National Taiwan University

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

Hashing for searching

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Subdivision Of Triangular Terrain Mesh Breckon, Chenney, Hobbs, Hoppe, Watts

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

CPS222 Lecture: Sets. 1. Projectable of random maze creation example 2. Handout of union/find code from program that does this

More B-trees, Hash Tables, etc. CS157B Chris Pollett Feb 21, 2005.

FRUSTUM-TRACED RASTER SHADOWS: REVISITING IRREGULAR Z-BUFFERS

Accelerated Raytracing

CMSC 425: Lecture 10 Geometric Data Structures for Games: Index Structures Tuesday, Feb 26, 2013

Scalar Algorithms: Contouring

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Hashing. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

CS 4649/7649 Robot Intelligence: Planning

Computer Science 136 Spring 2004 Professor Bruce. Final Examination May 19, 2004

l Without collision detection (CD), it is practically impossible to construct e.g., games, movie production tools (e.g., Avatar)

Hash[ string key ] ==> integer value

Principles of Computer Game Design and Implementation. Revision Lecture

Graphics for VEs. Ruth Aylett

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

Ray Tracing Acceleration Data Structures

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Hello, Thanks for the introduction

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Cpt S 223. School of EECS, WSU

Ray Tracing: Intersection

Outline. Computer Science 331. Desirable Properties of Hash Functions. What is a Hash Function? Hash Functions. Mike Jacobson.

CSC 261/461 Database Systems Lecture 17. Fall 2017

Ray Tracing with Spatial Hierarchies. Jeff Mahovsky & Brian Wyvill CSC 305

Sung-Eui Yoon ( 윤성의 )

Ray Tracing Acceleration. CS 4620 Lecture 20

CPSC GLOBAL ILLUMINATION

Ray Casting. 3D Rendering. Ray Casting. Ray Casting. Ray Casting. Ray Casting

FRUSTUM-TRACED RASTER SHADOWS: REVISITING IRREGULAR Z-BUFFERS

Ray Tracing. Outline. Ray Tracing: History

Today. Acceleration Data Structures for Ray Tracing. Cool results from Assignment 2. Last Week: Questions? Schedule

Lecture 11: Ray tracing (cont.)

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Recursion and Data Structures in Computer Graphics. Ray Tracing

Ray Intersection Acceleration

Acceleration Structures. CS 6965 Fall 2011

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Hashing file organization

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Computer Graphics. - Spatial Index Structures - Philipp Slusallek

B+ Tree Review. CSE332: Data Abstractions Lecture 10: More B Trees; Hashing. Can do a little better with insert. Adoption for insert

Collision Detection based on Spatial Partitioning

Computer Graphics. - Rasterization - Philipp Slusallek

Determination (Penentuan Permukaan Tampak)

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Fundamentals of Stereo Vision Michael Bleyer LVA Stereo Vision

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

LECTURE 4. Announcements

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

R-Trees. Accessing Spatial Data

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far

Advanced Ray Tracing

Questions. 6. Suppose we were to define a hash code on strings s by:

Platform Games Drawing Sprites & Detecting Collisions

Texture Mapping II. Light maps Environment Maps Projective Textures Bump Maps Displacement Maps Solid Textures Mipmaps Shadows 1. 7.

Principles of Computer Game Design and Implementation. Lecture 11

Geometric Representations. Stelian Coros

AAL 217: DATA STRUCTURES

Advanced 3D-Data Structures

Introduction to Geographic Information Science. Some Updates. Last Lecture 4/6/2017. Geography 4103 / Raster Data and Tesselations.

Principles of Computer Game Design and Implementation. Lecture 6

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Remember. 376a. Database Design. Also. B + tree reminders. Algorithms for B + trees. Remember

Ray Tracing Acceleration. CS 4620 Lecture 22

Lecture 25: Board Notes: Threads and GPUs

Raycasting. Chapter Raycasting foundations. When you look at an object, like the ball in the picture to the left, what do

Transcription:

Principles of Computer Game Design and Implementation Lecture 13

We already knew Collision detection overlap test and intersection test Detailed view Mid-level view 2

Outline for today High-level view for collision detection Uniform grid 3

High-Level View Too many objects in the world problem Divide the space into regions Check for collisions inside regions An approximation Spatial data structures needed Stationary objects Moving objects 4

Spatial Data Structures Uniform grids Implicit grids Non-uniform grids Arbitrary space partitions Used for collision detection and various other purposes Example: Visibility check as collision detection Camera frustum 5

Uniform Grid Split the volume into 3- dimentional cells For a moving object Identify objects in surrounding cells Test for collision with those objects From now on all pictures will be in 2D. Same principles apply 6

Locating Objects j 0 Linked lists of objects 0 i i = (int) (x / CellSize); j = (int) (y / CellSize); k = (int) (z / CellSize) Array of linked lists Test for collision for every element of the list at grid(i,j,k) 7

Ray Tracing Intersection of a ray with an object Computer graphics Shooting Ray = half-line? Ray collision detection: which object will it intersect with? 8

Ray Collision Detection One can define mathematically Ray to triangle collision Ray to box collision Ray to sphere collision Grid is ideally suited for tracing rays 9

Ray Collision Detection in jme jmonkeengine can detect Ray-Geometry collisions See Examples coming with the library 10

Explicit Uniform Grid Advantages: Very fast Easy to implement (especially in C, C++) Disadvantages May be difficult in Java (generic /non-generic type mixes) Use a lot of memory (proportional to the number of cells) 14

Spatial Hash Represent grids implicitly j (i,j,k) Hash 0 0 i Linked lists of objects i = (int) (x / CellSize); j = (int) (y / CellSize); k = (int) (z / CellSize) class Triple {int x,y,z; Triple(..){..}}; HashMap<Triple,LinkedList<Spatial>> grid; 15

Side Remark: Maps How to store associations of the form For example, List them (key, value)? (gav, 3) (mike, 5) (john, 1) (gav, 3) l (mike, 5) (john, 1) l As many elements as pairs 16

Maps As Lists Storing information in a list is memory efficient but search is expensive Queries like what age is john potentially will go through all the stored elements (gav, 3) l (mike, 5) (john, 1) l 17

Hash Function Let h(x) maps the key to a number between 0 and N E.g. name -> number of first letter in alphabet gav -> 7 john -> 10 mike -> 11 Bad idea! 18

Hash Map Clash 0 1 ann,5 alice, 7 h 7 gav, 3 10 John, 1 Linked lists of objects 26 What s john s age? What s alice sage? 19

Spatial Hash Represent grids implicitly j (i,j,k) Hash 0 0 i Linked lists of objects For example, h(i,j,k) = i+j+k mod 100 Very bad choice 20

Good Hash Function Ideally, for two keys k 1, k 2 there shouldn t be a clash, that is, h(k 1 ) h(k 2 ) This is impossible to achieve Writing a good hash function is hard Java has in-built support (but you may wish to supply your own implementation of hash function) (see javadoc on HashMap) 21

Spatial Hash Advantages Moderate memory use (proportional to the number of objects) Fast access Easy in Java Disadvantages Slower than array lookup Trickier in C/C++ 22

Cell Size How fine should the grid be? ) Too fine Too coarse Too coarse and too fine? Inadequate Cell size should roughly be the size of an object. Works in some cases Does not work in others 23

Cell Size How fine should the grid be? ) Too fine Too coarse Too coarse and too fine? Inadequate Cell size should roughly be the size of an object. Works in some cases Does not work in others 24