Worklog for Rob Farley

Worklog 1

Return to Worklogs

The Rescue!(Posted 2006-03-28)
OK Guys... I'm on my way...



Get in... No pushing...



Stop fighting in the back!



You'll all just going to have to get along... it's a tight squeeze!



The only reason I'm showing this is because it was actually a very complex bit of code to get the guys to run to pick a side of the helicopter, get to the bases of the ramp, run up them, get inside, and then stand in a specifc place based on how many people are already in the helicopter... Oh and not to try to get in if there are already 6 people in there. And once they're in they parent themselves to the helicopter too...

Yes I know they don't have faces yet... and I know they don't have shadows yet!

Anyway... In the game you won't actually be getting anything like this close to them, but I thought I'd show that they all get into the helicopter properly as opposed to just going inside and disappearing! You can physically fit 6 people inside... 7 if you count the pilot... even if it is a bit of a squeeze!

Oh... and at the bottom of the last pic you can see my single surface text thing... all the weird characters you see there are all part of the cool drawing / undrawing of the text, it sort of decodes itself onto the screen which looks funky. And it's all a neat self contained bit of code so I just write:
NewText("PRISONER "+onboardcount+" ON BOARD",3000)
And this will display the message "PRISONER 5 ON BOARD" for 3 seconds, scroll up any existing messages out of the way and do all the funky decoding onto the screen, all I need to do is call
UpdateText()
in the main loop.

Cheers Rob

And so it begins(Posted 2006-02-26)
Well, I've have a few requests asking me to do a worklog for this so here's my first attempt at it...

The Helicopter game started off life as a vertical scrolling shoot'em up however, things quick progress into a full 3D world. The idea was to make a game that plays like a 2D game but still has the 3D element to make it feel fairly realistic...

Having played with blitz terrains I quickly realised I would have to write my own terrain system... The problem with creating your own terrain system means you have to write a lot more code, however, you get additional flexibility and functionality, obviously an editor had to be written too.

After a few attempts I came up with this as a final result...

The terrain is 2kmē. It is made up of 256 meshes (16x16), each mesh is 32x32 quads, each quad 4unitsē. 1 unit = 1 metre, therefore 4 * 32 * 16 = 2048 metres. Or around 2km. Not huge, but big enough. Each 4unit quad has a 256x256 texture on it which effectivly gives you a detail level of 131072 x 131072 pixels.
Then on top of that it's all vertex lit.

It starts with a 513x513 grey scale height map (0-255), the editor then smooths this into a 16bit heightmap (0-65535) then it's flattened, coloured or adjusted based on the tile that is placed between the points.

There's 3 smoothing passes and 3 flattening passes to make the roads flat, as well as a beach pass to make a severe drop when it hits water level so you don't get Z buffer fighting at the waters edge.

The editor then exports the new 16bit heightmap information as well as the tile information (including rotation of the tile).

The game then loads this data and creates multiple meshes based on this data. Creates brushes as it finds new textures and creates new surfaces per mesh as
it needs them. This works out pretty effeciant on the surface count per mesh as you rarely have more than 3 surfaces per mesh. This allows you to have a varied
tile set but still keep the surface count down if you keep the meshes far enough apart so they can't 'see' each other.

Got all that?

The first hit looked like this:


This then progress to using grey scale textures (or very diluted colour) and colouring the terrain using vertex colours, this meant that you could add variation to the terrain without added textures.



At this point all object placement was just random as the editor didn't have any kind of placement stuff in it yet...

Bad guys were added... Helicopters, Jeeps, and Tanks. This also meant an auto aim system had to be written so they could actually hit you, likewise as the game is 3rd person your gun auto aims too. This makes life much easier from the player point of view and I think more fun.

I used Noel Cowers Lotus Particle system too as my particle system was crap. This gave the game some of the necessary fx to make it look pretty.



3 types of weapons are currently in, Cannon, Shell and Missile. This will probably increase as time goes on however, this does for the time being.

Next to come in the game was some kind of story... OK... I didn't come up with one, however, the idea of having to rescue people was a pretty good one so I added POWs who you would spring from prisions.



The sky was looking poor... This needed a face lift...
The water was looking poor... This needed a face lift...

So I gave them a face lift!



It was time to add object placement into the editor... Needed to organise where things were and see how much it could take without getting severe FPS drops...

So each object has a definition file, looks something like this:
<mesh>Tree.b3d</mesh>
<type>static</type>
<xsize>8</xsize>
<ysize>10</ysize>
<zsize>8</zsize>
<health>10</health>
<death>fall</death>
<sway>1</sway>
<randomise>1</randomise>
The editor and game use this file, the editor uses it to make the boxes on the screen the right size for level creation. The game uses it to do pretty much everything else!

The actual level object file looks something like this:
<OBJECT><ID>1</ID><TYPE>static</TYPE><NAME>radio</NAME><X>453</X><Z>229</Z><ROT>45</ROT></OBJECT>
<OBJECT><ID>2</ID><TYPE>static</TYPE><NAME>radio</NAME><X>431</X><Z>236</Z><ROT>90</ROT></OBJECT>
<OBJECT><ID>3</ID><TYPE>vehicle</TYPE><NAME>tank</NAME><X>482</X><Z>169</Z><ROT>90</ROT><PARENT>51</PARENT></OBJECT>
etc
etc
So when an object is loaded it checks out the definition file for that object and loads the right mesh etc etc.

The object definition file can be extended as much as necessary, it already accounts for special types of death (for example trees fall over rather than blow up!).

Likewise the level objects file will include scripting for what to do when they die... or maybe this will be in the object definition... not sure yet... and example would be when a prision is destoryed it will spawn a damaged prison and a bunch of prisioners... or maybe a prisioner spawner... or something...

As you may have noticed the type is denormalised into the level object file, this is because static objects are delt with in a single function and vehicles and other things that I've not though of yet are delt with in other functions. If I read the object defintion file every time to get the type I'd have to open and close files loads, this just makes life a little simpler. Obviously once the respective function is called with the object name it will go off and read the definition file within the correct function.

The update of the sky gave me an idea of a sort of global illumination thing going on, so on the load of the skybox the general hue of the sky is calculated... This then affects the colour of the terrain and objects on it. This means you can get some cool fx going on...




I also adjusted the shadows so as things get higher the shadow gets bigger and moves away in the opposite direction of the light source, this is a complete cheat, but looks quite nice!

The helicopter now has gained doors on the sides, this is mainly a cheat for getting the prisioners on board, the doors fold down and create ramps either side of the helicopter. This means that the prisoner in theory can just run up the ramp and not have to do any complex climbing into the helicopter.



So that brings you up to date! Phew!

Here's some pictures of explosions!







Cheers Rob