求助.net下绘制骨骼动画的问题

d3ddx d3ddx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的源代码和directxSDk上的动画实例基本一样但运行时会在
private void DrawMeshContainer(AnimationMeshContainer mesh, AnimationFrame parent)
{
// first check for skinning
if (mesh.SkinInformation != null)
{
if (mesh.NumberInfluences == 1)
device.RenderState.VertexBlend = VertexBlend.ZeroWeights;
else
device.RenderState.VertexBlend = (VertexBlend)(mesh.NumberInfluences - 1);

if (mesh.NumberInfluences > 0)
device.RenderState.IndexedVertexBlendEnable = true;

BoneCombination[] bones = mesh.GetBones();

for (int iAttrib = 0; iAttrib < mesh.NumberAttributes; iAttrib++)
{
// first, get world matrices
for (int iPaletteEntry = 0; iPaletteEntry < mesh.NumberPaletteEntries;
++iPaletteEntry)
{
int iMatrixIndex = bones[iAttrib].BoneId[iPaletteEntry];
if (iMatrixIndex != -1)
{
device.Transform.SetWorldMatrixByIndex(iPaletteEntry,
mesh.GetOffsetMatrices()[iMatrixIndex] *
mesh.GetFrames()[iMatrixIndex].
CombinedTransformationMatrix);

}
}

// Setup the material
device.Material = mesh.GetMaterials()[bones[iAttrib].AttributeId].Material3D;
device.SetTexture(0, mesh.GetTextures()[bones[iAttrib].AttributeId]);

// Finally draw the subset
Mesh x = mesh.MeshData.Mesh;
x.DrawSubset(iAttrib);
}
}
else
{
// Standard mesh, just draw it using FF
device.RenderState.VertexBlend = VertexBlend.Disable;

// Set up transforms
device.Transform.World = parent.CombinedTransformationMatrix;

ExtendedMaterial[] materials = mesh.GetMaterials();
for (int i = 0; i < materials.Length; ++i)
{
device.Material = materials[i].Material3D;
device.SetTexture(0, mesh.GetTextures()[i]);
mesh.MeshData.Mesh.DrawSubset(i);
}
}
}的 Mesh x = mesh.MeshData.Mesh;
x.DrawSubset(iAttrib);处抛出异常,望高手指教
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
d3ddx
C# 111,128 成员 642,536 内容