Archive for the ‘Software Development’ Category

Saturday, February 24th, 2007

I have just updated the source Code with some optimizations. (they’ll be incorporated in my next game release soon too)

I haven’t updated the tutorials to reflect these enhancements yet, but the general concept is still the same.

The main changes are these:

  • When constructing a BoundingPart you now additionally pass the original ModelMesh’s original BoundingSphere. This is used as a general proximity test, so the rest of the BoundingSphere’s don’t need to be transformed and tested on every frame.
  • This behavior is optional. When calling Transform() there is a bool “optimizeâ€? parameter. Pass false and the behavior is as it was before.
  • Re factored a little. The List stuff is now encapsulated into a class.
  • When you run the sample, you will notice the BoundingSpheres often don’t move with the model. This is deliberate, and demonstrates the optimizations working. It means they didn’t need to get transformed on each frame because nothing (i.e. the 3D Mouse Cursor) is in the general proximity of their BoundingPart.
  • the XBOX 360 controller now rumbles when the 3D Mouse cursor collides. ;)

The old “tutorial” code is still available in the usual place, but you can get the new optimized version here also. (just scroll down the page further to find the updated version)

Average Rating: 4.7 out of 5 based on 295 user reviews.

Sunday, February 11th, 2007

The only way to know for sure is to try it, so sorry for the spam.

Here goes… (more…)

Average Rating: 4.4 out of 5 based on 285 user reviews.

Sunday, February 4th, 2007

G’day folks. 

A couple of people reported that the last release of “Air Legends” was crashing for them.  I’ve just uploaded a new build containing some small tweaks, and one fix that may help.  If it doesn’t fix the problems outright,  this release may at least assist in diagnosing the mystery problem(s).

Here’s what’s new…

  • I discovered and fixed a compiler warning (doh!!!) that was suggesting two of my textures might not work on some video cards.
  • I added the ability to change from Fullscreen to Windowed mode.  At this stage it is not an in-game setting.  Just edit the settings.xml file (in Notepad is fine) and change the <FullScreen> element to false. Then try running the game again.

e.g.

<FullScreen>false</FullScreen>

As always, you can get this new release from the Latest Builds page here.

Contrary to what my wife seems to believe, I can’t actually read minds.  So please do let me know if this build crashes for you.

 

Update:

Just so you know…  You may have discovered my screenshot functionality (PrintScrn key or controller “Y” button). It is not really ready for public consumption, but I forgot to comment it out.  You’ll find the results do not match what you see things on screen.  All the alpha blended stuff comes out funny.  I’m working on this one.  ;)

Average Rating: 4.5 out of 5 based on 264 user reviews.

Thursday, February 1st, 2007

Greeting earthlings.

I’ve been meaning to do this for a while actually.  Ultrahead’s provided me personally a lot of feedback, help & ideas for my own XNA adventures.

Check out his “Do as I say, not as I do …” blog.

He frequently blogs answers to things I haven’t even got round to searching for.  But there’s more to it than just XNA stuff.  Animation, movies, shameless pimpage of Sharky’s blog!  ;)

This one particularly caught my eye…

“TIP: Deploying games to the 360 without sharing source code”

Once again he’s saved me the trouble of actually reading the forums!  Now all I need is a 360!!!

;)

Thanks Ultrahead.

Average Rating: 4.8 out of 5 based on 194 user reviews.

Tuesday, January 30th, 2007

Well it ended up being 3 parts instead of 2. (techinical difficulties with Windows Live Writer, and me ranting on too much)

Anyway, blog form is not ideal for tutorials, so eventually I might make pages out of them.

In the meantime I’ve collated links to the 3 parts & the sample code here.

Plane in BoundingBox

Enjoy!

Average Rating: 4.7 out of 5 based on 150 user reviews.

Tuesday, January 30th, 2007

After some technical difficulties with Windows Live Writer, I think I’m back in action.

;)

So continuing from where I left off in Part 2 (part 1 is here)…

What about this BoundingPart class then?

As mentioned earlier it wraps a Collection of BoundingSphere’s. Well actually it contains two Collections of BoundingSpheres.

  1. One collection is the sphere’s populated as we saw above. These sphere’s coordinates are in Object Space and are populated when the Model is first loaded.
  2. The second collection is for holding Transformed versions of these spheres. Their coordinates will be transformed into World Space, and the Radius scaled on each frame of our game. Think of these as being the Spheres as they are positioned and scaled in our game’s world. This is necessary so we can test for Collisions! Object Space simply wouldn’t cut the mustard, since it would be equivalent to having all our models stacked on top of each other at the same (0, 0, 0) position. They’d always be colliding like some kind of roman orgy. World Space puts them in their rightful place with their hands in their pockets.

(more…)

Average Rating: 4.4 out of 5 based on 237 user reviews.

Tuesday, January 30th, 2007

Hi there.

