Lovin LINQ

December 12th, 2011 by

One of the many joys I get from programming is creating beautiful LINQ expressions in C#. This is one I made today to create a random sequence of integers containing a few doubles. The Shuffle method is an extension I wrote a while back. It basically creates a random order of an Enumerable.

itemsInOrder = Enumerable.Range(0, itemCount)
                .Concat(
                    Enumerable.Repeat(
                        Enumerable.Range(0, itemCount), doubleOccurance)
                        .Aggregate(Enumerable.Concat)
                        .Shuffle()
                        .Take(numDoubles))
                .Shuffle()
                .ToArray();

Gotta love those things.

Animations Part 1 – Sprite-sheets

November 17th, 2011 by


Our engine supports 3 types of animations: animations from code, sprite-sheet animations and skeletal animations. The idea of the first system is to allows programmers to define simple animations like changing a value over time.
Sprite-sheet animations are simple animations that show a different image every so many milliseconds. This type of animations allows artists to paint each frame of the animation to create super complex animations. But it also takes much more time to create smooth animations because an artists has to create a lot of different images to make the animation look smooth. This is where the third system comes in.
Skeletal animations are probably the most complex animations. With this system an artists creates a skeleton consisting of bones, attaches sprites to each bone and then animates the bones. Then the artist creates snapshots for the skeleton at certain moments in time and the system interpolates between these snapshots. Because of this interpolation the animation looks perfectly smooth.

In this 3 part blog I will elaborate on each of the systems. I will describe how they work and I will show you how we have supported our artists with the tools they require. I will start with the simplest system namely sprite-sheet animations, then I will continue with animations from code and last but not least I will describe skeletal animations.

Lets start by defining what a sprite is. In Computer Graphics, a sprite is a two dimensional image that is part of a larger whole. Sprites are used a lot, for instance for characters and items in the world. The entire game world probably exists of sprites.

Lets take a simple example. Take this red box on the right. This is a simple object that is placed somewhere in the game world. Now lets say we want to animate the red box and use it in our engine. The animation we want is to turn this red box into a blue box as if paint is dripping on it. This is a typical example were sprite-sheets work great. A sprite-sheet contains multiple sprites that are all displayed in a specific order at a specific time. The sprite-sheet to turn the red box into a blue box is shown below.

We mostly use GIMP for drawing and with it creating an animation like this is very easy. The script found  here simply creates the sprite-sheet for you from the different layers in your file. All that is required is that you paint all the different frames seperatly and put them in to seperate layers.

The next step in creating an animation with sprite-sheets is to get the animation in game. However, before we can load the animation in the engine we have to specify when to show which frames of the sprite-sheet. We created a simple tool to do this. With this tool an artist can set a sequence of frames and the time a single frame is shown. It also shows a nice preview of the animation.

The tool creates an .anim file which our engine can load. With this file we can place the box anywhere we want in our game and we can animate it whenever we want. That’s really all there is to it. And here is the result.

The advantages of using sprite-sheets for animation is that you have a lot of freedom because you can really paint whatever you want. The disadvantages are that they take a lot of time to create, they take up much more memory compared to the other animation techniques I will describe and you often require a lot of frames to get a smooth animation. We did use them a LOT in lamapalooza, though.

Next time I will talk about animation from code which will be (a lot) more technical. I personally LOVE that system because of its flexibility and ease of use. Hell even sprite-sheet animations use that system.

See you next time!

My first attempt at drawing

October 31st, 2011 by

I got meself a tablet cause I want to learn to draw just a little. I think its important because it allows me to visualize what I think better than some text and I think drawings are a great communication tool. So here is my first drawing.. Tell me what you think! But remember respect is everything!

 

Particles

October 27th, 2011 by

Nowadays almost all games feature some form of particle systems. Particle systems are simple effects that add enormous detail to a game. Particle systems are used to model effects that are otherwise very hard to model. Think of things like explosions, fire, portals, sparks, etc. Ronimo’s upcomming game Awesomenauts is packed with particle effects and it really adds to the feel of the game.

We are also plan to use a lot of particle effects in our game to simulate things like campfires, smoke, wind blowing, butterflies, dirt falling of things and stuff like that.

For a previous project I also created particle systems. The system worked beautifully from a programmers perspective. I pulled all optimization techniques from my bag of optimization techniques; from being task based multithreaded to very ugly pointer hacks (which can still be beautiful). However, in the end the system was way to complicated for our artist (Adriaan). Mostly because he had to modify a XML file, rerun the application and see if the changes he made looked good, this took way to much time. Here is a screenshot of the end result:

Creating a particle effect requires a lot of itererations and therefor doing a single iteration has to be fast. Very fast. Ideally, the way to do this is by using a WYSIWYG editor. So I went looking around for what is available on the webs. There are quite a few good particle system engines available like Mercury Particle EngineParticle Universe and the particle system in Ogre3D. Mercury Particle Engine is a great library for XNA but it lacked a lot of features we were looking for (emitters emitting emitters for example). In the end I decided I’d build the system myself simply because I could very easily integrate it in our technology and support all the features we want. I have also build a WYSIWYG editor so our artists can create these effects in a super short time. All in all it took me about a week to create the system and the tool (although its not completely finished). Anyway here are some screenshots from simple particle systems created with the editor and one of a particle systems in the editor.

That’s all folks! Let me know what you think! :)

– Bas

 

 

 

Progress on the landscape

October 11th, 2011 by

Above is a screenshot of one of my tests with the landscape. The most fancy thing about this terrain is that it is completely made up of bezier curves. With bezier curves we can make the terrain look super smooth no matter how much the player wants to zoom in. The curves are rendered on the GPU using Loop-Blinn’s technique from GPU Gems 3. I adapted the technique a little bit to render both convex and concave curves in one draw call. This technique is super fast but the area below the surface of the planet has to be filled too. This requires not only generating triangles for the curves but also for the interior of the planet.

The above image shows the triangles that my simple algorithm (for now) generates. Using this algorithm, the triangles can be generated in real-time (takes 0.5ms currently). It will get a lot more complex though because we have to add different layers of cover (rocks, grass, snow), vegetation, water and probably a lot more. But as long as I don’t let the designers go completely crazy it will probably work out. :)

The above screenshots may not look that pretty (as its a development shot) so here is also a little artist impression of what the game could look like in a few months time.

Cheers!

How it probably will look like...kind off