TAILIEUCHUNG - Character Animation with Direct3D- P11
Character Animation with Direct3D- P11: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. | 186 Character Animation with Direct3D D3DVERTEXELEMENT9 morphVertexDecl Stream 0 Human Skinned Mesh 0 0 D3DDECLTYPE_FLOAT3 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_POSITION 0 0 12 D3DDECLTYPE_FLOAT1 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_BLENDWEIGHT 0 0 16 D3DDECLTYPE_UBYTE4 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_BLENDINDICES 0 0 20 D3DDECLTYPE_FLOAT3 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_NORMAL 0 0 32 D3DDECLTYPE_FLOAT2 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_TEXCOORD 0 Stream 1 Werewolf Morph Target 1 0 D3DDECLTYPE_FLOAT3 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_POSITION 1 1 12 D3DDECLTYPE_FLOAT3 D3DDECLMETHOD_DEFAULT D3DDECLUSAGE_NORMAL 1 D3DDECL_END The next trick to perform is to set up the different streams. In this example the two meshes are stored in the same .x file. The meshes are loaded using the same code used to load the skinned meshes back in Chapter 3. Hopefully you remember how the bone hierarchy was created from the .x file and how it was traversed to render the skinned mesh. Now there are two meshes in the bone hierarchy the skinned human mesh and the static werewolf mesh. Here s the code that finds the static werewolf mesh in the hierarchy and sets it as stream source 1 Set werewolf stream Find bone named werewolf located in the m_pRootBone hierarchy D3DXFRAME wolfBone D3DXFrameFind m_pRootBone werewolf if wolfBone NULL If bone contains a mesh container then this is the werewolf mesh if wolfBone- pMeshContainer NULL Get werewolf vertex buffer ID3DXMesh wolfmesh wolfMesh wolfBone- pMeshContainer- lease purchase PDF Split-Merge on to remove this watermark. Chapter 8 Morphing Animation 187 DWORD vSize D3DXGetFVFVertexSize wolfmesh- GetFVF IDirect3DVertexBuffer9 wolfMeshBuffer NULL wolfmesh- GetVertexBuffer wolfMeshBuffer Set vertex buffer as stream source 1 pDevice- SetStreamSource 1 wolfMeshBuffer 0 vSize Now all you need to do is search though the hierarchy and find the mesh that has skinning information this will be the skinned human mesh . .
đang nạp các trang xem trước