Warning: Undefined array key "translationlc" in /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php on line 237
Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/parser/code.php on line 33
Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/parser/code.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/parser/code.php on line 35
var
FParticles : TGorillaParticleEmitter;
procedure TForm1.FormCreate(Sender: TObject);
var LParticleMat : TParticleMaterialSource;
LVPreset : TParticleVectorPreset;
LColorInfl : TGorillaColoredParticleInfluencer;
begin
// create the particle material shader
LParticleMat := TParticleMaterialSource.Create(FGorilla);
LParticleMat.Parent := FGorilla;
LParticleMat.UseTexture := false;
LParticleMat.IsTextureAtlas := false;
// create particle emitter for spraying effect
FParticles := TGorillaParticleEmitter.Create(FGorilla);
FParticles.Parent := FGorilla;
// connect particle shader and emitter
LParticleMat.Emitter := FParticles;
// limit number of particles
FParticles.EmitParticles := 100;
FParticles.MaxParticles := 10000;
// disable auto emittance, becaus we want only to emit on mouse click
FParticles.AutoEmit := false;
// enable particle caching
FParticles.Reuse := true;
// randomize particle properties
// 1) random position of particles
LVPreset := TParticleVectorPreset.Create(0, 0, 1000, Point3D(1, 1, 1), [axX, axY, axZ]);
FParticles.ParticlePosition := LVPreset ;
// 2) random velocity of particles
LVPreset := TParticleVectorPreset.Create(5, 10, 1000, Point3D(1, 2, 1), [axX, axY, axZ]);
LVPreset.RangeY.Negative := false;
FParticles.ParticleVelocity := LVPreset;
// 3) the rest of properties
FParticles.ParticleSize := TParticlePreset.Create(2, 3, 1, false);
FParticles.ParticleAngle := TParticlePreset.Create(0, 360, 1, false);
FParticles.ParticleWeight := TParticlePreset.Create(1, 1, 1, false);
FParticles.ParticleGrowth := TParticlePreset.Create(0, 0, 1, false);
FParticles.ParticleLifeTime := TParticlePreset.Create(500, 5000, 1000, false);
// create a color influencer for a starting and end color
LColorInfl:= TGorillaColoredParticleInfluencer.Create(FParticles);
LColorInfl.StartColor := TAlphaColorF.Create(0, 1, 0, 1);
LColorInfl.EndColor := TAlphaColorF.Create(0, 0, 1, 0);
end;
var
FLatest : TPointF;
FMouseMove : Boolean = false;
FClickPt : TPoint3D;
procedure TForm1.DoOnViewportMouseUp(ASender : TObject; AButton : TMouseButton;
AShift : TShiftState; X, Y : Single);
begin
FMouseMove := false;
end;
procedure TForm1.DoOnViewportMouseDown(ASender : TObject; AButton : TMouseButton;
AShift : TShiftState; X, Y : Single);
var I : Integer;
begin
if (ssLeft in AShift) then
begin
FMouseMove := true;
FLatest := PointF(X, Y);
// emit particles at mouse position
FClickPt := FGorilla.ScreenToWorld(Point(round(X), round(Y)));
for I := 0 to (FParticles.EmitParticles - 1) do
FParticles.EmitParticle(FClickPt);
end;
end;
procedure TForm1.DoOnViewportMouseMove(ASender : TObject; AShiftState : TShiftState;
X, Y : Single);
var lDiff : TPointF;
I : Integer;
lOrigin : TPoint3D;
begin
if (ssLeft in AShiftState) then
begin
// emit particles at mouse position
FClickPt := FGorilla.ScreenToWorld(Point(round(X), round(Y)));
for I := 0 to (FParticles.EmitParticles - 1) do
FParticles.EmitParticle(FClickPt);
end;
if FMouseMove then
begin
FLatest := PointF(X, Y);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
// on some constellations you will need an interval to update the viewport
FGorilla.Invalidate();
end;