Presentation is loading. Please wait.

Presentation is loading. Please wait.

Updating an Animated Scene

Similar presentations


Presentation on theme: "Updating an Animated Scene"— Presentation transcript:

1 Updating an Animated Scene
CSE 3541/5541 Matt Boggus

2 Overview Unity script structure reminder Animation use-case
Undo/redo use-case

3 Unity example script using UnityEngine; using System.Collections; public class SomeScript : MonoBehaviour { // fields void Start() { // code to run when start is pressed } void Update () { // code to run on repeat during execution } // other methods }

4 Animation terms 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 use 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

5 Animating objects 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)

6 Time control or frame selection
Braid (2008) Autodesk MotionBuilder Image from Image from

7 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)

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

9 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

10 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

11 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

12 Scene drawing options 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)

13 Summary Unity script structure reminder Animation use-case
Undo/redo use-case


Download ppt "Updating an Animated Scene"

Similar presentations


Ads by Google