chapter 11 collision detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

25
Chapter 11 Collision Detection 가가가가 가가 2002.6.5 가가가가 가가가 가가가

Upload: dulcie-blake

Post on 21-Jan-2016

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

Chapter 11Collision Detection

가상현실 입문

2002.6.5

그래픽스 연구실 민성환

Page 2: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

2

Collision Detection (CD)

A fundamental and important ingredient in many comput

er graphics and virtual reality applications

Can be divided into three major parts

Collision detection

Detects whether two objects collide

Collision determination

Finds the actual intersections between a pair objects

Collision response

Determines what actions should be taken in response

Page 3: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

3

Content

In section 11.1

We discuss simple and fast CD techniques

Main idea is to approximate a complex object using a set of lines

In section 11.2

Hierarchical bounding volume collision detection algorithm

In section 11.3 and 11.4

Two particular implementations

In section 11.5

A Multiple objects CD system

Page 4: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

4

CD System

There are desirable for most CD system

Achieve interactive rates

Handle polygon soup ( general polygon models with no restriction

s)

Can undergo rigid-body motion

Provide efficient bounding volume(BV) fitting

A restriction

The methods are static, meaning the collision detection only occur

s at discrete times

Page 5: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

5

Naive approach

A scenario may contain tens or hundreds of moving objec

ts

If the scenario contains n moving objects and m static objects, the

n a naïve method would perform

Object tests for each frame

The naive approach quickly becomes expensive as m and n rise

2

nnm

Page 6: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

6

CD with Rays A fast technique which works very well under certain circums

tance

We can approximate a moving object with a set of rays

Imagine that a car drives upward on an incline road

In the case of the car, we can put one ray at each of the four wheels

The rays are then intersection-tested against the environment

– If the distance from a ray origin to the environment is zero wheel is exactly on the

ground

– If the distance is greater than zero no contact with the environment

– A negative distance means that the wheel has merged “into” the environment

The application can use these distance for computing a collision response

– A negative distance move the car upward

– A positive distance move the car downward

Page 7: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

7

CD with Rays (cont.)

To speed up

Can use the same technique we always use to speed thing up in C

G a hierarchical representation

Environment can be represented by a BSP tree

Page 8: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

8

General Hierarchical CD

Hierarchy Building

There are three ways to build a hierarchy

Bottom-up method

Incremental tree-insertion method

Top-down approach method

Page 9: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

9

Hierarchy Building (1/3)

Bottom-up method

Starts by combining a number of primitives and finding a BV for

them

Then this BV is grouped with one or more BVs constructed a simi

lar way,thus yielding a new, larger parent BV

Repeated until only one BV exists, which then becomes the root

Page 10: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

10

Hierarchy Building (2/3)

Incremental tree-insertion method

Starts with an empty tree

Then all other primitives and their BVs are added one at a time

To make an efficient tree, an insertion point in the tree must be fo

und

This point should be selected so that the total tree volume increase is minimize

d

Page 11: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

11

Hierarchy Building (3/3)

Top-down approach

Starts by finding a BV for all primitives of the model root

Then a divide and conquer strategy is applied

BV is first split into k

For each such part, all included primitives are found, and then a BV is create

d in the same manner as for the root

A potential advantage is that a hierarchy can be created lazily

This means that we only construct the hierarchy for those parts of the scene w

here it is actually needed

Page 12: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

12

Collision Testing between Hierarchies

Pseudocode

A and B are tow nodes in the model hierarchiesFindFirstHitCD(A,B)returns ({TRUE,FALSE});

