[bb] Lotus Particle System R2 - Part 2 by N [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:39

Previous topic - Next topic

BlitzBot

Title : Lotus Particle System R2 - Part 2
Author : N
Posted : 1+ years ago

Description : This is part 2 of the source code (since it's too large to go into one entry, as Rob pointed out).  For part 1: <a href="codearcs1d1b.html?code=1654" >Lotus Particle System R2 - Part 1</a>

In the interest of furthering the potential usefulness of Lotus R2 (I will try to document some of it later, just don't expect it overnight), I'm releasing it into the public domain.

Hopefully this will help those people who are particularly hateful of licenses (can't blame'em considering I loathe anything longer than 100 lines).

Anywho, feel free to use and abuse.  I'll add a comment when I begin documenting the source.  (No guarantee that it will work with the DIMs arranged in the order they're in, however I don't think there will be a problem with them).

Media for Lotus R2 is laid out like so:
particles.png
_________________
| 0 | 1 | 2 | 3 |
|___|___|___|___|
| 4 | 5 | 6 | 7 |
|___|___|___|___|

Where numbers indicate the indices of particle cells (textures).  These cells are individual particles or animation frames (depending on which Load function you use).

The Graph functionality allows you to have keyframe'd values (color and size were all that were finished last I checked) instead of linearly interpolating between two values.

The public domain license does not apply to the existing archive of Lotus R2.  That is to say, all media, samples, the editor, etc. are still under the license they were originally released under. [/i]

Code :
Code (blitzbasic) Select
Function DrawLotusParticle( P.LotusParticle, TPivot )
If P <> Null Then

If PCull > 0 Then
CameraProject gLotusCamera, PPositionX, PPositionY, PPositionZ
If ProjectedZ() <= 0 Then Return
PX = ProjectedX()
If PX < -75 Or PX > gWidth+75 Then Return
PY = ProjectedY()
If PY < 0 Or PY > gHeight+75 Then Return
EndIf

LFrom# = PLife/PLifeSpan
LTo# = 1.0 - LFrom#

PositionEntity gLotusParticlePivot,PPositionX,PPositionY,PPositionZ
RotateEntity gLotusParticlePivot,PAngleX,PAngleY,0

Gr.LotusGraph = PColorGraph
If Gr <> Null Then
If GrKeys-1 <= 0 Then Gr = Null
EndIf

If Gr = Null Then
If PRange <> 0 Then
A# = Max(PAlphaFrom*LFrom + PAlphaTo*LTo,1.0-(EntityDistance(gLotusCamera,gLotusParticlePivot)/PRange))
Else
A# = PAlphaFrom*LFrom + PAlphaTo*LTo
EndIf
R = PRedFrom*LFrom + PRedTo*LTo
G = PGreenFrom*LFrom + PGreenTo*LTo
B = PBlueFrom*LFrom + PBlueTo*LTo
Else
AccumulateGraphArray( Gr )
Pivot# = GrWidth * LTo
Front = -1
Behind = -1
For N = 0 To GrKeys - 1
If gGraphArray( N, 0 ) >= Pivot Then
Behind = N-1
Front = N
Exit
EndIf
Next

If Front = - 1 Then
Front = GrKeys-1
Behind = 0
EndIf

Behind = Min( Behind, 0 )
Front = Max( Front, GrKeys - 1 )

VFrom# = 1.0-ReturnedY#( Pivot#, gGraphArray( Behind, 0 ), gGraphArray( Behind, 1 )*10, gGraphArray( Front, 0 ), gGraphArray( Front, 1 )*10 )/10
VTo# = 1.0 - VFrom

If PRange > 0 Then
A# = Max(PAlphaFrom*VFrom + PAlphaTo*VTo,1.0-(EntityDistance(gLotusCamera,gLotusParticlePivot)/PRange))
Else
A# = PAlphaFrom*VFrom + PAlphaTo*VTo
EndIf

R = PRedFrom*VFrom + PRedTo*VTo
G = PGreenFrom*VFrom + PGreenTo*VTo
B = PBlueFrom*VFrom + PBlueTo*VTo
EndIf

Gr.LotusGraph = PSizeGraph
If Gr <> Null Then
If GrKeys-1 <= 0 Then Gr = Null
EndIf

If Gr = Null Then
SizeX# = PSizeFromX*LFrom+PSizeToX*LTo
SizeY# = PSizeFromY*LFrom+PSizeToY*LTo
SizeZ# = PSizeFromZ*LFrom+PSizeToZ*LTo
Else
AccumulateGraphArray( Gr )
Pivot# = GrWidth * LTo
Front = -1
Behind = -1
For N = 0 To GrKeys - 1
If gGraphArray( N, 0 ) >= Pivot Then
Behind = N-1
Front = N
Exit
EndIf
Next

If Front = - 1 Then
Front = GrKeys-1
Behind = 0
EndIf

Behind = Min( Behind, 0 )
Front = Max( Front, GrKeys - 1 )

VFrom# = 1.0-ReturnedY#( Pivot#, gGraphArray( Behind, 0 ), gGraphArray( Behind, 1 )*10, gGraphArray( Front, 0 ), gGraphArray( Front, 1 )*10 )/10
VTo# = 1.0 - VFrom

SizeX# = PSizeFromX*VFrom+PSizeToX*VTo
SizeY# = PSizeFromY*VFrom+PSizeToY*VTo
SizeZ# = PSizeFromZ*VFrom+PSizeToZ*VTo
EndIf

If PHidden = False And A > 0 And SizeX > 0 And SizeY > 0 And SizeZ > 0 Then
T.LotusTexture = PTexture

If T <> Null Then
Select PBlendMode
Case 1
Surface = TAlpha
Case 2
Surface = TMultiply
Case 3
Surface = TAdd
End Select
If Surface = 0 Then Surface = gLotusNullTextureAlpha
Else
Surface = TAlpha
EndIf

If Surface <> 0 Then
If PWaveRadiusX <> 0 Or PWaveRadiusY <> 0 Or PWaveRadiusZ <> 0 Then
MoveEntity gLotusParticlePivot,(gSine(Int((PLifeBegan+(PLifeSpan-PLife))*PWaveSpeedX) Mod 359)*PWaveRadiusX)*LFrom,(gCosine(Int((PLifeBegan+(PLifeSpan-PLife))*PWaveSpeedY) Mod 359)*PWaveRadiusY)*LFrom,(gCosine(Int((PLifeBegan+(PLifeSpan-PLife))*PWaveSpeedZ) Mod 359)*PWaveRadiusZ)*LFrom
EndIf

Select PViewMode
Case 1 ;; Always Facing
PointEntity gLotusParticlePivot,gLotusCamera,PAngleZ
Case 2
TurnEntity gLotusParticlePivot,0,0,PAngleZ
Case 3 ;; X-facing
PositionEntity TPivot,PPositionX,PPositionY,PPositionZ
RotateEntity TPivot,PAngleX,PAngleY,0
EntityParent gLotusParticlePivot,TPivot,1
TurnEntity TPivot,0,DeltaYaw(gLotusParticlePivot,gLotusCamera),0
EntityParent gLotusParticlePivot,0,1
TurnEntity gLotusParticlePivot,0,0,PAngleZ
Case 4 ;; Y-facing
PositionEntity TPivot,PPositionX,PPositionY,PPositionZ
RotateEntity TPivot,0,PAngleY,0
EntityParent gLotusParticlePivot,TPivot,1
TurnEntity TPivot,DeltaPitch(gLotusParticlePivot,gLotusCamera),0,0
EntityParent gLotusParticlePivot,0,1
TurnEntity gLotusParticlePivot,0,0,PAngleZ
End Select

If PRollMode => 1 And PRollMode <= 3 Then
AlignToVector gLotusParticlePivot,PLastPositionX-PPositionX,PLastPositionY-PPositionY,PLastPositionZ-PPositionZ,PRollMode,1
EndIf

If PAnimated >= True Then
PFrame = (TRows*TColumns)*LTo
EndIf
Rows = 0
Columns = 0
Frame = PFrame
While Frame >= TColumns
Rows = Rows + 1
Frame = Frame - TColumns
Wend
Columns = PFrame Mod TColumns

eU# = Columns*TUStep
eV# = Rows*TVStep

Select PParticleMesh
Case cP_QUAD
TFormPoint -SizeX,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
V = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV)
PVertex = V

TFormPoint SizeX,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV)

TFormPoint SizeX,-SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV+TVStep)

