Wednesday, 23 February 2011

New Roller Skate Rink

This is completely unrelated to coding my game but I do need a break from time to time.  I used to have to drive for 45 minutes each way to go skating.  Now there is an excellent rink just 10 minutes from home in Maldon, Essex, UK.

Sk8ters at Madison Heights
http://www.madisonmaldon.com/

I went there on Monday when it had only just opening.  Met the owner and builder.  Very nice guy and the place had a friendly atmosphere.  I think I will be there a lot.

Wednesday, 9 February 2011

Windows Menus and Small Fixes

I still don't have anything new to demonstrate but I've had a few things on the go on and off over the last week.  Small things but all moving the project along slightly.

I've resized the entire game to use 1024x576.  This helps considerably with performance on the Xbox.  Not tricky work but required every 2D texture and menu to be resized.  I did this to avoid Predicated Tiling which happens when the back buffer exceeds the 10MB of fast EDRAM on the Xbox.
http://msdn.microsoft.com/en-us/library/bb464139.aspx

I've fixed the terrain so that the texture layers display again.  That had stopped working ever since I had split the terrain up in to chunks.  It was a simple fix to clone the effect file so each chunk uses it's own shader instance.  It just needed the few minutes to look at it.

A few minor changes to the maths to allow for textures to span the boundary between chunks and for them to line up correctly.

As part of the changes to the textures I noticed how awkward my property windows are for use in the editor.  I originally created them based on the game windows.  That was OK but I decided to spend some time seeing if I could use proper Windows menus and dialogue boxes. 

I have used WinForms for my TakeExtractor programme which I'll come to in a minute.  That works by having a class to simulate a game inside a WinForm application.  I want the other way round.  I want a WinForm menu inside an XNA game class.

As it happens it only took two minutes searching on the Internet and a bit of messing about with a sample app. to test it out and I have exactly what I want.  
http://code.google.com/p/xna-game-menu/



I'll be changing all my forms and menus in my game Editor over the next few days.  That will make creating maps much quicker.  I need to get some finished 3D graphics in the game so I can produce some videos to show it off.

Lastly and still on the same goal of getting the 3D graphics done, I have made minor tweeks to my TakeExtractor programme:
https://code.google.com/p/take-extractor/

I had a problem with an animation that was above the ground but in the TakeExtractor you could not tell.  I've added the option to show a floor.  That way you can judge height.  I've also changed it to add zoom in and out and basic rotation control.


Back to the game Editor to add menus and forms now.

Monday, 24 January 2011

Level of detail and frame rates

I haven't posted for over a month.  I've made a lot of changes over that time but I have nothing to show for it!

My original aim was to have the ability to create large open vistas to play on.  My current level designs don't need them but it was a nice to have.  This works on the PC but with my current code the Xbox 360 cannot cope. 

I added some level of detail (LoD) reduction to the terrain and split it up in to chunks.  Unfortunatelly although I am pleased with the code it does not help much with the performance on the Xbox for large views.

For the Xbox I am going to have to restrict the viewing distance on the maps to about 80m.  The maps can still be large but will have more twists and turns in them.

I have removed the full Parallel Split Shadow mapping (PSSM) that I had and replaced it with just a single shadow map that fades out the shadows between 35 and 40m from the camera.  I am pleased with the look and very pleased with the frame rate.  I can maintain 60 FPS most of the time dropping to a still playable 30 FPS for short periods with more complex views.  It might need some adjustment when I get more models in the scenes but I am more confident that this is now workable.

Sunday, 12 December 2010

When I thought I'd finished converting to XNA 4

A few posts back I reported that I had finished converting everything to get my XNA 3.1 code to work in XNA 4.0.  Well I was close and everything worked on the PC but when I came to test on the Xbox I had some errors.  Proper game stopping exceptions.

It's taken a few hours on and off to narrow down the problem and it's fixed now.  The problem was code I had written to replace point sprites in one of my particle systems.  Point sprites are no longer available in XNA.  That is not a problem because triangle lists do the job just as well.  The trouble was that I did not fully understand how vertexBuffers work and that the Xbox cannot reuse vertices until the GPU has finished with them.

In my defence the posts I read to find out how to resolve my issues were posted by some well respected programmers who were also caught out by the Xbox behaviour.

