Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cs3241 Lab 10

710 views

Published on

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

Cs3241 Lab 10

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

×