skinned meshes l.
Skip this Video
Download Presentation
Skinned Meshes

Loading in 2 Seconds...

play fullscreen
1 / 33

Skinned Meshes - PowerPoint PPT Presentation

  • Uploaded on

Skinned Meshes. Viacheslav Filonenko Michael McKenna Tang Ke. Skeletal Animation. Animating Skinned Meshes. So far we only worked with Static Meshes. Skinned Meshes have flexible Vertices – position of each vertex can be changed in real time.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Skinned Meshes' - jana

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
skinned meshes

Skinned Meshes

Viacheslav Filonenko

Michael McKenna

Tang Ke

animating skinned meshes
Animating Skinned Meshes

So far we only worked with Static Meshes.

Skinned Meshes have flexible Vertices – position of each vertex can be changed in real time.

Not very useful if that has to be done manually. Animating complicated meshes of living beings manually can be very challenging and the results will be far from convincing (actually may turn out scary).

Skeletal Animation can help a lot.

skeleton structure
Skeleton structure
  • All bones are connected
  • Bones are arranged in a hierarchy.
  • Moving one node will move all the children nodes attached to it but won’t affect other nodes.
  • The coordinates of every bone is given relative to its parent’s local space - rotating the forearm will cause the palm and the finger to be moved and rotated as well.
calculating mesh coordinates
Calculating Mesh coordinates

Every part of mesh is attached to a certain bone. For example vertices that make up foot will be attached to foot bone. When a bone moves, attached vertices move together with it.

FingerWorldMat = FingerMat * PalmMat * ForearmMat * ... * BodyMat

This way is not used anymore as having every vertex to be attached only to one bone will cause gaps (cracks) in the mesh.

vertex blending
Vertex Blending
  • Skin meshes have the same bone hierarchies, but a single part of a skin mesh can be transformed by more than one bone.
  • Linear interpolation formula is used to calculate how a vertex is affected by multiple bones.
  • Requires that each vertex have a blending weight so that the vertex shader can determine how the bones affect the vertex.
  • For example, if we have a vertex that's to be affected by two bones, the following formula will give the world's coordinate of the vertex as affected by the two bones:

Vw = Vm * M1 * w + Vm * M2 * (1-w)

Where Vw is the vertex position in world coordinate. Vm is the vertex position relative to the model's local space. M1 and M2 are the transformation matrices of the two bones. w is the blending weight.

uses for skeletal animation
Uses for Skeletal Animation

Skeletal animation is useful because it allows the animator to control just those characteristics of the model that are independently moveable. A character cannot move the bottom part of their skin independent of the top part.

Typically a visual model for the skin will have lots of elements, that the animator would otherwise have to coordinate. Using a skeleton allows the animator to ignore such issues and focus on the large scale motion.

Animation is therefore made much simpler: an animation can be defined by simple movements of the bones, instead of vertex by vertex.


The weakness of the skeletal approach is that it doesn't by itself provide realistic muscle movement. A character flexing an arm will have both large scale bone movement and local skin motion caused by the change in muscle shape under the skin. It is common in animation for the movie industry and increasingly in computer games to have special muscle controllers attached to the bones that mimic this effect.

Next step – Virtual Anatomy Simulation?

what are x files
What are X Files?
  • X files are file formats using templates for storing meshes, textures, animations, user-defined objects and other 3D Geometry.
  • History:
    • X files were introduced with DirectX 2.0.
    • A binary version was released with DirectX 3.0.
    • Interfaces and Methods that allow reading and writing of X files was introduced with DirectX 6.0.
x file contents header
X File Contents - Header
  • X files need to identify themselves when they are being loaded by a program. Each file starts with a small header which in our version is:

xof 0302txt 0032

    • xof is known as the Magic Number. This signifies that the file is an x file.
    • The 0302txt informs the program that the file is using the DirectX .x file version 3.2 formats and is stored as text instead of binary (bin).
    • The 0032 signifies how many bits are to reserved for floating points 32-bit or 64-bit.
x file contents data
X File Contents - Data
  • All the remaining data in X files are either templates or data objects.
  • The templates look similar to C structure definitions while the data objects are instances of them. You can tell the difference between them as templates start with the word template.
x file contents templates
X File Contents - Templates.
  • Templates are used to define any information that data objects can contain in an X file. These templates can contain any combination of data types from the template data type list:
  • WORD 16-bit value

WORD numWords;

  • DWORD 32-bit value (int/long)

DWORD numDWords;

  • FLOAT Float value

FLOAT numFloats;

  • DOUBLE 64-bit floating-point value

DOUBLE numDoubles;

  • CHAR 8-bit signed value

CHAR imChar;

x file contents templates cont
X File Contents – Templates (Cont).
  • UCHAR 8-bit unsigned value

UCHAR imUChar;

  • BYTE 8-bit unsigned value

BYTE byte;

  • STRING A NULL termination String

STRING sentence;

  • Array An array of one of the above types

array DWORD data[nDWords];

x file contents template types
X File Contents – Template Types
  • Templates are defined by assigning a unique class name preceded by the keyword template. Templates also require a unique Identification Number GUID.
  • There are three types of templates that can be constructed for an X file. The types are determined by their restrictions:
      • Open
      • Closed
      • Restricted
  • These restrictions determine which data types can appear in the hierarchy of a data object defined by the template.
open templates
Open Templates
  • Open Templates have no restrictions on which data types can be implemented in a data object. This means that when data is being added new variables can be added.

