CS 4620 Practicum Programming Assignment 6 Animation



Similar documents
Fundamentals of Computer Animation

Animation (-4, -2, 0 ) + (( 2, 6, -4 ) - (-4, -2, 0 ))*.75 = (-4, -2, 0 ) + ( 6, 8, -4)*.75 = (.5, 4, -3 ).

Maya 2014 Basic Animation & The Graph Editor

Computer Animation. Lecture 2. Basics of Character Animation

Metrics on SO(3) and Inverse Kinematics

CATIA V5 Tutorials. Mechanism Design & Animation. Release 18. Nader G. Zamani. University of Windsor. Jonathan M. Weaver. University of Detroit Mercy

Tutorial: Biped Character in 3D Studio Max 7, Easy Animation

Kinematical Animation

Blender 3D Animation

CS 4204 Computer Graphics

the points are called control points approximating curve

MovieClip, Button, Graphic, Motion Tween, Classic Motion Tween, Shape Tween, Motion Guide, Masking, Bone Tool, 3D Tool

Working With Animation: Introduction to Flash

Adding Animation With Cinema 4D XL

Interactive Computer Graphics

Intro to 3D Animation Using Blender

Overview of the Adobe Flash Professional CS6 workspace

Essential Mathematics for Computer Graphics fast

Solar-Generation Data Visualization Software Festa Operation Manual

11.1. Objectives. Component Form of a Vector. Component Form of a Vector. Component Form of a Vector. Vectors and the Geometry of Space

Flash MX 2004 Animation Lesson

(Refer Slide Time: 1:42)

CMSC 425: Lecture 13 Animation for Games: Basics Tuesday, Mar 26, 2013

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Gas Dynamics Prof. T. M. Muruganandam Department of Aerospace Engineering Indian Institute of Technology, Madras. Module No - 12 Lecture No - 25

IMD4003 3D Computer Animation

Character Creation You can customize a character s look using Mixamo Fuse:

Triggers & Actions 10

Computer Graphics CS 543 Lecture 12 (Part 1) Curves. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

521493S Computer Graphics. Exercise 2 & course schedule change

SketchUp Instructions

Creating Hyperlinks & Buttons InDesign CS6

Computer Animation: Art, Science and Criticism

GeoGebra. 10 lessons. Gerrit Stols

CIS 536/636 Introduction to Computer Graphics. Kansas State University. CIS 536/636 Introduction to Computer Graphics

Understanding Rotations

Animator V2 for DAZ Studio. Reference Manual

Character Animation Tutorial

Beginner s Matlab Tutorial

Project 2: Character Animation Due Date: Friday, March 10th, 11:59 PM

Software Application Tutorial

We can display an object on a monitor screen in three different computer-model forms: Wireframe model Surface Model Solid model

Flash Tutorial Part I

CARTOON BUILDER. Character animation the art of. Creating animated characters with Blender KNOW-HOW. Pulling Strings

Autodesk Fusion 360: Assemblies. Overview

Years after US Student to Teacher Ratio

Math for Game Programmers: Dual Numbers. Gino van den Bergen

animation animation shape specification as a function of time

Introduction to Computer Graphics Marie-Paule Cani & Estelle Duveau

3D Tranformations. CS 4620 Lecture 6. Cornell CS4620 Fall 2013 Lecture Steve Marschner (with previous instructors James/Bala)

How to rotoscope in Adobe After Effects

Creating Your Own 3D Models

Microsoft Mathematics for Educators:

INTRODUCTION TO RENDERING TECHNIQUES

Introduction to the TI-Nspire CX

Dhiren Bhatia Carnegie Mellon University

Chapter 3.8 & 6 Solutions

Dreamweaver and Fireworks MX Integration Brian Hogan

YOUR GUIDE TO THE iphone MOBILE APP WITH 1st SOURCE

Gerrit Stols

POINT OF SALES SYSTEM (POSS) USER MANUAL

ART 269 3D Animation Fundamental Animation Principles and Procedures in Cinema 4D

Content. Chapter 4 Functions Basic concepts on real functions 62. Credits 11

Classroom Tips and Techniques: The Student Precalculus Package - Commands and Tutors. Content of the Precalculus Subpackage

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Friday 18 th January 2008.

Assignment 2: Animated Transitions Due: Oct 12 Mon, 11:59pm, 2015 (midnight)

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

3 Orthogonal Vectors and Matrices

INSTRUCTIONS FOR MAKING 3D,.DWG CONTOUR LINES

A Short Introduction to Computer Graphics

