Particle Effects and Projectiles

From Multiverse

Jump to: navigation, search
Example particle effect in World Editor
Enlarge
Example particle effect in World Editor

The Multiverse Platform enables you to create particle effects to display features such as smoke, fire, falling water, and so on. Additionally, you can create projectiles that travel to a designated target, to create effects such as a "fireball" or a laser beam. Projectiles are implemented as particle effects that travel to a designated target.

Particle effects are defined by particle scripts, declarative rendering scripts based on OGRE, described in the following articles:

For more information on OGRE and Axiom, see:


Contents

Adding particle effects to a world

Use World Editor to add a particle effect to a world. See World Editor Tasks - Adding a particle effect for more information.

Particle effects

There are two types of particle effects:

  • Static particle effects that are fixed and always extant in a world. You define a static particle effect in the World Editor, attaching it to a SceneNode anywhere in the world, or to an attachment point of a model.
  • Dynamic particle effects that may change at runtime. You create dynamic particle effects with server or client scripting.

Defining a particle effect in a server script

To create a dynamic particle effect with a server Python script, call the method of AnimationClient.addParticleEffect(). The following table describes this method's parameters, in order.

Parameter Datatype Description
Object ID (OID) java.lang.Long OID of client object to which to attach the particle effect.
Socket name String If particle effect is to be attached to an attachment point on a model, the name of the attachment point (socket) to use. Otherwise, must be the empty string ("").
Name of the particle effect. String See multiverse.server.objects.ParticleEffect.
Orientation multiverse.server.math.Quaternion   Orientation of the particle effect relative to the SceneNode or attachment point to which it is attached. Currently, this is ignored.
Velocity multiplier float Scaling factor for particle velocity; 1.0 means use the particle velocity specified in the particle script; 5.0 means use five times that velocity, and so on.
Size multiplier float Scaling factor for particle size scale factor; 1.0 means use the particle size specified in the particle script; 5.0 means use five times that size, and so on.
Flags byte A collection of boolean flags ORed together. Currently supported flags:
  • WorldOrientation, value 2: If set, Orientation parameter is interpreted as a world orientation; if not, Orientation is interpreted relative to the orientation SceneNode or attachment point to which particle system is attached.
  • HasColor, value 4: If set, ignore the color specified by the particle script; instead use the color specified by the Color parameter.
Color multiverse.server.objects.Color Specifies particle color. Ignored unless the HasColor bit in the Flags argument is set.

Example

The server's config/common/proxy.py has a command that attaches particle effects to the currently-targeted object:

Defining a particle effect in a client script

It is possible to add particle effects using only client-side scripting. See:

Time interpolators

Time interpolators enable you to synchronize effects to the frame rate of a specified time interval. The projectile system uses time interpolators. You can also use time interpolators for other purposes in client scripts.

The abstract class TimingInterpolator takes two constructor arguments:

  • The WorldManager instance, which you can get in Python code from ClientAPI.World
  • An integer giving the number of milliseconds before the TimingInterpolator instance expires.

Any user of TimingInterpolator must create a derived class that overrides two abstract methods:

  • void UpdateTimeFraction(WorldManager worldManager, float timeFraction). This method is called every frame, passing the fraction of the time interval that has already passed as the floating point timeFraction value. You can use the timeFraction to time your visual effect. For example the projectile system moves the projectile along its trajectory such that at timeFraction 0.0 it's at the start of the trajectory, and at timeFraction 1.0 it's at the end of the trajectory. The WorldManager instance is passed to the method because WorldManager provides the necessary methods to manipulate SceneNode instances and other visual components.
  • void ExpireInterpolator(WorldManager worldManager). This method is called during the first frame when the timeFraction is greater than 1.0; that is, after the timeInterval is expired. This method's implementation should do whatever cleanup is appropriate. For example, the projectile system destroys the projectile's particle effect when this method is called.
Personal tools