In Part 1 of this tutorial we looked briefly at one of the simplest techniques for collision detections – the radius (forgive me, if there’s a fancy name for it). A perfectly adequate solution for some games.

We also looked into what XNA has to offer out of the box, and why the BoundingBox class may not be suitable for some games, due to it’s Axis Aligned nature, and how that doesn’t work so well with rotated models.

If you missed part 1, check it out here…

Meanwhile, lets get on with this 2nd, and if all goes well, final part. By the end of this I hope I’ll have shared some sort of solution. I see it as an interim solution as I really hope Microsoft will address this in a future version of XNA.

In Part 1 I mentioned that there would be no working code sample. I lied. I found it so difficult to explain it all from bits and pieces of my game’s code, that I bit the bullet and made a working sample.

As you may already be aware, I’ve published this sample on the blog already. Feel free to grab it over here. I will be refering to code in the sample throughout the rest of this tutorial.

Bye bye BoundingBox, hello BoundingSphere.

Besides BoundingBox, XNA provides an BoundingSphere class for collision detection. (more…)

Average Rating: 4.7 out of 5 based on 212 user reviews.

Monday, January 29th, 2007

Can people please let me know (via blog comments) if they are having problems with either…

  1. my latest “Air Legends” release?
  2. or my Collision Detection sample code?

I’ve had one report of a problem with “Air Legends” crashing after choosing from the menu screen.  Works fine for myself & some others.

Also Ultrahead alerted me to a problem he was having running my Collision Detection sample code (v1.0.0.1).

While it worked fine for me, a crash was occuring on the DrawIndexedPrimitives lines that actually draws the spheres. I wish I could understand why it would crash. My code for rendering the spheres was taken pretty much straight from an XNA help file example. 

While investigating the problem I ended up changing the code a little.

  • I had been using a LineList, but in retrospect a LineStrip seems simpler, and perfect for a list of connected lines. Once again, I based my code on the XNA help file example.

I’ve just uploaded a new version (v1.0.0.2). I’ll be interested to hear if it also gives anyone grief. 

If it does please do let me know. And as a work-around if it also fails, I’m guessing that changing these lines of code…

device.DrawIndexedPrimitives(
    PrimitiveType.LineStrip,
        0, // vertex buffer offset to add to each element of the index buffer
        0, // minimum vertex index
        CIRCLE_NUM_POINTS + 1, // number of vertices. If this gets an exception for you try changing it to 0. Seems to work just as well.
        0, // first index element to read
        CIRCLE_NUM_POINTS); // number of primitives to draw

to…

device.DrawIndexedPrimitives(
    PrimitiveType.LineStrip,
        0, // vertex buffer offset to add to each element of the index buffer
        0, // minimum vertex index
        0, // number of vertices. If this gets an exception for you try changing it to 0. Seems to work just as well.
        0, // first index element to read
        CIRCLE_NUM_POINTS); // number of primitives to draw

…will probably solve the problem (much like the solution Ultrahead found with my original code). The “number of vertices” parameter seems to be quite optional. Zero works fine for me too.  Kinda bugs me though. I hate this uncertainty.

Meanwhile, I should really get on with Part 2 of the tutorial, perhaps even some Battlefield 2142…  ;)

Average Rating: 4.5 out of 5 based on 270 user reviews.

Sunday, January 28th, 2007

I’ve just uploaded a new build of “Air Legends”.

The only change in this release is that I’ve incorporated the improved collision detection that I’ve been blogging about so much lately. If you’ve played the previous versions I’m sure you’ll notice it’s a lot better now.

You should be able to survive much closer flybys now than before.  More of your bullets will miss now. For obvious reasons really – the collision zones are much tighter and more realistic than before.  But also, and this one was slightly unexpected,  some bullets will fly right over or behind a wing missing altogether.  This is not a fault.  Wings are narrow – bullets are small and could go either side of a wing depending on the planes roll.

You can get the new release from the Latest Builds page here.

Average Rating: 4.6 out of 5 based on 176 user reviews.

Saturday, January 27th, 2007

Shawn Hargreaves (of the XNA team) gave me a nice simple solution to the small hack I had in my code.

…

In your BoundingPart.Transform method, you build up a full matrix to transform the bounding sphere center point, but don’t take that matrix scaling into account when updating the bounding sphere radius.

There isn’t a really general way of extracting scaling information from a matrix in XNA at the moment (this is something we’re planning on adding for the next version), but a good workaround is to take the length of the Matrix.Forward vector. That will be accurate as long as the matrix doesn’t include any shearing on non-uniform scaling, so it works fine for pretty much everything you are likely to encounter in real life model data.

I changed your:

bsTransformed.Radius = bs.Radius * scale * DODGY_HACK_MAGIC_NUMBER;

to:

bsTransformed.Radius = bs.Radius * localWorld.Forward.Length();

which will hopefully be more consistent with different meshes as well

…

I’ve tested it and it works sweet.  The new version of the sample is now available here.

Average Rating: 4.6 out of 5 based on 191 user reviews.