CPSC 427 Video Game Programming

CPSC 427 Video Game Programming

Helge Rhodin CPSC 427 Video Game Programming Transformations for Skeleton Kinematics 1 © Alla Sheffer, Helge Rhodin Recap: Fun to play? https://www.androidauthority.com/level-design-mobile-games-developers- make-games-fun-661877/ 2 © Alla Sheffer, Helge Rhodin Recap: Indirect relationships Value of a piece • It is not possible to get a knight for 3 pawns • But one can ‘trade’ pieces • A currency How to determine the value? • Ask the users • Auction house 3 © Alla Sheffer, Helge Rhodin Recap: Relationships • Linear relations • Exponential relations • Triangular relationship • 1, 3, 6, 10, 15, 21, 28, … • The difference increases linearly • The function has quadratic complexity • Periodic relations 4 © Alla Sheffer, Helge Rhodin Asymptotic analysis? • Linear * linear? • Linear + linear? • Linear + exponential? • Linear * exponential? 5 © Alla Sheffer, Helge Rhodin Numerical Methods - Optimization • Iterative optimizers • Single variable? Exponential Target function • Multiple variables? Linear approx. • Gradient descent? Constant approx. Lecture 14: https://youtu.be/ZNsNZOnrM50 • Balancing demo starts at 1h20 • Optimizer used at ~ 1h30 6 © Alla Sheffer, Helge Rhodin Difficulties: • Placement of towers changes the time damage is dealt • Path of enemies can be hindered to increase time ➢ Measure during playtest ➢ cross-play • Some enemies are resistant to fire/magic/…? • kind of a periodic feature 7 © Alla Sheffer, Helge Rhodin Counter Measures • Transitive Mechanics • Repair costs • Consumables (food, potions, …) • Tax 8 © Alla Sheffer, Helge Rhodin A/B Testing Testing two variants of your game (with and w/o a feature) • randomized participants (same pool) • with respect to a measurable objective (e.g., clicks on website) Related to • two-sample hypothesis testing • Clinical tests, e.g., testing of a COVID-19 vaccine • Placebo effect 9 https://www.optimizely.com/optimization-glossary/ab-testing/ © Alla Sheffer, Helge Rhodin Logistics 10 © Alla Sheffer, Helge Rhodin M4 updated requirement User study Carefully balance one aspect of your game (e.g., movement-speed, health points, strength, bonus,…). • Report on the theoretical analysis • Change log with testing 11 © Alla Sheffer, Helge Rhodin M4 Advanced shaders? • Use ShaderToy.com • Demo in Lecture 4 https://youtu.be/S97-fYMv4Xk 45 minute mark 12 © Alla Sheffer, Helge Rhodin Upcoming lectures: Tuesday: • Working in teams • Supported by TA Thursday: • Last formal lecture: • Skeleton Animation continued • Summary and Outlook Tuesday (April 13.): • M4 grading with TAs Monday (April 19.): • Final cross play, including industry jury and awards 13 © Alla Sheffer, Helge Rhodin Final cross play Room Purpose Timeline: 1 Team 1 – open cross-play 7 – 8 pm: scheduled (10 minutes) cross play 2 Team 2 – open cross-play 7 – 8:30 pm: open cross play (those not with jury) … … 8 – 8:30 pm: jury votes, student votes are counted 8:30 – 9 pm: awards! 12 Team 12 – open cross-play 13 Jury 1 (Skybox) – scheduled 10 min slots Communication: 14 Jury 2 (EA) – scheduled 10 min slots On Slack to reach beyond zoom rooms … … • OK to include jury? 20 Overflow – breakout for open cross-play 21 Overflow – breakout for open cross-play Presence: … … • Mandatory! 14 © Alla Sheffer, Helge Rhodin Today Becoming an expert on transformation • Mental picture • Math • Practical examples Composite transformations • Articulated skeleton motion • Skeleton animation 15 © Alla Sheffer, Helge Rhodin Recap: Transformations Lecture 3, 20 minute mark • https://youtu.be/l9xQUxJT7fg 16 © Alla Sheffer, Helge Rhodin From local object to camera coordinates Camera Camera World World coordinates coordinates coordinates coordinates y y x x x x y y object -> world world -> camera object -> camera transform projection projection * transform 17 © Alla Sheffer, Helge Rhodin Recap: GLSL Vertex shader The OpenGL Shading Language (GLSL) • Syntax similar to the C programming language • Build-in vector operations x and y coordinates • functionality as the GLM library our assignment template uses of a vec2, vec3 or vec4 world object void main() -> camera -> world { // Transforming The Vertex vec3 out_pos = projection * transform * vec3(in_pos.xy, 1.0); gl_Position = vec4(out_pos.xy, in_pos.z, 1.0); } float vector of 3 (vec3) and 4 (vec4) floats (32 bit) 18 © Alla Sheffer, Helge Rhodin Affine transformations • Linear transformations + translations • Can be expressed as 2x2 matrix + 2 vector • E.g. scale+ translation: x' x'2 02 00xx Ttxx = + y'=y'0 20 02yy +Tty z' 0 0 1 z 0 © Alla Sheffer, Helge Rhodin Modeling Transformation Adding a third coordinate x' x'2 02 00xx Ttxx = + y'=y'0 20 02yy +Tty z' 0 0 1 z 0 Affine transformations are now linear • one 3x3 matrix can express: 2D rotation, scale, shear, and translation © Alla Sheffer, Helge Rhodin Forward transformations • Given position, scale, angle • Compute transformation matrix • Transform the object • Examples? • Later: Inverse transformations 21 © Alla Sheffer, Helge Rhodin Parallax scrolling background Further objects • are smaller • move slower Multiple layers! Weak perspective projection • Approximates perspective projection 22 © Alla Sheffer, Helge Rhodin Parallax scrolling background Ingredients: • Multiple layers • One sprite per layer x' 2 0 0 x t • One transformation per layer x • Scale y' down= 0 with2 distance0 y + ty • Move z' inversely 0 0 proportional1 z to0 the distance 23 © Alla Sheffer, Helge Rhodin 24 © Alla Sheffer, Helge Rhodin TRANSFORMATION COMPOSITION p x • What operation rotates XY by around P = ? py P P © Alla Sheffer, Helge Rhodin TRANSFORMATION COMPOSITION p x • What operation rotates XY by around P = ? py • Answer: • Translate P to origin P P © Alla Sheffer, Helge Rhodin TRANSFORMATION COMPOSITION p x • What operation rotates XY by 휃 < 0 around P = ? py • Answer: • Translate P to origin • Rotate around origin by • Translate back P P © Alla Sheffer, Helge Rhodin TRANSFORMATION COMPOSITION ( p , p ) (− px ,− p y ) T x y RT (V ) 1 0 p cos − sin 01 0 − p v x x x = 0 1 p sin cos 00 1 − p v y y y 0 0 1 0 0 10 0 1 1 © Alla Sheffer, Helge Rhodin two interpretations cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATES cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATES cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATES cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME Columns are new basis vectors (and new origin)! cos 휃 − sin 휃 푝푥 ⋅ (1−cos 휃) + 푝푦 ⋅ sin휃 푣푥 sin 휃 cos 휃 푝푦 ⋅ (1−cos 휃) + 푝푥 ⋅ sin휃 푣푦 0 0 1 1 P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME 풗풙 (풑 ,풑 ) 휽 (−풑 ,−풑 ) 푻 풙 풚 푹 푻 풙 풚 풗풚 ퟏ P P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME 푣푥 (풑 ,풑 ) 휃 (−푝 ,−푝 ) 푻 풙 풚 푅 푇 푥 푦 푣푦 1 P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME 푣푥 (풑 ,풑 ) 휃 (−푝 ,−푝 ) 푻 풙 풚 푅 푇 푥 푦 푣푦 1 P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME 푣푥 (푝 ,푝 ) 휽 (−푝 ,−푝 ) 푇 푥 푦 푹 푇 푥 푦 푣푦 1 P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME 푣푥 (푝 ,푝 ) 휃 (−풑 ,−풑 ) 푇 푥 푦 푅 푻 풙 풚 푣푦 1 P © Alla Sheffer, Helge Rhodin TRANSFORMING COORDINATE FRAME World Coordinate Object Coordinate Frame Frame 푣′푥 푣푥 (푝푥,푝푦) 휃 (−푝푥,−푝푦) 푣′푦 = 푇 푅 푇 푣푦 1 1 P P © Alla Sheffer, Helge Rhodin TWO INTERPRETATIONS OF COMPOSITE World Coordinate Object Coordinate Frame Frame 푣′푥 푣푥 (푝푥,푝푦) 휃 (−푝푥,−푝푦) 푣′푦 = 푇 푅 푇 푣푦 1 1 1) read from inside-out as transformation of object 2) read from outside-in as transformation of the coordinate frame © Alla Sheffer, Helge Rhodin Transformation Hierarchies © Alla Sheffer, Helge Rhodin Transformation Hierarchies Scenes have multiple coordinate systems • Often strongly related • Parts of the body • Object on top of each other • Next to each other… Independent definition is bug prone Solution: Transformation Hierarchies © Alla Sheffer, Helge Rhodin Transformation Hierarchy Examples 2 4 5 3 1 y x © Alla Sheffer, Helge Rhodin Transformation Hierarchy Examples 푀1 = 푇푟(푥,푦) ⋅ 푅표푡휃1 2 푀2 = 푀1 ⋅ 푇푟(2.5,5.5) ⋅ 푅표푡 휃2 4 푀3 = 푀2 ⋅ 푇푟(0,−3.5) ⋅ 푅표푡 휃3 5 3 1 y x © Alla Sheffer, Helge Rhodin Transformation Hierarchies world torso LUleg RUleg LUarm RUarm head LLleg RLleg LLarm RLarm Lfoot Rfoot Lhand Rhand rot(z, ) trans(0.30,0,0) © Alla Sheffer, Helge Rhodin Transformation Hierarchy Quiz M.setIdentity(); M = M*Translation(4,1,0); M = M*Rotation(pi/4,0,0,1); House.matrix = M; Which color house will we draw? A. Red B. Blue C. Green FW D. Orange E. Purple © Alla Sheffer, Helge Rhodin Hierarchical Modeling Advantages • Define object once, instantiate multiple copies • Transformation parameters often good control knobs • Maintain structural constraints if well-designed Limitations • Expressivity: not always the best controls • Can’t do closed kinematic chains • E.g., how to keep a hand on the hip? © Alla Sheffer, Helge Rhodin Forward vs.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    54 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us