Chipmunk Physics Remember that we talked about this a bit when we did collision handlers for the space ship integration task (SpritesActionsPhysicsSound).

Slides:



Advertisements
Similar presentations
AP Physics C Mechanics Review.
Advertisements

Chapter 12: Momentum 12.1 Momentum
Two-Dimensional Rotational Dynamics W09D2. Young and Freedman: 1
Summer School 2007B. Rossetto1 5. Kinematics  Piecewise constant velocity t0t0 tntn titi t i+1 x(t) x(t i ) h t x i = v(t i ). h Distance runned during.
Color Problem Have a black-box function that returns a bright color in 24-bit RGB Want a paler version of the output What to do?
Chapter 5 Rotation of a Rigid Body. §5-5 Angular Momentum of a rigid Body Conservation of Angular Momentum §5-1 Motion of a Rigid body §5-2 Torque The.
1Notes  Demetri Terzopoulos talk: Thursday, 4pm Dempster 310.
Test 3 today, at 7 pm and 8:15 pm, in Heldenfels 109 Chapters
Chapter Eight Rotational Dynamics Rotational Dynamics.
Rigid Bodies Rigid Body = Extended body that moves as a unit Internal forces maintain body shape Mass Shape (Internal forces keep constant) Volume Center.
Physics 1901 (Advanced) A/Prof Geraint F. Lewis Rm 557, A29
Physics 218: Mechanics Instructor: Dr. Tatiana Erukhimova Lectures Hw: Chapter 15 problems and exercises.
Semester Physics 1901 (Advanced) A/Prof Geraint F. Lewis Rm 560, A29
Physics 218: Mechanics Instructor: Dr. Tatiana Erukhimova Lectures 24, 25 Hw: Chapter 15 problems and exercises.
Physics 111: Mechanics Lecture 11 Dale Gary NJIT Physics Department.
Computer graphics & visualization Collision Detection – Narrow Phase.
FE Exam: Dynamics review
S2 Final Exam Review. Newton's First Law of Motion There are two parts to this statement – one which predicts the behavior of stationary objects and the.
THIS IS Review Your Physics For WorkEnergyMomentum Circular Motion GravitationAssorted.
Spring Topic Outline for Physics 1 Spring 2011.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Game Physics – Part IV Moving to 3D
 Torque: the ability of a force to cause a body to rotate about a particular axis.  Torque is also written as: Fl = Flsin = F l  Torque= force x.
Section 13.4 The Cross Product. Torque Torque is a measure of how much a force acting on an object causes that object to rotate –The object rotates around.
Two-Dimensional Rotational Dynamics 8.01 W09D2 Young and Freedman: 1.10 (Vector Product), , 10.4, ;
Chapters 10, 11 Rotation and angular momentum. Rotation of a rigid body We consider rotational motion of a rigid body about a fixed axis Rigid body rotates.
FE Exam: Dynamics review D. A. Lyn School of Civil Engineering 21 February 2012.
CSE 380 – Computer Game Programming Box2D Box2D TestBed.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
AP Physics C: Mechanics Chapter 11
Resistance of an object to a change in its motion inertia.
Chapter 12 Static Equilibrium and Elasticity. Introduction Equilibrium- a condition where an object is at rest OR its center of mass moves with a constant.
1© Manhattan Press (H.K.) Ltd. 1.7 Stability 2 © Manhattan Press (H.K.) Ltd. Stability 1.7 Stability (SB p. 75) What makes objects more stable than others?
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Course Summary Xcode & iPhone Simulator
Sprites Actions/Particles/Sound Revisit the 'flying saucer' sprite: Again add it to the game Implement Chipmunk Physics collision feedback with missiles.
Introduction to Particle Simulations Daniel Playne.
9.4. Newton’s Second Law for Rotational Motion A model airplane on a guideline has a mass m and is flying on a circle of radius r (top view). A net tangential.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Linear and Angular Motion. The greater the applied impulse the greater the increase in velocity. Principle 4 – Linear Motion.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Rigid Body Dynamics CSE169: Computer Animation
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Approach Two aspects: Physical collision experiment with eraser boxes o provides real world data to corroborate simulation Interactive computer simulation.
Two-Dimensional Rotational Dynamics W09D2. Young and Freedman: 1
Two-Dimensional Rotational Dynamics 8.01 W09D2 Young and Freedman: 1.10 (Vector Product), , 10.4, ;
Computer Graphics Imaging Ying Zhu Georgia State University Lecture 29 Soft Bodies and Rigid Bodies.
Concepts for Programming a Rigid Body Physics Engine Part 2 Presented by Scott Hawkins.
UNIT 6 Rotational Motion & Angular Momentum Rotational Dynamics, Inertia and Newton’s 2 nd Law for Rotation.
Review Scene Management (Scene, Layer, Director) Sounds Menus Sprites & Actions.
Advanced Computer Graphics Rigid Body Simulation
Course Summary Xcode & iPhone Simulator
2D Simulation of Rigid Bodies
Done already for your convenience!
Computer Animation Ying Zhu Georgia State University
Lecture Rigid Body Dynamics.
Angular Momentum 7.2.
Review Scene Management (Scene, Layer, Director) Sounds Menus
Physics: Principles with Applications, 6th edition
Balanced and unbalanced
Manipulator Dynamics 2 Instructor: Jacob Rosen
Forces.
FORCE.
Useful Tools for Making Video Games
Advanced Games Development Game Physics
Forces.
Forces.
Forces & Newton’s Laws of Motion
Presentation transcript:

