tweex[dot]net

Like many people, I grew up watching Dragonball Z and it has been brought to my attention that not everyone has seen the Dragonball Z Abridged series by Team Four Star. Those of you that haven’t should be considered shamed and should rectify this immediately by clicking on the link and watching the videos; they are truly hilarious.

Bayonetta

For those of you that are unaware, Bayonetta is a game which is touted as being spiritually related to the Devil May Cry series, mainly due to the fact that the game was designed by Hideki Kamiya, the designer of the original Devil May Cry game.

When the demo came out on XBOX Live I downloaded and played it, then felt very dissatisfied, then played it again and still felt the same. The main problem I have with the game is the controls; I’m not sure why but somehow I can’t correlate the buttons to the actions because to me the actions the buttons perform don’t seem to be deterministic; this ultimately results in random button mashing (and quite often death).

I’ve played through Devil May Cry and I really enjoyed that game, mainly because I got the controls since they always did the same thing. I am told that Bayonetta isn’t so bad if you play the actual game from the beginning, and if that’s the case then I would consider the game demo to be a failure since I’m not going to be buying the game due to not being sure I can play it (given, I could put it on super-easy one button mode but that would just make me feel like an idiot, and no-one wants to feel like an idiot).

New Blog

Well I’ve moved over to tumblr for my blogging needs. This is mainly due to the fact that I don’t really want the hassle of keeping my blog software up-to-date any more; especially now that I have three separate pieces of software to keep up-to-date for the Insimnax SDK website.

As a result of this move, and the fact that tumblr doesn’t have an import option, almost all of my really old posts have gone. It’s somewhat sad to throw away around 2 years of content, but it’s also quite liberating since I have only moved over the most recent content and any older content that I felt was interesting or informative. It was nice to look back over the years of blog posts and see how far I have come to get to where I am today; who knows, maybe this new start will prompt me to update more often :)

I’ll be setting http://blog.tweex.net to point here, although it might take a while for the DNS information to propagate correctly.

If they're Ninja's, why can I see them?

AI
Also, why are they dressed in green?

My AI demo was finished and handed in. My extension task was behaviour trees and there is a video of the demo below, all in HD and powered by the Insimnax Framework.

Insimnax Framework
The Insimnax Framework has finally been released. It is cut down from what I had originally planned since I decided to move the integration of things like physics, GUI, audio etc to the games that use it so that developers could be more flexible. You can grab the full source code (licensed under the MIT license) along with the code for the Insimnax Common Framework (ICL) from here.

I’m currently in the early stages of working on a level editor for it.

Welcome to the Madhouse

So what I have been doing since my last update. Well, I have played through Batman: Arkham Asylum, AND YOU SHOULD TOO! It’s a great game (given, the boss fights aren’t up to much) but I love the sneaky, pick people off one a time, parts (the Batclaw has to be my favourite weapon for doing this, just catch someone unaware and yank them over the side of a fence for an instant incapacitation).

I have also been back at Uni, so have been working on a variety of game programming related tasks. My modules for this semester are Artificial Intelligence Techniques, Advanced 3D Graphics, Network Programming and my Applied Research Project (my dissertation - which is actually a year long module).

AI
AI has been interesting so far. We started by looking into State Machines, and then Behaviour Layering before moving onto Steering Systems and Path-finding. The culmination of this is that I currently have a demo application that uses a state machine to drive the steering behaviours of a steering system following a path calculated by an A* path-finding algorithm.


AI path-finding demo, using the Insimnax Framework

A3D
Advanced 3D Graphics has three “mini-assessments”, one of which I have already completed (Shaders), and the second of which I am currently half way through (Animation). The final one will be large-scene rendering.

The shaders assignment took the form of a report looking into a particular field. This was a partner exercise and we worked on Post-processing effects.

The animation assignment is looking at skeletal animation with blending, as well as being able to influence particular bones in a mesh to make them perform certain things (like look at a point of interest). Being able to attach objects to a mesh is also another desired feature. All this is being done in DirectX 9 and I currently have instanced skinned meshes (software and HLSL) with animation event callbacks.

