I have modified the SkinningSample to accept more bones, and upped the shader version to vs_3_0 and ps_3_0 in the fx file. However, when I try to draw my model, the DrawIndexedPrimitives() throws an exception saying that both a valid vertex shader and a valid pixel shader needs to be set before drawing.
At this point, I turn on Direct3D debugging in the DirectX control panel. However, I see no additional debug output from Direct3D.
So I re-implement drawing of a mesh, instead of calling mesh.Draw(), to try to diagnose it. Here is the code:
// Render the skinned mesh.
foreach (ModelMesh mesh in currentModel.Meshes)
{
foreach (Effect effect in mesh.Effects)
{
effect.Parameters["Bones"].SetValue(bones);
effect.Parameters["View"].SetValue(view);
effect.Parameters["Projection"].SetValue(projection);
}
foreach (ModelMeshPart mmp in mesh.MeshParts)
{
mmp.Effect.Begin(SaveStateMode.None);
EffectTechnique et = mmp.Effect.CurrentTechnique;
foreach (EffectPass ep in mmp.Effect.CurrentTechnique.Passes)
{
ep.Begin();
mmp.Effect.GraphicsDevice.Vertices[0].SetSource(
mesh.VertexBuffer, mmp.StreamOffset, mmp.VertexStride);
mmp.Effect.GraphicsDevice.VertexDeclaration = mmp.VertexDeclaration;
mmp.Effect.GraphicsDevice.Indices = mesh.IndexBuffer;
mmp.Effect.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList,
mmp.BaseVertex, 0, mmp.NumVertices, mmp.StartIndex, mmp.PrimitiveCount);
ep.End();
}
mmp.Effect.End();
}
}
Note that the current technique is the correct technique, and the current pass is the correct pass, and the system doesn't throw when I call Begin() on either of them. Here is the every so slightly modified technique description, from the skinning sample .fx file:
technique SkinnedModelTechnique
{
pass SkinnedModelPass
{
// note: MaxBones is set to 69 here and in the cs file, hence vs_3_0
VertexShader = compile vs_3_0 VertexShader();
PixelShader = compile ps_3_0 PixelShader();
}
}
I don't get it. How am I supposed to debug this? As far as I can tell, all the building goes great (including the updated processor, that can take 69 bones). As far as I can tell, Direct3D has nothing against the state. As far as I can tell, the effect technique and pass are both being applied correctly. There is nothing in debug output. So how can I diagnose why I get this IllegalOperationException?
--
Jon Watte, Direct3D MVP
kW X-port 3ds Max .X exporter
14 days after getting my RROD box back, it's going back for service again. Grr.