Time for another post and another experiment. I was just reading an interesting paper called Procedural Techniques For City Generation by some chaps in working at the ITB in ireland all about how to generate completely algorithmic city plans given a starting point and a landscape to build on. The image below shows an example of some of the stuff that can be produced with these algorithms and it truly is amazing!
Anyway I thought I'd step back a bit and try to produce some of my own landscapes to start with, and then move onto road generation and finally buildings. Its always nice to start with the easy stuff, that way I find at least I get something done!
Since the actionscript random function generates a new random seed each time a program is run I decided to use a custom random number function which could take a seed. The generator I used is the Park-Millar-Carter PRNG which is ideal for the job. I like the idea of using words (like in the original worms) as seeds so using an input string, eg "Terrain1" and then taking an MD5 hash of it, converting this into a number provided a constant seed for a word. The seed would generate every piece of information in the same way every time, very useful when you find an interesting image.
So I built this in then created several layers of bitmap data, each with different resolution with each pixel on each grid set to a random value (in the range [0,0xFF]). The resulting addition of all the bitmaps would produce the data for my final landscape. Here are a few examples of the kinds of landscapes I was able to produce:
To me the third image is a spitting image of europe, with spain, germany and france and even the UK to the very top left! I'm quite happy with the results all in all. To try out the app for yourselves just click here, enter a keyword, and press generate!
Next Step, build some roads!
Friday, 29 January 2010
Terrain Generation
Labels:
AS3,
Emergence,
Flash,
procedural generation
Saturday, 16 January 2010
Anaglyph Raytracing
I made a few changes to the raytracer I've been designing to create anaglyph images, that is two channel 3D images. The changes are very simple, literally two black and white images are drawn from slightly different angles, then one is tinted in cyan, and the other red. I don't have any 3D glasses but it should work. If anyone has some check out the test image below!
I'll try to produce some more images like this and get a pair of glasses to test with. Imagine realtime anaglyph raytracing!
I'll try to produce some more images like this and get a pair of glasses to test with. Imagine realtime anaglyph raytracing!
Sunday, 10 January 2010
New! - Recommended Books
I've got together a list of books related to flash and learning AS3 you might like. These will permanently stay in the right column but right now here are a few of my favourites:
As a general guide to getting started in AS3 the following is great. I would recommend it for beginners though:
Essential ActionScript 3.0 (Essential)
For anyone interested in game design this is a fantastic and comprehensive guide:
ActionScript 3.0 Game Programming University
More on the theme of this blog one of my favourite books of all time. The Author Phillip Ball discusses connections between the natural world and various mathematical models that describe them. I still find it a great source of inspiration for various experimental flash projects that I have worked on recently!
Critical Mass: How One Thing Leads to Another
Like I said from now on there will always be a list of books to the right!
Get reading folks :)
As a general guide to getting started in AS3 the following is great. I would recommend it for beginners though:
Essential ActionScript 3.0 (Essential)
For anyone interested in game design this is a fantastic and comprehensive guide:
ActionScript 3.0 Game Programming University
More on the theme of this blog one of my favourite books of all time. The Author Phillip Ball discusses connections between the natural world and various mathematical models that describe them. I still find it a great source of inspiration for various experimental flash projects that I have worked on recently!
Critical Mass: How One Thing Leads to Another
Like I said from now on there will always be a list of books to the right!
Get reading folks :)
Subscribe to:
Posts (Atom)