Instanced, animated, Tiny’s

Network Programming
Network programming involves making a game (I am using C# and XNA) which can have 4 or more players playing over a network. I am making a 4-player version of Asteroids and currently have the “player-chat” lobby part of this working, as well as a nice framework for handling application layer packets.


Main lobby

ARP
My dissertation is on the topic of “Visual Scripting Systems for Games”. Not much to report on this yet since it has been mostly research based so far.

Insimnax Framework
The Insimnax Framework is a game framework I am currently working on which makes heavy use of OGRE 3D. The framework itself is currently a wrapper to make getting started and using OGRE 3D easier, although I have plans to extend it by adding “systems” such as GUI, Physics and Audio. I am currently using this framework for my AI project and hope to use it for my dissertation too. I plan to release it under an MIT license once it has reached a decent (and somewhat stable) stage of its development.

… and finally
Oh yeah, did you hear about Epic releasing the UDK for free?! Crazy!

Templates and Streams; the perfect couple

Recently I’ve been doing some work templatifying my two I/O classes, and from that have come to the conclusion that templates and streams make for the ultimate generic programming tool. Previously I had a load of old duplicate bloat code in these classes, that was all removed and replaced by one templated member function, and two specialised template functions from it, and best of all since this code is now able to take external streams as input/output sources, it means that I no longer have one code path for handing files, and another code path for serialising to memory. Instead I just pass an fstream when working with files, and a stringstream when I want to serialise to/from memory, simple!

One of the best changes the templates and streams has made is to my tryParse function. Previously there were a load of these, each handling a different variable type using old C functions. Now the function has been replaced by a single templated function, and a stringstream. If you try and tryParse a type a stringstream can’t handle, it just doesn’t compile, best of all is that you can still expand the function using template specialisation if you want to tryParse to your own custom types.

//! Try and parse a string to another type
//! \return true if the conversion was ok, false otherwise
template <typename T>
bool tryParse(
	const std::string &str,		//!< String to convert
	T &out				//!< Output variable
	)
{
	std::stringstream sstream;
	sstream.exceptions(std::ios::failbit | std::ios::badbit);
	sstream << str;
	try { sstream >> out; }
	catch(std::exception&) { return false; }
	return true;
}

I actually worked out the total number of lines of code before, and after my changes. The results are below:

Old:
Reader 		- 183   (header) 1,042 (source)
Writer 		- 209   (header)   839 (source)
TryParse 	- 50    (header)   115 (source)
Total 		- 2,438

New:
Reader 		- 271   (header)   351 (source)
Writer 		- 226   (header)   245 (source)
TryParse 	- 30    (header)     0 (source)
Total 		- 1,123

Quite impressive :) (Although I did cheat slightly since the new reader and writer have a macro which removes a lot of code repetition from the header, it probably saves ~39 lines of code from each class, so ~78 in all. Still that would only make it 1,201 lines of code which is still a huge saving for something that has more functionality with less code).

[C++] Anything to/from a Hex String

Introduction

I recently needed to be able to convert any instance of an object in C++ to a file so it could be serialised, and then restored later; I did most of this by writing out each member variable of the object individually at the most basic level. This works fine and is easy enough to implement; but then came the time to do the “generic” version, the version that could write out any object (such as a struct) as a whole.

The I/O classes can write out/read in using either binary or text, the binary version of the generic writer is simply a case of writing out the length of the data, and then each byte of the data. The text version however required me to convert the bytes of data making up the object into something that was sensible as text, I decided to do this by converting each byte into a hex value and adding it to a string. As I was working on this I found that the information about how to do this without using some of the old C-style string manipulation functions is quite sparse on the net, so after much searching, trying, and failing, I now have a solution that works both ways using good old C++ string streams.

I should probably point out that I don’t think this solution is endian neutral, so you would likely want to add a method of endian detection and switching to ensure consistency across different architectures.

The Code

When a byte is encoded to hex string, each byte becomes two characters in the range 0 to F. For example, the value “10” would be written out as “0A”.

