1. Introduction
Particle systems represent techniques used to simulate certain fuzzy phenomena in 3D computer graphics. These phenomena use other traditional rendering techniques to achieve realistic game physics. We often use particle systems to simulate fire, explosion, smoke, water flow, Sparks, fallen leaves, clouds, fog, snow, dust, meteor trails, or abstract visual effects like trajectory.
2. Particle System Structure
The particle system of the OGE engine is represented by particles, particle transmitters, particle initiators, and particle modifiers.
Particle System: it is a subclass of entity, a system that manages particle transmitters, emission ratios, particle hatching, and particle modifiers.
Particle transmitter: inherits iupdatehandler and randomly generates emission coordinates within a fixed range.
Particle initializer: initializes some entity parameters. Example: Alpha Value
Particle modifier: a subclass of the particle initializer. It also modifies some entity parameters, but is updated in onmanagedupdate of the particle system, similar to the effect of registering modifier in entity.
Particle: encapsulate an entity that contains attributes of some particles.
3. instance code:
Public void setmyparticle (float PX, float py, textureregion region, scene pscene ){
Pointparticipant leemitter maid = new pointparticipant leemitter (PX, Py );
Spriteparticlesystem mparticlesystem = new spriteparticlesystem (maid, 10, 10, 30, region, pscene. getvertexbufferobjectmanager ());
Mparticlesystem. addparticipant leinitializer (New velocityparticipant leinitializer <sprite> (-150,150,-380, 0 ));
Mparticlesystem. addparticipant leinitializer (New expireparticipant leinitializer <sprite> (5f, 6f ));
Mparticlesystem. addparticipant lemodifier (New scaleparticlemodifier <sprite> (0f, 5f, 0, 1.3f ));
Mparticlesystem. addparticipant lemodifier (New alphaparticlemodifier <sprite> (0.8f, 1, 0.2f, 1f ));
Pscene. attachchild (mparticlesystem );
}
[V2.x OGE tutorial 20] particle effect