Principles of Computer Game Design and Implementation. Lecture 17

Similar documents
Physical Simulation. October 19, 2005

the gamedesigninitiative at cornell university Lecture 17 Physics and Motion

Modeling and Solving Constraints. Erin Catto Blizzard Entertainment

Conservation of Momentum. Last modified: 08/05/2018

IMPACT Today s Objectives: In-Class Activities:

Stop my Constraints from Blowing Up! Oliver Strunk (Havok)

2007 Problem Topic Comment 1 Kinematics Position-time equation Kinematics 7 2 Kinematics Velocity-time graph Dynamics 6 3 Kinematics Average velocity

GAME PHYSICS ENGINE DEVELOPMENT

Review of Linear Momentum And Rotational Motion

EXPERIENCE COLLEGE BEFORE COLLEGE

Computer Animation. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics. Slides courtesy of Leonard McMillan and Jovan Popovic

Dynamics and Time Integration. Computer Graphics CMU /15-662, Fall 2016

Game Physics: Basic Concepts

CS-184: Computer Graphics

IMPACT (Section 15.4)

Physically-based modelling. Ruth Aylett

the gamedesigninitiative at cornell university Lecture 18 Box2D Physics

MITOCW free_body_diagrams

Quadrotor Modeling and Control

Notes Momentum. Momentum and Impulse. - The product (multiplication) of an objects mass and velocity is called momentum.

GAME PHYSICS (INFOMGP) FINAL EXAM

CS 480/680: GAME ENGINE PROGRAMMING

Model Rocketry. The Science Behind the Fun

Problem Solving Day and Movie Project Introduction

CEE 271: Applied Mechanics II, Dynamics Lecture 17: Ch.15, Sec.2 4

Module 17: Systems, Conservation of Momentum and Center of Mass

APPLICATIONS. CEE 271: Applied Mechanics II, Dynamics Lecture 17: Ch.15, Sec.4 7. IMPACT (Section 15.4) APPLICATIONS (continued) IMPACT READING QUIZ

LECTURE 23: Momentum-Impulse

CS 387/680: GAME AI MOVEMENT

Momentum is a property of moving matter. Momentum describes the tendency of objects to keep going in the same direction with the same speed.

PHYSICS I RESOURCE SHEET

EF 151 Final Exam, Fall, 2011 Page 1 of 11

8.012 Physics I: Classical Mechanics Fall 2008

Modelling of a Tennis Ball Server

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Physics Lecture 12 Momentum & Collisions

Having a ball with science:

Collision Resolution

Chapter 6. Preview. Section 1 Gravity and Motion. Section 2 Newton s Laws of Motion. Section 3 Momentum. Forces and Motion.

General Physics I Momentum

Simulation in Computer Graphics Elastic Solids. Matthias Teschner

What is the initial velocity (magnitude and direction) of the CM? Ans: v CM (0) = ( 7 /2) v 0 ; tan 1 ( 3 /2) 41 above horizontal.

CS 480: GAME AI MOVEMENT. 4/10/2012 Santiago Ontañón

CHAPTER 6 TEST REVIEW -- MARKSCHEME

Momentum. A ball bounces off the floor as shown. The direction of the impulse on the ball, is... straight up straight down to the right to the left

Vector and Relative motion discussion/ in class notes. Projectile Motion discussion and launch angle problem. Finish 2 d motion and review for test

Lab/Demo 5 Periodic Motion and Momentum PHYS 1800

Physics Tutorial 6: Collision Response

CS 387/680: GAME AI MOVEMENT

Review of Linear Momentum And Rotational Motion

Chapter 9: Impulse and Momentum

Lesson 1: What is a Parabola?

Modesto Junior College Course Outline of Record PHYS 101

Physics 11 (Fall 2012) Chapter 9: Momentum. Problem Solving

Momentum Review. Lecture 13 Announcements. Multi-step problems: collision followed by something else. Center of Mass

PHYSICS. Chapter 5 Lecture FOR SCIENTISTS AND ENGINEERS A STRATEGIC APPROACH 4/E RANDALL D. KNIGHT Pearson Education, Inc.

Graphical Analysis; and Vectors

Welcome back to Physics 211

When particle with mass m moves with velocity v, we define its Linear Momentum p as product of its mass m and its velocity v:

Physics for Scientists and Engineers. Chapter 5 Force and Motion

Physics Tutorial 6: Collision Response

EXAM 3 MECHANICS 40% of the final grade

Chapter 7- Linear Momentum

Chapter 2 Solutions. = 16.1 m/s. = 11.5 m/s m. 180 km = ( ) h. = 2.5 m/s. = 3.3 m/s

Dynamics and Time Integration

Example problem: Free Fall

