Creating a Simple 3D Game with XNA/Rendering Your Model

Getting Started
First of all, open up Visual c#, and select 'File'/'New Project'. From there select to create a new C# project.



What you should see in front of you are the standard starting XNA starting code. Add the projects 'SkinnedModelPipeline' and 'SkinnedModelWindows' from the previously downloaded skinned model sample, and add a reference to them by entering  along with your other using statements and by right clicking on your project and selecting them under 'Add Reference'.



Plus ensure that the class is referencing the 'Game' class as below by changing the first line of your class.

And place the 'SkinnedModel.fx' file from 'SkinnedModelWindows' project into your projects content folder as your model will use it to render.

Fish Renderer
Next up, create a new game component file called 'ModelRenderer'. From this, add the following class variables.

Change the constructor as follows.

This code, more or less taken from original sample, initialises methods which will eventually be used for the animation process.

Next, remove the code from the pre-made update method, and replace it with this.

The .Update method here will ensure that the animation currently playing by the method will be played in sequence and in time with everything else using the passed 'gameTime'.

The active ingredient of this class is the below Draw method:

We don't need to worry about this too much for the sake of this tutorial.

Add a new method which will be called from the parent file which will call elements of the pre-loaded 'SkinnedModel', playing the animation.

We will be adding to this code as we extend the logic of the actual gameplay (as its quite a convienent place to store instance variables on the fish we will be using), but for now this more than covers the basics which are needed for the system, and next we can worry about using it to render the model.

Using Your Renderer
Create a new folder under 'Content' in your project called 'Models', and add your fish model and all the .tga texture files. Now right click on the 'References' folder, and add 'SkinnedModelPipeline'. This will allow you to select the correct renderer for your model by going into your models properties and changing it to the new 'SkinnedModelProcessor'. If you are unable to select it, ensure that the two 'SkinnedModel' projects are built by right clicking on them and selecting 'Build'.

Now go back to your parent file. Add some new class variable;

And put it into use by going into your update method and adding the line at the start of the method, and in the draw method adding  after your   line.

And finally, add the following in the start of your 'LoadContent' method.



Now, run your application, and everything should work.