Monday 11 October 2010

More XNA 4 stuff

Over the weekend and still continuing the XNA forums are down for an upgrade.  Everyone suspects this is because of the Windows Phone 7 launch.

This is inconvenient and I have had to resort to Twitter for advise.  Not as bad as I thought everyone was very helpful.  Thanks to @mikebmcl, @UberGeekGames and others. 140 characters is a bit short to get much across but I got what I needed to know.

I had to re-write the muzzle flash code to make it easier to change the graphic.  My previous code, working in XNA 3.1, produced a too harsh effect in XNA 4.  I wanted it to fade out a bit more at the edges.  In the process I discovered that the new XNA 4 Particle3D sample on the creators club uses the XNA 3.1 syntax for VertexDeclarations.  It did not stop it working but I like to use the best methods so I re-wrote those as well.

I have three major areas left to get working properly.  Shadows, which are now very rough on Windows because of the enforced HLSL instruction slot limits, 512 for PS_3_0.  As the game is for the Xbox360 I am not going to worry about that until I see the results on the 360.

Animations are limited to only one per FBX file.  I am also not worried about this because at worst I could export all my animations from Blender one at a time.  I will most likely change the code to simply use the FBX file almost unchanged instead of my own animation format only invented in order to save the animations individually.

What I am left with to deal with are triangles...  The new model class has a separate VertexBuffer for each mesh.  The old one had one vertex buffer for the whole model.  In theory I should find this easier to extract triangles from each model.  My first quick guess did not work.

I need to reinstate my debug code that lets me view the triangles so that I know when I have got it right.

In game the collision is based on spheres but the editor uses the triangles to calculate the location of the spheres.  In game the only time the individual triangles are used is to calculate the orientation of bullet impact decals so that they line up correctly with the faces of the model.

I'd better get on with it instead of typing this.

[Edit]
I did what I said and the resulting code to extract triangles can be found on the following web page:
http://www.discoverthat.co.uk/games/xna.htm#vertex

I found another similar blog giving yet more useful details on the transition from XNA 3.1 to 4.0 it covers much of the same ground as my posts but also has some example code:
http://blogs.microsoft.co.il/blogs/grozen/archive/2010/10/23/converting-a-3d-xna-3-0-game-to-xna-4-0-an-example.aspx

2 comments:

DDreaper said...

Great stuff and looking good, you say you are on Twitter, what's your twit tag?

John C Brown said...

I should probably put this information somewhere. I'm @MistyManor on Twitter and JCBDigger on the XNA forums.

A bit confusing but JCBDigger was gone and XNA no longer allows me to rename so I'm stuck with the mismatch!