TAILIEUCHUNG - Character Animation with Direct3D- P5

Character Animation with Direct3D- P5: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. | 66 Character Animation with Direct3D set up bone transforms int numBones boneMesh- pSkinInfo- GetNumBones for int i 0 i numBones i D3DXMatrixMultiply boneMesh- currentBoneMatrices i boneMesh- boneOffsetMatrices i boneMesh- boneMatrixPtrs i Set HW Matrix Palette D3DXMATRIX view proj pEffect- SetMatrixArray MatrixPalette boneMesh- currentBoneMatrices boneMesh- pSkinInfo- GetNumBones Render the mesh for int i 0 i boneMesh- NumAttributeGroups i int mtrl boneMesh- attributeTable i .AttribId pEffect- SetTexture texDiffuse boneMesh- textures mtrl D3DXHANDLE hTech pEffect- GetTechniqueByName Skinning pEffect- SetTechnique hTech pEffect- Begin NULL NULL pEffect- BeginPass 0 boneMesh- DrawSubset mtrl pEffect- EndPass pEffect- End if bone- pFrameSibling NULL Render Bone bone- pFrameSibling if bone- pFrameFirstChild NULL Render Bone bone- pFrameFirstChild lease purchase PDF Split-Merge on to remove this watermark. Chapter 3 Skinned Meshes 67 Not much has changed in this function compared to the software skinning example. Most notable of course is the use of the shader and uploading the Matrix Palette to it. Otherwise you loop through the different attribute groups of the mesh and render it using the shader. Rendering Static Meshes in Bone Hierarchies Sometimes you might not want the character skinned. Making animated machinery is a prime example. Machinery rarely has soft parts thus you don t really need to skin a mesh to make mechanical creations in your games. Nonetheless you might want to have a bone hierarchy controlling the different parts of the machine. Take the example of a robot arm as shown in Figure . sase purchase PDF Split-Merge on to remove this watermark. 68 Character Animation with Direct3D FIGURE As you can see each part of the robot arm is rigid and therefore does not require skinning. Another case where you need rigid solid objects is when they are combined with skinned meshes. In the previous examples .