Crystal Space: 4.10.15 Emitter Mesh Object

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.10.15 Emitter Mesh Object

Written by Wouter Wijngaards, wouterw@cs.vu.nl.

An emitter particle system is a very general particle system, that can do a variety of things. See the general particle system documentation which is valid for all particle systems, for global options. See section Particle Systems in General.

The emitter can be customized to a high degree, using the ``iEmitGen3D'` objects. Particles are emitted from position you choose, with speeds and accelerations you choose. During their lifetime they age and change as you choose.

#### Basic Structure

The following SCF class names are used (for `csLoadPlugin`):

- Type plugin: ``crystalspace.mesh.object.emit'`
- Loader plugin: ``crystalspace.mesh.loader.emit'`
- Factory loader plugin: ``crystalspace.mesh.loader.factory.emit'`

Objects in this plugin implement the following SCF interfaces (acquire with `scfQueryInterface`):

- MeshObject
  - Implements ``iMeshObject'`
  - Implements ``iParticleState'`
  - Implements ``iEmitState'`
- MeshObjectFactory
  - Implements ``iMeshObjectFactory'`
  - Implements ``iEmitFactoryState'`
- MeshObjectFactory
  - Implements ``iMeshObjectType'`

#### Factory State Interface

The factory state interface has methods to create new emitter objects, that implement the ``iEmitGen3D'` interface. These objects return a random 3D x,y,z value. They are used to specify starting position, speed and acceleration for the particles. Several exist:

`iEmitFixed`

  This emitter returns a fixed x,y,z value. Corresponds to a point in space, a fixed speed, or fixed acceleration.

`iEmitBox`

  Returns a value with each component between a min and max. Corresponds to points from a box in space. Use it to variate x,y,z for speed and acceleration, or to get positions inside a box.

`iEmitSphere`

  Returns a point in a sphere. The center of the sphere and a min and max radius must be given. The point is between the min and max radius from the center. Thus you can generate points from a hollowed sphere if you like. The points are evenly distributed across the entire volume of the sphere.

`iEmitCone`

  Returns a point inside a cone. Give a start point, aperture angle, azimuth and elevation just like in the fountain particle system. The points are chosen between a min and max distance from the origin.

`iEmitMix`

  The mix has a set of other ``iEmitGen3D'` objects, and samples a weighted distribution from them. You can give some other emitgen3ds and a weight for each one. Items with a heavier weight will be asked to return a point more often.

  For example, you could add several EmitLine objects to the mix, each with a weight equal to its length. Then the mix will return points from a random line, but those points will be evenly distributed in space.

`iEmitLine`

  Returns points from the line between start and end position.

`iEmitCylinder`

  Give the start and end of the middle line of the cylinder, the two end points. Returns points between min and max radius from the middle line. The points are evenly distributed in space. Also, when the start = end point, points from a circle are returned.

`iEmitSphereTangent`

  The position point that is passed is used to compute a vector that is tangential to a sphere, relative to given origin. Use it to give a speed or acceleration tangential to a sphere. Speed is between min and max.

`iEmitCylinderTangent`

  The position point that is passed is used to compute a vector that is tangential to a cylinder, relative to given start and end of the middle line. Use it to give a speed or acceleration tangential to a cylinder. Speed is between min and max.

#### Factory Loader

The emitter mesh factory loader has no parameters.

#### Object State Interface

``iEmitState'` is the SCF interface that you can use to set/get settings for a emitter object. The definition of this interface can be found in ``CS/include/imesh/emit.h'` and that's also the header file you need to include in your applications to use this plugin. Using this interface you can access the number of particles, the size of the particles, and various other emitter parameters. You can set:

- The number of particles
- If particles are lighted
- The time a particle lives, in msec (1/1000). This is the maximum age of the particles.
- The starting position ``iEmitGen3D'`.
- The starting speed ``iEmitGen3D'`.
- The starting acceleration ``iEmitGen3D'`.
- The attractor ``iEmitGen3D'`. You can also leave this at NULL, and no attractor is used. If given, each point is mysteriously attracted to a point generated by the attractor ``iEmitGen3D'`.
- The force of the attractor, higher means a faster acceleration towards the attractor. Negative will repel.
- The shape of the particles, either rectangular (given width, height) or regular shaped (given number of sides and radius).
- Also a table a ages and settings can be given. The particles will have their settings interpolated from the table in their lifetime. At a particular time (in milliseconds), you can set the colour of the particle, the alpha value of the particle (1=transparent), the swirliness of the particle (it will jiggle around a bit), the rotationspeed (positive or negative) in radians per second, and the scale (relative to the starting scale) of the particle.

In addition you can use ``iParticleState'`.

#### Object Loader

Also see the general documentation for particle systems for other recognized keywords. See section Particle Systems in General.

`<rectparticles w="" h="" />`

  Set the width and height of the particles rectangular shape.

`<regularparticles sides="" radius="" />`

  Set the number of sides and a radius of the regular shaped particles.

`<totaltime>milliseconds</totaltime>`

  Set the maximum age in milliseconds.

`<lighting>yes/no</lighting>`

  Disable or enable lighting for the particles

`<number>numberparticles</number>`

  Set the number of particles

`<startpos> ...`

  Give an EMIT object for starting position.

`<startspeed> ...`

  Give the starting speed EMIT.

`<startaccel> ...`

  Give the starting acceleration EMIT.

`<attractorforce>forcevalue</attractorforce>`

  Give the attractor force value.

`<attractor> ...`

  Give the EMIT that makes attracting points (per particle).

`<aging> ...`

      <aging>
        <color red="" green="" blue="" />
        <time>time</time>
        <alpha>alpha</alpha>
        <swirl>swirl</swirl>
        <rotspeed>rotspeed</rotspeed>
        <scale>scale</scale>
      </aging>

  Give a colour red, colour green, colour blue, age time, alpha, swirl, rotationspeed and scale.

`<emitfixed x="" y="" z="" />`

  Fixed (x, y, z) emitter.

`<emitbox> ...`

  Box emitter, min x,y,z, max x,y,z.

      <emitbox>
        <min x="" y="" z="" />
        <max x="" y="" z="" />
      </emitbox>

`<emitsphere x="" y="" z="" p="" q="" r="" />`

  Sphere emitter, origin x,y,z, min, max.

`<emitcone x="" y="" z="" p="" q="" r="" s="" t="" />`

  Cone emitter, start x,y,z, elevation, azimuth, aperture, min,max radius.

`<emitmix> ...`

  Use several ``emitmix'` keywords in a row to create a mix with several EMITs. Inside each ``emitmix'`, `WEIGHT(value)` can be used to set the weight.

`<emitline>`

  Line emitter, start, end point.

      <emitline>
        <min x="" y="" z="" />
        <max x="" y="" z="" />
      </emitline>

`<emitcylinder p="" q="" />`

  Cylinder emitter, min, max distance, start, end point.

      <emitcylinder>
        <min x="" y="" z="" />
        <max x="" y="" z="" />
      </emitcylinder>

`<emitcylindertangent p="" q="" />`

  CylinderTangent emitter. Give start, end point, min, max speed.

      <emitcylindertangent>
        <min x="" y="" z="" />
        <max x="" y="" z="" />
      </emitcylindertangent>

`<emitspheretangent p="" q="" />`

  SphereTangent emitter. Give origin, min, max speed.

      <emitspheretangent>
        <min x="" y="" z="" />
        <max x="" y="" z="" />
      </emitspheretangent>

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.