Archive for the ‘XNA’ Category

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.6 out of 5 based on 212 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.5 out of 5 based on 164 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.4 out of 5 based on 197 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.7 out of 5 based on 186 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.4 out of 5 based on 252 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: 5 out of 5 based on 233 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.5 out of 5 based on 249 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.4 out of 5 based on 166 user reviews.

Saturday, January 27th, 2007

As promised I’ve uploaded the working sample solution that I will explain later in Part 2 of the tutorial…coming soon!

I’ve also added a Tutorials section on the site so it should be easy enough to navigate.

Enough talk… go get the source

If anyone finds a solution to the one small hack in my solution, please let me know!

Update: I forgot to mention the sample’s controls & that there is a Mouse moveable black Cursor that goes White when colliding. The controls are…

  • Pitch model: XBOX 360 Left Thumbstick Forward/Backwards or Keyboard W/S
  • Roll model: XBOX 360 Left Thumbstick Left/Right or Keyboard A/D
  • Yaw model: XBOX 360 Right Thumbstick Left/Right or Keyboard Q/E
  • Scale model: XBOX 360 Left/Right Trigger or Keyboard LeftShift/LeftCtrl
  • Move 3D cursor: Mouse
  • Move 3D cursor forward/backwards: Mouse Scrollwheel Forwards/Backwards
  • Screenshot and XML Dump (put in \Screenshots sub directory): Keyboard PrintScrn

Note: my Mouse code is very rushed and obviously not quite right yet.  Suggestions welcome. ;)

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

Friday, January 26th, 2007

G’day folks.

Quick update…

I’ve been working hard to get Part 2 in a state ready to publish.  While I’ve got a working solution in my game It’s been painfully hard to write a tutorial showing snippets. So I’ve had to bite the bullet and make a working sample to share.

That has been worthwhile though. In the process I’ve cleaned up a lot of ugly code, or stuff related to “Air Legends” current architecture, that just complicates things.

It has also highlighted some problems that I’ve fixed.  There is one remaining problem – some models seem to behave differently. Something to do with their BoneTransforms I believe.  I’ve found a simple, but less than ideal solution (aka. a dodgy hack), but IT WORKS reliably!!

I think I’ll post the working sample code in the next couple of days.  (Maybe someone can point out solutions to the dodgy hack)

I’ll follow that up with Part 2 of the tutorial to actually explain it all.

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