TFormPoint -SizeX,-SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV+TVStep)

AddTriangle Surface,V,V+1,V+2
AddTriangle Surface,V+2,V+3,V

For N = 0 To 3
VertexColor Surface,V+N,R,G,B,A
Next

Case cP_TRIANGLE
TFormPoint -SizeX,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
V = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV)
PVertex = V

TFormPoint SizeX*3,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep-TUStep*2,eV)

TFormPoint -SizeX,-SizeY*3,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV+TVStep*2)

AddTriangle Surface,V,V+1,V+2

For N = 0 To 2
VertexColor Surface,V+N,R,G,B,A
Next

Case cP_TRAIL,cP_TRAILVERTICAL
If PParticleMesh = 2 Then
TFormPoint -SizeX,0,0,gLotusParticlePivot,gLotusParticleMesh
V = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV+LTo*TVStep)
PVertex = V
TFormPoint SizeX,0,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV+LTo*TVStep)
Else
TFormPoint 0,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
V = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV+LTo*TVStep)
PVertex = V
TFormPoint 0,-SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV+LTo*TVStep)
EndIf

If PPrevious <> Null Then
If PTexture = PPreviousTexture And PPreviousParticleMesh = PParticleMesh And PPreviousVertex > -1 And PPreviousBlendMode = PBlendMode Then
AddTriangle Surface,V,V+1,PPreviousVertex+1
AddTriangle Surface,PPreviousVertex+1,PPreviousVertex,V
EndIf
EndIf

For N = 0 To 1
VertexColor Surface,V+N,R,G,B,A
Next

Case cP_DENT
TFormPoint -SizeX,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
V = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV)

TFormPoint SizeX,SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV)

TFormPoint SizeX,-SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU,eV+TVStep)

TFormPoint -SizeX,-SizeY,0,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep,eV+TVStep)

TFormPoint 0,0,-SizeZ,gLotusParticlePivot,gLotusParticleMesh
AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),eU+TUStep*.5,eV+tVStep*.5)

AddTriangle Surface,V,V+1,V+4
AddTriangle Surface,V+1,V+2,V+4
AddTriangle Surface,V+2,V+3,V+4
AddTriangle Surface,V+3,V,V+4

For N = 0 To 4
VertexColor Surface,V+N,R,G,B,A
Next

