Physics simulation in a 3D environment Sylvain EUDIER MSCS Candidate Union College May 28 th, Spring 2004.

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

Real-Time Game Physics
A Simple Method for Extracting the Natural Beauty of Hair Ken-ichi Anjyo, Yoshiaki Usami, Tsuneya Kurihara Presented by Chris Lutz How many roads must.
7.2. AI E NGINE AND S TEERING B EHAVIOUR I Design of an AI Engine and introduction to steering in game AI.
Rigid Body Dynamics Jim Van Verth
GRAPP, Lisbon, February 2009 University of Ioannina Skeleton-based Rigid Skinning for Character Animation Andreas Vasilakis and Ioannis Fudos Department.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Beams and Frames.
Computational Geometry & Collision detection
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Interactive Animation of Structured Deformable Objects Mathieu Desbrun Peter Schroder Alan Barr.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
1cs533d-term Notes  list Even if you’re just auditing!
3D Geometry for Computer Graphics
1 Advanced Scene Management System. 2 A tree-based or graph-based representation is good for 3D data management A tree-based or graph-based representation.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collision Detection – Narrow Phase.
3.7. O THER G AME P HYSICS A PPROACHES Overview of other game engine physics approaches.
SVD(Singular Value Decomposition) and Its Applications
Faking Dynamics of Cloth Animation for Animated Films Fabian Di Fiore Expertise Centre for Digital Media Hasselt University, Belgium
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Physically Based Animation.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Antigone Engine Kevin Kassing – Period
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Final Project Presentation& Demo Zhi Dong Real Time FEM of Elasto-Plastic Simulation.
A Spring 2005 CS 426 Senior Project By Group 15 John Studebaker, Justin Gerthoffer, David Colborne CSE Dept., University of Nevada, Reno Advisors (CSE.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Evolving Virtual Creatures & Evolving 3D Morphology and Behavior by Competition Papers by Karl Sims Presented by Sarah Waziruddin.
Collaborative Visual Computing Lab Department of Computer Science University of Cape Town Graphics Topics in VR By Shaun Nirenstein.
Developing An Educational Rigid Body Dynamics Physics Engine By Neal Milstein.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
Minimum Distance between curved surfaces Li Yajuan Oct.25,2006.
Computer Game Design and Development
Beyond Bouncing Boxes Fast, yet still Realistic, Deformation and Fracture Jeff Lander Darwin 3D, LLC Luxoflux James O'Brien U. of California, Berkeley.
Developing An Educational Rigid Body Dynamics Physics Engine By Neal Milstein.
Presented by Paul Phipps
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
CSC321 Lecture 5 Applying backpropagation to shape recognition Geoffrey Hinton.
More on Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 24, 2004.
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Havok Xtra Training
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
Introduction to Game Programming & Design III Lecture III.
Computer Graphics Imaging Ying Zhu Georgia State University Lecture 29 Soft Bodies and Rigid Bodies.
Final Presentation CS491B ALAIN VINIOT DE LARA Spring 2007, CSULA.
Research and Development of a Physics Engine by Timmy Loffredo.
- Introduction - Graphics Pipeline
Computer Animation Ying Zhu Georgia State University
Collision Detection Spring 2004.
3.7. Other Game Physics Approaches
Parts of these slides are based on
Introduction to MATLAB
Chapter 4.2 Collision Detection and Resolution
Computer Animation Algorithms and Techniques
Advanced Games Development Game Physics
GPAT – Chapter 7 Physics.
Presentation transcript:

Physics simulation in a 3D environment Sylvain EUDIER MSCS Candidate Union College May 28 th, Spring 2004

Agenda  Why Physics Simulation?  Where am I, where am I going?  Start Coding  Entry point: The Spring Model  Extension to the Flag / Cloth simulation  Introduction to Collision Detection  Collision improvement: an example  Conclusion

Why Physics Simulation?  Getting more and more interest from the game industry  How does it work behind the scenes?  Combines physics and CS

Where am I?  Physics are used in many programs (CAD, games, simulators…)  Commercial physics libraries exist  As well as open source  Evolution of the simulation models up to now

Evolution : Quake 2 – Doom 3

Where am I going?  How precisely do we want to simulate the world  How do we want to represent it  For what expected quality / expense

Start Coding – Define the rules  Use of C++  Representation using the OpenGL API  Game-like precision  Find a model for this problem (classes)  Starting point: Write a stable and easy-to- use CVector3D class

The CVector3D class  3 constructors : Default, copy, by components  Overloading of operators: +, -, *, /, +=, -=, *=, /=  Methods: length, normalize, unit, crossProduct and dotProduct

What can I start with?  The spring model Simulate the behavior of a deformable object under certain constraints. Easy to implement (as a beginning) Gives convincing results rapidly  Allows me to test the architecture of my program

The Spring Model  To the basic formula, we add the inner friction (to stabilize it):

The Spring Model  These properties are the basics we can give to a mass.  Considered as a dot

The Spring Model  For the computation: L: steady length x: actual length of the spring u: unit vector between mass1 and mass2

Application to a rope  The rope is made of several masses that interact with each other  By changing the variables, the rope may be: stiffer, more / less extendable  We can create different kinds of extensible material

Demonstration  Rope simulation 1  Rope simulation 2

Spring Model : First impressions  (+) The result looks good enough for such a simple simulation.  (-) The rope behaved differently on different machines (different speeds)  (-) The rope cannot be very stiff

Spring Model : Speed problem  Need for a time regulation algorithm Why? How?  After the first try, I had a slow and fast behavior… Due to the GetTickCount() function Use of the QueryPerformanceCounter()

Spring Model : Stiffness issue  The stiffness problem: Due to the Euler’s approximation method

Spring Model : Stiffness issue – Why?

Euler function stability comparison

Spring Model : Extensions  The rope does not include any bending information: Can be solved using interleaved springs (explained later, cf. Flag)  Stiffness problem: Regarding the sources I found, the Runge-Kutta algorithm should solve the problem

The Runge-Kutta Algorithm Runge-Kutta 4 (55, )

Spring Model : Flag simulation  A flag is just a patch of springs Create n*m masses Create (n-1)*(m-1) springs Connect the springs to the masses  Possibility to add a wind effect

Spring Model : Flag simulation  Flag simulation

Flag simulation : Results  (+) The mesh reacts well to the wind and gravity  (-) The flag is harder to simulate because of the stiffness problem and the lack of bending factor

Flag simulation : Extensions  Can simulate a flag flexibility with interleaved springs…  …and add a universal repulsive force to every node  More complex and realistic simulation

High quality flag simulation  Demonstration

Collision Detection  Why?  How?  Dependencies: A strong math library: vectors, matrices, plane-point collision, face-face collision… Possibility to work on predefined meshes

On the way to the collision  Math library: Matrices:  Overloading of arithmetic operators (+, -, *, +=…)  Overloading of input / output operators ([], <<)  Matrices functions : determinant, multiplications, inversions, transposition, identity  Matrix-related functions : rotate, scale, translate… Vectors Collision functions: PointToPlaneDistance, IsPointInPolygon…

Importing 3DS files  3DS is a standard in the industry  I already had an importing class for 3DS files .3DS files have several advantages: Face defined clockwise, Texture information, Normals information, And a lot more…

Into the collision  Brute force algorithm: CheckForCollisions(): MakePreselection(Scene, Collisions) For all objects in the Collision List if(this object collides with another one) Find the collision point Apply the physics on the objects, at that point  But this will never work!!!

Buggy Collision  Demonstration

Into the collision (2)  New algorithm: Do ComputePhysics(NextTimeChunk); CheckForCollisions(Scene, Collisions); if(MaxPenetrationInAnObject < Limit) Problem is solved; if(Problem NOT solved) NextTimeChunk = PreviousTime / 2; CancelTheComputations(); else ValidateTheComputations(); While(Problem is NOT solved); proceed to the next time chunk; While(TimeChunknotSimulated);

The rollback function

Collision improvement  We can extend the sphere collision test to a more general one.  Add a real collision and motion behavior (friction, rotation…)  The MakePreselection function can improve a lot the computation time

Improvements and trade-offs  The vast majority of the program use an aggressive MakePreselection algorithm to be able to deal with a lot of objects  Optimization without loss of information AABB = Axis Aligned Bounding Box OBB = Oriented Bounding Box 6-dop = Discrete Orientation Polytope Convex Hull

Example of an approximation algorithm Approximation: Based on some assumptions over “insignificant” constraints of objects (=has to look good enough)  The Opposing Face Geometry algorithm: Algorithm in 8 steps, The pro… …And cons

Opposing Face Geometry algorithm  1. Preselection: check collision between object A's bounding sphere and object B's bounding sphere.  2. Find the closest k faces of object A relative to object B.

O.F.G. algorithm  3. Calculate the geometric center of the new selection and the bounding sphere radius.  4. Find the closest k faces of object B relative to object A's new selection of k faces.  5. Calculate the geometric center of object B's new selection of faces and their maximal bounding sphere radius.

The O.F.G. algorithm  6. PreSelection: check collision between spheres to determine if there is even a chance for face collisions.  7. Sort the two sets of faces by increasing distance  8. Test the two sets of faces against each other, starting with the closest pairs of faces.

Pro / Cons of such this algorithm  (+) This is a lot faster. Runtime of O(k 2 ) Where k is usually between 4 and 8 (k is a variable representing the number of faces we want to work on) Brute force approach would be O(n*m) n and m could be 1000 of faces  (-) Cannot really work on concave polygons This is TRUE for most of today’s engines

The discrete Time problem  Due to the intrinsic nature of the simulation : Time- discrete based  If the dt variation is too big, an object might be “teleported” through another one  Solution: Extrude the silhouette of the object. Test this polygon for collisions

Summary  Springs are the basis of a lot of models and can be used for powerful simulations (i.e. any kind of elastic models)  Collision detection needs a robust design and math support. There is a lot to do about optimization and trade-offs  Physics simulation is a vast field where a lot of techniques are to be discovered

Selection of References  “Computer Graphics with OpenGL”, third Edition by Hearn- Baker, Prentice Hall  Huge source of information for game programming:  Chris Hecker’s famous columns about physics:  Everything you need to know about geometry:  A lot about everything, from physics to light computations:

Conclusion - Discussion  Questions? Need Explanations? What kind of extensions could we add to a physics simulator?

References  Collision detection Advanced  Gamasutra - Features - "Advanced Collision Detection Techniques" [ ] Gamasutra - Features - "Advanced Collision Detection Techniques" [ ]  Advanced Collision Detection Techniques Advanced Collision Detection Techniques  Advanced Collision Detection Techniques Advanced Collision Detection Techniques  Chris Hecker's Rigid Body Dynamics Information Chris Hecker's Rigid Body Dynamics Information  DDJ DDJ GameDev.net - Opposing Face Geometry GameDev.net - Simple Bounding-Sphere Collision Detection GameDev.net - Practical Collision Detection GameDev.net - General Collision Detection for Games Using Ellipsoids Collision Response: Bouncy, Trouncy, Fun Gamasutra - Features - "Crashing into the New Year" [ ] Snooker simulation (+Formulaes) Rotation computation  HyperPhysics HyperPhysics MODEL-BASED ANIMATION SIGGRAPH - Collision Detection ('88) AIWisdom.com - Game Articles & Research Geometry Cours de Mécanique - Index The good-looking textured light-sourced bouncy fun smart and stretchy page Deformation  GameDev.net - Real time deformation of solids, Part 1 GameDev.net - Real time deformation of solids, Part 1  GameDev.net - Real time deformation of solids, Part 2 GameDev.net - Real time deformation of solids, Part 2  Gamasutra - Features - "Exploring Spring Models" [ ] Gamasutra - Features - "Exploring Spring Models" [ ] Cloths  Awesome paper on cloth simulation Awesome paper on cloth simulation  ch06.pdf (application/pdf Object) ch06.pdf (application/pdf Object)  Rotational Motion Rotational Motion