Chipmunk Physics Remember that we talked about this a bit when we did collision handlers for the space ship integration task (SpritesActionsPhysicsSound). Also available code.google.com It's a 2D rigid body physics library written in “C”.

2D Rigid Body Physics The bodies are 2D only, and can overlap (i.e., look carefully at some of the asteroids). The bodies do not deform when they hit other objects. e.g., Couldn't simulate collision damage on a car. The bodies obey some “simulated physical” laws.

Overview There are 4 basic objects: Space holds the other 3 objects. Body holds the properties (mass, position, rotation, velocity, angular momentum, etc) associated with a physical object. Shapes attached to a body; defines the surface boundaries of a body for collision purposes; also the friction and elasticity. Constraints define the type of interactions that bodies can have.

To Start to Use From our test code you know that you need to: Initialize the system with 'cpInitChipmunk()' AsteroidsLayer init method. Schedule a method to be fired at intervals (usually 1/60 sec) AsteroidsLayer step method. Invoke the cpSpaceStep function in the scheduled method.

Basic Types we have used The library defines some basic C types other than the main ones (space, shape, body, constraint). We have used: cpFloat which is a double cpVect which is a 2D vector (i.e., ). e.g., used to define the boundries of a shape. cpCollisionType allows you to categorize things that can collide with other things. e.g., asteroid, space ship, missile, alien ship.

Defines Operations on Vectors In addition to the trigonometry functions found in math.h (see AsteroidLayer.m): Addition, subtraction, multiplication with float, negative, dot product, cross product, rotate, length, normalize, distance between, vector-angle, angle-vector operations.

cpBody Defined using vectors: position, velocity, current force applied to. Defined using floats: mass, moment (a measure of an object's resistance to changes to its change in rotation), angle, rotational velocity, torque applied to. Defines a place for the user to store a data pointer (e.g., game object associated with the body).

cpBody Functions Memory management (alloc & free) Moment of inertia assuming certain shapes (circle, segment, polygon, box) Getters & Setters maintained cached data Incremental (velocity update, position update) Coordinate conversion Application of forces and torque

cpShape Currently three types: (circle, line, convex polygon) Defined by: elasticty (bouncability), friction, collision_type, associated body, layers, & groups. Layers allow shapes to collide only if they are in the same “plane” Shapes in the same “group” never collide. Defines a place for the user to store a data pointer (e.g., game object associated with the body).

Collisions Collisions are defined as talking place between two shapes Handlers can be defined to be called when: Begin: two shapes just started touching Are: can get back collision force End: two shapes just stopped touching Callbacks are used in removing objects during a collision.

cpSpace Groups bodies, and shapes together for simulation. Simulation iterations define how much computation is done to make something “solid”. Defined by: iterations, gravity, viscous dampening. An “infinite mass, static body” can be attached to a space. Gives it a “immovable body” to attach others to via constraints (e.g., rotate about a point or slide to within limits)

cpSpace Functions Same memory management functions as the others (alloc, free) Ability to add/remove: bodies, shapes, constraints Ability to simulate (cpSpaceStep)

cpConstraint Describes how two bodies interact or constrain each other's movements (e.g., joints act like joints in your body) Defined by: two bodies, max force used to act on them, a data pointer. Some examples: &feature=player_embedded

Our Tie in with physics engine We subclassed CCSprite so that: The body and collision shape are created at init time The 'setPosition' method also tells the physics engine Delete the body and shape with the sprite is deallocated iphone.org/wiki/doku.php/prog_guide:sprites#how _to_subclass_sprites