Default
PVertex = CountVertices(Surface)
For N = 1 To CountSurfaces(PParticleMesh)
V = CountVertices(Surface)
S = GetSurface(PParticleMesh,N)
For eV = 0 To CountVertices(S)-1
TFormPoint VertexX(S,eV)*SizeX,VertexY(S,eV)*SizeY,VertexZ(S,eV)*SizeZ,gLotusParticlePivot,gLotusParticleMesh
nV = AddVertex(Surface,TFormedX(),TFormedY(),TFormedZ(),VertexU(S,eV),VertexV(S,eV))
VertexColor Surface,nV,R,G,B,A
Next

For eT = 0 To CountTriangles(S)-1
eV0 = TriangleVertex(S,eT,0)
eV1 = TriangleVertex(S,eT,1)
eV2 = TriangleVertex(S,eT,2)
AddTriangle Surface,V+eV0,V+eV1,V+eV2
Next
Next

S = 0
End Select
gLotusParticlesDrawn = gLotusParticlesDrawn + 1
Else
PVertex = -1
EndIf
Else
PVertex = -1
EndIf
Else
Return False
EndIf
Return True
End Function


;; PARTICLE
Function CreateParticle(Emitter)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ORoll# = EntityRoll( Emitter )
OPitch# = EntityPitch( Emitter )
OYaw# = EntityYaw( Emitter )
RotateEntity Emitter, OPitch, OYaw, 0
For Emission = 1 To EEmissionRate
; If EBlendMode = 3 Then Stop
gLotusParticleCount = gLotusParticleCount + 1
P.LotusParticle = New LotusParticle

PParent = E
PTrail = ETrail
PChild = EChild

; PLastPosition = New LotusVector
; PPosition = New LotusVector

RndRad# = Rnd(0,ECylinderX)
RndAng% = Rand(359)
ET# = MilliSecs()
gTempLotusVectorX = gSine(RndAng)*RndRad + (gSine(ET*ECircleSpeedX Mod 359)*ECircleRadiusX)+Rnd(-ECubeX,ECubeX)
gTempLotusVector = Rnd(ECylinderZ,ECylinderY) + gSine(ET*ECircleSpeedY Mod 359)*ECircleRadiusY+Rnd(-ECubeY,ECubeY)
gTempLotusVectorY = gCosine(RndAng)*RndRad + (gCosine(ET*ECircleSpeedZ Mod 359)*ECircleRadiusZ)+Rnd(-ECubeZ,ECubeZ)
LotusVec_TFormPoint gTempLotusVector,EEntity,0
; LotusVec_TFormedB PPosition
PPositionX = TFormedX()
PPositionY = TFormedY()
PPositionZ = TFormedZ()

; PTranslation = LotusVec_Copy(ETranslation)
gTempLotusVectorX = Rnd(-ETranslationJitterX*ETranslationJitterDown,ETranslationJitterX*ETranslationJitterUp)
gTempLotusVectorY = Rnd(-ETranslationJitterY*ETranslationJitterDown,ETranslationJitterY*ETranslationJitterUp)
gTempLotusVector = Rnd(-ETranslationJitterZ*ETranslationJitterDown,ETranslationJitterZ*ETranslationJitterUp)
PTranslationX = ETranslationX + gTempLotusVectorX
PTranslationY = ETranslationY + gTempLotusVectorY
PTranslationZ = ETranslationZ + gTempLotusVector
; LotusVec_Add(PTranslation,gTempLotusVector)

; PAngle = New LotusVector

PVelocityDecay = EVelocityDecay

gTempLotusVectorX = Rnd(-ERandomRotationX,ERandomRotationX)
gTempLotusVectorY = Rnd(-ERandomRotationY,ERandomRotationY)
gTempLotusVector = Rnd(-ERandomRotationZ,ERandomRotationZ)
PAngleX = OPitch + gTempLotusVectorX
PAngleY = OYaw + gTempLotusVectorY
PAngleZ = ORoll + gTempLotusVector

; PVelocity = LotusVec_Copy(EVelocity)
gTempLotusVectorX = Rnd(-EVelocityJitterX*EVelocityJitterDown,EVelocityJitterX*EVelocityJitterUp)
gTempLotusVectorY = Rnd(-EVelocityJitterY*EVelocityJitterDown,EVelocityJitterY*EVelocityJitterUp)
gTempLotusVector = Rnd(-EVelocityJitterZ*EVelocityJitterDown,EVelocityJitterZ*EVelocityJitterUp)
POVelocityX = EVelocityX + gTempLotusVectorX
POVelocityY = EVelocityY + gTempLotusVectorY
POVelocityZ = EVelocityZ + gTempLotusVector
RotateEntity gLotusParticlePivot,PAngleX,PAngleY,0,1
TFormVector POVelocityX,POVelocityY,POVelocityZ,gLotusParticlePivot,0
PVelocityX = TFormedX()
PVelocityY = TFormedY()
PVelocityZ = TFormedZ()
; LotusVec_Add(PVelocity,gTempLotusVector)
; PAngleVelocity = LotusVec_Copy(EAngleVelocity)
; PAcceleration = LotusVec_Copy(EAcceleration)
; PAngleAcceleration = LotusVec_Copy(EAngleAcceleration)
PAngleVelocityX = EAngleVelocityX
PAngleVelocityY = EAngleVelocityY
PAngleVelocityZ = EAngleVelocityZ
PAccelerationX = EAccelerationX
PAccelerationY = EAccelerationY
PAccelerationZ = EAccelerationZ
gTempLotusVectorX = Rnd(-ESizeJitterX*ESizeJitterDown,ESizeJitterX*ESizeJitterUp)
gTempLotusVectorY = Rnd(-ESizeJitterY*ESizeJitterDown,ESizeJitterY*ESizeJitterUp)
gTempLotusVector = Rnd(-ESizeJitterZ*ESizeJitterDown,ESizeJitterZ*ESizeJitterUp)
If ESizeJitterUniform Then
S# = (gTempLotusVectorX+gTempLotusVectorY+gTempLotusVector)/3
gTempLotusVectorX = S
gTempLotusVectorY = S
gTempLotusVector = S
EndIf
; PSizeFrom = LotusVec_Copy(ESizeFrom)
PSizeFromX = ESizeFromX + gTempLotusVectorX
PSizeFromY = ESizeFromY + gTempLotusVectorY
PSizeFromZ = ESizeFromZ + gTempLotusVector

