25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals 3D Modelling: Animation Fundamentals •CITS3003 Graphics & Animation Thanks to both Richard McKenna and Marco Gillies for permission to use their slides as a base. The second half of this lecture note was extracted from the MIT EECS 6.837 Computer Graphics course. Thanks to MIT for providing their teaching materials online. •1 Topic 21 – 3D Modeling: Animation Fundamentals Jack Skellington, from The Nightmare Before Christmas 1 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Static objects are boring • Look at your project part 1 scene objects – they just sit there – we can move them to other places and alter the rotation and colour, but they’re still pretty boring • What about more complicated & interesting shapes? – living things – vehicles – etc. • These things are all made up of separate moving parts that are still part of the whole object – where I go, my arms go with me Topic 21 – 3D Modeling: Animation Fundamentals Example: Game Player Animation States • Think about a First Person Game • What game states does the player have? – – – – – – – – running forward running backwards running sideways jumping falling landing dying (in all sorts of ways) etc. 2 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Typical Role of Artist • Create a mesh for a game shape/character/vehicle – geometry – texturing – materials • Create animation sequences for different game states for that entity • NOTE: exporting data from modeling/animation tools so that it can be imported can be tricky Topic 21 – 3D Modeling: Animation Fundamentals Keyframe (Cell) Animation In traditional hand-drawn animation: the senior key artist would draw the keyframes, and the junior artist would fill the in-between frames. We can use a similar approach for computer animation For a 30-fps animation, < 30 frames are defined per second: 1. The key data are assigned to the keyframes 2. In-between frames are interpolated 11-6 3 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Again, the positions between frames? • The positions between frames must be interpolated. Linear interpolation is commonly used. • Assume a time from 0.0 to 1.0 – from one keyframe to the next 𝑝𝑖 = 𝑝1 + 𝑡𝑖 ∗ (𝑝2 – 𝑝1) where 𝑝1 and 𝑝2 are positions in keyframes 1 and 2; 𝑖 is the index of the frame (between the two keyframes) to be interpolated. Topic 21 – 3D Modeling: Animation Fundamentals A Simple Animation Example: A Tank • Gun Turret should be able to rotate • Gun Barrel should be able to move up and down • The wheels should be able to spin 4 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Topic 21 – 3D Modeling: Animation Fundamentals 5 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Topic 21 – 3D Modeling: Animation Fundamentals What would be the Tank Hierarchy? • Tank hull – central parent section – Wheels – children of the hull and siblings to each other – Gun Turret – child of the hull • Gun Barrel – child of the Gun Turret • Sub-meshes – wheels vertices would be a sub-mesh of the hull – where the hull goes, the wheels go – when the hull rotates, the wheels rotate 6 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Combined Matrices for Transformations • Our tank will have a location – we translate according to that location, by building a matrix • Remember, the sub-meshes may move and rotate additionally, relative to the tank, but independently of the hull • Combined matrices combine the two – move, scale, and rotate the mesh (along with entire object) – move, scale, and rotate the sub-mesh relative to the parent mesh Topic 21 – 3D Modeling: Animation Fundamentals Animation – rigging • Animation is usually specified using some form of low-dimensional controls as opposed to remodeling the actual geometry for each frame. – E.g., A rigid motion such as rotating the rectangular box on a previous slide is specified a transformation matrix, which is then applied to all the points of the object. – E.g., The joint angles (known as bone transformations) in a hierarchical character determine the pose. • Building the controls is called “rigging”. 7 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Articulated Character Models • Forward kinematics describes the position of the body parts as a function of joint angles. – Body parts are usually called “bones” – Angles are low-dimensional control. • Inverse kinematics specifies constraint locations for bones and solves for joint angles Courtesy Robert C. Duvall, Duke University. License CC BY-NC-SA. Topic 21 – 3D Modeling: Animation Fundamentals Skinning Characters • Embed a skeleton into a detailed character mesh • Animate “bones” –Change the joint angles over time –Keyframing, procedural, etc. • Bind skin vertices to bones –Animate skeleton, skin will move with it. Courtesy of Blender Foundation. License CC-BY. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use. Courtesy Robert C. Duvall, Duke University. License CC BY-NC-SA. 8 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Skinning/Enveloping • Need to infer how skin deforms from bone transformations. • Most popular technique: Skeletal Subspace Deformation (SSD), or simply Skinning Other aliases o vertex blending o matrix palette skinning o linear blend skinning This image is in the public domain. Source: Wikimedia Commons. Topic 21 – 3D Modeling: Animation Fundamentals Skinning • Each bone has a deformation of the space around it (rotation, translation) What if we attach each vertex of the skin to a single bone? oSkin will be rigid, except at joints where it will stretch badly Let’s attach a vertex to many bones at once! oIn the middle of a limb, the skin points follow the bone rotation (near-rigidly) oAt a joint, skin is deformed according to a “weighted combination” of the bones 9 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Skinning Colored triangles are attached to 1 bone Black triangles are attached to more than 1 © ACM. All rights reserved. This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Note how they are near joints James & Twigg, Skinning Mesh Animations, 2005, used with permission from ACM, Inc. Topic 21 – 3D Modeling: Animation Fundamentals Vertex Weights or Bone Weights • We’ll assign a weight wij for each vertex pi for each bone Bj. o o o “How much should vertex pi move with bone j ?” wij = 1 means pi is rigidly attached to bone j. We can interpret wij to be the weight being exerted by bone Bj on vertex pi – thus the term “bone weight”. • Weight properties o o Usually want weights to be non-negative Also, want the sum over all bones to be 1 for each vertex • We’ll limit the number of bones N that can influence a single vertex o o o o N = 4 bones/vertex is a usual choice Why? You most often don’t need many. Also, storage space is an issue. In practice, we’ll store N pairs (bone index j, weight wij) per vertex. 10 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Computing Vertex Positions • Basic Idea 1: Transform each vertex 𝒑𝑖 with each bone as if it was tied to it rigidly. • Basic Idea 2: Then blend the results using the weights. 𝒑′𝑖𝑗 = 𝑇𝑗 𝒑𝑖 𝒑′𝑖 = 𝑤𝑖𝑗 𝒑′𝑖𝑗 𝑗 where 𝒑′𝑖𝑗 is the vertex i transformed using bone j; 𝑇𝑗 is the current transformation of bone j; 𝒑′𝑖 is the new skinned position of vertex i. Topic 21 – 3D Modeling: Animation Fundamentals Blender • Blender is a software application that provides a good interface for 3D modelling, skinning, and rigging. Key poses of the animated character can be defined in a number of keyframes. The animated character and its movements can be exported to several formats, including DirectX. A gingerbread man and the underlying skeletal model. This is the rest pose. 11 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals The DirectX File • The DirectX file generated by Blender contains the hierarchical skeletal model and animation of the character. The data structure loaded into OpenGL looks like this: Frame Root { ... Frame Armature { FrameTransformMatrix { ... } Frame Armature_torso { FrameTransformMatrix { ... } Frame Armature_head { FrameTransformMatrix { ... } } } } Definition of the hierarchical skeletal model Transformation matrices of the different bones of the skeletal model for the rest pose. Note that the definition for “head” is at one indentation level deeper than “torso”. “torso” is the parent bone of “head”. Topic 21 – 3D Modeling: Animation Fundamentals The DirectX File (cont.) Frame Cube { FrameTransformMatrix { ... } Mesh { Total number of 3D points in the mesh 19968; 63.776588;93.765533;70.995056;, ... 4992; Total number of polygons in the mesh ... MeshNormals { 19968; ... } x, y, and z components of the 1st point Total number of vertex normals vertex normals } MeshTextureCoords { ... Texture } coordinates SkinWeights { "Armature_shoulder_L"; 3314; 256, ... Same as “bone weights” When the left shoulder bone moves, 3314 vertices would be affected. The indices of these vertices are listed underneath. The first vertex index is 256. 12 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals The DirectX File (cont.) } } The last part of the DirectX file describes the animation. In this examples, there are 81 frames. The first frame index is 0. The last frame inde is 80. The animation is given by the rotation, scaling, translation, etc. of each bone. } AnimationSet Global { Animation { {Armature_torso} AnimationKey { // Rotation 0; 80; 0;4;-0.707107, 0.707107, 0.000000, 0.000000;;, 1; ... ... quaternion 81; ... } AnimationKey { // Scale 0; The first frame index 80; 0; ... The last frame index ... } } } Topic 21 – 3D Modeling: Animation Fundamentals The DirectX File (cont.) Exercise: Inspect the .x file of your gingerbreadman created by blender for part 2 of the project. The .x file is a text file. Its content can be viewed using any text editor. 13 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals Super Cool: Automatic Rigging • When you just have some reference skeleton animation (perhaps from motion capture) and a skin mesh, figure out the bone transformations and vertex weights! • Ilya Baran, Jovan Popovic: “Automatic Rigging and Animation of 3D Characters”, SIGGRAPH 2007 © ACM. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. Topic 21 – 3D Modeling: Animation Fundamentals Super Cool: Automatic Rigging From “Automatic Rigging and Animation of 3D Characters” by Baran and Popovic, used with permission from ACM, Inc. © ACM. All rights reserved. This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 14 25/04/2016 Topic 21 – 3D Modeling: Animation Fundamentals The Other Direction © ACM. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. From Skinning Mesh Animations. 15