Projectile Motion Horizontal Distance

Impulse. Two factors influence the amount by which an object s momentum changes.

Measurement p. 1 What Is Physics? p. 2 Measuring Things p. 2 The International System of Units p. 2 Changing Units p. 3 Length p. 4 Time p. 5 Mass p.

LECTURE 13- PROBLEMS. Chapter 1-9,13 Professor Noronha-Hostler Professor Montalvo

Projectile Motion trajectory Projectile motion

Projectile Motion: Vectors

E 490 FE Exam Prep. Engineering Mechanics

Physics Tutorial 1: Introduction to Newtonian Dynamics

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Mechanics. In the Science Program, Mechanics contributes to the following program goals described in the Exit Profile:

Time scales. Notes. Mixed Implicit/Explicit. Newmark Methods [ ] [ ] "!t = O 1 %

Get Discount Coupons for your Coaching institute and FREE Study Material at Force System

Unit 2: Vector Dynamics

1/9/2017. Newton s 2 nd Law of Motion, revisited

Chapter 5 Force and Motion

Unit 1 Test Review Physics Basics, Movement, and Vectors Chapters 2-3

HADDONFIELD PUBLIC SCHOOLS Curriculum Map for AP Physics, Mechanics C

Physics 8 Friday, September 29, 2017

Honors Physics Acceleration and Projectile Review Guide

Honors Physics Final Exam Review. Symbol Units Units (if applicable)

Physics Kinematics, Projectile Motion, Free-Body Diagrams, and Rotational Motion

Physics 207 Lecture 11. Lecture 11. Chapter 8: Employ rotational motion models with friction or in free fall

An astronaut of mass 80 kg pushes away from a space Both!p x

Elementary Mechanics Using Matlab

PHYSICS 231 INTRODUCTORY PHYSICS I

CS229 Programming Assignment 3: Dynamics

Chapter 7 Lecture Notes

Physic 602 Conservation of Momentum. (Read objectives on screen.)

One Dimensional Collisions 1 Fall 2018

Video Lecture #2 Introductory Conservation of Momentum Problem using Unit Vectors

Exam. Name. 1) For general projectile motion with no air resistance, the horizontal component of a projectile's velocity A) B) C) D)

UNIT 2G. Momentum & It s Conservation

Chapter 6 - Linear Momemtum and Collisions

Section /07/2013. PHY131H1F University of Toronto Class 9 Preclass Video by Jason Harlow. Based on Knight 3 rd edition Ch. 5, pgs.

Transcription:

Principles of Computer Game Design and Implementation Lecture 17

We already learned Collision response Newtonian mechanics An application of Newtonian dynamics in targeting Collision recipe Ball-plain bouncing problem 2

Outline for today Collision recipe Ball-ball collision problem Other physics simulation rigid-body physics, soft-body physics, fluid mechanics, etc. 3

Ball-Ball Collision Recipe First, consider 1D case V 1 V 2 No roll No friction No energy loss Then 3D Elastic collision X 4

1D Ball-Ball Collision Laws Impulse conservation Before collision m 1 V 1 + m 2 V 2 = m 1 V 0 1 + m 2 V 0 2 Energy conservation m 1 V 2 1 2 + m 2V 2 2 2 = m 1V 0 2 1 2 + m 2V 0 2 2 2 After collision V 1 V 2 m 1 m 2 X 5

1D Ball-Ball Collision: Different Masses Can be solved V 0 1 = V 1(m 1 m 2 )+2m 2 V 2 m 1 + m 2 V 0 2 = V 2(m 2 m 1 )+2m 1 V 1 m 1 + m 2 V 1 V 2 m 1 m 2 X 6

1D Ball-Ball Collision: Same Mass If the balls have same mass (e.g. billiard balls) V 0 1 = V 2 V 0 2 = V 1 Examples: V 1 = 10mph, V 2 = 0 V 1 = 10mph, V 2 = -10mph V 1 = 10mph, V 2 = 3mph V 1 = 0, V 2 = 10mph V 1 = -10mph, V 2 =10mph V 1 = 3mph, V 2 =10mph Negative speed means that the ball moves from right to left V 1 V 2 m 1 m 2 X 7

Ball-Ball Inter Penetration V 2 V 1 m 1 m 2 X V 1 = 10mph, V 2 = -10mph V 1 = -10mph, V 2 =10mph V 1 = -10mph, V 2 = 10mph V 1 = 10mph, V 2 =-10mph V 1 = 10mph, V 2 = -10mph V 1 = -10mph, V 2 =10mph V 1 = -10mph, V 2 = 10mph V 1 = 10mph, V 2 =-10mph Move nowhere! 8