; PSizeTo = LotusVec_Copy(ESizeTo)
PSizeToX = ESizeToX + gTempLotusVectorX
PSizeToY = ESizeToY + gTempLotusVectorY
PSizeToZ = ESizeToZ + gTempLotusVector

; PWaveRadius = LotusVec_Copy(EWaveRadius)
; PWaveSpeed = LotusVec_Copy(EWaveSpeed)
PWaveRadiusX = EWaveRadiusX
PWaveRadiusY = EWaveRadiusY
PWaveRadiusZ = EWaveRadiusZ
PWaveSpeedX = EWaveSpeedX
PWaveSpeedY = EWaveSpeedY
PWaveSpeedZ = EWaveSpeedZ

If Float(EColorJitterRed + EColorJitterBlue + EColorJitterGreen) + EColorJitterAlpha <> 0 Then
If EColorJitterUniform = False Then
RR = Rand(-EColorJitterRed*EColorJitterDown,EColorJitterRed*EColorJitterUp)
RG = Rand(-EColorJitterGreen*EColorJitterDown,EColorJitterGreen*EColorJitterUp)
RB = Rand(-EColorJitterBlue*EColorJitterDown,EColorJitterBlue*EColorJitterUp)
Else
C = (EColorJitterRed+EColorJitterGreen+EColorJitterBlue)/3
C = Rand(-C*EColorJitterDown,C*EColorJitterDown)
RR = C
RG = C
RB = C
EndIf
RA# = Rnd(-EColorJitterAlpha*EColorJitterDown,EColorJitterAlpha*EColorJitterUp)
EndIf

PRedFrom = ERedFrom + RR
PGreenFrom = EGreenFrom + RG
PBlueFrom = EBlueFrom + RB
PAlphaFrom = EAlphaFrom + RA

PRedTo = ERedTo + RR
PGreenTo = EGreenTo + RG
PBlueTo = EBlueTo + RB
PAlphaTo = EAlphaTo + RA

PLifeSpan = ELifeSpan + Rand(-ELifeSpanJitter*ELifeSpanJitterDown,ELifeSpanJitter*ELifeSpanJitterUp)
PLife = PLifeSpan
PLifeBegan = MilliSecs()
PTexture = ETexture
PBlendMode = EBlendMode
PParticleMesh = EParticleMesh
PPrevious = ELatest
ELatest = P
PVertex = -1
PViewMode = EViewMode
PLifeMode = ELifeMode
PChildMode = EChildMode
PDraw = 1
PFrozen = EFrozen
PHidden = EHidden
PFrame = EFrame
PAnimated = EAnimated
PGravity = EGravity + Rnd(-EGravityJitter*EGravityJitterDown,EGravityJitter*EGravityJitterUp)
PGravityEnabled = EGravityEnabled
PWeight = EWeight
PRollMode = ERollMode
PRange = ERange
PCull = ECull
PSorting = ESorting
PSizeGraph = ESizeGraph
PColorGraph = EColorGraph
PBounce = EBounce
PBounceDecay = EBounceDecay
PBounceMax = EBounceMax
PMinY = EMinY
PBounceSound = EBounceSound
PSplineMesh = ESplineMesh
PBounceSoundRange = EBounceSoundRange
PDeflectorsAffect = EDeflectorsAffect

If PBlendMode = 1 And PSorting => 1 Then
gLotusAlphaParticleCount = gLotusAlphaParticleCount + 1
EndIf

; If PBlendMode = 1 Then
; Insert P Before First LotusParticle
; ElseIf PBlendMode = 3 Then
; Insert P After Last LotusParticle
; EndIf
Next

If P <> Null Then
If PChild <> Null Then
If PChildWaitB <= 0 And PChildMode <> 1 Then
ax# = EntityPitch(PChildEntity,1)
ay# = EntityYaw(PChildEntity,1)
az# = EntityRoll(PChildEntity,1)
RotateEntity PChildEntity,PAngleX,PAngleY,PAngleZ,1
PositionEntity PChildEntity,PPositionX,PPositionY,PPositionZ,1
CreateParticle(PChildEntity)
RotateEntity PChildEntity,ax,ay,az,1
PositionEntity PChildEntity,PChildPositionX,PChildPositionY,PChildPositionZ,1
EndIf
EndIf
EndIf

RotateEntity Emitter, OPitch, OYaw, ORoll
End Function

Function KillParticle(P.LotusParticle)
If P = Null Then Return False
gLotusParticleCount = gLotusParticleCount - 1
If PBlendMode = 1 Then gLotusAlphaParticleCount = gLotusAlphaParticleCount - 1

