Oldest known version of this page was edited on 2006-07-23 16:43:38 by skinhat []
Page view:
There are currently four effect types that can be used with a scene object.
1) PFX Requires either polygon PFX manager or point light PFX manager.
2) Fire Requires fire effects manager.
3) Thor Requires thor effects manager.
4) Explosion Requires either polygon PFX manager or point light PFX manager.
All scene objects that inherit from TGLBaseSceneObject has a Effects property of type TGLObjectEffects.
TGLObjectEffects defines the list of effects that play on the object. Each item in the list is of base type TGLObjectEffect.
Any custom effect you might define should however not inherit from TGLObjectEffect, rather one of the following:
1) TGLObjectPreEffect Rendered before owner object render.
2) TGLObjectPostEffect Rendered after the owner object render.
3) TGLObjectAfterEffect Rendered at the end of the scene rendering
Don't forget to override the ReadFromFiler/WriteToFiler persistence methods if you add data in a subclass !
Subclasses must be registered using the RegisterXCollectionItemClass function.
Common Ground
For creating a effect there you will need:
1) The appropriate effects manager.
2) Cadencer.
3) The appropriate effect in the scene objects effect list.
Setting up an effect for your scene
- Assign rendering scene to the cadencer using the scene property of the cadencer.
- Assign the cadencer to the relevant effects manager using the cadencer property of the effects manager.
- Create a required effect in the desired object's effects list.
- Assign the relevant effects manager to the created effect in list using the fire effect's manager property.
- Set the effect manager's properties as required for look and feel.
Note: Should this be done in design time, the effect will not be rendered. Effects are only visible during runtime.
By examining the effects units, you will notice that there are helper functions available for some effects.
Effect and effect manager units are :
1) GLParticleFX.
2) GLFireFX.
3) GLThorFX.
4) GLExplosionFX.
See the reference file for further details.
Design Time Effect Creation
For the purpose of this example we will assume that you are adding a fire effect to a scene object.
1) Drop a cadencer on form.
2) Drop GLFireFXManager on form.
3) Set the GLFireFXManager's cadencer property to the cadencer dropped at 1).
4) Select scene object that the effect is meant for.
5) Open the effects list manager by clicking on the ellipsis button of the effects property in the object inspector.
6) Clicking on the add button of the effects list manager will produce a drop down menu listing the possible effects.
7) On selecting the FireFX menu item, a FireFX effect will be added to the list.
8) Rename the effect to describe what it will represent.
9) Set the newly created effect's manager property to the GLFireFXManager as seen at 2).
10) Select the GLFireFXManager and set the fire's properties as required.
Runtime Effect Creation
For the purpose of this example we will assume that you are adding a fire effect and that the GLFireFXManager already exists and has been connected to a cadencer.
1) Add the GLFireFX unit to the uses clause.
2) Create fire effect and add it to the effects list of the object to use the effect.
- Create a local variable of type TGLBFireFX.
- Create the fire effect.
One way of doing this is to use to create constructor. e.g. lEffect := TGLBFireFX.Create(GLCube1.Effects);
Note the constructor's parameter. The parameter of the constructor is the effects list of the object that the effect is created for.
The other way of creating the fire effect is to use the GetOrCreateFireFX helper function as found in the GLFireFX unit.
e.g. lEffect := GetOrCreateFireFX(GLCube1); The parameter for this function can either be the desired object or the effects list of that object.
- Set the manager property of the newly created effect to the appropriate effects manager.
Source Example:
var
lEffect : TGLBFireFX;
begin
lEffect := TGLBFireFX.Create(GLCube1.Effects);
lEffect.Manager := GLFireFXManager1;
end;
I did all that, by my effect does not display ?
In such a case, you have to back up and make sure that the effect's supporting objects has been set up correctly.
1) Has the cadencer's scene property been set to the correct scene object.
2) Has the effects manager's cadencer property been set to the correct cadencer.
3) Has the effect's manager property been set to the correct effects manager.
4) Is the cadencer enabled.
5) Is the effects manager's disabled property false.
6) If you used BeginUpdate, make sure that you have also called EndUpdate