Game and animation control flow

Slides:



Advertisements
Similar presentations
Using 2D sprite with OpenGL 2003 team Koguyue. Overview Motivation and basic concepts Advantages with using OpenGL Basic requirements of implementation.
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Computer Graphics Programming: Matrices and Transformations CSE 3451 Matt Boggus.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
INTRODUCTION. Painting with numbers! Aspects Modeling Rendering Animation.
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
Shading Languages By Markus Kummerer. Markus Kummerer 2 / 19 State of the Art Shading.
Chapter 1 Pseudocode & Flowcharts
Week 1 - Friday.  What did we talk about last time?  C#  SharpDX.
2D Physics and Camera Systems For CSE 3902 By: Matt Boggus.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Lesson 1: Intro to Animation
CSE 381 – Advanced Game Programming Basic 3D Graphics
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Computer Graphics Week2 –Creating a Picture. Steps for creating a picture Creating a model Perform necessary transformation Lighting and rendering the.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Control flow for interactive applications CSE 3541 Matt Boggus.
BY CASEY KUCERA Multimedia. Vector Graphics Composed of objects not pixels Object oriented graphics = vector graphics Stores a series of mathematical.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
CIS 3.5 Lecture 2.2 More programming with "Processing"
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.
CISC 110 Day 3 Introduction to Computer Graphics.
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
Fall UI Design and Implementation1 Lecture 13: Animation.
Over the recent years, computer vision has started to play a significant role in the Human Computer Interaction (HCI). With efficient object tracking.
Numerical Integration for physically based animation
Crowds (and research in computer animation and games)
CPT 450 Computer Graphics 12th Lecture – Animation.
Sprites (Images) and Sounds
Reading and Writing Image Files
Game and animation control flow
2D Physics and Camera Systems
MOM! Phineas and Ferb are … Aims:
- Introduction - Graphics Pipeline
Character Animation Forward and Inverse Kinematics
Week 2 - Monday CS361.
PYGAME.
8. Installing Pygame
Entry Ticket: Algorithms and Program Construction
Game Loops + Part II Reference:
Chapter 10 Computer Graphics
Image Segmentation Classify pixels into groups having similar characteristics.
Deferred Lighting.
From Turing Machine to Global Illumination
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
TerraForm3D Plasma Works 3D Engine & USGS Terrain Modeler
GUIs and Events CSE 3541/5541 Matt Boggus.
Introduction to Object-Oriented Programming
Numerical integration for physically based animation
Crowds (and research in computer animation and games)
Chapter 11-Business and Technology
Updating an Animated Scene
Representing Images 2.6 – Data Representation.
Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
8. Starting Pygame Let's Learn Python and Pygame
2.02C Frame-by-Frame Computer Animation Using PowerPoint
More programming with "Processing"
Chapter I Introduction
Rendering – Basic Concepts
Computer Graphics Lecture 15.
Introduction to spagetti and meatballs
Chapter 7 The Game Loop and Animation
Presentation transcript:

Game and animation control flow CSE 3541/5541 Matt Boggus

Overview Pseudocode for a game/animation loop Undo/redo example Tradeoff in saving cause vs. effect Unity transform and hierarchy computations as saving the effect

Game/Animation loop main(){ Initialize(); while(true){ DrawScene(); HandleEvents(); Update(); }

Draw() and HandleEvents() Draw() handled by Unity Types of events I/O Timers Scripted events Network message

Initialize() frame time Scene/Hierarchy objects Initially 0, increases by 1 every time the scene is drawn time Initially 0, increases by dt (a.k.a. timestep, Δt) every update Units might be seconds, minutes, or days, etc. Unity Time and Framerate Management Scene/Hierarchy objects Geometric objects Lights Camera Note the ese of your own dt value for controlling the speed of the animation vs. the Unity Time.deltatime which controls frame-rate for different hardware or run-time conditions

Update() P’(time+dt) = P(time) + Displacement(dt) Displacement(dt) is the change in position over the amount of time, dt, passing Can have similar equation for change in orientation How is Displacement(dt) calculated? Real-time user input Physics Behavior Key-frame data / Interpolation (Motion capture – save positions at each frame instead of computing displacement)

Time control or frame selection Braid (2008) Autodesk MotionBuilder Image from http://www.mobygames.com/game/xbox360/braid/screenshots/ Image from http://www.autodesk.com/products/motionbuilder/overview

Two approaches P(time-dt) = P’(time) - Displacement(dt) Save the cause (of the position change): Displacement(dt) Save the effect or result (of the position change) P’(time)

Timeline control – undo/redo of drawing shapes Ex: see MSPaint Removes the last drawn shape Replace removed shapes, unless a new one is drawn

Undo/Redo – two options Save the cause (the data to draw each shape) Which shape? Starting mouse (x, y) Ending mouse (x, y) Save the effect (the image after drawing the new shape) Image width * image height pixels Each pixel has a red, green, and blue value

Undo/Redo – two options Save the cause (of each drawn shape) Algorithm: to undo, clear the background and redraw shapes Storage cost: 5 ints per shape Save the effect (image after each shape is drawn) Algorithm: to undo, revert to previous image Storage cost: x * y * 3 ints per shape

Tie-in with hierarchical scenes in Unity Storing the result of a series of geometric transformations in an object’s transform is comparable to “saving the effect” Image from https://www.packtpub.com/books/content/unity-3-0-enter-third-dimension

Additional slides

draw_scene() Input: 3D scene + camera Output: 2D image When to redraw? Camera change [1] Object in view moves [1] Every frame [2] Every xth frame [3] [1] if(flag_set){ draw(); flag_set = false; } [2] [3] counter = (counter + 1)%draw_rate; if(counter == 0)

Graphics pipeline