![Page 1: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/1.jpg)
Ch 15: Collision and Simple Physics
Quiz # 5 Discussion
![Page 2: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/2.jpg)
Collision Detection Resources:
http://sharky.bluecog.co.nz/?p=108
![Page 3: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/3.jpg)
Collision: Bounding Box
ò Circle or sphere around the object
ò Collision detection is:
If (d2 <= (r2 +r1)2)
collision = true; else collision = false;
x,y r
d r1 r2
![Page 4: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/4.jpg)
Collision: Bounding Box (AABB) [XNA]
ò Axis-Aligned Bounding Box (AABB)
ò Collision detection is: If ( (object1.max.x < object2.min.x) || (object1.min.x > object2.max.x) )
return false; if ( (object1.max.y < object2.min.y) ||
(object1.min.y > object2.max.y) ) return false;
if ( (object1.max.z < object2.min.z) || (object1.min.z > object2.max.z) ) return false;
return true;
min (x, y, z)
max(x, y, z)
min (x, y, z)
max(x, y, z)
![Page 5: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/5.jpg)
Collision: Bounding Box (OBB)
ò Oriented Bounding Box (OBB)
![Page 6: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/6.jpg)
Collision: Others
ò Convex Hull
ò Divide model meshes – sphere around each mesh separately
![Page 7: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/7.jpg)
Processing and Efficiency
1. Sphere
2. AABB
3. OBB
4. Convex Hull
Decrease in efficiency
![Page 8: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/8.jpg)
Using XNA AABB Make sure to rotate and scale and translate the bounding box
BoundingBox boxbox = new BoundingBox(new Vector3(0, 0, 0), new Vector3(125, 100, 75));
BoundingBox playerbox = new BoundingBox( new Vector3(modelpos.X -‐ 50, -‐50, modelpos.Z -‐ 50), new Vector3(modelpos.X + 50, 50, modelpos.Z + 50));
if (playerbox.Intersects(boxbox))
{
System.Console.WriteLine("there is a collision");
}
![Page 9: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/9.jpg)
Try it
ò Get your assignment # 2
ò Add another object
ò Move the object closer to the character
ò Just print out a message when a collision happens
![Page 10: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/10.jpg)
More resources on Collision
ò Gottschalk, Stephan, Ming Lin and Dinesh Manocha, “OBB-Tree: A Hierarchical Structure for Rapid Interference Detection,” SIGGRAPH ‘96.
ò Ericson, Christer, Real-Time Collision Detection, Morgan Kaufmann, San Francisco, 2004.
ò Van den Bergen, Gino, Collision Detection in Interactive 3D Environments, Morgan Kaufmann, San Francisco, 2003.
ò Van Verth, James M. Essential Mathematics for Games and Interactive Applications A Programmer’s Guide, Morgan Kaufmann, San Francisco, 2004
![Page 11: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/11.jpg)
For Physics
ò Physics and Collision:
ò Raycast: can be good for AI vision
ò Shapecast
ò Procedural Animation and Rag Doll physics: turned on at death or other events
ò Use a Physics engine. You can integrate:
ò Bullet: http://bulletphysics.org/wordpress/
ò ODE: http://www.ode.org/
![Page 12: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/12.jpg)
Ray Casting
ò Shoot a ray from object to another:
ò Given Position, direction (use parametric line equation)
ò Check for collision along the way (object intersections)
![Page 13: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/13.jpg)
Parametric line Equation
xy
!
"##
$
%&&=
xp0 + t(xp1 − xp0 )
yp0 + t(yp1 − yp0 )
(
)
**
+
,
-- p0
p1
![Page 14: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/14.jpg)
For Physics
ò Physics and Collision:
ò Raycast: can be good for AI vision
ò Shapecast
ò Procedural Animation and Rag Doll physics: turned on at death or other events
ò Use a Physics engine. You can integrate:
ò Bullet: http://bulletphysics.org/wordpress/
ò ODE: http://www.ode.org/
![Page 15: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/15.jpg)
Inverse Kinematics
1. Set goal configuration of end effector 2. calculate interior joint angles
Analytic approach – when linkage is simple enough, directly calculate joint angles in configuration that satisfies goal
Numeric approach – complex linkages At each time slice, determine joint movements that take you in direction of goal position (and orientation)
From Rick Parent’s slides
![Page 16: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/16.jpg)
Forward Kinematics - review
Pose – linkage is a specific configuration
Pose Vector – vector of joint angles for linkage
Degrees of Freedom (DoF) – of joint or of whole figure
Articulated linkage – hierarchy of joint-link pairs
Types of joints: revolute, prismatic
Tree structure – arcs & nodes Recursive traversal – concatenate arc matrices Push current matrix leaving node downward Pop current matrix traversing back up to node
![Page 17: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/17.jpg)
Goal
End Effector
θ1
θ2 θ3 L1
L2 L3
Inverse Kinematics
![Page 18: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/18.jpg)
Animation
ò Procedural animation disadvantages:
ò Too expensive
ò Doesn’t look good – not controlled by the artist
ò Most games now use a mix of both
ò Alternative Smartbody by USC (blend of both with constraint system)
![Page 19: Ch 15: Collision and Simple Physics - Northeastern …...Environments, Morgan Kaufmann, San Francisco, 2003. ! Van Verth , James M. Essential Mathematics for Games and Interactive](https://reader035.vdocuments.us/reader035/viewer/2022062505/5ee0e360ad6a402d666bf6cc/html5/thumbnails/19.jpg)
Animation & Control (the need for Physics)
GDC Vault