Vectors 2. The METRIC Project, Imperial College. Imperial College of Science Technology and Medicine, 1996.

Lecture 2 Mathcad Basics

Working with SmartArt

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

A. OPENING POINT CLOUDS. (Notepad++ Text editor) (Cloud Compare Point cloud and mesh editor) (MeshLab Point cloud and mesh editor)

AR-media TUTORIALS OCCLUDERS. (May, 2011)

Lecture 7. Matthew T. Mason. Mechanics of Manipulation. Lecture 7. Representing Rotation. Kinematic representation: goals, overview

A Novel Multitouch Interface for 3D Object Manipulation

Reviewer s Guide. Morpheus Photo Animation Suite. Screenshots. Tutorial. Included in the Reviewer s Guide:

0 Introduction to Data Analysis Using an Excel Spreadsheet

Munis Payroll Entry Instructions

The 3D rendering pipeline (our version for this class)

Copyright 2006 TechSmith Corporation. All Rights Reserved.

CS 378: Computer Game Technology

Creating Online Surveys with Qualtrics Survey Tool

SpaceClaim Introduction Training Session. A SpaceClaim Support Document

Switching from PC SAS to SAS Enterprise Guide Zhengxin (Cindy) Yang, inventiv Health Clinical, Princeton, NJ

Animation. Basic Concepts

LESSON 7: IMPORTING AND VECTORIZING A BITMAP IMAGE

A) What Web Browser do I need? B) Why I cannot view the most updated content? C) What can we find on the school website? Index Page Layout:

Chapter 9- Animation Basics

CSE 167: Lecture 13: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Dealing with Data in Excel 2010

VRSPATIAL: DESIGNING SPATIAL MECHANISMS USING VIRTUAL REALITY

Using Audacity to Podcast: University Classroom Version Dr. Marshall Jones Riley College of Education, Winthrop University

Transcription:

CS 4620 Practicum Programming Assignment 6 Animation out: Friday 14th November 2014 due: : Monday 24th November 2014 1 Introduction In this assignment, we will explore a common topic in animation: key frame animation. You will solve some written problems to get a better understanding of the underlying theory of animations and then write code to animate scenes using key frames. Key frame animation is a technique wherein we define the layout of a scene at certain times (key frames), and we create frames between them by cleverly interpolating between our defined key frames. This rapid rendering of scenes gives us the illusion of animation. The award winning animation short film Hunger (1974) was one of the first applications of key frame animation. http://bit.ly/1edvu6r 2 Written Problem 1 - Interpolating in 2D On another page are pictures of a square object (with its edges marked so you can tell them apart) under three pairs of linear transformations. For each pair: 1. Write the 2x2 transformation matrices for each pose; call them M 0 and M 1. 2. Write the matrix M lin 0.5 by linearly interpolating elementwise halfway between M 0 and M 1. 3. Write each of these two poses in the form M i = R i S i, where R i is a rotation and S i is a symmetric matrix with positive entries on the diagonal. 4. Use this decomposition to interpolate a matrix M pol 0.5 that is halfway between M 0 and M 1. 5. Draw the two intermediate states of the object (you can print out the PDF and draw on it if you want). 1

CS 4620 Animation 2 Figure 1: Written Problem 1

CS 4620 Animation 3 3 Written Problem 2 - Interpolating 3D Rotations Using the egl.math.quat class to convert between quaternions and rotation matrices. 1. Write down the quaternion q 1 that corresponds to the identity rotation and the quaternion q 2 that corresponds to a rotation of 180 degrees around the x axis. 2. Using the formula for spherical linear interpolation, generate the quaternion q 3 that is onefourth of the way from q 1 to q 2. What are the axis and angle of the rotation q 3 represents? 3. Convert q 3 to a 3x3 rotation matrix M(q 3 ). Verify that starting with the identity and applying this matrix 4 times results in the rotation corresponding to q 2. 4. Write down the matrix corresponding to a rotation of 90 degrees around x followed by a rotation of 90 degrees around y, and convert it to a quaternion q 4. Do the same with y and then z, producing q 5. 5. Using the formula for spherical linear interpolation, generate the quaternion q 6 that is onefourth of the way from q 4 to q 5. What are the axis and angle of the rotation q 6 represents? 6. Compute the quaternion q 7 for the rotation that rotates from q 4 to q 6 that is, M(q 6 ) = M(q 7 )M(q 4 ). (It might be easiest to do this by converting everything to matrices, determining the rotation, and then converting back.) Verify that starting with M(q 4 ) and applying M(q 7 ) four times, you end up at M(q 5 ). 7. What are the axis and angle of the rotation q 7 represents? Spend a few minutes holding a book and rotating it around its various axes, until it seems clear that this is the right answer. 4 Problem 1: Keyframe Animation 4.1 Getting Started For the programming assignment, we will implement the primary features of a keyframe animation framework. A new commit has been pushed to the class Github page in the master branch. We recommend switching to your master branch, pulling this commit, and creating a new branch (e.g. A6 solution) and committing your work there. This new commit contains all the framework changes and additions necessary for this project. For this project, we use lwjgl, so you may need to update some settings of your build to have this external library work properly. We have included the correct jar files, but you may need to configure your native library location. To do this in Eclipse, go to Project -> Properties -> Java Build Path -> Select Libraries -> Select the lwjgl Drop Down Menu -> Modify Native Library Location. Modify this setting so that it matches your OS. We have added a framework in the package cs4620.anim that stores keyframes and provides an interface for editing them; you will build on that framework and implement a few main features that enable correct interpolation of animations between keyframes.

