Well, it's pretty simple. TBH, your best using Candy Store particle editor. You design your particle effect, or choose from pre-defined ones, then it exports the code.
For instance, i will create a fire torch emitter in Candy Store, and it will export the following .b3d file:
;----------------- CODE CREATED BY CANDY STORE ---------------------
Function CreateEmitter_torch% ()
Local EM% , P1% , P2% , P3%
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; SLOT 1 (One)
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
P1 = CreateParticleType()
ParticleType_SetImage P1 , 5
ParticleType_SetAddedBlend P1 , 0
ParticleType_SetSpeed P1 , 5.0 , 2.0
ParticleType_SetRandomSpeed P1 , 0.0 , 0.0 , 0.0
ParticleType_SetSize P1 , 0.4 , 1.0 , 0.84 , 3.0
ParticleType_SetAlpha P1 , 0.7 , 0.5 , -1.0
ParticleType_SetWeight P1 , -1.0 , 0.5
ParticleType_SetRotation P1 , 1 , 90.0
ParticleType_HorizontalAlign P1 , 0
ParticleType_SetColor P1 , 155 , 155 , 170 , 60 , -100.0 , -100.0 , -105.0
ParticleType_SetStartOffsets P1 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0
ParticleType_SetEmissionShape P1 , 0
ParticleType_SetInnerAngle P1 , 0.0
ParticleType_SetOuterAngle P1 , 30.0
ParticleType_SetCircularMotion P1 , 0.0
ParticleType_SetLifeTime P1 , 1500
ParticleType_SetBounce P1 , 0.0 , 0.0 , 0
ParticleType_SetPulsation P1 , 0.0
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; SLOT 2 (Two)
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
P2 = CreateParticleType()
ParticleType_SetImage P2 , 9
ParticleType_SetAddedBlend P2 , 1
ParticleType_SetSpeed P2 , 5.0 , 2.0
ParticleType_SetRandomSpeed P2 , 0.0 , 0.0 , 0.0
ParticleType_SetSize P2 , 2.0 , 1.0 , 2.0 , 3.0
ParticleType_SetAlpha P2 , 0.7 , 0.5 , -2.0
ParticleType_SetWeight P2 , -2.0 , 0.5
ParticleType_SetRotation P2 , 0 , 90.0
ParticleType_HorizontalAlign P2 , 0
ParticleType_SetColor P2 , 250 , 150 , 50 , 50 , -50.0 , -50.0 , -55.0
ParticleType_SetStartOffsets P2 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0
ParticleType_SetEmissionShape P2 , 0
ParticleType_SetInnerAngle P2 , 0.0
ParticleType_SetOuterAngle P2 , 75.0
ParticleType_SetCircularMotion P2 , 0.0
ParticleType_SetLifeTime P2 , 1500
ParticleType_SetBounce P2 , 0.0 , 0.0 , 0
ParticleType_SetPulsation P2 , 0.0
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; SLOT 3 (Three)
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
P3 = CreateParticleType()
ParticleType_SetImage P3 , 1
ParticleType_SetAddedBlend P3 , 1
ParticleType_SetSpeed P3 , 8.0 , 5.0
ParticleType_SetRandomSpeed P3 , 0.0 , 0.0 , 0.0
ParticleType_SetSize P3 , 0.2 , 0.2 , -0.5 , 10.0
ParticleType_SetAlpha P3 , 1.0 , 0.5 , -1.0
ParticleType_SetWeight P3 , 3.0 , 1.0
ParticleType_SetRotation P3 , 2 , 90.0
ParticleType_HorizontalAlign P3 , 0
ParticleType_SetColor P3 , 250 , 100 , 0 , 50 , -100.0 , -100.0 , 0.0
ParticleType_SetStartOffsets P3 , 0.0 , 0.0 , -0.5 , 0.0 , 0.0 , 0.0
ParticleType_SetEmissionShape P3 , 0
ParticleType_SetInnerAngle P3 , 0.0
ParticleType_SetOuterAngle P3 , 360.0
ParticleType_SetCircularMotion P3 , 0.0
ParticleType_SetLifeTime P3 , 1000
ParticleType_SetBounce P3 , 0.0 , 0.7 , 10
ParticleType_SetPulsation P3 , 0.0
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; CREATE EMITTER AND ADD PARTICLES
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EM = CreateEmitter()
Emitter_AddParticleType EM , P1 , 0 , 9000000 , 50
Emitter_AddParticleType EM , P2 , 0 , 9000000 , 50
Emitter_AddParticleType EM , P3 , 0 , 9000000 , 45
Emitter_SetSound EM , "Particles\flames.mp3" , 1
Return EM
End Function
Please NOTE that the 9000000 is the life time of the particle. Candy Store exports the code but gives it a very short life time, so increase it :o)
Anyway, to create the emitter, using that code:
InitParticles(camera,"particles\particles.png", 3) ; standard code to start up the lib.
; this code uses the functions created by Candy Store in the above code.
Global torch_Emitter = CreateEmitter_torch% () ; calls the function in the Candy Store generated code
PositionEntity torch_Emitter,111.7, -403.2, -74.2 ; basic code to position the emitter
Emitter_Start torch_Emitter ; starts the emitter
Emitter_SetScale torch_Emitter,1
Global torch_light = CreateLight(2)
PositionEntity torch_light,111.7,-403.2,-74.2
LightColor torch_light,252,221,93
LightRange torch_light,15
Please also note, that you MUST position the emitter before you start it. For some reason, if you are using sounds, then the sound will emit from the position of the emitter when it starts. So, starting the emitter, then moving it, will cause the sound to emit from it's previous position. Took me AGES <<<<< to find the problem :o)
|