Custom Model Processor

After updating the Skinning Sample project to fix the rotation problem with Blender FBX files, I was able to compile this code into a library.  This library is found in the SkinningSample_4_0SkinnedModelbinx86Debug directory.  In my main BlastingBits game project, I added a reference to SkinnedModel.dll from that directory, which allows me to make references to the SkinningData, AnimationPlayer, and AnimationClip classes.


After running my game again, I got the ArgumentNullException error from the AnimationPlayer class from the code which checks to see if the skinningData is null.  This is most commonly due to the ContentProcessor of the model being imported not being set to the SkinnedModelProcessor.  Unfortunately, this was not an option for my fullbody5.fbx model which I had imported.  However, I figured out that this can be fixed by adding another reference under the BlastingBitsContent project, which points to the DLL for the SkinnedModelProcessor (SkinningSample_4_0SkinnedModelPipelinebinx86DebugSkinnedModelPipeline.dll).  After setting that value, I was successfully able to change the Content Processor of my fullbody5 Model to SkinnedModelProcessor.  Compiling and running the game again resulted in no errors.


In my main game class, I added an instance variable for the AnimationPlayer, which will probably later be changed to a Dictionary to hold all of the animations for all of the models in the game.  In the model load method, I create the AnimationPlayer and AnimationClip for my model.  Then the StartClip method is called to start the animation.  Additionally, the Update method is called on the AnimationPlayer instance variable in the main game update method.


After adding the updated code to draw the player model in my GameScreen3D class, the animated model displayed correctly.  However, when I tried rotating the model 45 degrees, it still displayed but there still appeared to be polygon clipping problems.  After an hour or two of testing different camera positions and angles in both my game code and the Skinning Sample code, I was able to track down that this problem only occurs when a call to SpriteBatch Begin and End is made.  After I found the code that caused the problem, I was able to do a web search and found that this problem has been reported before, and the solution is to set two RenderState boolean values on the graphics device.  When I tried to run that code, it threw an error.  However, I was able to find that error reported and a more elegant solution, which is to set the GraphicsDevice.DepthStencilState to DepthStencilState.Default before rendering the model.  Adding that one line of code before calling the model draw method completely solved the problem with the overlapping polygons in my animated model.