Google
 

Tuesday, October 23, 2007

New Post on XNA UK

Find the new post here.

Friday, October 12, 2007

Moving the Blog - New URL

For those that would like to follow my XNA babbling further, the new blog will be here http://xna-uk.net/blogs/randomchaos

Moving the blog

Well it looks like I have taken the plunge over at the XNA UK User Group!

Leaf offered to host my blog there a while back when my FTP issues started, and has also been gracious enough to host my FTP files. I think what they are trying to do there is a great idea, I think having a good XNA community in the UK is important to home brew development here and I am only too glad to be involved.

There are only 2 user blogs there at the moment, myself and ConkerJoe, who's blog is centered around a 2D XNA engine called CreamX.

What I intend to do is keep this blog as it is. I am going to spend some time moving these post over to the new blog and any new post will appear there.

Once I have the new blog url, I will post it here.

To all of you that have commented on the blog or downloaded and used any of my code, thank you very much, I hope this stuff has been useful to you and helped you with your XNA development. I trust you will follow the blog over to the XNA UK User Group and continue to find it useful.

Once I have started posting there I will put the url up here.

Thanks,

Charles.

Friday, October 05, 2007

FTP - Fixed

We have the FTP issue resolved now, so by all means download what you want.

I do hope this is the last of my FTP troubles. Sorry for the hastle to all those that got the zips and found they had been corrupted, and thanks for your interest.

Thursday, October 04, 2007

Generic XNA - A.I Finite State Machine

I have a great book Programming Game AI By Example by Mat Buckland. The first chapter was an eye opener for me as it is a Maths and Physics Primer which is just what I needed, I have not used either of those parts of my Brain since 1988 and they are a bit whithered :P

Anyway I digress. The next chapter is on Finite State Machines (FSM), I have a little experience of these having played with writing very simple CA's (Cellular Automata) way back when.

So I thought, "I have not seen any examples for A.I in XNA yet, wouldn't it be nice, using the examples in this book to come up with a FSM A.I for XNA" So that is what I have tried to do here in this post.

The basic model I put forward here IMHO is quite extensible, you have two base class's and an interface, the BaseAgent, BaseState and IBaseAgent. These objects are the framework of the FSM, to create a new Agent just inherit from the BaseAgent and create an agent interface to go with you new Agent class off the back of IBaseAgent and create your new states inheriting from the BaseState for each, then have your None Player Character or Bot (NPC) inherit from the new interface and write your AI logic for your NPC in the interface stubs.

In this example project I have just implemented the base states:

Patrol
Fight
Flee
isSafe
runAway


I guess these are the most basic items an NPC will need, you can always add other states like Seek and Chase or anything else you may need your NPC to do.


The NPC Patrols...


The NPC Fights!


The NPC Flees!



Again, this is a simple example, but I hope it gives you a base to work from and develop your own FSM's and as ever, if you think I am going about it wrong, leave a comment, it's the only way I can improve my examples.

Controls
AWSD - Translate Camera
Mouse - Rotate camera.

Move to the plane while it is patrolling in a circle, it will engage you and once it has lost enough hits will flee (don't worry, it loses hits just by being close to you)

GenericXNAExampleAIFSM.zip

Wednesday, October 03, 2007

FTP Woes...

Looks like there is an issue with the FTP at XNA UK, some of you are getting corrupted zip files, I have not had the issue my self but they are looking at it now.

Tuesday, October 02, 2007

Generic XNA - Ocean Shader


I have moved this shader and it's associated class over to a generic XNA class. This should make it easier to bolt into your own projects should you not want to use the Randomchaos3DEngine as your base.

See this post for reference: Source Example 5 - Ocean

GenericXNAOceanExample.zip

Generic XNA - Under Water Post Process Effect


I guess the idea for this came from Bioshock, a few weeks a go a friend of mine asked if it was possible for my to create an underwater post process effect for him (thanks for the idea Dave). I already had a shader from Microsoft (can't remember where I got it) that I used for a nice ripple effect on 2D images, so I thought I should be able to adapt that to do this effect. And that is exactly what I have done with this.

It is not perfect as I am using a shader that was not intended for this effect, but it gives you an idea of how to go about doing it.

Here is a shot of the shader being used as intended on a background image.



The post processing code in this sample is all thanks to Chr0n1x, with out his tutorial written for the HazyMind Engine I would not have a clue how to create post processing effects.

Controls
Esc - Exit
AWSD - Translate Camera
Mouse - Rotate Camera

GeneralXNAUnderWaterPP.zip

Monday, October 01, 2007

Generic XNA - Content Pipeline Mod


I have a few examples using custom pipeline code on here, now an issue I get a lot, mainly because I have next to no modeling skills, is when I try to use a new model that has been UV'd I get compile errors because the UV texture that is embedded in the model file is not present or in the right place. So I have to find the texture file reference in the model file and remove it, but some times the models are not plain text so I have to find the physical texture file (or create a dummy) put it in the right place then compile again.

Now I find this a real pain in the back side, I also then have textures in my projects I may not want to use if I cant pull them out of the model file. So I have found a nice simple solution to my problem, override the ConvertMaterial method in the ModelProcessor and just ignore any texture exceptions.

Here is the code to do it

       protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
       {
           try
           {
               return base.ConvertMaterial(material, context);
           }
           catch
           {
               return null;
           }
       }



I have not put a code sample up for this as it is pretty simple to do, if you like try it out on one of the pipeline processors here.

FTP - Sorted

All my source is now hosted on the XNA UK User Group. I have updated the content pipline for the engine so that tangents are now calculated correctly, there is also now no references to disabled/removed classes.

You can access the lot here, and I am now in the process of altering the links to the source on this blog.

Hope you find it useful.