physical simula on
play

Physical Simula-on CS 2501 Intro to Game Programming and - PowerPoint PPT Presentation

Physical Simula-on CS 2501 Intro to Game Programming and Design CS 2501 First thing to realize Physics (like, all of physics and doing


  1. Physical ¡Simula-on ¡ CS ¡2501 ¡– ¡Intro ¡to ¡Game ¡Programming ¡and ¡Design ¡ ¡ CS ¡2501 ¡

  2. First ¡thing ¡to ¡realize… ¡ • Physics ¡(like, ¡all ¡of ¡physics ¡and ¡doing ¡all ¡of ¡ physics) ¡is ¡HARD ¡ • Physics ¡in-­‑game ¡is ¡HARD ¡ • You ¡(as ¡beginning ¡game ¡designers… ¡or ¡as ¡later ¡ pro ¡game ¡designers) ¡probably ¡do ¡NOT ¡want ¡to ¡ do ¡your ¡own ¡physics ¡in ¡many ¡circumstances ¡ • … ¡well, ¡it ¡depends. ¡ CS ¡2501 ¡ 2

  3. KinemaPcs ¡vs. ¡Dynamics ¡ • KinemaPcs ¡is ¡the ¡study ¡of ¡moPon ¡(posiPon, ¡ velocity, ¡acceleraPon) ¡ • Dynamics ¡is ¡the ¡full ¡interacPvity ¡of ¡all ¡the ¡ forces ¡in ¡the ¡environment ¡ • You ¡can ¡handle ¡kinemaPcs ¡ • You ¡probably ¡don’t ¡want ¡to ¡handle ¡dynamics ¡ • So, ¡we’ll ¡use ¡enough ¡kinemaPcs ¡to ¡make ¡ people ¡believe ¡it ¡and ¡“fake” ¡the ¡rest! ¡ • Yes. ¡ ¡Fake ¡it. ¡ CS ¡2501 ¡ 3

  4. Immersion ¡in ¡the ¡World ¡ • When ¡a ¡ball ¡hits ¡a ¡paddle ¡or ¡brick ¡in ¡Breakout, ¡ how ¡does ¡it ¡behave? ¡ • hZp://www.roundgames.com/game/ Xenocrate+2 ¡ CS ¡2501 ¡ 4

  5. Immersion ¡in ¡the ¡World ¡ • How ¡does ¡the ¡ball ¡react? ¡ • Why ¡does ¡it ¡react ¡the ¡way ¡it ¡does? ¡ • How ¡does ¡it ¡react ¡differently ¡if ¡it ¡hits ¡in ¡the ¡ middle ¡of ¡the ¡paddle ¡vs. ¡the ¡edge ¡of ¡the ¡ paddle? ¡ CS ¡2501 ¡ 5

  6. Immersion ¡in ¡the ¡World ¡ • Why ¡does ¡the ¡ball ¡behave ¡like ¡this? ¡ • Is ¡this ¡an ¡“accurate” ¡portrayal ¡of ¡the ¡world? ¡ • What’s ¡wrong ¡with ¡the ¡physics ¡here? ¡ CS ¡2501 ¡ 6

  7. Physics ¡in ¡Games ¡ • So ¡the ¡quesPon ¡is ¡not ¡always ¡“how ¡do ¡we ¡ model ¡precise ¡physics” ¡ ¡ • But ¡more ¡oben ¡it’s ¡“how ¡do ¡we ¡model ¡a ¡ physics ¡that ¡makes ¡sense ¡in ¡this ¡world” ¡ • “The ¡correct ¡physics” ¡is ¡oben ¡essenPal ¡to ¡a ¡ posiPve ¡play ¡experience ¡and ¡also ¡fosters ¡new ¡ dynamics ¡in ¡a ¡game ¡ • Remember: ¡physics ¡is ¡the ¡mathemaPcal ¡study ¡ of ¡the ¡physical ¡world ¡ CS ¡2501 ¡ 7

  8. The ¡Role ¡of ¡Physics ¡ Detect Collisions • Responsive forces Accumulate Forces • Equations of Motion Numerical Integration • Updated world at Δ t in the future Enforce Constraints • Adjust world to maintain user constraints CS ¡2501 ¡ 8

  9. Basic ¡Overall ¡Idea ¡ • Assume ¡you ¡have ¡a ¡simple ¡parPcle ¡ • You ¡know ¡it’s ¡current ¡start ¡posiPon ¡ • You ¡know ¡it’s ¡current ¡velocity ¡and ¡acceleraPon ¡ • You ¡know ¡the ¡current ¡forces ¡working ¡on ¡it ¡ • You ¡know ¡(or ¡can ¡adjust) ¡the ¡Pme ¡unPl ¡the ¡ next ¡frame ¡to ¡draw ¡ • Where’s ¡the ¡parPcle ¡when ¡the ¡next ¡frame ¡is ¡ drawn? ¡ CS ¡2501 ¡ 9

  10. How ¡do ¡we ¡pull ¡this ¡off? ¡ • Roll ¡your ¡own ¡ – Pull ¡out ¡your ¡physics ¡book ¡(or ¡don’t ¡as ¡the ¡game ¡ requires) ¡and ¡go ¡to ¡town ¡ – Perhaps ¡crazy ¡physics ¡is ¡a ¡mechanic ¡in ¡your ¡game ¡ – Consider ¡the ¡physics ¡of ¡Breakout ¡ – What ¡do ¡you ¡have ¡to ¡calculate? ¡ – How ¡do ¡you ¡change ¡from ¡frame ¡to ¡frame? ¡ CS ¡2501 ¡ 10

  11. How ¡do ¡we ¡pull ¡this ¡off? ¡ • Pull ¡in ¡a ¡package ¡ – Unity ¡ – Havoc ¡ – PhysX ¡(hardware ¡acceleraPon) ¡ – Chipmunk ¡ – Farseer ¡(what ¡you ¡would ¡probably ¡use) ¡ CS ¡2501 ¡ 11

  12. Newton’s ¡Laws ¡ • First ¡Law: ¡An ¡object ¡in ¡moPon ¡will ¡remain ¡in ¡ moPon ¡unless ¡acted ¡upon ¡by ¡external ¡force. ¡ • Second ¡Law: ¡Force ¡= ¡Mass ¡* ¡AcceleraPon ¡ • Third ¡Law: ¡Every ¡acPon ¡has ¡an ¡equal ¡and ¡ opposite ¡reacPon. ¡ CS ¡2501 ¡ 12

  13. Variables ¡ • t x ¡The ¡final ¡Pme ¡for ¡the ¡period ¡we ¡are ¡ ¡ ¡examining ¡ • t 0 ¡The ¡iniPal ¡Pme ¡ • Δ t ¡The ¡change ¡in ¡Pme ¡(t x ¡– ¡t 0 ) ¡for ¡the ¡period ¡ we ¡are ¡examining ¡ • Δ v ¡The ¡change ¡in ¡velocity ¡(v x ¡– ¡v 0 ) ¡for ¡the ¡ ¡ ¡period ¡we ¡are ¡examining ¡ • Δ a ¡The ¡change ¡in ¡acceleraPon ¡(a x ¡– ¡a 0 ) ¡for ¡the ¡ ¡ ¡period ¡we ¡are ¡examining ¡ CS ¡2501 ¡ 13

  14. The ¡Problem ¡With ¡IntegraPon ¡ • It’s ¡all ¡an ¡approximaPon ¡ • If ¡the ¡Δt ¡is ¡too ¡big, ¡then ¡you ¡get ¡really ¡ imprecise ¡physics ¡ • If ¡the ¡Δt ¡is ¡too ¡small, ¡your ¡processor ¡can’t ¡ handle ¡it ¡all ¡ • If ¡it ¡happens ¡in ¡a ¡single ¡frame, ¡all ¡variables ¡are ¡ constant ¡ • How ¡do ¡curved ¡trajectories ¡turn ¡out? ¡ CS ¡2501 ¡ 14

  15. It ¡Gets ¡Worse… ¡ • Rigid ¡body ¡physics ¡adds ¡in ¡volume ¡and ¡mass ¡ • So ¡now, ¡we ¡are ¡focusing ¡our ¡equaPons ¡on ¡the ¡ center ¡of ¡mass ¡of ¡the ¡body… ¡but ¡other ¡things ¡ could ¡also ¡happen, ¡such ¡as ¡torque ¡ CS ¡2501 ¡ 15

  16. Different ¡Physics ¡ • Why ¡are ¡these ¡built ¡differently? ¡ • Why ¡does ¡this ¡maZer? ¡ – Mechanics ¡perspecPve ¡ – Dynamics ¡perspecPve ¡ – AesthePcs ¡perspecPve ¡ CS ¡2501 ¡ 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend