cs3241 lab 10
TRANSCRIPT
Simple Collision Detection
CS3241 Lab 10
Objectives
Implement
Plane to Sphere collision detection
Sphere to Sphere collision detection
Collision Response
Sphere to Sphere Collision Detection
If sphere1 & sphere2
collide
n = c2 – c1
|n| <= r1 + r2
depth = |n| - (r1+r2)
normal = n / |n|
c1
c2
nr2
r
1
Plane to Sphere Collision
Detection
Forming a plane
Compute normal by 3
vertices, p1, p2, p3
normal = (p2-p1) x (p3-p1)
If plane and sphere
d = c1 * plane’s normal
d <= p + r
normal = plane’s normal
depth = p + r - d
c1
p
d
Collision Response
c1
norma
l
Ori. velocity
Simulate response
From Physics, we know….
As original Velocity can be de-
composited to two part V1, V2
V2 will remain the same but V1 will
flip
Vnew = Vold – 2* (Vold *
Normal)*Normal
How about stickiness?V1 V2
Tasks Task 1 Plane to Sphere collision detection Fill in bool checkCollide(BoundSphere *n1, BoundPlane*n2, float
dt, ContactInfo *ci)
Some notes:
BoundSphere & BoundPlane are just simple structure holding normal, radius…
Please look into ContactInfo as returning these info will help you adding collision response
Task 2 Collision Response Fill in void checkCollision()
Some notes:
Work on sphere to plane collision response
But other responses are similar
Thanks Hope you enjoy this lab and find it useful for your
assignment 4