Friday, 6 December 2013

Ogre Particles Scipts

In our game, Bullet Devil: Attack of the Elements, we will be using the particle system with the Ogre engine. What we will be mainly using them for is to show off the effects of our elemental attacks in the game. One of the core mechanics we have in our game is the use of elements, where elements counter each other to deal extra damage as well as have unique effects. Other uses for the particle system is to create more appealing visual effects on things such as when a player shoots, or for our enemies making them look more fantasy like.

Currently, in our game we have 1 working particle effect that we are quite satisfied with, and that is our ice effect which has blue snowflakes and moves upwards around a character. What this effect shows (and what other elemental particles will show), is that that character (player or enemy) has been hit with that elemental attack and has a status effect now.


Ogre Particles uses their own scripts to setup attributes for their particles. These attributes include the amount of particles the user wishes to emit, the size of the particles, the type of emitter, the velocity of the particles, and many other attributes. By changing values and adding new attributes to their particle script, the user can create a large variety of particles.  

To create a particle script, the first thing the user must do is to create a text document but instead of ending the file name with .txt, the user should end their text document with .particle because ogre parses .particle files automatically. In the ogre particle script there are 2 main parts, the particle properties section and the emitter section. The particle properties section deals with the size of the particle, the amount of particles to be created per emitter, how many emitters the user wants. The emitter section has the type of emitter (usually box or point), the angle of where the particles will be emitted from, the rate that they will emit, the time each particle will live, the up direction of the particles and velocity. Of course there are many other attributes but these are most commonly used for most particle systems. 




This is a fireworks particle script using ogre particles. One thing unique about this script is that there are 2 emitters, this is because for fireworks, there are 2 parts to it, when the fireworks are shot into the air, and then the explosion. The affectors are what functions that will effect the particles in some way. This specific one interpolates 2 colours together to change the particle from 1 colour to another. 

The first thing in your .particle file is to write what your particle script will be called at the top of your file using particle_system particleScriptName{}, replacing particleScriptName with the name of your own particle script. Next is to get a material or picture of your particle, from a separate .material file (can also be edited with a text editor). Particle_width and particle_height change the size of the actual particle. Quota is the number of particles to be emitted. Billboard_type is how the particles will be rendered and orientate, the point billboard is used if you want the particles to orientate towards the camera. 

For emitters, you start with the emitter type, in this case it is a box, so the script is emitter Box {}. The first attribute for this box emitter is the name of the emiiter. This emitter has a special case because it emits a second emitter called explosion. Angle deals with the range where the particles can spread, 0 being one direction to 180 being the around the emitter. Emission rate is how many particles per second should be emitted, (I've found out from my own experience and asking someone else that your emission rate should be 1/10 of your quota). Time_to_live is self explanatory. Direction is where the up vector is for your emitter. Velocity is the speed of your particles. 

There are many more attributes to explain and most of them have a predefined value when they are not defined in the script itself or in some cases, if the values are set to 0. I can't explain every single attribute for ogre's particle script but they all can be found through Ogre's manual from their SDK (which I use frequently). It has many attributes that I still haven't tested myself, but I do plan to experiment with these to create more interesting particle effects.




No comments:

Post a Comment