Ball-Ball Collision: Better Solution If (V 1 - V 2 > 0) V 0 1 = V 2 V 0 2 = V 1 Else no change in velocities V 2 V 1 m 1 m 2 V 1 = 10mph, V 2 = -10mph V 1 = -10mph, V 2 =10mph V 1 = -10mph, V 2 = 10mph V 1 = 10mph, V 2 =-10mph V 1 = 10mph, V 2 = -10mph V 1 = -10mph, V 2 =10mph V 1 = -10mph, V 2 = 10mph V 1 = 10mph, V 2 =-10mph X 9

3D Ball-Ball Collision (Same Mass) Collision does not change the parallel component of velocity N = 1 kp 2 P 1 k (P 2 P 1 ) V 1N = (NV 1 )N V 2N = (NV 2 )N V 1 = V 1 V 1N V 2 = V 1 V 2N Y V 1 V P 1 P 2 V N N V 2 V 1N = (NV 2 )N V 2N = (NV 1 )N V 2 = V 1N + V 1 V 2 = V 2N + V 2 Z X Position vectors 10

Same Mass Ball-Ball Collision jme code if( ) { Vector3f n = ball2.getlocaltranslation(). subtract(ball1.getlocaltranslation()). normalize(); float proj1v = velocity1.dot(n); float proj2v = velocity2.dot(n); Vector3f tan1 = velocity1. subtract(n.mult(proj1v)); Vector3f tan2 = velocity2. } subtract(n.mult(proj2v)); if(proj1v proj2v > 0) { velocity1 = tan1.add(n.mult(proj2v)); velocity2 = tan2.add(n.mult(proj1v)); } Z Penetration Handling Y V V 1 P 1 V N P 2 N X 11 V 2

Recall: Main Loop Start Naïve approach: for(i=0;i<num_obj-1;i++) for(j=i+1;j<num_obj;j++) if(collide(i,j)){ react; } Issues: How Can be very slow Initialise Update Game Draw Scene Are we done? Cleanup End 12

Simple Newtonian Mechanics Accurate physical modelling can be quite complicated We considered simplest possible behaviours Particle motion Ball-plain and ball-ball collision No friction, no properties of materials 13

Other Example: Box-Box collision Boxes can interact in a number of ways Hard to achieve a realistic behaviour without considering rotation, deformation, friction 14

402 Chapter 17 Putting It All Together Other Physical Simulations adrivinggamewillmodelconesandfences,allowingthemtobreakandbescattered Rigid body (no deformation) physics Rotation, friction, multiple collisions Joints and links Ragdoll physics 17.2.1 RAGDOLLS Zobject realistically, for example. In situations where different kinds of physical behavior need to interact, there is little to substitute for a complete physics engine. Z world Ragdolls are the hot physics X application world of the moment: characters that can be thrown around and generate their own realistic animation using physics. They are part of X object awidermovetowardproceduralanimation:animationthatdoesn tneedanartist creating keyframes. Center of Mass Aragdollismadeupofaseriesoflinkedrigidbodies(seefigure17.2).These rigid bodies are called bones (they roughly correspond to the bones used in skeletal animation, although there can be a different number of ragdoll bones and rendering bones). At their most complex, ragdolls can contain dozens of bones, essential for getting a flexible spine or tail. The bones are connected together with joints: constraints very much like those we saw in chapter 7. Finally, in some games force generators are added to the joints to simulate the way characters would move in flight: shielding their faces and trying to brace their hands against the fall. On the CD the ragdoll demo omits the force generators 1 but includes the joints to keep the bones together. The constraints are implemented as contacts. In addition to the regular contact generator, a list of joints is considered and contacts are generated to keep them to- 15

More Physics Soft body physics (shapes can change) Cloth, ropes, hair Fluid dynamics 16

Putting It All Together Combine all aspects of a physical model Force/Torque generators Rigid-body update (Integrator) Contact generator (possibly with pluggable constraints) 1 2 3 Apply forces and torques Write integrated position and velocity Contact data Rigid-body data Write postcollision position and velocity 4 Create contacts Contact resolution I. Millington. Game Physics Engine Development. Use hardware acceleration 17

Decoupling Physics and Graphics What if we need physics simulation for something not shown? E.g. reconsider the targeting problem Drag acts on the projectile V v V Computed trajectory (without drag) Real trajectory V h S 18

What Can We Do Euler steps give us the updated entity position based on the interaction with other entities and forces Analytical solution can be difficult to obtain Quadratic drag? Wind? Rocket-propelled grenade? 19

Interactive Approach Compute the initial velocity as if there is no drag, wind, thrust, (or simply pick a value) While not hit sufficiently close, repeat Use Euler steps to see where it gets If overshot, reduce speed If undershot, increase speed Fun to watch, but does it solve our problem? 20