Camera Movement

http://www.youtube.com/watch?v=2WwGt3QqENc

The camera in the 3D game world can now be moved and rotated.

Since I’ve had a few days off from work, I tried to make as much progress as I could with development of the Blasting Bits game.  I was able to get the new model processor working, and now the player model is animated in the game.  In Blender I can make multiple animations/clips, but unfortunately XNA will only allow one animation to be imported as noted in this article by Shawn Hargreaves.  So for now the player model continuously runs.  There doesn’t appear to be any elegant solutions for having multiple animations in an FBX file.

I added camera controls to the game, so when the player holds the right trigger the left thumbstick will zoom and rotate the game world.  Zoom is basically just the distance the camera is away from the game world.  Initially, I had the camera changes in set increments which appeared jarring when changed.  To fix this, I added three variables which are increment, speed, and target for both rotation and zoom.  When the player changes the camera, the increment value is added (or subtracted) from the target value.  Then for each update, the increment value is added to the current position until it reaches the target value.  This gives a much more smoother effect when rotating or zooming.

Blasting Bits

Blasting Bits

blasting_bits_promo

Overview

Blasting Bits is a game that puts you in a world where cyber terrorists have hacked the top level domain and unleashed a horde of malicious viruses.  Using the mass-to-binary converter will allow you to enter the digital world and eliminate the viruses.  If not defeated, the viruses will destroy the digital world.

This was  a game that I was developing in XNA.  Upgrade your abilities by collecting the orbs to fill the sockets in your equipment.

 

Development Log

Development Playlist

 

Released

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.

screen090

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.

screen091

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.

screen092

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.