CS 4620 Animation 4 4.2 The Interface At first glance, your window may not like the one in the picture. Hover over the bottom of the window to reveal the timeline, complete with highlighted keyframes. We have implemented a keyboard based animation interface: Moving between frames: [ ] : We use the [ and ] keys to move to the left and right keyframes. Adding a frame: To add a keyframe at the current frame, press the n key. The new keyframe will be initialized to the current state of the scene when you clicked the button. Editing a keyframe: To edit a keyframe, navigate to that keyframe, edit the transformations at that state, and press n. Removing a keyframe: Navigate to a keyframe and press the m key to remove a key frame. Playing and pausing the animation: The \ key is used to play or pause the animation. 4.3 Keyframes For this problem, we have extended the scene graph system to store information about multiple keyframes. The AnimTimeline class stores a: TreeSet of AnimKeyFrame. Each key frame contains a frame index number and a 4 x 4 matrix transformation. A SceneObject that it operates on. Every time the update loop is called in the Game loop, updatetransformations is called in AnimationEngine which sends transformation events to the corresponding SceneObjects. We have already implemented the functionality of adding and deleting keyframes from the scene. 4.4 Functionality to Implement You will implement: void updatetransformations() A method that iterates through all the animation timelines, and calls sendevent on the scene with the correct interpolated transformation on the object. For example, if the object on the AnimTimeline is called object, then scene.sendevent(new SceneTransformationEvent(object)); would begin the propagation of the event.

CS 4620 Animation 5 Figure 2: The keyframe animation interface (The timeline appears on hover).

CS 4620 Animation 6 4.5 Interpolation Overview 4.5.1 Naive Approach When computing the interpolation of two transformations, the naive approach is to linearly interpolate each of the 12 free values of the 4 x 4 matrix. You may want to try this out and see why this doesn t work so well. See what happens when you rotate an object 180 degrees! 4.5.2 The more accurate approach Linearly interpolating rotations by value does not work very well. While scales and translations can be linearly interpolated to give good results, the same doesn t apply to rotations. So what can we do? It turns out there is a good way to interpolate between two pure rotations: first express the rotations as quaternions, then use a method called slerp, or spherical linear interpolation, to interpolate between the quaternions. Therefore, the general idea for a more accurate interpolation is: Decompose the surrounding 4x4 matrix transformations around the current key frame into rotations, translations, and scales. Linearly interpolate the translations and scales, and interpolate the rotations by converting to quaternions, slerping, and then converting the result back to a rotation matrix. Recompose the constituents to give a transformation for the current frame. 4.5.3 Decomposing transformations A homogenous transformation M is a 4x4 matrix that can be decomposed firstly as follows [ ] RS T 0 1 Here, T represents the translation, R the rotation and S the scale. So just how do we decompose the upper left 3x3 portion of the matrix into its constituents? Polar decomposition. We have conveniently written the egl.math.matrix3.polar decomp function for you. There is more about quaternions, spherical linear interpolation, and the polar decomposition, in the Animation lecture slides and notes, and in Chapter 17 of the textbook. 4.6 Slerp Spherical linear interpolation occurs between quaternions, so we need to convert our representation of R as a 3 x 3 matrix into a quaternion for each keyframe, and then convert the interpolated quaternion back to a matrix.

