-
Notifications
You must be signed in to change notification settings - Fork 0
/
uParticles.pas
602 lines (521 loc) · 21.3 KB
/
uParticles.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
unit uParticles;
interface
uses OpenGL, u3DTypes, uCalc{, FormOpenGL};
const
MaxSparks = 20; // max. 20 vonken tegelijkertijd
SparkSize = 7; // textures zijn zoveel punten groot in beeld
MaxSparksTrail = 10; // iedere vonk heeft zoveel vonken in zijn staart
RotateTex = false; // textures roteren?
type
TRGBA = record
R,G,B,A: single;
end;
const
wit : TRGBA = (R:1.0; G:1.0; B:1.0; A:1.0;);
zwart : TRGBA = (R:0.0; G:0.0; B:0.0; A:1.0;);
startKleur : TRGBA = (R:1.0; G:1.0; B:0.0; A:1.0;);
eindKleur : TRGBA = (R:0.6; G:0.0; B:0.0; A:1.0;);
type
TSparkRec = record
Position,
Direction: TVector; // unitvector
Color, ColorDelta : TRGBA; // de kleur (Rood Groen Blauw Alpha)
Size, SizeDelta, // de huidige grootte van de vonken (en delta)
Speed, // de snelheid van de vonken
Gravity: single; // de zwaartekracht op de vonken (zodat ze vallen in een boog)
Alive: boolean; // deze particle nog levend?
StartTime, TimeOfDeath: Int64; // queryperformancecounter-tijd van dood vonk
end;
TMainSparkRec = record
MainSpark: TSparkRec;
TailLength: integer;
SparkTrail: array[0..MaxSparksTrail-1] of TSparkRec;
end;
TSpark = class(TObject)
private
Position,
Direction: TVector;
Speed,
MaxAngle: Single; // de maximale hoek verschil op Direction van de vonken in het bereik[0..180]
N_Sparks: integer; // Het aantal vonken tegelijkertijd zichtbaar
TimeOfDeath: Int64; // Het tijdstip waarop de vonken stoppen..
Trail: boolean; // een spark trail produceren?
//
{Sparks: array of TSparkRec;}
Sparks: array of TMainSparkRec;
procedure RenderSpark(var Spark: TSparkRec; LineOfSight: TVector);
public
// object
constructor Create;
destructor Destroy; override;
// start een vonken effect..vanaf aPosition,
// in richting aDirection,
// (evt) de normaal van het geraakte vlak
// het aantal vonken
// de snelheid van de vonken
// de tijdsduur waarover de vonken zichtbaar zijn
// een "komeetstaart" aan de vonken?
procedure Start(aPosition,aDirection, PlaneNormal: TVector; PlaneDistance: Single; NumberOfSparks: integer; aSpeed: Single; aDurationMS: Integer; aTrail: boolean);
//
procedure KillSpark(i: integer);
procedure KillSparks;
procedure Render(LineOfSight: TVector);
end;
TLensFlare = class(TObject)
private
local_Active: boolean;
public
Flare_TextureHandle: array[0..3] of GLuint; // 4 textures tbv. de lens-flare
// object
constructor Create;
destructor Destroy; override;
//
procedure ToggleFlare;
procedure Render(SunPosition, CameraPosition, LineOfSight: TVector);
end;
Var
Spark_TextureHandle: GLuint;
Sparks: TSpark;
LensFlare: TLensFlare;
implementation
uses Math, Windows, uQuake3BSP, uPlayer, uTexture, uOpenGL;
{ TSpark }
constructor TSpark.Create;
begin
SetLength(Sparks, 0);
Trail := false;
end;
destructor TSpark.Destroy;
begin
SetLength(Sparks, 0);
//
inherited;
end;
procedure TSpark.Start(aPosition, aDirection, PlaneNormal: TVector; PlaneDistance: Single; NumberOfSparks: integer; aSpeed: Single; aDurationMS: Integer; aTrail: boolean);
var i: integer;
Freq, STime, ETime, duration: Int64;
TPms, distance: single;
V: TVector;
ColDelta: TRGBA;
begin
Position := aPosition;
Direction := aDirection;
Trail := aTrail;
QueryPerformanceFrequency(Freq);
QueryPerformanceCounter(STime);
TPms := Freq/1000; // het aantal ticks per milliseconde
// alle vonken dezelfde duration
// duration := Round(aDurationMS * TPms);
// TimeOfDeath := STime + duration;
// niet meer dan het maximum aantal vonken laten produceren..
N_Sparks := Min(NumberOfSparks, MaxSparks);
SetLength(Sparks, N_Sparks); //de dynamische array alloceren..
// vonk begin-posities vastleggen..
for i:=0 to Length(Sparks)-1 do begin
duration := Random(Round(aDurationMS * TPms));
Sparks[i].MainSpark.Position := aPosition;
V := RandomizeVector(ReflectVectorOnPlane(aDirection, PlaneNormal), 30); // 30 graden willekeurige richting
Sparks[i].MainSpark.Direction := V;
Sparks[i].MainSpark.Size := Random(SparkSize);
Sparks[i].MainSpark.SizeDelta := Sparks[i].MainSpark.Size / duration;
Sparks[i].MainSpark.Speed := Random(Round(aSpeed*1000))/1000;
Sparks[i].MainSpark.Alive := true;
Sparks[i].MainSpark.StartTime := STime;
// Sparks[i].MainSpark.TimeOfDeath := TimeOfDeath;
Sparks[i].MainSpark.TimeOfDeath := STime + duration;
Sparks[i].MainSpark.Gravity := 0;
Sparks[i].MainSpark.Color := startKleur;
// de kleur delta's voor RGB per performanceCounter-tick
Sparks[i].MainSpark.ColorDelta.A := 0.0; //alpha niet aanpassen..
Sparks[i].MainSpark.ColorDelta.R := (eindKleur.R - startKleur.R) / duration;
Sparks[i].MainSpark.ColorDelta.G := (eindKleur.G - startKleur.G) / duration;
Sparks[i].MainSpark.ColorDelta.B := (eindKleur.B - startKleur.B) / duration;
Sparks[i].TailLength := 0;
end;
end;
procedure TSpark.KillSpark(i: integer);
begin
Sparks[i].MainSpark.Alive := false;
end;
procedure TSpark.KillSparks;
begin
// "gewoon" alle vonken wissen..
SetLength(Sparks, 0);
end;
procedure TSpark.RenderSpark(var Spark: TSparkRec; LineOfSight: TVector);
var V1,V2,V3,V4: TVector;
begin
with Spark do begin
// is er een texture?..
if Spark_TextureHandle <> 0 then begin
// Een billboard, altijd loodrecht op de LineOfSight van de camera..
BillBoard(Position,LineOfSight,Size,V1,V2,V3,V4);
if RotateTex then begin //textures rondraaien?
glMatrixMode(GL_TEXTURE);
glPushMatrix;
glLoadIdentity();
glRotatef(random(360), 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
end;
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Spark_TextureHandle);
//blending en fog... dan zie ik dat het mixen anders gaat dan verwacht..:|
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA {GL_ONE}); //GL_SRC_COLOR, GL_DST_ALPHA
glBegin(GL_QUADS);
glColor3f(Color.R, Color.G, Color.B);
{glNormal3f(Direction.X, Direction.Y, Direction.Z);}
glTexCoord2D(0,0);
glVertex3f(V1.X, V1.Y, V1.Z);
glTexCoord2D(1,0);
glVertex3f(V2.X, V2.Y, V2.Z);
glTexCoord2D(1,1);
glVertex3f(V3.X, V3.Y, V3.Z);
glTexCoord2D(0,1);
glVertex3f(V4.X, V4.Y, V4.Z); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
if RotateTex then begin //textures rondraaien?
glMatrixMode(GL_TEXTURE);
glPopMatrix;
glMatrixMode(GL_MODELVIEW);
end;
end else begin // er is geen texture..
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glPointSize(2.0);
glBegin(GL_POINTS);
glColor3f(Color.R, Color.G, Color.B);
glVertex3f(Position.X, Position.Y, Position.Z);
glEnd;
end;
end;
end;
procedure TSpark.Render(LineOfSight: TVector);
var i, j: integer;
T: Int64;
speed_, grav, perc : single;
OldPosition, NewPosition, V: TVector;
begin
// zijn er welvonken om af te beelden?
if Length(Sparks) = 0 then Exit;
grav := {fOpenGL.GetFrameTime} OGL.GetLastFrameTime * 9.81;
// de actuele tijd-teller ophalen
QueryPerformanceCounter(T);
glPushMatrix;
//
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE); //niet in de z-buffer schrijven, wel lezen..
// alle vonken doorlopen en afbeelden als ze nog leven..
for i:=0 to Length(Sparks)-1 do begin
with Sparks[i].MainSpark do begin
// nog levend die vonk?
if Alive and (T < TimeOfDeath) then begin
OldPosition := Position; //even bewaren voor de raytrace..
//
speed_ := {fOpenGL.GetFrameTime} OGL.GetLastFrameTime * Speed;
// met een snelheid in een richting afschieten die vonken
V := ScaleVector(UnitVector(Direction), speed_);
NewPosition := AddVector(OldPosition, V);
// omlaag laten vallen die vonken..
NewPosition.Y := NewPosition.Y - Gravity;
Gravity := Gravity + grav;
// een lijn raytracen..zodat het geraakte vlak bekend is
NewPosition := Quake3BSP.TraceRay(OldPosition, NewPosition);
if Quake3BSP.CollisionTest.Colliding then begin
Direction := ReflectVectorOnPlane(Direction, Quake3BSP.CollisionTest.VCollisionNormal);
//beetje foppen die zwaartekracht..
if Quake3BSP.CollisionTest.VCollisionNormal.Y > 0.8 then
Gravity := -Gravity*0.7;
end;
Position := NewPosition;
// afbeelden..
RenderSpark(Sparks[i].MainSpark, LineOfSight);
// kleuren veranderen..
perc := TimeOfDeath-T;
Color.R := eindKleur.R - perc*ColorDelta.R; if Color.R<0 then Color.R:=0;
Color.G := eindKleur.G - perc*ColorDelta.G; if Color.G<0 then Color.G:=0;
Color.B := eindKleur.B - perc*ColorDelta.B; if Color.B<0 then Color.B:=0;
//grootte veranderen..
Size := perc*SizeDelta; if Size<0 then Size:=0;
// de spark-trail
if Trail then begin
// trail lengte met 1 verhogen..
Inc(Sparks[i].TailLength); if Sparks[i].TailLength > MaxSparksTrail then Sparks[i].TailLength := MaxSparksTrail;
// trail-array aanpassen..
for j:=Sparks[i].TailLength-1 downto 1 do begin
Sparks[i].SparkTrail[j] := Sparks[i].SparkTrail[j-1];
with Sparks[i].SparkTrail[j] do begin
// kleur van het spoor aanpassen..
Color.R := eindKleur.R - (perc / j)*ColorDelta.R; if Color.R<0 then Color.R:=0;
Color.G := eindKleur.G - (perc / j)*ColorDelta.G; if Color.G<0 then Color.G:=0;
Color.B := eindKleur.B - (perc / j)*ColorDelta.B; if Color.B<0 then Color.B:=0;
{//grootte veranderen..
Size := Size - (perc / j)*SizeDelta; if Size<0 then Size:=0;}
end;
end;
Sparks[i].SparkTrail[0] := Sparks[i].MainSpark;
// afbeelden..
for j:=0 to Sparks[i].TailLength-1 do
RenderSpark(Sparks[i].SparkTrail[j] , LineOfSight);
end;
end else begin
KillSpark(i);
//break;
end;
end;
end;
glDepthMask(GL_TRUE);
glPopMatrix;
end;
{ TLensFlare }
constructor TLensFlare.Create;
begin
local_Active := true;
end;
destructor TLensFlare.Destroy;
begin
//
inherited;
end;
procedure TLensFlare.ToggleFlare;
begin
local_Active := not local_Active;
end;
procedure TLensFlare.Render(SunPosition, CameraPosition, LineOfSight: TVector);
var M, P: array[0..15] of glDouble; // modelview- & projection-matrix
V: array[0..3] of glInt;
SunX,SunY,SunZ: glDouble;
V1,V2,V3,V4, SunPos2D, Dir, Pos, NewPosition: TVector;
Xminus,Xplus, Yminus,Yplus: Single;
TheSize, Size, DirLen: Single;
ShowFlare: boolean;
begin
if not local_Active then Exit;
if Flare_TextureHandle[0] <= 0 then Exit;
glPushMatrix;
// de 2D scherm-coordinaten van de zon berekenen
glGetDoublev(GL_MODELVIEW_MATRIX, @M);
glGetDoublev(GL_PROJECTION_MATRIX, @P);
glGetIntegerv(GL_VIEWPORT, @V);
//
with Player.Camera.Position do glTranslatef(X, Y, Z);
//is de zon zichtbaar (voor de camera)??
if DotProduct(InverseVector(LineOfSight), SunPosition) - VectorLength(CameraPosition) <= 0 then begin
(*
// de lens-flare verbergen als de zon wordt bedekt door een vlak in de bsp
ShowFlare := true;
if Quake3BSP.IsMapLoaded then begin // collision test in BSP
ShowFlare := false;
// een lijn schieten..tot aan de eerste brush die de lijn raakt.
NewPosition := CameraPosition;
while not Quake3BSP.Collision(NewPosition) do begin
NewPosition := AddVector(NewPosition, LineOfSight);
// NewPosition buiten frustum? dan stoppen met de shooter..
if VectorLength(SubVector(NewPosition, CameraPosition)) > 5000 then begin
ShowFlare := true;
break;
end;
end;
end;
if ShowFlare then
*)
if gluProject(SunPosition.X, SunPosition.Y, SunPosition.Z,
@M, @P, @V,
SunX, SunY, SunZ) > 0 then begin
SunPos2D := Vector(SunX,SunY,0);
// de lijn Sun-CenterScreen
Dir := Vector({fOpenGL.}OGL.Center.X-SunX, {fOpenGL.}OGL.Center.Y-SunY, 0);
// de grootte van de zon-texture is relatief aan de grootte van de viewport
TheSize := Sqrt(Sqr(OGL.Width/3) + Sqr(OGL.Height/3));
// plat tekenen
{fOpenGL.}OGL.SetupFor2D;
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
//blending en fog... dan zie ik dat het mixen anders gaat dan verwacht..:|
glEnable(GL_BLEND);
glBlendFunc(GL_COLOR, GL_ONE_MINUS_SRC_ALPHA);
// De eerste flare
// de 2D-positie van de texture(s)
Pos := SunPos2D;
Size := TheSize/2;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[0]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de zon in beeld (binnen viewport)??
if (SunX >= V[0]) and (SunX <= V[2]) and (SunY >= V[1]) and (SunY <= V[3]) then begin
// de 1e halo
Pos := AddVector(SunPos2D, ScaleVector(Dir, 0.7));
Size := TheSize*0.5/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[1]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de 1e burst
Pos := AddVector(SunPos2D, ScaleVector(Dir, 0.33));
Size := TheSize*0.25/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[2]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de 2e halo
Pos := AddVector(SunPos2D, ScaleVector(Dir, 0.125));
Size := TheSize/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[1]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de 2e burst
Pos := AddVector(SunPos2D, ScaleVector(Dir, 1.5));
Size := TheSize*0.5/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[2]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de 3e halo
Pos := AddVector(SunPos2D, ScaleVector(Dir, 1.1));
Size := TheSize*0.25/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[1]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
// de 3e burst
Pos := AddVector(SunPos2D, ScaleVector(Dir, 1.2));
Size := TheSize*0.2/4;
Xminus := Pos.X-Size;
Xplus := Pos.X+Size;
Yminus := Pos.Y-Size;
Yplus := Pos.Y+Size;
V1 := Vector(Xminus,Yplus,0);
V2 := Vector(Xplus,Yplus,0);
V3 := Vector(Xplus,Yminus,0);
V4 := Vector(Xminus,Yminus,0);
glBindTexture(GL_TEXTURE_2D, Flare_TextureHandle[3]);
glBegin(GL_QUADS);
glColor3f(1,1,1);
//glNormal3f(InverseVector(LineOfSight).X, InverseVector(LineOfSight).Y, InverseVector(LineOfSight).Z);
glTexCoord2D(0,0);
glVertex2f(V1.X, V1.Y); //glVertex3f(Position.X-Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,0);
glVertex2f(V2.X, V2.Y); //glVertex3f(Position.X+Size, Position.Y-Size, Position.Z);
glTexCoord2D(1,1);
glVertex2f(V3.X, V3.Y); //glVertex3f(Position.X+Size, Position.Y+Size, Position.Z);
glTexCoord2D(0,1);
glVertex2f(V4.X, V4.Y); //glVertex3f(Position.X-Size, Position.Y+Size, Position.Z);
glEnd;
end;
end;
end;
glPopMatrix;
end;
initialization
Sparks := TSpark.Create;
LensFlare := TLensFlare.Create;
finalization
Sparks.Free;
LensFlare.Free;
end.