"V2.x oge Tutorial 20" Particle effects

Source: Internet
Author: User
Tags modifier modifiers
1. Introduction

The particle system represents the technique of simulating some specific fuzzy phenomena in three-dimensional computer graphics, and these phenomena are difficult to achieve with other traditional rendering techniques. Real game physics. Frequently used particle systems to simulate phenomena such as fire, explosion, smoke, water, sparks, leaves, clouds, fog, snow, dust, meteor trails or the like, such as the trajectory of abstract visual effects and so on.

2. Particle system Structure

particles, particle emitters, particle initializers, particle modifiers in the particle system of the OGE engine represent particle effects.

Particle system: is a subclass of entity that manages a system of particle emitters, emission ratios, particle hatching, management of particle modifiers, etc.

Particle emitter: Inherits Iupdatehandler, randomly generates emission coordinates at a fixed range

Particle initializer: Initializes the entity portion of the parameter. such as: Alpha value

Particle modifier: the particle initializer subclass, which also modifies the entity part parameters, but is updated in the onmanagedupdate of the particle system, similar to the effect of registering modifier in entity

Particle: Encapsulates an entity that contains properties of some particles

3. Example code:

public void setmyparticle (float PX, float PY, Textureregion region, Scene pscene) {

Pointparticleemitter particleemitter = new Pointparticleemitter (PX, PY);

Spriteparticlesystem Mparticlesystem = new Spriteparticlesystem (Particleemitter, ten, Ten, Pscene.getvertexbufferobjectmanager ());

Mparticlesystem.addparticleinitializer (New velocityparticleinitializer<sprite> (-150, 150,-380, 0));

Mparticlesystem.addparticleinitializer (New expireparticleinitializer<sprite> (5f, 6f));

Mparticlesystem.addparticlemodifier (New scaleparticlemodifier<sprite> (0f, 5f, 0, 1.3f));

Mparticlesystem.addparticlemodifier (New Alphaparticlemodifier<sprite> (0.8f, 1, 0.2f, 1f));

Pscene.attachchild (Mparticlesystem);

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.