template Mesh {


DWORD nVertices;

array Vector vertices[nVertices];

DWORD nFaces;

array MeshFace faces[nFaces];

[ ... ] // An open template


closed templates
Closed Templates
  • Closed Templates reject all data types that have not been defined in the template. It follows the template definition exactly.

template Vector {





} // A closed template

restricted templates
Restricted Templates
  • These templates are a combination of the both Open and Closed. Every variable in a closed template must be defined in a data object. Restricted Templates allow a number of additional templates or data types to be added later on.

template FileSystem {


[ Directory <UUID>, File <UUID> ]

// A restricted template


what use are these templates
What use are these templates?
  • What use are these templates if they are not universally used.
  • These template structures can be used for personal programs and storage however the DirectX SDK provides a number of templates that are used for mesh related data.
  • These are often referred to as standard templates. Each has their own GUID and unique template name.
standard templates
Standard Templates
  • From research I have seen 32 different templates but not all of these are used for Skinned Animated Meshes.

Frame - A frame of reference template that defines a hierarchy.

FrameTransformationMatrix - Holds the transformation Matrix for a parent Frame template.

Mesh - Contains a single mesh’s data.

MeshNormals - Holds the normals used by mesh data.

MeshTextrueCoords - Holds Texture wrapping for mesh faces.

MeshMaterialList - Contains the materials for face mapping values.

Material - Contains material colour values.

VertexDuplicationIndeices - Informs which vertices are duplicates of other vertices.

standard templates22
Standard Templates

SkinWeights - Contains an array of weight values mapped to a mesh’s vertices. Used specifically in Skinned Meshes.

AnimationSet - Contains a collection of animation templates.

Animation - Defines animation data for a single frame.

AnimationKey - Defines a single key frame for the parent animation templates.

XSkinMeshHeader - Used by skinned meshes to define the number of bones contained in a mesh.

TextureFilenameContains - the texture filename to use as a material

data objects
Data Objects
  • Creating Data objects is similar to instantiating a class or a structure. It is important that each variable contained in the template is included in the data object and is defined in the same order as the template.
  • Some templates do not define any data types but may reference other templates which create a hierarchy of data objects. This hierarchy of objects makes the skeletal structure of meshes a lot easier to define.
  • The data objects are declared in the same manner as any class:

StructureName InstanceName{


model used
Model Used
  • Working with the DirectX .X File Format and Animation in DirectX 9.0 By Jason Jurecka
  • CAllocateHierarchy
    • This class is used with the D3DXLoadMeshHierarchyFromX function.
    • It handles the Creation and Deletion of Frames and Mesh Containers.
  • //1. The name of the frame
  • //2. The output new frame
  • HRESULT CAllocateHierarchy::CreateFrame(LPCTSTR Name, LPD3DXFRAME *ppNewFrame)
  • HRESULT CAllocateHierarchy::CreateMeshContainer(
  • LPCSTR Name, //1. Name of the Mesh
  • CONST D3DXMESHDATA *pMeshData, //2. The mesh Data
  • CONST D3DXMATERIAL *pMaterials, //3. that materials of the mesh
  • CONST D3DXEFFECTINSTANCE *pEffectInstances, //4. the effects on the mesh
  • DWORD NumMaterials, //5. the number of meterials in the mesh
  • CONST DWORD *pAdjacency, //6. the adjacency array for the mesh
  • LPD3DXSKININFO pSkinInfo, //7. the skin information for the mesh
  • LPD3DXMESHCONTAINER *ppNewMeshContainer //8. the output mesh container );
  • SkinnedMeshWrapper
  • Wrapper class that handles loading, drawing and animation of the skinned mesh.
  • void SetCurrentAnimation(DWORD dwAnimationFlag);
  • void SetupBoneMatrices(LPFRAME pFrame, LPD3DXMATRIX pParentMatrix, IDirect3DDevice9* device);
  • void UpdateFrameMatrices(LPFRAME pFrame, LPD3DXMATRIX pParentMatrix);
  • D3DXLoadMeshHierarchyFromX(_meshName, // File load
  • D3DXMESH_MANAGED, // Load Options
  • device, // D3D Device
  • &Alloc, // Hierarchy allocation class
  • NULL, // NO Effects
  • &m_pFrameRoot, // Frame hierarchy
  • &m_pAnimController))) // Animation Controller
  • AnimatedCharacter / Dalek extends Character
  • StaticMeshWrapper / SkinnedMeshWrapper extends MeshWrapper
  • ((SkinnedMeshWrapper * )(_meshWrapper))->SetCurrentAnimation(_animationState);
  • _meshWrapper->update(timeDelta);
  • _meshWrapper = AssetLoader::instance()->getSkinnedMeshWrapper("tiny_4anim.x", device);
  • _meshWrapper = AssetLoader::instance()->getStaticMeshWrapper("assets/dalek.x", device);
problems encountered
Problems Encountered
  • Scaling
    • D3DXMATRIX mScale, mRot, T;
    • D3DXMatrixScaling(&mScale, 0.05, 0.05, 0.05);
    • D3DXMatrixRotationX(&mRot, -90.0);
    • T = mScale * mRot;
    • _worldTransform=T*_worldTransform;
    • device->SetTransform(D3DTS_WORLD, &_worldTransform);
problems encountered32
Problems Encountered
  • Cannot Load Daleks and Tinys together
  • .h files confliction

AnimatedCharacter * dalek= new AnimatedCharacter();

Dalek * dalek= new Dalek();

future work
Future Work
  • Play different animations
  • Load new form of meshes