CS 4620 Animation 7 4.6.1 Converting between Rotation Matrices and Quaternions We do not ask you to implement the inter-conversion between rotation matrices and Quaternions. You can use the class egl.math.quat to convert from a rotation matrix (using the appropriate Quat constructor) and to a rotation matrix (using the torotationmatrix method). Feel free to look at the code to understand how it works if you re interested. All you need to know about Quaternions is that they are 4-vectors, and that unit-length quaternions, called unit quaternions, can represent 3D rotations and also interpolate them well. If you want to learn more, take CS 5625 next semester! 4.6.2 Linear Interpolation Typically, we visualize quaternions as vectors that represent rotation. Yes, they have 4 numbers, but as most things with higher dimensionality, imagine them to be in a lower dimensional space, say 2D, and say four to yourself. Given two quaternions q 1 and q 2, and a t to interpolate such that 0 < t < 1, a linear interpolation, or lerp, q is given by: q = (1 t)q 1 + tq 2 This will work, if we normalize the interpolated quaternion so that it s a unit quaternion again, but unfortunately the rotation does not happen at constant speed it will go faster towards t=0.5 and slower towards the ends. 4.6.3 Spherical Linear Interpolation Intuitively, spherical linear interpolation, or slerp, gets around this problem by interpolating these quaternions (read: vectors) along the sphere they are both a part of. We ll avoid the details of the derivation of the slerp formula, which are in the lecture slides. Let s just review how slerp is calculated. Given quaternions q 1 and q 2 at the surrounding key frames and a interpolation ratio t such that 0 < t < 1, we first calculate the angle between q 1 and q 2, called Ω, as follows: Then the interpolated quaternion q is given by cos Ω = q 1 q 2 q = sin(1 t)ω sin tω q 1 + sin Ω sin Ω q 2 5 Extra Credit Currently, we only use the 2 immediate surrounding key frames of the current frame to generate it. What if we wanted to smooth things out, by interpolating over a larger window. For extra credit,

CS 4620 Animation 8 Figure 3: A graphical explanation of spherical linear interpolation you can choose to implement the Catmull-Rom Spline Interpolation. 5.1 Catmull-Rom Spline Interpolation The Catmull-Rom spline is a cubic interpolating spline that passes through all its control points. For the interval of the curve specified by control points P i 2, P i 1, P i, P i+1, the spline has the formula 0 2 0 0 P i 2 P (t) = 1 [ 1 t t 2 t 3] 1 0 1 0 P i 1 2 2 5 4 1 P i 1 3 3 1 P i+1 Note that each patch interpolates its middle two control points. That is, P (0) = P i 1, P (1) = P i. Additionally, the tangents at these points are determined by the remaining two control points as follows: v i 1 = 1 2 (P i P i 2 ) v i = 1 2 (P i+1 P i 1 ). 5.2 Finding Control Points To interpolate the state at some frame f using Catmull-Rom spline interpolation, we need to find four frames to define our control points. Call these frames f 0, f 1, f 2, and f 3. The frames are chosen as follows: f 1 is the closest keyframe before frame f. f 0 is the closest keyframe before frame f 1. f 2 is the closest keyframe after frame f. f 3 is the closest keyframe after frame f 2.

CS 4620 Animation 9 That is, we find the four subsequent keyframes in our animation that satisfy f 0 < f 1 < f < f 2 < f 3. The time t for the interpolation is determined by how far along frame f lies between f 1 and f 2. We must also consider a few corner cases. When f is later than the final keyframe of the animation, we can simply copy the state of the final keyframe. Otherwise, if fewer than four control points can be found, you can duplicate keyframes where necessary (e.g., set f 0 = f 1 or f 3 = f 2 if there is only one keyframe before or after f). Done correctly, your spline should successfully pass through every keyframe in the animation. 5.3 Interpolating Rotations While using a spline to interpolate scales and translations is (relatively) straightforward, it s not obvious how to generalize slerp to a smooth interpolation using 4 keyframes. As an additional extra credit problem, read about and implement some form of quaternion spline that has the properties (1) evenly spaced keyframes result in constant-speed rotation, and (2) rotations are C 1 continuous across keyframes. 1 6 Implementation Notes As with previous assignments, places where you will add code are marked with TODO; note that some of these are marked as optional. 7 What to Submit Submit a zip file containing: 1. Your solutions to the written problems, in pdf form. 2. Your solution organized the same way as the code on CMS. Please include your.classpath and.project in the submission as well as all the pre-existing files in the codebase, and not merely your modified files. 3. A readme file containing You and your partner s names and NetIDs. The answer for the written problem. Whether or not you have done the extra credit problem. Any problems with your solution. Anything else you want us to know. 1 Note that this is a fairly tough extra credit problem and you can still get extra credit for spline interpolation of translation and scale, without smoothly interpolating the rotations.