if (not overlap(ABV,BBV) return FALSE;else if (isLeaf(A)) if (isLeaf(B)) for each triangle pair TA AC and TV BC

if (overlap(TA,TB)) return TRUE; else for each child CB BC

FindFirstHitCD(A,CB)else for each child CA AC

FindFirstHitCD(CA,B)return FALSE

Page 13: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

13

Cost Function

It used to evaluate the performance of CD algorithms

uuppvv cncncnt

nv : number of BV/BV overlap testscv : cost for a BV/BV overlap testnp : number of primitive pairs tested for overlapcp : cost for testing whether two primitives overlapnu : number of BVs updated due to the model’s motioncu : cost for updating a BV

Page 14: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

14

OBB Tree

OBB Tree: A Hierarchical Structure for Rapid Interferen

ce Detection

At SIGGRAPH 96, Gottschalk et al.

Oriented bounding box

AABB and sphere provide quite poor fits in general ( contain a lot of empty s

pace)

Authors developed a new method for determining whether two OBBs overlap

Page 15: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

15

Hierarchy Building

A basic data structure is a binary tree

Internal node holding an OBB

External node (leaf) hoding only one triangle

Top-down approach

A tight-fitting OBB

Can be found by computing an orientation of the triangles of the

convex hull

Quickhull algorithm

Page 16: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

16

OBB

Denotation

N triangles defined as Δpkqkrk, where pk, qk, and rk are the vertice

s of triangle k, 0 <= k < n

The area of triangle k as ak

Total area of the convex hull

Centroid of triangles i is mi=(pi+qi+ri)/3

The centroid of the whole convex hull

1

0

n

k

kH aa

1

0

1 n

k

kkH

H maa

m

Page 17: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

17

OBB (cont.)

With the use of definitions, we will present a formula that

computes a 3X3 covariance matrix

After computing C

The eigenvectors are computed and normalized (direction vectors

of OBB)

Find the center and the half-lengths of the OBB

Determine the size and position of the box

3,0,

]))9(12

1[(][

0

ji

mmrrqqppmma

acC

ka

k

Hk

Hi

kj

ki

kj

ki

kj

ki

kj

ki

k

Hij

Page 18: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

18

Split

After we have computed an OBB

The volume and the triangles should be split

Gottschalk et al. use a strategy

Takes the longest axis of the box

Splits it into two parts of the same length

Page 19: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

19

Handling Rigid-Body Motions In the OBBTree hierarchy

Each OBB is stored together with a rigid-body transformation( a rotation matrix R and a translation vector t) matrix MA

This matrix holds the relative orientation and position of the OBB with respect to its parent

Assume that we start to test two OBBs, A and B The Idea is then to transform B into A’s coordinate system

TAB is decomposed as below

A and B overlap, A’s child called C Transform B into A’s coordinate and then transform that into the coordinate

system of C

BAAB MMT 1

00TAB

tRT

ABCAB TMT 1

Page 20: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

20

K-DOPTree

K-DOP

BV/BV overlap test is faster than the OBB

Directions of the planes of the k-DOP are fixed

A tighter fit

As k grows, the k-DOP tends to resemble the convex hull

Tested in order to find a good compromise between the B

V tightness and BV/BV overlap cost

6-DOPs(AABBs), 14-DOPs, 18-DOPs, 26-DOPs

K=18 gave the best execution times for several different scenarios

Page 21: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

21

Hierarchy Building

K-DOPTree

Also uses a binary tree

The leaves may contain an arbitrary number of triangles

Top-down approach

To splitting the k-DOP into two subvolumes

Four methods have been investigated for selection of one of the main axes, x,y,

z

– Min Sum : selects the axis that minimizes the sum of the subvolumes

– Min Max : selects the axis that minimizes the larger of the two subvolumes

– Splatter : computes the variances of the projections of the centroids of the triangle

s (largest variance)

– Longest Side : selects the axis along which the BV is longest

Page 22: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

22

Updating the k-DOPTree

Orientations of the planes of the k-DOPs are fixed

A rigid-body motion of an object makes the hierarchy invalid

It must be rebuilt or updated

Klosowski et al. proposed two ways of updating

Approximation method

Avoid recomputing a new k-DOP

Vertex locations at the corners of the original k-DOP are transformed and use

d

Hill climbing

Require additional storage

At each frame, local updates are made to a new best-fit k-DOP for the geomet

ry

Page 23: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

23

A Multiple Objects

A Multiple Objects CD System

Require collision detection between possibly hundreds of pairs of

objects

Describe a two-level collision detection system

The first level of this system reports potential collisions among all the objects i

n environment

Second level performs exact collision detection (previous section)

Page 24: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

24

The First-Level CD

A simple approach

Use an AABB

Instead of cubes, spheres can be used

Sweep-and-Prune

Exploit the temporal coherence

If two AABBs overlap

Three one-dimensional intervals

in each main axis direction must

also overlap

Page 25: Chapter 11 Collision Detection 가상현실 입문 2002.6.5 그래픽스 연구실 민성환

25

Summary

The outline of the collision detection system

First , using the sweep-and-prune algorithm

Second, the object pairs are sent to exact CD algorithms

Finally, the results are forwarded and taken care of by the

application (Collision response can be taken)

Simulation

Pruning Multi-Body Pair Exact Collision

Detection

(OBBTree&k-DOPTree)Collision

Response

Object transformation Overlapping pairs

Colliding pair