1 Lecture 2 Animation References: [1] Gregory Junker, Pro OGRE 3D Programming, Apress, 2006 [2] Ogre Tutorials – Ogre Wiki

Slides:



Advertisements
Similar presentations
Animation Marco Gillies. Computer Animation Making things move A key aspect of computer graphics Non-realtime for films Realtime for virtual worlds and.
Advertisements

Introduction Games have always been a fundamental part of human life. Space storm “ عاصفة الفضاء” is a 3D SCI-FI game that consists of two stages presented.
Game Programming 09 OGRE3D Lighting/shadow in Action
10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Virtual Reality Design Virtual reality systems are designed to produce in the participant the cognitive effects of feeling immersed in the environment.
Verbs and Adverbs: Multidimensional Motion Interpolation Using Radial Basis Functions Presented by Sean Jellish Charles Rose Michael F. Cohen Bobby Bodenheimer.
Animation Following “Advanced Animation and Rendering Techniques” (chapter 15+16) By Agata Przybyszewska.
3D Graphics for Game Programming (J. Han) Chapter XI Character Animation.
Trajectory Generation
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
1 2. Controlling Robot Car in Ogre References: 1. LEGO.com MINDSTORMS NXT Home, 2. OGRE 3D, 3. MSDN,
1 5. Video Object Tracking and Processing To achieve augmented reality, computer generated graphics should be shown together with the live video In addition,
Computer Graphics 12: Spline Representations
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system,
Animation. Outline  Key frame animation  Hierarchical animation  Inverse kinematics.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
Computer-Based Animation. ● To animate something – to bring it to life ● Animation covers all changes that have visual effects – Positon (motion dynamic)
Animation Theory.
11 Lecture 4 Introducing Physics to Ogre References: [1] Gregory Junker, Pro OGRE 3D Programming, Apress, 2006 [2] Ogre Tutorials – Ogre Wiki
AGD: 5. Game Arch.1 Objective o to discuss some of the main game architecture elements, rendering, and the game loop Animation and Games Development.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Object Orientated Data Topic 5: Multimedia Technology.
1 References: 1. J.M. Hart, Windows System Programming, 4th Ed., Addison-Wesley, 2010, Ch.12 2.Microsoft Kinect SDK for Developers,
Integration Of CG & Live-Action For Cinematic Visual Effects by Amarnath Director, Octopus Media School.
05/09/02(c) 2002 University of Wisconsin Last Time Global illumination algorithms Grades so far.
Chapter 5.2 Character Animation. CS Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Lab 8 – C# Programming Adding two numbers CSCI 6303 – Principles of I.T. Dr. Abraham Fall 2012.
Business and Computing Deanery Multimedia Week 6 Animation.
Canyon Adventure Technology David Maung, Tristan Reichardt, Dan Bibyk, Juan Roman Department of Computer Science and Engineering The Ohio State University.
Objective Understand concepts used to create digital animation. Course Weight : 5%
Computer Graphics 2 In the name of God. Outline Introduction Animation The most important senior groups Animation techniques Summary Walking, running,…examples.
CHAPTER TEN AUTHORING.
Object Orientated Data Topic 5: Multimedia Technology.
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.
Yingcai Xiao Game Development Interactive Animation.
1 Mpeg-4 Overview Gerhard Roth. 2 Overview Much more general than all previous mpegs –standard finished in the last two years standardized ways to support:
110/27/ :47 Graphics II Animation Introduction and Motion Control Session 6.
11 Lecture 3 Particle Effects References: [1] Gregory Junker, Pro OGRE 3D Programming, Apress, 2006 [2] Ogre Tutorials – Ogre Wiki
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Reference: The Game Loop Animation / Game loop 1. Update variables 2. [Get input from the user] (GameLoop only) 3. Draw (using variables)
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
Introduction to Interactive Media Interactive Media Tools: Authoring Applications.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Subject Name: Computer Graphics Subject Code: Textbook: “Computer Graphics”, C Version By Hearn and Baker Credits: 6 1.
Welcome Mill Lesson 15 – Part-2 Computer Aided Manufacturing Using Mastercam.
CSCE 441 Computer Graphics: Keyframe Animation/Smooth Curves Jinxiang Chai.
ถ้าจะพูดถึง 3ds MAX  ทุกคนก็คงนึกถึงโปรแกรมทำ 3D อนิเมชั่น ซึ่งหลายๆคนคงรู้จักกัน  โดยปัจจุบันได้มีถึงเวอร์ชั่น 9 และล่าสุดคือ 2008 จึงจะมาบอกถึงความแตกต่างของเวอร์
Syed ardi syed yahya kamal 2011 chapter five.  Creating in-between positions is still a hallmark of animation.  Using techniques called interpolation.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
Lecture 5: 11/5/1435 Computer Animation Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
Introduction to Animation In animation, a series of images are rapidly changed to create an illusion of movement.
Unbuffered Input Games generally use unbuffered Input Ogre provides FrameListeners – Ogre's main infinite loop → startRendering – Also called the render.
Animation Animation is about bringing things to life Technically: –Generate a sequence of images that, when played one after the other, make things move.
Processing Images and Video for An Impressionist Effect Automatic production of “painterly” animations from video clips. Extending existing algorithms.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
Reference: What is it? A multimedia python library – Window Management – Graphics geometric shapes bitmaps (sprites) – Input Mouse Keyboard.
Unity 3D Rolfe Bozier 24-Apr-2017
Games Development Practices 3D Modelling
- Introduction - Graphics Pipeline
Introducing Blender.
Ogre Overview Lecture 3.
Ogre Overview.
Introducing Blender.
Introducing Blender.
Chapter I Introduction
Computer Graphics Lecture 15.
SUBJECT : COMPUTER GRAPHICS
Presentation transcript:

