Particle effects


At the beginning I want to say that approach mentioned here in my earlier post – so creating sequences of frames consisting for full animation of explosion was totally wrong. After creating one explosion animation in ExploTexGen or Particle Illusion, I wanted to have more of these. So simply I started to create another fixed animations. What was th result? TGA files weighing over 2MB each with poor scalability and repeatable look. It wasn’t too efficient way to produce graphics effects. Additionally, I spent a lot of time on creating, exporting and transforming to looping animation.

So, I decided to create my particle system which could create various effects. Firstly I was thinking that I can use Bullet physics engine to simulate particles without collision. But then, I found that Bullet is calculating too much – too much for simple movement with gravitation, without any collision response. So I am calculating trajectory of  particles by myself. Each particle emitter has 20 parameters which determine appearance of spawned particles. most important of them are:

  • size of particle ( more precisely it is side length of textured square )
  • texture – it can be really small, I’m using 8×8 and 16×16 pixels
  • color – RGBA  begin values
  • lifeTime -as the name suggests, it is time after which particle is removed
  • dieTime – time after which particle begins to die, so it’s color and size starts interpolating to dieColor and dieSize
  • frequency – amount of particles

Full options visible on screenshoot.

It can be used for simulating things like:

  • fire
  • smoke
  • wind steams
  • rain, snow
  • explosion
  • blood
  • falling leaves from trees
  • spells, sparks
  • teleports
  • magic areas
  • waterfalls
  • fountains

As well as lot of other things which I can’t now come up with. What is important is that these various effects are produced / simulated in the same way but with different parameters ( so, logic for falling leaves is the same like in simulating fire or gas steam but final effect is totally different). Moreover, the design of new graphical effects is fast as hell. All particle emitters shown in the video bellow were created in less than 15 minutes. Of course everything is integrated in my world editor (new section added)

On video You can see examples of particle emitters and at the end – gas stream which is also forcefield and source of sound

triggers, switches, levers – custom actions


Last time, I started to make my game more unpredictable. To achieve that i created my internal “script language” which is integrated into my editor and allows me to make custom actions. For now I see many uses, for example :

  • controlling moving platforms
  • opening doors
  • spawning monsters  (yep, monsters are already implemented)
  • changing music, playing suitable sounds ( mystical sound when when entering the room)

How it’s made?

Simply, first in editor I create my level, next i write formula on new script window ( yeah, it will grow to  something like UDK 🙂 ) then I can attach this formula to any object on scene like bottom of switch. After that my chosen object gains new functionality, which is executed every physics update. Especially, typical  trigger checks every update if something collide with it, than if collision occurs, it executes selected action e.g. formula like :

[sourcecode language=”cpp”]

mean,  if something touches the object then reverse motor of object which name is “OBJ1″. Of course OBJ1 must have joint with motor enabled, without that nothing will happen. And one more thing is needed to get it to work – object OBJ1 must exist on scene, so we must choose object and name it:

[sourcecode language=”cpp”]

Of course formulas can be combined to give various effects like:

[sourcecode language=”cpp”]

reverse motor at OBJ1 and reverse motor at OBJ2. This is used in post video – opening horizontal gate
Or something like that:

[sourcecode language=”cpp”]

which can mean:  reverse motor at OBJ1 (open door) then wait 5 seconds (300 * physics fixed time-step (1/60 sec) ) then again reverse motor at OBJ1 – close the door. So player have limited time to pass through the door

Switches are made with usage benefits of bullet. Simply capsule-like shape with motor which pushes object in certain direction. Power of motor can be adjusted to the needs. If something is lying on capsule and it’s enough heavy to break power of the motor than it triggers the action. Other type of switch is made with weak motor and it triggers action twice: on collision begin and collision end. The difference of this two switches You can see on video.

Lever is a tricky part.  Every mechanics/logic work beyond eyes of player – lower part of lever  is obscured by non colliding terrain. In fact lever is composed of stick anchored in the middle and the trigger which is waiting for hit. And the only on object which is able to knock it is of course previously mentioned stick.

Especially, trigger doesn’t need to have graphical representation like switch or lever, it can be  also invisible trigger which can create situation like suddenly closed doors after entering new location and played scary sound.




Ps.  Success! first not jerking film!

ropes and ladders

I specialized a new type of object, that allows to stick on it. After physics tick if player wants to catch object, I’m looking on his physics object contact points and simply if there is something to grab – just stick together by adding suitable constraint in right place. When player is sticking something then I unlock his jump possibility, which gives ability to climb. In the video bellow you can see two climbing/sticking models, and as you probably noticed they are not behaving in typical way. I mean specifically that they don’t collide with other objects (especially with player)

in bullet, for turning off collisions per object you can do such things:

  • specify collision group and collision mask while adding object to the world via

[sourcecode language=”cpp”]
btDynamicsWorld::addRigidBody (btRigidBody *body, short group, short mask)

but this is not the way, I use for my ropes, because it prevents collision in very early stage and contact points are not generated for these objects

  • set CF_NO_CONTACT_RESPONSE  flag while constructing body

[sourcecode language=”cpp”]
mBody->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE));

contact points will be generated,  so if you don’t need them use previous method because of performance. My sticking objects use this method to let know about ability to grab

sound, springs, trees and bushes

Ok, at last my game prototype has audio. To achieve that I used SDL_mixer which has quite easy api, and with this wasn’t problem. More difficult part was to determine when certain sound must be played. Of course I am not writing here about trivial cases like player jump, or when player shoots than play “boom” sound. The difficulty is in physics based sounds because of collision ambiguity.  I created two types of physical sound:

  • first is  impact sound e.g.  when box falls to the ground
  • second – sound of scratching e.g. when some object is sliding on ground

All this you can hear on video (sound was recorded little too loud, so there are some defects )



On the video you can also see upgraded graphics. Adding some plants can really refresh game appearance,  they don’t have physical body they can be displayed behind or before player (hiding places). They are only purely cosmetic aspect.

The last new thing is the spring implemented from bullet physics engine, which may have various frequency of oscillation.

Now I must think about player improvement. I am thinking about creating him legs or feet 🙂

incredible machine

Hello everyone!

Officially I must say that youtube sucks so much.. I moved to vimeo, which is great. Video is put on their site exactly as it is (some jerkiness on video below is from my fault). On the beginning you can see my new feature – forcefields that push objects inside them in chosen direction, here through the “pipe”. On the end, you probably won’t be able to see that (I zoomed out too much) but player is talking(ya, really! he reacted for ball hit). It’s my new target – to create logic-adventure-physics based-platform game with plot.

Terrain destruction vol.3

Finally, physics destruction is completed, I have reduced number of triangles per object to necessary minimum by storing object envelope in it. Than when collision occurs I make geometric difference between ground and explosion vertices, in this example it is simplified circle, but it can be everything (just imagine laser which creates deep but slim holes – great for passing). Final concave polygon is triangulated. Graphics and physics store the same triangles and as far as that’s good for graphics is not as efficient for physics (convex polygons are better)

Another new thing is the animation, created using ExploTexGen. It can generate texture that contains  sequence of smaller images. I only have to manipulate texture coordinates to jump to the correct place – position of the next frame.

Here is video where you can see this news. In middle of film you can see bullet controlled by mouse (I stopped simulation then grabbed it) Ps. youtube screwed my video : (