Wednesday, 21 April 2010

Games for 3D glasses with XNA

Following on from my post about creating images for 3D glasses, here is how I modified my XNA game engine to render stereo images.

Previously my camera class simply set up the view and projection matrices based on various input. These matrices are then used by the other components in the game to draw themselves. I have now added an extra property to the class, AnaglyphType, to determine whether the scene is rendered as a left/right stereo pair. Also extra code is added to the game loop to draw the scene into two textures, then combine them with a pixel shader.

Monday, 12 April 2010

Simple 2D car steering physics in games

How to do a realistic moving car in only 6 lines of code!

I find nothing more frustrating in car games than when the developer has implemented some ridiculously unrealistic model for how the car moves. For most games, especially flash-based mini-games, simulation grade 3D physics are not required, but still the car should move and turn roughly like you'd expect a real car to.

Have a quick go at this car parking game, or this one, try to turn into a parking space, something doesn't feel right. More specifically the rear wheels are sliding sideways whenever you turn - this does not (normally) happen in a real car, and it makes this game very hard for all of us used to controlling a real car. I'll show you here how to get better physics than this in just half a dozen lines of code.

Sunday, 11 April 2010

Creating images for 3D glasses

I got a copy of Coraline for my birthday, and it came with a few pairs of those red/green 3D glasses.  I thought I'd have a go and making some of my own 3D photos.  The idea is pretty simple, you take two photos of the subject, one from the position of your left eye, and one for your right eye.  You then tint the left image green, the right one red, and merge them together (this can all be easily done in Photoshop or equivalent).

I think this one came out pretty well, the rotors on the top of this model helicopter really look like they're coming out towards you!