If PChild <> Null Then
If PChildWaitB <= 0 And PChildMode <> 1 Then
RotateEntity PChildEntity,PAngleX,PAngleY,PAngleZ,1
PositionEntity PChildEntity,PPositionX,PPositionY,PPositionZ,1
CreateParticle(PChildEntity)
RotateEntity PChildEntity,PChildAngleX,PChildAngleY,PChildAngleZ,1
PositionEntity PChildEntity,PChildPositionX,PChildPositionY,PChildPositionZ,1
EndIf
EndIf

Delete P
End Function

Function ClearParticles()
Delete Each LotusParticle
End Function


;; GRAPH

Function CreateGraph()
G.LotusGraph = New LotusGraph
GBank = CreateBank( 0 )
GKeys = 0
Return Handle(G)
End Function

Function AddGraphPoint( Graph, X#, Y# )
G.LotusGraph = Object.LotusGraph( Graph )
If G = Null Then Return False
Dim gGraphArray( GKeys, 1 )
For N = 0 To GKeys-1
gGraphArray( N, 0 ) = PeekFloat( GBank, N*8-1 )
gGraphArray( N, 1 ) = PeekFloat( GBank, N*8+4-1 )
Next
gGraphArray( GKeys, 0 ) = X
gGraphArray( GKeys, 1 ) = Y
DebugLog "Adding "+gGraphArray( GKeys, 0 )+","+gGraphArray( GKeys, 1 )+" to graph "+Graph
InsertionSort( GKeys )
If gLotusDebugInfo Then
DebugLog ""
DebugLog "----GRAPH REPORT-----"
For N = 0 To GKeys
DebugLog gGraphArray( N, 0 ) + "  ,    "+gGraphArray( N, 1 )
Next
DebugLog "---------------------------"
DebugLog ""
EndIf
GKeys = GKeys + 1
ResizeBank GBank, GKeys*8
For N = 0 To GKeys - 1
PokeFloat( GBank, N*8-1, gGraphArray( N, 0 ) )
PokeFloat( GBank, N*8+4-1, gGraphArray( N, 1 ) )
Next
GWidth = gGraphArray( GKeys-1, 0 )
DebugLog "Resized graph to "+GWidth
End Function

Function RemoveGraphPoint( Graph, X#, Range# = 0 )
G.LotusGraph = Object.LotusGraph( Graph )
If G = Null Then Return False
Dim gGraphArray( GKeys-2, 1 )
For N = 0 To GKeys-1
eX# = PeekFloat( GBank, N*8-1 )
If (eX > X+Range And eX < X-Range) Or Found = True Then
gGraphArray( C, 0 ) = eX
gGraphArray( C, 1 ) = PeekFloat( GBank, N*8+4-1 )
C = C + 1
Else
Found = True
EndIf
Next
InsertionSort( GKeys-2 )
GKeys = GKeys - 1
ResizeBank GBank, GKeys*8
For N = 0 To GKeys - 1
PokeFloat( GBank, N*8-1, gGraphArray( N, 0 ) )
PokeFloat( GBank, N*8+4-1, gGraphArray( N, 1 ) )
Next
GWidth = gGraphArray( GKeys-1, 0 )
DebugLog "Resized graph to "+GWidth
End Function

Function AccumulateGraphArray( G.LotusGraph )
If G = Null Then Return False
Dim gGraphArray( GKeys-1, 1 )
For N = 0 To GKeys-1
gGraphArray( N, 0 ) = PeekFloat( GBank, N*8-1 )
gGraphArray( N, 1 ) = PeekFloat( GBank, N*8+4-1 )
Next
End Function

Function FreeGraph( Graph )
G.LotusGraph = Object.LotusGraph( Graph )
If G = Null Then Return False
FreeBank GBank
Delete G
End Function


Function SetLotusCamera(Camera)
gLotusCamera = Camera
End Function

Function StartEmitter( Emitter, ActiveSpan = -2, FreeEmitterOnEnd=0 )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If ActiveSpan > -2 Then
SetEmitterActiveSpan Emitter,ActiveSpan
EndIf
EActive = EActiveSpan
EEmit = 1

If EEmitSound <> 0 Then EEmitSoundChannel = PlaySound( EEmitSound )

EFreeOnEndActive = FreeEmitterOnEnd
End Function

Function StopEmitter( Emitter )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If EEmitSoundChannel <> 0 And ELoopEmitSound >= 1 Then StopChannel( EEmitSoundChannel )
EEmit = 0
EActive = -1
End Function

Function SetEmitterLifespan(Emitter,Lifespan,Jitter%=0,Up%=1,Down%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ELifespan = Lifespan
ELifeSpanJitter = Jitter%
ELifeSpanJitterUp% = Up%
ELifeSpanJitterDown% = Down%
End Function

Function SetEmitterActiveSpan( Emitter, Active=-1 )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EActiveSpan = Active
End Function

Function SetEmitterPosition(Emitter,X#,Y#,Z#) ;; Backwards compatibility
If EmitterExists( Emitter ) = 0 Then Return False
PositionEntity Emitter,X,Y,Z
End Function

Function SetEmitterAngle(Emitter,Pitch#,Yaw#,Roll#) ;; Backwards compatibility
If EmitterExists( Emitter ) = 0 Then Return False
RotateEntity Emitter,Pitch,Yaw,Roll
End Function

Function SetEmitterTranslation(Emitter,X#,Y#,Z#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ETranslationX = X
ETranslationY = Y
ETranslationZ = Z
Return True
End Function

Function SetEmitterVelocity(Emitter,X#,Y#,Z#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EVelocityX = X
EVelocityY = Y
EVelocityZ = Z
Return True
End Function

Function SetEmitterVelocityDecay(Emitter,Decay#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EVelocityDecay = Decay
End Function

Function SetEmitterAcceleration(Emitter,X#,Y#,Z#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EAccelerationX = X
EAccelerationY = Y
EAccelerationZ = Z
End Function

Function SetEmitterAngleVelocity(Emitter,Pitch#,Yaw#,Roll#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EAngleVelocityX = Pitch
EAngleVelocityY = Yaw
EAngleVelocityZ = Roll
End Function

Function SetEmitterAngleAcceleration(Emitter,Pitch#,Yaw#,Roll#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EAngleAccelerationX = Pitch
EAngleAccelerationY = Yaw
EAngleAccelerationZ = Roll
End Function

Function SetEmitterTranslationJitter(Emitter,X#,Y#,Z#,Up%=1,Down%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ETranslationJitterX = X
ETranslationJitterY = Y
ETranslationJitterZ = Z
ETranslationJitterUp = Up
ETranslationJitterDown = Down
End Function

Function SetEmitterVelocityJitter(Emitter,X#,Y#,Z#,Up%=1,Down%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EVelocityJitterX = X
EVelocityJitterY = Y
EVelocityJitterZ = Z
EVelocityJitterUp = Up
EVelocityJitterDown = Down
End Function

Function SetEmitterColorFrom(Emitter,Red=255,Green=255,Blue=255,Alpha#=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName$(Emitter)))
If E <> Null Then
ERedFrom = Red
EGreenFrom = Green
EBlueFrom = Blue
EAlphaFrom = Alpha
Else
Return False
EndIf
Return True
End Function

Function SetEmitterColorTo(Emitter,Red=255,Green=255,Blue=255,Alpha#=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName$(Emitter)))
If E <> Null Then
ERedTo = Red
EGreenTo = Green
EBlueTo = Blue
EAlphaTo = Alpha
Else
Return False
EndIf
Return True
End Function

Function SetEmitterColorJitter(Emitter,Red%=0,Green%=0,Blue%=0,Alpha#=0,Uniform%=1,Up%=1,Down%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EColorJitterRed = Red
EColorJitterGreen = Green
EColorJitterBlue = Blue
EColorJitterAlpha = Alpha
EColorJitterUniform = Uniform
EColorJitterUp = Up
EColorJitterDown = Down
End Function

Function SetEmitterColor(Emitter,Red=255,Green=255,Blue=255,Alpha#=1)
If EmitterExists( Emitter ) = 0 Then Return False
SetEmitterColorFrom Emitter,Red,Green,Blue,Alpha
SetEmitterColorTo Emitter,Red,Green,Blue,Alpha
End Function

Function SetEmitterSizeFrom(Emitter,X#=1,Y#=1,Z#=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESizeFromX = X
ESizeFromY = Y
ESizeFromZ = Z
End Function

Function SetEmitterSizeTo(Emitter,X#=1,Y#=1,Z#=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESizeToX = X
ESizeToY = Y
ESizeToZ = Z
End Function

Function SetEmitterSizeJitter(Emitter,X#=0,Y#=0,Z#=0,Uniform%=1,Up%=1,Down%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESizeJitterX = X
ESizeJitterY = Y
ESizeJitterZ = Z
ESizeJitterUniform = Uniform
ESizeJitterUp = Up
ESizeJitterDown = Down
End Function

Function SetEmitterSize(Emitter,X#=1,Y#=1,Z#=1)
If EmitterExists( Emitter ) = 0 Then Return False
SetEmitterSizeFrom Emitter,X,Y,Z
SetEmitterSizeTo Emitter,X,Y,Z
End Function

Function SetEmitterBlend(Emitter,Blend=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EBlendMode = Blend
End Function

Function SetEmitterRandomRotation(Emitter,PitchRange#=0,YawRange#=0,RollRange#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ERandomRotationX = PitchRange
ERandomRotationY = YawRange
ERandomRotationZ = RollRange
End Function

Function SetEmitterParticleMesh(Emitter,Mesh=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EParticleMesh = Mesh
End Function

Function SetEmitterRoll(Emitter,Roll#=0)
If EmitterExists( Emitter ) = 0 Then Return False
RotateEntity Emitter,EntityPitch(Emitter,False),EntityYaw(Emitter,False),Roll
End Function

Function SetEmitterAutoEmit(Emitter,Emit=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EEmit = Emit
If Emit Then EActive = -1
End Function

Function SetEmitterTrail(Emitter,TrailEmitter=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If TrailEmitter <> 0 Then
Trail.LotusEmitter = Object.LotusEmitter(Int(EntityName(TrailEmitter)))
Else
Trail.LotusEmitter = Null
EndIf

ETrail = Trail
End Function

Function SetEmitterChild(Emitter,ChildEmitter=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If ChildEmitter <> 0 Then
Child.LotusEmitter = Object.LotusEmitter(Int(EntityName(ChildEmitter)))
Else
Child.LotusEmitter = Null
EndIf

EChild = Child
If Child <> Null Then ChildParent = E
End Function

Function SetEmitterParent(Emitter,ParentEmitter=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If ParentEmitter <> 0 Then
Parent.LotusEmitter = Object.LotusEmitter(Int(EntityName(ParentEmitter)))
Else
Parent.LotusEmitter = Null
EndIf

EParent = Parent
If Parent <> Null Then ParentChild = E
End Function

Function SetEmitterBox(Emitter,X#=0,Y#=0,Z#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ECubeX = X
ECubeY = Y
ECubeZ = Z
End Function

Function SetEmitterCylinder(Emitter,Radius#=0,Top#=0,Bottom#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ECylinderX = Radius
ECylinderY = Top
ECylinderZ = Bottom
End Function

Function SetEmitterRadius(Emitter,Radius#=0,InnerRadius# = 0,YRadius# = 0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ERadius = Radius
EInnerRadius = InnerRadius
If YRadius# = 0 Then YRadius# = Radius#
EYRadius# = YRadius
End Function

Function SetEmitterWaveSpeed(Emitter,X#=1,Y#=1,Z#=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EWaveSpeedX = Abs X
EWaveSpeedY = Abs Y
EWaveSpeedZ = Abs Z
End Function

Function SetEmitterWaveRadius(Emitter,X#=0,Y#=0,Z#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EWaveRadiusX = X
EWaveRadiusY = Y
EWaveRadiusZ = Z
End Function

Function SetEmitterEmissionRate(Emitter,Amount%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EEmissionRate = Amount
End Function

Function SetEmitterViewMode(Emitter,Mode%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EViewMode = Mode
End Function

Function SetEmitterLifeMode(Emitter,Mode%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ELifeMode = Max(Min(Mode,1),3)
End Function

Function SetEmitterChildMode(Emitter,Mode%=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EChildMode = Mode
End Function

Function SetEmitterWaitSpan(Emitter,Span%=1,Jitter%=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EWaitSpan = Min(Span,1)
EDWaitSpan = Min(Span,1)
EWaitSpanJitter = Jitter
End Function

Function SetEmitterCircleSpeed(Emitter,X#,Y#,Z#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ECircleSpeedX = Abs X
ECircleSpeedY = Abs Y
ECircleSpeedZ = Abs Z
End Function

Function SetEmitterCircleRadius(Emitter,X#,Y#,Z#)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ECircleRadiusX = X
ECircleRadiusY = Y
ECircleRadiusZ = Z
End Function

Function SetEmitterRadii(Emitter,X#,Y#,Z#) ;; Backwards compatibility
Return SetEmitterCircleRadius(Emitter,X,Y,Z)
End Function

Function SetEmitterRadiiSpeed(Emitter,X#,Y#,Z#) ;; Backwards compatibility
Return SetEmitterCircleSpeed(Emitter,X,Y,Z)
End Function

Function FreezeEmitter(Emitter,Recursive% = True)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
While E <> Null
EFrozen = True
T.LotusEmitter = ETrail
If T <> Null And Recursive = True Then TFrozen = True
For P.LotusParticle = Each LotusParticle
If PParent = E Or (PParent = T And Recursive) Then
PFrozen = True
EndIf
Next
If EEmitSoundChannel <> 0 Then PauseChannel( EEmitSoundChannel )
If Recursive Then
E = EChild
If E <> Null Then T = ETrail
Else
E = Null
EndIf
Wend
End Function

Function UnFreezeEmitter(Emitter,Recursive% = True)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
While E <> Null
EFrozen = False
T.LotusEmitter = ETrail
If T <> Null And Recursive = True Then TFrozen = False
For P.LotusParticle = Each LotusParticle
If PParent = E Or (PParent = T And Recursive) Then
If PLifeMode = 2 And PFrozen = True Then
PLifeBegan = MilliSecs()-(PLifeSpan-PLife)
EndIf
PFrozen = False
EndIf
Next
If EEmitSoundChannel <> 0 Then ResumeChannel( EEmitSoundChannel )
If Recursive Then
E = EChild
If E <> Null Then T = ETrail
Else
E = Null
EndIf
Wend
End Function

Function HideEmitter(Emitter,Recursive% = True)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
While E <> Null
T.LotusEmitter = ETrail
EHidden = True
If T <> Null And Recursive = True Then THidden = True
For P.LotusParticle = Each LotusParticle
If PParent = E Or (PParent = T And Recursive = True) Then
PHidden = True
EndIf
Next
If Recursive Then
E = EChild
If E <> Null Then T = ETrail
Else
E = Null
EndIf
Wend
End Function

Function ShowEmitter(Emitter,Recursive% = True)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
While E <> Null
T.LotusEmitter = ETrail
EHidden = False
If T <> Null And Recursive = True Then THidden = False
For P.LotusParticle = Each LotusParticle
If PParent = E Or (PParent = T And Recursive = True) Then
PHidden = False
EndIf
Next
If Recursive Then
E = EChild
If E <> Null Then T = ETrail
Else
E = Null
EndIf
Wend
End Function

Function SetEmitterGravity(Emitter,Gravity#=0,Enabled=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EGravity = Gravity
EGravityEnabled = Min(Max(Enabled,1),0)
End Function

Function SetEmitterGravityJitter(Emitter,GravityJitter#=0,Up=1,Down=1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EGravityJitter# = GravityJitter
EGravityJitterUp = Up
EGravityJitterDown = Down
End Function

Function SetEmitterWeight(Emitter,Weight#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EWeight = Weight
End Function

Function SetEmitterRollMode(Emitter,Mode%=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ERollMode = Mode
End Function

Function SetEmitterViewRange(Emitter,Range#=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ERange# = Range#
End Function

Function SetEmitterCulling(Emitter,Enabled=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ECull = Enabled
End Function

Function SetEmitterSorting(Emitter,Enabled=0)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESorting = Enabled
End Function

Function SetEmitterColorGraph(Emitter, Graph)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EColorGraph = Object.LotusGraph( Graph )
End Function

Function SetEmitterSizeGraph(Emitter, Graph)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESizeGraph = Object.LotusGraph( Graph )
End Function

Function SetEmitterBounce(Emitter, MinY#, Bounce%=-1, BounceDecay#=.25, MaximumBounces%=-1)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EMinY = MinY
If Bounce > -1 Then EBounce = Bounce
EBounceDecay = BounceDecay
If MaximumBounces > -1 Then EBounceMax = MaximumBounces
End Function

Function SetEmitterEmissionSound(Emitter, Sound, Loop = 0, Range# = 100)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
If EEmitSound <> Sound Then
If EEmitSoundChannel <> 0 Then
StopChannel EEmitSoundChannel
EEmitSoundChannel = 0
EndIf
EndIf
EEmitSound = Sound
ELoopEmitSound = Loop
EEmitSoundRange = 100
End Function

Function SetEmitterBounceSound(Emitter, Sound, Range# = 100)
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EBounceSound = Sound
EBounceSoundRange = Range
End Function

Function SetEmitterSplineMesh( Emitter, Mesh=0 )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
ESplineMesh = Mesh
End Function

Function SetEmitterDeflectorsAffect( Emitter, Enabled=1 )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EDeflectorsAffect = Enabled
End Function

Function EnableDeflectors( Emitter )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EDeflectorsAffect = True
End Function

Function DisableDeflectors( Emitter )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
EDeflectorsAffect = False
End Function

Function EmitterActive( Emitter )
If EmitterExists( Emitter ) = 0 Then Return False
E.LotusEmitter = Object.LotusEmitter(Int(EntityName(Emitter)))
If E = Null Then Return False
Return EEmit
End Function

Function LoadASCIIEmitters( Path$ )
i.XMLNode = ReadXML(Path)
f.XMLNode = i

While f <> Null
ParseLPXML(f)
f = XMLNextNode(f)
Wend

XMLDeleteNode(i)

Return 1
End Function

Function ParseLPXML(i.xmlNode)
End Function


Comments :


Wayne(Posted 1+ years ago)

 The html to part one should be:<a href="codearcs1d1b.html?code=1654#" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=1654#</a>Nice work, checking it out.


Mikele(Posted 1+ years ago)

 Thanks Noel for amazing library but could you explain how can i use "graph" things ?


N(Posted 1+ years ago)

 Think of them as a keyframe system.For example:
SetEmitterColorFrom( emt, 255, 0, 0, 1 ) ; Start color = blue
SetEmitterColorTo( emt, 0, 255, 0, 1 ) ; End color = green

Graph = CreateGraph( )
AddGraphPoint( Graph, 0, 0 ) ; Starting point 0 uses red
AddGraphPoint( Graph, 5, 1 ) ; Middle point 5 uses green
AddGraphPoint( Graph, 10, 0 ) ; End point 10 uses red
SetEmitterColorGraph( emt, Graph ) ; Use the graph
The idea here is that 0 is the starting keyframe, 5 is halfway through, and 10 is the end.  The highest X is always the ending in the graph.  Y denotes the value between the From and To values of the corresponding component the graph is assigned to.For example, if you had a graph with Y points like this:1.5010The interpolation would be something like this:End valueMiddle valueStart valueEnd valueStart value


Mikele(Posted 1+ years ago)

 Ahh... ok. Thank you!BTW. SetEmitterRadius function don't work.You can change lines:gTempLotusVectorX = gSine(RndAng)*RndRad + (gSine(ET*ECircleSpeedX Mod 359)*ECircleRadiusX)+Rnd(-ECubeX,ECubeX)
gTempLotusVector = Rnd(ECylinderZ,ECylinderY) + gSine(ET*ECircleSpeedY Mod 359)*ECircleRadiusY+Rnd(-ECubeY,ECubeY)
gTempLotusVectorY = gCosine(RndAng)*RndRad + (gCosine(ET*ECircleSpeedZ Mod 359)*ECircleRadiusZ)+Rnd(-ECubeZ,ECubeZ)
toRRad# = Rnd(EInnerRadius,ERadius)
gTempLotusVectorX = gSine(RndAng)*RndRad + (gSine(ET*RRad Mod 359)*RRad) + (gSine(ET*ECircleSpeedX Mod 359)*ECircleRadiusX)+Rnd(-ECubeX,ECubeX)
gTempLotusVector =Rnd(-EYRadius,EYRadius) + Rnd(ECylinderZ,ECylinderY) + gSine(ET*ECircleSpeedY Mod 359)*ECircleRadiusY+Rnd(-ECubeY,ECubeY)
gTempLotusVectorY = (gCosine(ET*RRad Mod 359)*RRad) + gCosine(RndAng)*RndRad + (gCosine(ET*ECircleSpeedZ Mod 359)*ECircleRadiusZ)+Rnd(-ECubeZ,ECubeZ)
and now Radius, InnerRadius & YRadius works for me.


N(Posted 1+ years ago)

 Included the fix.  Can't test it as I no longer have Blitz3D, but I'll take your word for it. [/i]