Graphics Reference
In-Depth Information
F From the downloaded source, copy .\Ch04_01VertexSkinning\Character.fbx
to the project directory and include it in the project. The build action needs to
be changed to MeshContentTask .
F Also, copy .\Ch04_01VertexSkinning\Character.png to the project directory.
You can include it in the project if you want. There is no need to apply a build task to
this item as it will already be processed by MeshContentTask .
The compiled character mesh ( .cmo ) and character texture
( .dds ) can be found in the same location if there are issues
with the VS compilation process. Simply add these to the
project instead and select Copy if newer.
How to do it…
We will now update our mesh renderer so that it loads the bone information from the
Common.Mesh class that we have been using for loading the CMO files.
1.
First, add a new public property that provides access to the PerArmature buffer
we added in the previous recipe.
// The per armature constant buffer to use
public Buffer PerArmatureBuffer { get; set; }
2.
Now, within the MeshRenderer.CreateDeviceDependentResources
method, we can load the skinning information for the vertices. Update the
existing vertex buffer initialization code so that we are now including the
SkinningVertex structure.
// Initialize vertex buffers
for (int indx = 0; indx < mesh.VertexBuffers.Count; indx++)
{
...
for (var i = 0; i < vb.Length; i++)
{
// Retrieve skinning information for vertex
Common.Mesh.SkinningVertex skin = new
Common.Mesh.SkinningVertex();
if (mesh.SkinningVertexBuffers.Count > 0)
skin = mesh.SkinningVertexBuffers[indx][i];
// Create vertex
vertices[i] = new Vertex(vb[i].Position,
vb[i].Normal, vb[i].Color, vb[i].UV , skin );
...
}
 
Search WWH ::




Custom Search