1 /*
2  * Copyright 2011-2012 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Arx Libertatis is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /* Based on:
20 ===========================================================================
21 ARX FATALIS GPL Source Code
22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company.
23 
24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code').
25 
26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 
29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code.  If not, see
33 <http://www.gnu.org/licenses/>.
34 
35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these
36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx
37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below.
38 
39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o
40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
41 ===========================================================================
42 */
43 // Code: Cyril Meynier
44 //
45 // Copyright (c) 1999-2000 ARKANE Studios SA. All rights reserved
46 
47 #ifndef ARX_GRAPHICS_PARTICLE_PARTICLEEFFECTS_H
48 #define ARX_GRAPHICS_PARTICLE_PARTICLEEFFECTS_H
49 
50 #include <stddef.h>
51 
52 #include "graphics/Color.h"
53 #include "graphics/Vertex.h"
54 #include "math/MathFwd.h"
55 #include "math/Vector3.h"
56 #include "math/Angle.h"
57 
58 struct EERIEPOLY;
59 struct EERIE_CAMERA;
60 struct EERIE_SPHERE;
61 class TextureContainer;
62 class Entity;
63 
64 struct FLARES {
65 	unsigned char exist;
66 	char type;
67 	short flags;
68 	TexturedVertex v;
69 	TexturedVertex tv;
70 	float x;
71 	float y;
72 	float tolive;
73 	Color3f rgb;
74 	float size;
75 	long dynlight;
76 	long move;
77 	Entity * io;
78 	bool bDrawBitmap;
79 };
80 
81 struct POLYBOOM {
82 	long exist;
83 	short tx;
84 	short tz;
85 	EERIEPOLY * ep;
86 	float u[4];
87 	float v[4];
88 	Color3f rgb;
89 	TextureContainer * tc;
90 	unsigned long timecreation;
91 	unsigned long tolive;
92 	short type;
93 	short nbvert;
94 };
95 
96 struct PARTICLE_DEF {
97 	bool exist;
98 	long type;
99 	Vec3f ov;
100 	Vec3f move;
101 	Vec3f scale;
102 	Vec3f oldpos;
103 	float siz;
104 	bool zdec;
105 	long timcreation;
106 	unsigned long tolive;
107 	unsigned long delay;
108 	TextureContainer * tc;
109 	Color3f rgb;
110 	long special; // TODO ARX_PARTICLES_TYPE_FLAG
111 	float fparam;
112 	long mask;
113 	Vec3f * source;
114 	long sourceionum;
115 	short sval;
116 	char cval1;
117 	char cval2;
118 };
119 
120 //-----------------------------------------------------------------------------
121 struct FOG_DEF
122 {
123 	bool		exist;
124 	long		selected;
125 	Vec3f	pos;
126 	Color3f	rgb;
127 	float		size;
128 	long		special;
129 	float		scale;
130 	Vec3f	move;
131 	Anglef	angle;
132 	float		speed;
133 	float		rotatespeed;
134 	long		tolive;
135 	Vec3f	bboxmin;
136 	Vec3f	bboxmax;
137 	long		blend;
138 	float		frequency;
139 	unsigned long lastupdate;
140 };
141 
142 //-----------------------------------------------------------------------------
143 struct FLARETC
144 {
145 	TextureContainer * lumignon;
146 	TextureContainer * lumignon2;
147 	TextureContainer * plasm;
148 	TextureContainer * shine[11];
149 };
150 
151 #define MAX_FOG 100
152 #define FOG_DIRECTIONAL 1
153 #define MAX_POLYBOOM 4000
154 #define PARTICLE_2D	256
155 #define MAX_FLARES 300
156 #define MAX_FLARELIFE 4000
157 #define FLARE_MUL 2.f
158 
159 enum ARX_PARTICLES_TYPE_FLAG {
160 	FIRE_TO_SMOKE       = 0x00000001,
161 	ROTATING            = 0x00000002,
162 	FADE_IN_AND_OUT     = 0x00000004,
163 	MODULATE_ROTATION   = 0x00000008,
164 	DISSIPATING         = 0x00000010,
165 	GRAVITY             = 0x00000020,
166 	SUBSTRACT           = 0x00000040,
167 	FIRE_TO_SMOKE2      = 0x00000080,
168 	PARTICLE_SPARK2     = 0x00000100,
169 	FOLLOW_SOURCE       = 0x00000200,
170 	FOLLOW_SOURCE2      = 0x00000400,
171 	DELAY_FOLLOW_SOURCE = 0x00000800,
172 	NO_TRANS            = 0x00001000,
173 	PARTICLE_ANIMATED   = 0x00002000,
174 	PARTICLE_SPARK      = 0x00004000,
175 	SPLAT_GROUND        = 0x00008000,
176 	SPLAT_WATER         = 0x00010000,
177 	PARTICLE_SUB2       = 0x00020000,
178 	PARTICLE_GOLDRAIN   = 0x00040000,
179 	PARTICLE_NOZBUFFER  = 0x80000000
180 };
181 
182 //-----------------------------------------------------------------------------
183 #define BOOM_RADIUS 420.f
184 #define BOOM_RADIUS2 250.f
185 #define MAX_OBJFX			30
186 #define SPECIAL_RAYZ		1
187 #define FLARELINESTEP		7
188 #define FLARELINERND		6
189 #define MAX_EXPLO			24
190 
191 //-----------------------------------------------------------------------------
192 extern TextureContainer * explo[MAX_EXPLO];
193 extern TextureContainer * blood_splat;
194 extern FLARES flare[MAX_FLARES];
195 extern long flarenum;
196 extern short OPIPOrgb;
197 extern short PIPOrgb;
198 extern long BoomCount;
199 extern POLYBOOM polyboom[MAX_POLYBOOM];
200 extern FOG_DEF fogs[MAX_FOG];
201 extern TextureContainer * fire2;
202 extern long NewSpell;
203 extern FLARETC flaretc;
204 
205 void MagFX(const Vec3f & pos);
206 void RestoreAllLightsInitialStatus();
207 void TreatBackgroundActions();
208 void TreatBackgroundDynlights();
209 void MakeBookFX(const Vec3f & pos);
210 void UpdateObjFx() ;
211 void Add3DBoom(Vec3f * position);
212 void AddRandomSmoke(Entity * io, long amount = 1);
213 void AddFlare(Vec2s * pos, float sm, short typ, Entity * io = NULL);
214 void AddFlare2(Vec2s * pos, float sm, short typ, Entity * io);
215 void AddLFlare(float x, float y, Entity * io = NULL) ;
216 void FlareLine(Vec2s * pos0, Vec2s * pos1, Entity * io = NULL);
217 void LaunchDummyParticle();
218 void ManageTorch();
219 
220 void createSphericalSparks(const Vec3f & pos, float r, TextureContainer * tc,
221                            const Color3f & color, int mask);
222 void MakePlayerAppearsFX(Entity * io);
223 void MakeCoolFx(Vec3f * pos);
224 void SpawnGroundSplat(EERIE_SPHERE * sp, Color3f * rgb, float size, long flags);
225 
226 PARTICLE_DEF * createParticle(bool allocateWhilePaused = false);
227 long getParticleCount();
228 
229 void ARX_PARTICLES_FirstInit();
230 void ARX_PARTICLES_ClearAll();
231 void ARX_PARTICLES_Render(EERIE_CAMERA * cam);
232 void ARX_PARTICLES_Spawn_Blood(Vec3f * pos, float dmgs, long source);
233 void ARX_PARTICLES_Spawn_Blood2(const Vec3f & pos, float dmgs, Color col, Entity * io);
234 void ARX_PARTICLES_Spawn_Lava_Burn(Vec3f * pos, Entity * io = NULL);
235 void ARX_PARTICLES_Add_Smoke(Vec3f * pos, long flags, long amount, Color3f * rgb = NULL); // flag 1 = randomize pos
236 void ARX_PARTICLES_Spawn_Spark(Vec3f * pos, float dmgs, long flags);
237 void ARX_PARTICLES_Spawn_Splat(const Vec3f & pos, float dmgs, Color col);
238 void ARX_PARTICLES_SpawnWaterSplash(const Vec3f * pos);
239 
240 void ARX_BOOMS_ClearAllPolyBooms();
241 void ARX_BOOMS_Add(Vec3f * pos, long type = 0);
242 
243 void ARX_MAGICAL_FLARES_FirstInit();
244 void ARX_MAGICAL_FLARES_KillAll();
245 void ARX_MAGICAL_FLARES_Draw(long FRAMETICKS);
246 
247 void LaunchFireballBoom(Vec3f * poss, float level, Vec3f * direction = NULL, Color3f * rgb = NULL);
248 void SpawnFireballTail(Vec3f *, Vec3f *, float, long);
249 
250 #endif // ARX_GRAPHICS_PARTICLE_PARTICLEEFFECTS_H
251