If you want to know more the comments in the code for the particle system sample were useful:
http://create.msdn.com/en-US/education/catalog/sample/particle_3d
As were the comments in the following old post:
http://forums.create.msdn.com/forums/t/33931.aspx

Now at last I can get on with editing some models and creating some more animations for use in the game.

Saturday, 4 December 2010

Blender to XNA to be included in the next release of Blender

There is a good chance that the script I have just written to export from Blender to XNA will be included in the next release of Blender.  Apparently it has to be tested and approved by some of the Blender administrators but it is already on their SVN server.

The instructions are now on a Blender Wiki page:

http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/Blender-toXNA

Tuesday, 30 November 2010

Blender 2.5 to XNA 4 animated FBX models

The following post is out of date because as from Blender 2.56 the scripts mentioned are all shipped with Blender. See the following post for more up to date information:
http://blog.diabolicalgame.co.uk/2011/07/exporting-animated-models-from-blender.html


==


Following on from my previous post on this subject I have managed to create an FBX exporter script for Blender 2.55 Beta that works with keyframe animations and imports in to XNA 4.0.

Due to the limitations with the Autodesk FBX importer that ships with XNA 4.0 the animations need to be loaded individually from separate FBX files but there are simple solutions available to work with that.  Details and other links are in the Instructions with each of the following projects:

The package with several XNA FBX exporters for Blender 2.5 can be downloaded from:
http://code.google.com/p/blender-to-xna/
The most recent instructions are on the Blender Wiki:
http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/Blender-toXNA

An XNA model viewer that has an option to load FBX files as separate animations:
https://code.google.com/p/take-extractor/

The XNA TakeExtractor project also demonstrates how to rotate models and their animations within the pipeline.  That is useful for adjusting Blender models which face Z up to XNA's default which is Y up.  Use a rotation while loading of X = 90, Y = 0, Z = 180.   I think that ends up facing backwards because that is how my entire game appears to work and there is too much code for me to bother to change it!

Friday, 26 November 2010

Blender 2.5 to XNA 4 animated model pipeline

See the future linked post for more up to date information:
http://blog.diabolicalgame.co.uk/2011/07/exporting-animated-models-from-blender.html

The following is a bit out of date. If you want to know how to get models from Blender to XNA read the above linked post not this one.

==

It's been a while since I posted because I have been struggling with a problem since I finished the conversion to XNA 4.

As mentioned in my previous post, animated models from Blender would no longer display properly in XNA.  If I had imported the animation in XNA 3.1 they would still work in 4.0 but when I tried to save new animations from the models using XNA 4, the animations were distorted.

I tried fixing the FBX exporter from Blender but the FBX file format is not documented making it difficult.  To cut a long story short I have ended up with a solution that uses separate files for the animations.

The model, bones and bind pose are loaded in to XNA using FBX.  Each animation is exported from Blender as a list of bone transform matrices.  Those can then be imported in to XNA and converted to the AnimationClip format used by the Microsoft Skinning Sample.  Edit:  I now have FBX working see my next post.

The process takes a few steps but works with the models I have been using.  It needs more testing with other models.


The package with several exporters for Blender 2.5 can be downloaded from:
http://code.google.com/p/blender-to-xna/
The most recent instructions are on the Blender Wiki:
http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/File_I-O/Blender-toXNA

The XNA sample and model viewer demonstrating how to import the animations can be downloaded from:
https://code.google.com/p/take-extractor/

Both are on Google Code, if the links do not initially work, wait an hour and try again.  Google appear to have frequent outages but none so far have lasted longer than an hour.
There are still several limitations with the pipeline some are the same limitations as with earlier versions of XNA and Blender:

- All parts (Blender Objects) of a model must have the same centre (Origin, ideally at Zero)
- All parts of the model must have a scale of 1.0
- Every vertex must be weight painted or added to the bone vertex group for animation.
- The model has to be loaded in XNA before the animations can be converted to AnimationClip format.

At the moment the animations cannot be rotated in the content pipeline! [Fixed, see future posts]  My next job is to work out the maths to rotate the animations as they are imported.

==

Please make sure you read my future posts. I have done a lot more work to get it all working properly.