The code works by using a std::stringstream with hex mode set (std::hex), along with using zero’s for padding (std::setfill(‘0’)) and a fixed width of two for each byte added as hex (std::setw(2)).

The toHex function works by adding each byte of the passed data into the string stream as an integer with a width of two; because zero’s have been set as padding, any numbers which are added to the stream that are only one character long will be automatically prefixed with a zero resulting in the correct two character hex value being added to the string stream.

The fromHex function works by reading out two characters from the hex string into a string stream, these characters are then converted back into the byte value when read out from the string stream into an integer. Finally, the value of the integer is stored as the value of the byte, and the string is moved on to the next set of two characters.

Get the code.

Rant Tags On

Warning: Rant ahead, if you are a PS3 fan-boy stop reading now. I don’t need your hate.

For my birthday this year I bought myself a PS3 to go with my nice new 42” 1080p HDTV, this now completes my collection of current generation consoles as I also have a 360 and a Wii so I can tell you that this opinion comes from someone who isn’t biased to a particular console. So why did I buy it? Two main reasons, I had a shiny new TV and wanted to see what all the fuss about Bluray was, and I also wanted to play WipEout HD; now leaving aside the fact that buying a console that cost almost £300 to play a £14 game is perhaps a sign of insanity on my part, I have to say my experience so far has been mostly good, bar one thing, “installing… please wait”.

I believe this video (32 - 38 seconds) pretty much sums up my opinion on installing games on the PS3. A friend from work lent me some games to play, one of which was GT5, I had 10 minutes spare before lunch so I thought “Hey, I’ll give it a go”… WRONG! It took 10 minutes just to install the damn thing to the hard drive (what the hell is this, a PC?!) and then took another 20 minutes to download and install updates; perhaps I wouldn’t have minded so much if the hassle of getting the game to play was worth it, but it distinctly wasn’t and I only played the game for about 10 minutes before moving onto another game I had been lent. The most amusing thing about the near constant updates, is when I bought WipEout HD from the PlayStation Store, downloaded it, went to play it and was told that there were five updates for the game… I’m sorry, but I just downloaded over a gigabyte of data and now I need to download more?! Why can’t you just update the version you have on the PlayStation Store so that I don’t have to bother with this? Oh right, yeah, that would make sense wouldn’t it; can’t have that.

Oh, and just don’t get me started on the XMB. No seriously, don’t.

Rant Tags Off

So to be fair to the PS3, I said that my experience has so far been mostly good (although I have a feeling this is because I haven’t tried to do anything complicated with the XMB yet). I guess my good experience comes from the fact that there are a few games I enjoy playing on it, and also the fact that I can use my debit card in the PlayStation Store which is something I can’t do in the XBOX Marketplace (they don’t accept Maestro cards).

The games in question are WipEout HD, and Ratchet and Clank. As I said before, WipEout HD is the main reason I bought a PS3, so finding out last week that there was going to be a DLC expansion for the game caused me to almost go running around the office like a crazed fangirlboy, the trailer for the game is below. Can’t wait to try Zone Battle and I really hope their definition of summer is more towards the start of summer :D

I have never played a Ratchet and Clank game before this one, and I feel now that I have been missing out. I love it! The humour in the game is fantastic and somewhat dark (which is also the main reason I love Portal so much) and I’m having a great time playing it, even despite the fact that I sometimes get stuck (game play wise) in a level, and that the enemy collision detecting often screws up a bit leaving them stuck (physically) in walls.

Fences and what I do

I’ve taken to using Twitter to post updates on since I can do it more informally and whenever I feel like it.

Firstly, I’ve been using a program called Fences to help sort out my desktop icons and so far I’m finding it really handy to be able to group up my icons and not have Windows randomly decide to re-arrange them for me… bliss. You can see my desktop here.

Secondly, BlitzTech (where I work) has released a video of some of the features of the BlitzTech SDK, including the Scripting and Behaviour (State Machine) system which I am currently responsible for developing and maintaining. If you want to see what I work on on a day to day basis then you can find the video here (it’s the “Tools Demo” one).