TAILIEUCHUNG - Character Animation with Direct3D- P15

Character Animation with Direct3D- P15:This book is primarily aimed at teaching indie and hobby game developers how to create character animation with Direct3D. Also, the seasoned professional game developer may find some interesting things in this book. You will need a solid understanding of the C++ programming language as well as general object-oriented programming skills. | 266 Character Animation with Direct3D array of D3DVERTEXELEMENT9 objects. With these elements you control every aspect of how the bitstream from a mesh is interpreted. As a quick recap the following function shows you how to get the vertex declaration from a mesh and access the different elements in it very useful for debugging purposes . void PrintMeshDeclaration ID3DXMesh pMesh Get vertex declaration D3DVERTEXELEMENT9 decl MAX_FVF_DECL_SIZE pMesh- GetDeclaration decl Loop through valid elements for int i 0 i MAX_FVF_DECL_SIZE i if decl i .Type D3DDECLTYPE_UNUSED g_debug Offset int decl i .Offset Type int decl i .Type Usage int decl i .Usage n else break This function prints the offset type and usage of all active elements in a vertex declaration. Sometimes when you are building your own vertex formats it can be very useful to know at what offset a certain element is stored and what type it is especially when you deal with different meshes from different sources and or formats. Remember that you re already dealing with meshes containing different elements. In the bone hierarchy of the SkinnedMesh class for example you have static meshes containing position normal and texture coordinates. You also have the skinned meshes there as well and on top of the position normal and texture coordinates they also contain the bone index and bone weight components. So we need to be able to add components to any arbitrary vertex declaration. For this purpose I ve implemented the AddTangentBinormal function. This function is not much different from the PrintMeshDeclaration function. It takes a mesh as input extracts the current mesh declaration and adds the tangent and the binormal elements to it. Then it clones the original mesh by using the newly created vertex declaration. Lastly it computes the tangents and the binormals for all the vertices in lease purchase PDF Split-Merge on to remove this watermark. Chapter 12 Wrinkle Maps 267 the mesh using the .