Particle Effects and Projectiles
From Multiverse
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
SceneNodeanywhere 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:
|
| 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
WorldManagerinstance, which you can get in Python code fromClientAPI.World - An integer giving the number of milliseconds before the
TimingInterpolatorinstance 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 pointtimeFractionvalue. You can use thetimeFractionto time your visual effect. For example the projectile system moves the projectile along its trajectory such that attimeFraction0.0 it's at the start of the trajectory, and attimeFraction1.0 it's at the end of the trajectory. TheWorldManagerinstance is passed to the method becauseWorldManagerprovides the necessary methods to manipulateSceneNodeinstances and other visual components.
-
void ExpireInterpolator(WorldManager worldManager). This method is called during the first frame when thetimeFractionis greater than 1.0; that is, after thetimeIntervalis 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.
