Category Archives: Development

Bounding box corrosion test in Unity


Using bounding box boolean to create a random 'subtraction' effect. Applied to a pretty standard octree scene management system.

What's happening is basically the program is 'cutting' into the objects in the scene and generating new replacement parts (new bounding boxes)

The goal of this test is to just make sure the logic is sound.. not very efficient.

Next power of 2..

I came across this little snippet of code* to find the next power of 2 and found it quite helpful – from what I understand it's also very efficient compared to other methods.


public int NextPowerOfTwo(int inInt)
 inInt = ( inInt >> 1 ) | inInt;
 inInt = ( inInt >> 2 ) | inInt;
 inInt = ( inInt >> 4 ) | inInt;
 inInt = ( inInt >> 8 ) | inInt;
 inInt = ( inInt >> 16 ) | inInt;
 inInt++; // Val is now the next highest power of 2.
 return inInt;


Link to original article regarding technique and actually a more detailed explanation of the method – Acius' Snippets.

Galcon Unity Visualization (fifth pass)

So I created a quick planet texture (loosely based on a moon type texture) and added some functionality to make the ships to move towards the planets with a slight shift along the tangent – which basically means that fleets sent out and fleets incoming wont line up on top of each other so you can distinguish between the two.

The real big change is a added functionality to center and scale the camera viewport based on the map size so in theory this visualizer can handle any map of any size and it will stay centered and not clip off the screen.


moon texture

phase 5


Right now there seems to be a selective Unity bug that wont let me display instanced objects in the web viewer :'(.  I bugged the Unity guys and hopefully they'll release a patch soonish.

Galcon Unity Visualization (third pass)

So i cleaned up some of the code and added some aura type objects behind the planets. This really is so I can have a more subtle color on the planet without losing the indication that the planet has been converted.

phase 3

Seems like some of the auras are doubling up on the blue side – something is causing them to change hue.


Next up I'm going to work on getting some UI controls: "play", "pause", "goto beginning", "goto end"

Galcon Unity Visualization (second pass)

Added GUI text components for the planets and the fleets. I tried with 3D text but the results are true 1:1 pixel ratio for the text rendering so you get aliasing artifacts.

To get the GUI text in the right position I had to do a double transform. Once to Camera pixel space and then to camera viewport space (basically 0,0 to 1,1 extents representation of the viewport)

Vector3 screenPos = gameCamera.ScreenToViewportPoint(gameCamera.WorldToScreenPoint(pos));


second pass

Oh and I whipped up a quick ship model to use rather than the capsule I was using before


Galcon Unity Visualization (first pass)

So in the time while I waited for GoDaddy to update my wordpress I've managed to get a pretty basic implementation of the visualizer in Unity 3.0.

Right now it splits the game data string into rounds and creates a unique 'planet wars' object per round (List<PlanetWars>) – cloning the planets for each round and updating the owner and number of ships as well as creating the unique fleets for each round.

The 'CreateScene' function takes that array and creates a collection of GameObjects for the planets and fleets as needed.

It's creating and destroying the whole scene (planets, fleets etc) each round which isn't really a problem but pretty inefficient.

I need to add text rendering to show the numbers on the planets and fleets to show ship counts.

Unity 3.0 is pretty straight forward to get something like this up and running, however I am having a problem with Monodevelop on my PC.  It doesn't seem to want to debug properly. I mean I can start the debug session and everything it's just if I modify any of the source code Unity looses all responsiveness and stops being able to progress.  I think it has something to do with the recompile process because it only happens when I make a change to one of the scripts :'(.

Google AI Challenge (Galcon)

I'm having a go at the AI challenge over here it's being organized by the University of Waterloo Computer Science Club and sponsored by Google.  

The task is to make a bot that can play a random game of Galcon ( so far my bot is doing just OK ( I've got the core architecture sorted out and am slowly working on the correct decisions to be made based on the metrics I'm deriving from the state of play. Honestly if I finish in the top 100 I'll be ecstatic, there's some really talented guys in the competition.

Anyway they have a couple of visualizers which are nice (i.e. but I thought what if I made a visualizer with Unity.  It's a pretty good engine for doing stuff like this. So the next few posts will be me chronicling my development of a Galcon visualizer via Unity.

google AI thumb




Download the latest zip packages here:

Windows here.

Mac here.

Renaming objects in Maya (advanced)


[Download Script]


This is the third part to a three part tutorial on renaming objects in Maya.  In the first installment we established a collection of procedures and a simple UI that allows multiple objects to be renamed. In the second installment we evolved this tool to utilize an custom sorting method and improved the UI.

The previous system for sorting while functional limited our ability to do more sophisticated renaming. We're going to address these issues and introduce a neat system for managing object lists:

  • Ultimately we want to support an extended set of rename options (Prefix, Suffix, Find & Replace, exclusions) along with the standard rename and numeric incrementation

Continue reading

Renaming objects in Maya (intermediate)


[Download Script]


This is the second part to a three part tutorial on renaming objects in Maya.  In the first installment we established a collection of procedures and a simple UI that allows multiple objects to be renamed.

Some issues were identified with the methods used previously and so in this next stage I'm going to evaluate the procedures and improve the script. Specifically this tutorial will address the following issues:

  • The previous script is a handy quick renamer but doesn’t always produce unique names for all objects
  • Numerical increments with good padding options
  • The UI was over simplified and could be improved with more options

Continue reading