1 Lecture 2 Animation References: [1] Gregory Junker, Pro OGRE 3D Programming, Apress, 2006 [2] Ogre Tutorials – Ogre Wiki [3]Microsoft MSDN, C++ reference EIE360 Integrated Project Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

2 Architecture of the Interactive Virtual Aquarium Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun USB port 3D Graphics System 3D Graphics Your program Your program Network Computer A Computer B Kinect Sensor Device

3 I. A Brief Introduction to OGRE Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun EIE360 Integrated Project

4 The Software Development Platform – OGRE Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Combining Video and Graphics by Dr Daniel Lun The Interactive Virtual Aquarium is developed in a 3D environment The 3D graphics engine, OGRE, will be used to simplify the software development tasks OGRE stands for Object-Oriented Graphics Rendering Engine OO interface designed to minimize the effort required to render 3D scenes Independent of 3D implementation e.g. Direct3D, OpenGL, Glide etc. Contain example frameworks Common requirements for 3D rendering are done for the user automatically

5 Frequently Used Core Objects in OGRE The game world Entities attached to Scene Nodes A Plane filled with grass Texture Text overlaid on the graphics Light projected in this direction Everything are controlled by the SceneManager

6 Basic Execution Flow of OGRE Initialization Create all core objects Determine the motion of the objects in each update Update screen Finish update screen : Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Combining Video and Graphics by Dr Daniel Lun

7 II. Animation in OGRE Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun EIE360 Integrated Project

8 Animation in OGRE Animation, in general, is no different in the computer age than it was when some artists first flipped quickly through pages containing a series of slightly different images In Ogre, the scene is drawn from scratch every frame, whether or not it contains animation Ogre does not keep track of game characters’ velocity and acceleration vectors The animation features in Ogre are there only to help position and orient your characters as a function of some arbitrary variable (usually time, although any variable can act as a controller) Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Animation in OGRE (cont) An animation in Ogre is a collection of possibly (usually) related tracks An animation track is a set of data values stored as a function of time The pair of time point and track value composes a keyframe The term keyframe comes from the days of hand-drawn animation when master artists would provide the junior artists with a set of “key” frames in an animation Ogre works just like the junior artists to interpolate from your (master artist) keyframes designed using different 3D modeling tools (e.g. 3ds Max) to render the needed animation 9 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

