Game Physics Animation in Games
Total Page:16
File Type:pdf, Size:1020Kb
Video Game Dev - Univ Insubria Marco Tarini 2017/2018 Video Game Dev 2017/2018 Univ. Insubira Game Physics Marco Tarini Animation in games Non procedural Procedural Assets! Physics engine Artist/Designer Less control controlled (dramatic effects!) Not interactive Interactive Artist dependent Physics driven realism realism Less customizable Auto adaptation Game Physics - 1 1 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 (recall?) Game Engine Game part managing some of the common tasks Scene / levels Renderer Real time transform + lighting Models, materials … Animations Physics engine scripted or computed (soft real-time) Newtonian physical simulations Collision detection + response Networking (LAN – ex. using UTP) Sound mixer and “sound-renderer” HCI devices unified manager Main event loop, timers, windows manager… Memory management Artificial intelligence module AI common sub tasks solution Localization support Scripting GUI (HUD) Physics simulation in videogames 3D, or 2D “soft” real-time efficiency 1 frame = 33 msec (at 30 FpS) physics = 5% - 30% max of computation time plausibility (not necessarily realism) robustness (should almost never “explode”) Game Physics - 1 2 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 Physics engine: intro Game engine module executed at game run time An high-demanding computation on a low-time budget! …but highly parallelizable “embarrassingly parallel” hardware support (as the Rendering Engine) Game engine tasks: (Physics simulation!) Dynamics (Newtonian) for object types such as: Rigid bodies Soft bodies “ragdolling” Free-form deformation bodies: Specific solutions for Ropes Cloth Hair… Fluids Air (e.g. wind) etc Collision handling Collision detection Collision response Game Physics - 1 3 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 Hardware for Physics engine To exploit a strong parallelism, you need a strongly parallel hardware! Recently: PPU “Physical Processing Unit” HW unit specialized on physics More recently: GP-GPU “General Purpose Graphics Processing Unit” Use of the graphics card for generic tasks (not related with 3D computer graphics) Ex.: Cuda (nVidia) Software: libraries / SDK HW accelerated (CUDA) HW accelerated (OpenCL) by open source, free, HW accelerated open source, free 2D! open source, free Game Physics - 1 4 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 PhysX … Physics in games: cosmetics or gameplay? Just a graphic accessory? (for realism!) e.g.: particle effects (w/o feedback) secondary animations Ragdolling Or a gameplay component? e.g. physics based puzzles Popular approach in 2D (since always!) Game Physics - 1 5 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 Physics in games: cosmetics or gameplay? Just a graphic accessory? (for realism!) e.g.: particle effects (w/o feedback) secondary animations Ragdolling Or a gameplay component? e.g. physics based puzzles Rising trend in 3D Physics engine: Dynamics Physics simulation (Newtonian) Revision: object = mass Object state: . position and derivative: velocity . (and momentum) . direction and angular velocity . (and angular momentum) State change: . forces => acceleration, torque Game Physics - 1 6 Video Game Dev - Univ Insubria Marco Tarini 2017/2018 Reminder: Object position 2D Physics 3D Physics Position: Position: (x,y) (x,y,z) Orientation: Orientation: (α) – angle (scalar) quaternion or axis,angle or axis x angle or 3x3 matrix or Euler angles Not really suitable Newtonian dynamics: summary Actual Rate of change object of location (d / dt ) Position 푝 Velocity 푣⃗ 푝 = (x,y,z) 푣⃗ = 푝̇ ( |푣⃗| = “speed” ) Game Physics - 1 7.