Character Animation with Direct3D- P18: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. | 326 Character Animation with Direct3D hit position with a radius of the decal size . The problem with this approach however is quite obvious not only will it be quite slow especially for characters with tens of thousands of triangles but it also has the potential to include lots of unnecessary triangles as shown in Figure . FIGURE The problem with brute force selection of the decal mesh. As you can see in Figure the ray hits the front of the character s leg. Since the decal size is larger than the leg itself it will end up selecting polygons on the backside of the leg which is something you d like to avoid. This will happen as long as the decal size is larger than the thickness of the body part being tested and note that the polygons don t even have to be adjacent when selected with this method . So when a decal is added to the front of the character s torso there might be some polygons added on the back as well. So even though the brute force method would work let s try a better one. It is quite easy to calculate the adjacency information of a mesh information of which triangles share which edges . The adjacency information of a mesh can be calculated using the following D3DX library function defined in the ID3DXBaseMesh class lease purchase PDF Split-Merge on to remove this watermark. Chapter 14 Character Decals 327 HRESULT GenerateAdjacency FLOAT Epsilon DWORD pAdjacency This function returns a list of indices containing the information of which faces are adjacent to each other. Any vertices closer to each other than the Epsilon variable will be treated as coincident. The resulting adjacency data will be written to the pAdjacency pointer. An example mesh with its calculated adjacency information is shown in Figure . FIGURE Four example triangles. In Figure there s an example mesh consisting of four triangles numbered 1 to 4 . The adjacency information consists of double words dword . If a certain edge of a triangle .