Table Of Contents

Previous topic

20.10. The ParticleView Object

Next topic

21. High Level API

This Page

20.11. The ParticleRenderable Object

Added SDK 0.28.0

The ParticleRenderable object is used to provide the necessary glue between a ParticleSystem and a Scene. The object provides a necessary subset of the Renderable interface required to include ParticleSystems into a Scene with minimal effort.

The ParticleRenderable will be assigned a ParticleSystem to be rendered, and will manage the creation and deletion of ParticleViews for each unique Camera instance used to render a Scene. The ParticleRenderable will take part in the Scenes culling, and as a by-product of the scene being rendered will the ParticleSystem‘s sync method be called so that only visible ParticleSystems will ever be updated.

The ParticleRenderable exposes an API which permits ParticleSystems to be lazily allocated when the renderable is first rendered so that effects may be created all around a Scene, with those that have never become visible existing purely as an empty renderable in in the world. A similar API permits lazy allocation of ParticleViews instead of always creating a new ParticleView so that pooling of ParticleViews may also be achieved.

Renderable API not supported by ParticleRenderable

  • Custom world extents (addCustomWorldExtents, getCustomWorldExtents, removeCustomWorldExtents)
  • Cloning (clone)
  • Custom Materials (setMaterial)

Additionally, it is assumed that a ParticleRenderable should also be used as a transparent renderable, being sorted along side other transparent renderables in a Scene.

Transformation

A ParticleRenderable has its own local transform. If the renderable has fixedOrientation true, then the rotational and scaling components of any parent transforms are used only to compute the world position for the renderable, enforcing that only the rotation and scaling defined on the renderables local transform are used. If fixedOrientation is false, then a simple multiplication with the parent transform will be performed.

Note

This is a low-level particle system API.

20.11.1. Methods

20.11.1.1. create

Summary

Create a new ParticleRenderable

Syntax

var renderable = ParticleRenderable.create({
    graphicsDevice: graphicsDevice,
    passIndex: renderer.passIndex.transparent,
    system: particleSystem,
    sharedRenderContext: sharedRenderContext
});
graphicsDevice
The GraphicsDevice object.
passIndex
The transparent pass index of whatever Renderer is being used.
system (Optional)
The ParticleSystem to be rendered. If this field is not supplied, it is assumed that setSystem or setLazySystem will be called at some point before the renderable is actually added to a Scene.
sharedRenderContext (Optional)
The SharedRenderContext to be used whenever the ParticleRenderable is responsible for creating new ParticleView objects. Note that the restrictions regarding SharedRenderContexts being shared between systems and views applies equally to systems and renderables as this context is simply passed forwards to the view constructor.

20.11.1.2. setSystem

Summary

Set the ParticleSystem to be rendered by this renderable. This method should not be used whilst the renderable is inside a Scene.

Syntax

renderable.setSystem(system);
system
The ParticleSystem to be rendered, setting to null is permissible in which case it is assumed that either another non-null system will be assigned, or setLazySystem called before the renderable is added to a Scene.

20.11.1.3. setLazySystem

Summary

Assign a callback function to be used when the renderable is first made visible to assign a ParticleSystem to be rendered from that point on.

Syntax

renderable.setLazySystem(systemCallback, center, halfExtents);
systemCallback

The function to be called to allocate a ParticleSystem when renderable is first made visible. This function must return a valid ParticleSystem.

Setting the callback to null is permitted, but it is assumed that a non-null system or callback will be defined for the renderable before it is added to a Scene.

center
The center in local-coordinates of the ParticleSystem extents which will be later assigned to the renderable. This is required to enable proper visibility testing of the renderable.
halfExtents
The half-extents in local-coordinates of the ParticleSystem which will be later assigned to the renderable. This is required to enable proper visibility testing of the renderable.

20.11.1.4. setLazyView

Summary

Assign a callback function to be used when a new (or first) Camera instance makes visible the renderable for the first time to enable pooling of ParticleView objects.

If no lazy view callback is assigned, then the renderable will allocate a new view itself.

Syntax

renderable.setLazyView(viewCallback);
viewCallback

The function to be called to allocate a ParticleView when a new Camera makes visible the renderable for the first time.

This function is permitted to return null, in which case a new ParticleView will be allocated.

This callback may also be re-set to null via this method.

20.11.1.5. releaseViews

Summary

Remove all ParticleViews from the renderable, invoking the provided callback for each view to enable pooling when a ParticleRenderable is removed from a Scene.

Syntax

renderable.releaseViews(function (view)
    {
        ...
    });
recycleView (Optional)

Callback called for each ParticleView removed from the renderable.

If callback is not specified, then the ParticleView objects will instead be destroyed.

20.11.1.6. destroy

Summary

Destroy the renderable, rendering it invalid for future use, and destroying any remaining ParticleViews assigned to it.

Syntax

renderable.destroy();

20.11.1.7. setFixedOrientation

Summary

Set the fixedOrientation flag on this renderable.

Syntax

renderable.setFixedOrientation(true);

20.11.1.8. setLocalTransform

Summary

Set the localTransform field on this renderable. If changes are made directly to the renderables localTransform, this function must still be called to enact the necessary side-effects.

Syntax

renderable.setLocalTransform(transform);

transform (Optional)

If argument is unspecified, it is assumed that direct modifications were made to the local transform. Otherwise the provided Matrix43 transform will first be copied to the renderables local transform.

20.11.2. Properties

20.11.2.1. system

Summary

The currently bound ParticleSystem for this renderable. To modify this field use the setSystem or setLazySystem methods.

Note

Read Only

20.11.2.2. fixedOrientation

Summary

Fixed orientation flag of this renderable. To modify this flag use the setFixedOrientation method.

Note

Read Only

20.11.2.3. localTransform

Summary

The local transform Matrix43 of this renderable. If modifications are made to this field, you must ensure setLocalTransform method is still called to enact the necessary side effects.