A Simple Example Let’s use a simple example, “a swimming fish”, to demonstrate the basic idea of creating animation in Ogre Fish01 is a skeletally animated mesh object It has a skeletal animation – Swim They define the keyframes in these animations May preview them using OgreMax Win Viewer The animation is “in-place”, no translation motion To animate a swimming fish, need to move the scene node to make it look like moving 10 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

A Simple Example Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun An Entity based on fish.mesh is attached to a sceneNode The aquarium

Step-by-step … Initialization EIE360ProjectApp( … ) createScene( … ) 0. Define member variables 1. Create entity and scene node 2. Generate swimming route 3a. Define animation state Update screen Finish update screen Screen Update frameRenderingQueued( … ) 3b.Update animation state 4.Translate the scene nodes and determine orientation Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Detected by the frameListener of Ogre

Step-by-step … Initialization 0.Define member variables 1.Create entity and scene node 2. Generate swimming route 3a. Define animation state Update screen Finish update screen Screen Update 3b.Update the animation state 4.Translate the scene nodes and determine orientation Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

First Step: Create Entity and SceneNode Assume the following two variables are defined: Then 14 Entity * mCharacterEntity; SceneNode * mCharacterNode Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun mCharacterEntity = mSceneMgr-> createEntity("Character", “Fish01.mesh"); mCharacterEntity->setCastShadows(true); //Enable the fish to cast shadow mCharacterNode = mSceneMgr->getRootSceneNode()-> createChildSceneNode("CharacterNode"); mCharacterNode->attachObject(mCharacterEntity); Ogre::Real sizeFactor = 100; mCharacterNode->setScale(Ogre::Vector3(sizeFactor));

Step-by-step … Initialization 0.Define member variables 1.Create entity and scene node 2. Generate swimming route 3a. Define animation state Update screen Finish update screen Screen Update 3b.Update the animation state 4.Translate the scene nodes and determine orientation Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Second Step: Generate swimming route 16 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Waypoints Ogre will generate the curve that fits all waypoints

Second Step: Generate swimming route To better control the movement of the fishes, we often pre-generate their swimming paths Just need to follow the procedure below: Define the starting position (the 3D coordinates) Randomly generate a few waypoints Connect all waypoints using a spline function (curve fitting) Just give Ogre your waypoints. Ogre will find a smooth curve that goes thru them 17 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Second Step: Generate swimming route Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Ogre::SimpleSpline mFishSplines; //SimpleSpline is a simple spline class mFishSplines.setAutoCalculate(false); //Enable the fish to cast shadow Ogre::Vector3 lastPos = Ogre::Vector3(0,50,0); mFishSplines.addPoint(lastPos); //Define the initial position int room_width = 200; int room_depth = 100; //Define the size of a plane x=±200, z=±100 //that the fish will swim Splines are bendy lines. You define a series of points, and the spline forms a smoother line between the points to eliminate the sharp angles.

Second Step: Generate swimming route 19 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun //Generate the waypoints for (int waypoint = 1; waypoint < 5; waypoint++) { Ogre::Vector3 pos = Ogre::Vector3( Ogre::Math::SymmetricRandom() * room_width, lastPos.y, Ogre::Math::SymmetricRandom() * room_depth); mFishSplines.addPoint(pos); lastPos = pos; } //Close the spline //The last pos is just the first pos mFishSplines.addPoint(mFishSplines.getPoint(0)); //Ask Ogre to curve fit all waypoints mFishSplines.recalcTangents(); 19 Keep y-axis unchanged. So the fish will not swim up-and-down frequently Generate a random no. between (-1, 1)

Step-by-step … Initialization 0.Define member variables 1.Create entity and scene node 2. Generate swimming route 3a. Define animation state Update screen Finish update screen Screen Update 3b.Update the animation state 4.Translate the scene nodes and determine orientation Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Third Step: Get and Set Animation State As part of the export process, different parts of the timeline in an object’s animation can be given names – idle, swim, … One can use these names to “address” different animations on an entity For each animation, we can obtain or change its current state by calling function getAnimationState() It returns an animation state that provides access to different properties of an animation: length – obtain the duration of the animation time position – get/set the position of an object at a particular time loop – define if the animation should be played once or loop enable – define if the animation can be played weight – define the weighting when blending with other animations 21 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Third Step (a): Get and Set Animation State (cont) Assume the following variable is defined: Then 22 AnimationState * mAnimationState; Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun mAnimationState = mCharacterEntity-> getAnimationState(“swim"); // Get the animation state of “swim” mAnimationState->setLoop(true); // Play “swim” in a loop mAnimationState->setEnabled(true); // The animation can be played // “swim” can then be played forever until // you disable it or set loop to false

Third Step (b): Get and Set Animation State (cont) 23 Keyframes/Time positions defined by the designer t mAnimationState->addTime(evt.timeSinceLastFrame); Show time of Frame n Show time of Frame n+1 Show time of Frame n+2 t1t2 addtime (t1) addtime (t2) Since there may not be a keyframe at that time, Ogre will interpolate one based on the available keyframes In Ogre, the scene will be updated in an irregular period To synchronize the animation with that update rate, we may use the elapse time between frames to update the time position parameter of the animation state

Step-by-step … Initialization 0.Define member variables 1.Create entity and scene node 2. Generate swimming route 3a. Define animation state Update screen Finish update screen Screen Update 3b.Update the animation state 4.Translate the scene nodes and determine orientation Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun 24

Fourth Step (a): Translate the scene node The animation of the fish is in-place. Need to move its scene node to animate the swimming motion The path for the scene node to move has been pre- defined in step 2, it is a closed path 25 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun

Fourth Step (a): Translate the scene node 26 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun It is convenient to synchronize the swimming speed of the fish with the screen update rate To make sure the fish will swim in a constant speed irrespective to the speed of the computer, we want Fast computer  fast update  smaller movement each update Slow computer  slow update  larger movement each update To achieve this, use again evt.timeSinceLastFrame Ogre::Real mAnimTime; //Has been initialized to 0 mAnimTime += evt.timeSinceLastFrame; //Faster computer  smaller timeSinceLastFrame int fish_path_length = 30; while (mAnimTime > fish_path_length) mAnimTime -= fish_path_length; //Limit to be within 0 to 30 To indicate how far has the fish gone from the starting point of the path

Fourth Step (a): Translate the scene node 27 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Ogre::Real movePos = mAnimTime / fish_path_length; Ogre::Vector3 newPos = mFishSplines.interpolate(movePos); mCharacterNode->setPosition(newPos); Need a value between 0 and 1 representing the parametric distance along the whole length of the spline. Hence inputting a 0 means you want to get starting position of the spline, and a 1 mean the ending position. Return an interpolated 3D coordinates on that spline Move the scene node to the new position

Fourth Step (b): Determine the orientation The orientation of the fish needs to be adjusted from time to time to let it always face at the direction it is swimming 28 Ogre::Vector3 direction = mFishLastPosition - newPos; //Compute the direction that the fish is swimming //Difference of two 3D coordinates becomes the //direction between them direction.normalise(); //Compute the norm from the vector direction //At the same time, direction is converted to a //unit vector Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Original position of the fish New position after update

Fourth Step (b): Determine the orientation A “divide by zero” error will result if we rotate the fish by 180 o. Should detect this situation and use yaw() instead 29 Department of ELECTRONIC AND INFORMATION ENGINEERING 2. Animation by Dr Daniel Lun Ogre::Vector3 src = mCharacterNode-> getOrientation() * Ogre::Vector3::UNIT_X; //To find the fish orientation if ((1.0f + src.dotProduct(direction) < f) mCharacterNode->yaw(Degree(180)); //If the dot product of the current fish // orientation and the desired direction is -1, // yaw the fish 180 o else mCharacterNode-> rotate(src.getRotationTo(direction) * Ogre::Vector3(1,0,1)); The original orientation of the model fish01 Y-axis is masked since there should not be changes in y-axis