Jump to content
  • Advertisement
Sign in to follow this  
beetle2001

Skeletal Animation.

This topic is 4100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I programm in C# and use in my game the loader of Managed DirectX Kickstart by Tom Miller from the Chapter 13 which is devoted to Skeletal Animation. It works and it`s ok. Though I`ve got the following question: the application works with the *.x file which contains the only model. So for example if I want to load form *.x file some soldier ( first model) with the gun (second model) - there`s an error ((( Can you give me some recommendation to correct it. As I want to load multiple models from the single x file. Thank`s for your attention. Thank you in advance!!!

Share this post


Link to post
Share on other sites
Advertisement
The problem is that I can not explain clearly the nature of mistake.
It says just: "Error in Application"
The error raises in this function:

private void DrawMeshContainer(MeshContainerDerived mesh, FrameDerived frame)
{
// Is there skin information?
if (mesh.SkinInformation != null)
{

int attribIdPrev = -1;

// Draw
for (int iattrib = 0; iattrib < mesh.NumberAttributes; iattrib++)
{
int numBlend = 0;
BoneCombination[] bones = mesh.GetBones();
for (int i = 0; i < mesh.NumberInfluences; i++)
{
if (bones[iattrib].BoneId != -1)
{
numBlend = i;
}
}

if (device.DeviceCaps.MaxVertexBlendMatrices >= numBlend + 1)
{
// first calculate the world matrices for the current set of
// blend weights and get the accurate count of the number of
// blends
Matrix[] offsetMatrices = mesh.GetOffsetMatrices();
FrameDerived[] frameMatrices = mesh.GetFrames();
for (int i = 0; i < mesh.NumberInfluences; i++)
{
int matrixIndex = bones[iattrib].BoneId;
if (matrixIndex != -1)
{
Matrix tempMatrix = offsetMatrices[matrixIndex] *
frameMatrices[matrixIndex].
CombinedTransformationMatrix;

device.Transform.SetWorldMatrixByIndex(i, tempMatrix);

}
}

device.RenderState.VertexBlend = (VertexBlend)numBlend;
// lookup the material used for this subset of faces
//2005/07/11. TheZBuffer.com. Updated fro June 2005 SDK
//if ((attribIdPrev != bones[iattrib].AttribId) ||
if ((attribIdPrev != bones[iattrib].AttributeId) ||
(attribIdPrev == -1))
{
device.Material = mesh.GetMaterials()[
//2005/07/11. TheZBuffer.com. Updated fro June 2005 SDK
//bones[iattrib].AttribId].Material3D;
bones[iattrib].AttributeId].Material3D;

device.SetTexture(0, mesh.GetTextures()[
//2005/07/11. TheZBuffer.com. Updated fro June 2005 SDK
//bones[iattrib].AttribId]);
bones[iattrib].AttributeId]);

//2005/07/11. TheZBuffer.com. Updated fro June 2005 SDK
//attribIdPrev = bones[iattrib].AttribId;
attribIdPrev = bones[iattrib].AttributeId;
}

mesh.MeshData.Mesh.DrawSubset(iattrib);
}
}
}
else // standard mesh, just draw it after setting material properties
{
device.Transform.World = frame.CombinedTransformationMatrix;

ExtendedMaterial[] mtrl = mesh.GetMaterials();
for (int iMaterial = 0; iMaterial < mtrl.Length; iMaterial++)
{
device.Material = mtrl[iMaterial].Material3D;
device.SetTexture(0, mesh.GetTextures()[iMaterial]);

try
{
mesh.MeshData.Mesh.DrawSubset(iMaterial);
}
catch ( DirectXException ex)
{ MessageBox.Show(ex.Message); }
}
}
}
Error happens right at the place I put "TRY" After this the scene is rendered though this mistake happens each time the scene is rerendered.

I can share or send to E-mail the whole project if somebody can help.

[Edited by - beetle2001 on September 27, 2007 4:47:12 AM]

Share this post


Link to post
Share on other sites

I left the catch block empty and now there`s no error messages but the only one mesh is rendered (((
Ok, so can anyone recommend me the example of *.x file loader with multiple meshes withing one *.x file ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!