Devil Particle System - Manual
This is a manual which shows, how to handle the Devil
Particle System. It explains the engine step by step. From the first effect to
complex game effects.
The vocabulary
I just want to explain you a few "vocabulaires", to understand the manual.
| Emitter | An Emitter is an entity, which produces particles. |
| Template | A template is a list of properties for the emitter. You have to set up a template with properties like movement, rotation, color, textures and so on... Then you can provide an emitter with the template. |
| Particle | A particle is a sprite which is textured with a texture like a cloud or a spark. In this system aren't any sprites used. Indeed not! This is such slowly... Here are all particles of an emitter in one mesh(in one surface). This is the reason why this is called "single surface particle system". |
Engine setup
Well, like in most of the blitz engines, you have to initialise the system in
the beginning, and you have to delete it after using. Well, this is no exception!
Here is a simple program, which shows, how to create a very simple particle fx:
| Include "DevilParticleSystem.bb" Graphics3D 1024, 768, 32, 2 SetBuffer BackBuffer() ;Camera Cam = CreateCamera() ;Initialise particle system InitParticles(Cam) ;Create a template with the following properties: ;the commands like SetEmitter...() will be explained soon! template = CreateTemplate() SetTemplateEmitterBlend(template, 1) SetTemplateInterval(template, 1) SetTemplateEmitterLifeTime(template, -1) SetTemplateParticleLifeTime(template, 30, 45) SetTemplateTexture(template, "Media\Smoke.png", 2, 1) SetTemplateOffset(template, -.3, .3, -.3, .3, -.3, .3) SetTemplateVelocity(template, -.04, .04, .1, .2, -.04, .04) SetTemplateAlphaVel(template, True) SetTemplateSize(template, 3, 3, .5, 1.5) SetTemplateSizeVel(template, .01, 1.01) ;Set up an emitter emitter = CreatePivot() ;The emitter can also be a mesh(don't have to be a pivot!) SetEmitter(emitter, template) ;Sets the template which was created to this emitter pivot ;Main loop While Not KeyHit(1) PositionEntity emitter, Sin(MilliSecs() * .2) * 5, 0, 10 ;move the emitter UpdateParticles() ;Updates the particles and the emitters RenderWorld Flip Wend FreeParticles() ;Destroy the emitters, templates And particles End |
Just run this code and you will see: It isn't really
difficult to create you own particle fx. Read the comments and try to understand
what the functions means. If you already understood the code(except the
functions like SetTemplate...()), you can try to change a few values, to see
what happens. If you feel, you are for the next step, just read further!
The template properties functions
Now, we will try to understand those functions. They are for the properties of
the template. Just read one row of the table, try to understand. And then you
can try to change the sample above with your new knowledge!
| SetTemplateEmitterBlend(param1) | You know, that every particles of an emitter are packed into one entity(into one surface). This command sets the blend mode of this entity.4 |
| SetTemplateInterval(param1) | This command decides about the reease rate of the particles! If param1 is 1, every loop a particle will release out of the emitter. If param1 is 5, in 5 loops one particle will release. That means, the bigger param1 is, the less particles will release. |
| SetTemplateParticlesPerInterval(param1) | If you want an emitter to release more then one particle per interval, you have to use this function. What "interval" means is explained up there. This function decides, how many particles will release per interval, so you have got full controll about the particle release rate! |
| SetTemplateMaxParticles(param1) | If you want an emitter not to release more than 500 particles for example, you have to use SetTemplateMaxParticles(template, 500). So there won't be more than 500 particles on this emitter. |
| SetTemplateParticleLifeTime(param1, param2) | This command controlls about the life time of the particles. The life time of a particle means, how many loops a particle will live. A lifetime of 50 means, that the particle will live 50 loops. The life time of a particle will be Rand(param1, param2) |
| SetTemplateEmitterLifeTime(param1) | This commands controlls the life time of the emitter. Similar like in the command above, this command decides, how many loops an emitter will provide particles. If param1is -1, the emitter will provide particles for ever(until FreeParticles() is called) |
| SetTemplateEmitterTexture(path$, filter, mode) | If you want to texture the particles, you have to call this command. It will texture all particles of the emitter with the texture, which has been loaded from the path. You can set the texture filters and the texture blend mode. |
| SetTemplateOffset(min_ox#, max_ox#, min_oy#, max_oy#, min_oz#, max_oz#) | This is the start offset of the particles. When a particle is created, the position will be the coordinated of the emitter, and they will be offseted by those values. |
| SetTemplateVelocity(min_xv#, max_xv#, min_yv#, max_yv#, min_zv#, max_zv#) | This command sets the velocity of the particles. The particles will be translated by those values. |
| SetTemplateRotation(param1#, param2#) | This is a movement command, too. It rotated the particles. The rotation velocity of a particle will be Rand(param1, param2) |
| SetTemplateAlignToFall(align_to_fall, align_to_fall_offset = 0) | This command lets the particles align into the fall direction. This command is needed for spark effects. Set align_to_fall to true if you want them to align into the fall direction. align_to_fall_offset will be the rotation offset, the particles will have. The command SetTemplateRotation() will be ignored if align_to_fall is true! |
| SetTemplateGravity(param1) | This command sets the gravity to the particles. Normaly they don't have any gravity. |
| SetTemplateSize(sx#, sy#, sx#, sy#, size_multiplicator1# = 1, size_multiplicator2# = 1) | This command sets up the size of the particles. Every particle has got its own size multiplicator. That means that te size multiplicator of each particle will be Rand(sx#, sy#, size_multiplicator1# = 1, size_multiplicator2# = 1). |
| SetTemplateSizeVel(size_add#, size_mult#) | This command decides
the size velocity of the particles. The particle sized would be changed
like this: SizeX = (SizeX + size_add#) * size_mult# SizeY = (SizeY + size_add#) * size_mult# |
| SetTemplateAlpha(param1) | This command is pretty easy. It sets up the alpha of each of the particles. 1 Means full visibility. 0 means not vilibly. The default is 1. |
| SetTemplateAlphaVel(param1) | If param1 is true, the particle alpha will fade out. If it is false, the particle will not fade out. |
| SetTemplateColors(param1, param2) | This command sets up
the particle colors. Param1 is the start color, and param2 is the end
color. The colors will be interpolated linear. Warning: The colors must
be hex values, for example: SetTemplateColors(template, $FFFFFF, $FFA300) |
| SetTemplateBrightness(param1) | If you want a particle to be more bright, you have to use this command. A brightness of 1 is a default brightness. A brightness of 2 is 2 times more bright, and so on... But don't choose a value which is to large, because this could slow down the game. |
| SetTemplateFloor(param1, param2) | param1 is the y coordinate for the particle floor. That means that particles will not get below this y coordinate. They will bounce up when they reach this coordinate. param2 is the bounce. A bounce of 1 means that the particle will jump as high as deep it falls. A bounce of 0 means that the particle won't jump up. |
| SetTemplateFixAngles(pitch_fix, yaw_fix) | This command is needed for rain. In a template for rain, the particles are pitch-fixed. That means, that the particles are fixed in the pitch axis, so the camera pitch won't change the pitch of the particles. This is also possible with the yaw axis. |
| SetTemplateSubTemplate(param1) | If you want a template to have a sub template/template slot, you can set the sub template. Param1 is the sub template you want to hang on the main template. |
This was the manual for the Devil Particle System. I hope, you understood it.