2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/******************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
******************************************************************************/
33
#include "applet-struct.h"
34
#include "applet-evaporate.h"
37
gboolean cd_illusion_init_evaporate (Icon *pIcon, CairoDock *pDock, CDIllusionData *pData)
39
if (myData.iEvaporateTexture == 0)
40
myData.iEvaporateTexture = cd_illusion_load_evaporate_texture ();
41
double fMaxScale = (pDock->bAtBottom ? 1. : cairo_dock_get_max_scale (CAIRO_CONTAINER (pDock)));
42
CairoParticleSystem *pEvaporateParticleSystem = cairo_dock_create_particle_system (myConfig.iNbEvaporateParticles, myData.iEvaporateTexture, pIcon->fWidth * pIcon->fScale, pIcon->fHeight * fMaxScale);
43
g_return_val_if_fail (pEvaporateParticleSystem != NULL, FALSE);
44
double dt = pData->fDeltaT;
45
pEvaporateParticleSystem->dt = dt;
46
pEvaporateParticleSystem->bAddLuminance = TRUE;
47
pData->pEvaporateSystem = pEvaporateParticleSystem;
49
double a = myConfig.fEvaporateParticleSpeed;
50
static double epsilon = 0.1;
51
double r = myConfig.iEvaporateParticleSize;
53
double vmax = 1. / myConfig.iEvaporateDuration;
56
for (i = 0; i < myConfig.iNbEvaporateParticles; i ++)
58
p = &(pEvaporateParticleSystem->pParticles[i]);
60
p->x = 2 * g_random_double () - 1;
61
p->x = p->x * p->x * (p->x > 0 ? 1 : -1);
62
p->y = (myConfig.bEvaporateFromBottom ? 0. : 1.);
63
p->z = 2 * g_random_double () - 1;
64
p->fWidth = r*(p->z + 2)/3 * g_random_double ();
65
p->fHeight = p->fWidth;
68
p->vy = a * vmax * ((p->z + 1)/2 + epsilon) * dt;
69
p->iInitialLife = myConfig.iEvaporateDuration / dt;
71
p->iInitialLife = MIN (p->iInitialLife, 1. / p->vy);
74
p->iInitialLife *= g_random_double ();
75
p->iLife = p->iInitialLife;
77
if (myConfig.bMysticalEvaporate)
79
p->color[0] = g_random_double ();
80
p->color[1] = g_random_double ();
81
p->color[2] = g_random_double ();
85
fBlend = g_random_double ();
86
p->color[0] = fBlend * myConfig.pEvaporateColor1[0] + (1 - fBlend) * myConfig.pEvaporateColor2[0];
87
p->color[1] = fBlend * myConfig.pEvaporateColor1[1] + (1 - fBlend) * myConfig.pEvaporateColor2[1];
88
p->color[2] = fBlend * myConfig.pEvaporateColor1[2] + (1 - fBlend) * myConfig.pEvaporateColor2[2];
92
p->fOscillation = G_PI * (2 * g_random_double () - 1);
93
p->fOmega = 2*G_PI / myConfig.iEvaporateDuration * dt; // tr/s
96
p->fResizeSpeed = -.5 / myConfig.iEvaporateDuration * dt; // zoom 0.5 a la fin.
104
static void _cd_illusion_rewind_evaporate_particle (CairoParticle *p, CDIllusionData *pData, double dt)
106
static double epsilon = 0.1;
107
double a = myConfig.fEvaporateParticleSpeed;
108
double r = myConfig.iEvaporateParticleSize;
109
double vmax = 1. / myConfig.iEvaporateDuration;
110
p->x = 2 * g_random_double () - 1;
111
p->x = p->x * p->x * (p->x > 0 ? 1 : -1);
112
p->y = (myConfig.bEvaporateFromBottom ? pData->fEvaporatePercent : 1 - pData->fEvaporatePercent);
113
p->fWidth = r*(p->z + 2)/3 * g_random_double ();
114
p->fHeight = p->fWidth;
115
p->vy = a * vmax * ((p->z + 1)/2 * g_random_double () + epsilon) * dt;
117
p->iInitialLife = myConfig.iEvaporateDuration / dt;
119
p->iInitialLife = MIN (p->iInitialLife, 1. / p->vy);
122
p->iInitialLife *= g_random_double ();
123
p->iLife = p->iInitialLife;
127
static void cd_illusion_update_evaporate_system (CairoParticleSystem *pParticleSystem, CDIllusionData *pData)
131
for (i = 0; i < pParticleSystem->iNbParticles; i ++)
133
p = &(pParticleSystem->pParticles[i]);
135
p->fOscillation += p->fOmega;
136
p->x += p->vx + (p->z + 2)/3. * .02 * sin (p->fOscillation); // 3%
138
p->color[3] = 1.*p->iLife / p->iInitialLife;
139
p->fSizeFactor += p->fResizeSpeed;
145
_cd_illusion_rewind_evaporate_particle (p, pData, pParticleSystem->dt);
149
_cd_illusion_rewind_evaporate_particle (p, pData, pParticleSystem->dt);
153
void cd_illusion_update_evaporate (Icon *pIcon, CairoDock *pDock, CDIllusionData *pData)
155
pData->fEvaporatePercent = pData->fTime / myConfig.iEvaporateDuration;
157
cd_illusion_update_evaporate_system (pData->pEvaporateSystem, pData);
158
pData->pEvaporateSystem->fHeight = pIcon->fHeight * pIcon->fScale;
159
pData->pEvaporateSystem->fWidth = pIcon->fWidth * pIcon->fScale;
161
cairo_dock_redraw_icon (pIcon, pDock);
164
void cd_illusion_draw_evaporate_icon (Icon *pIcon, CairoDock *pDock, CDIllusionData *pData)
167
cairo_dock_set_icon_scale (pIcon, pDock, 1.);
169
_cairo_dock_enable_texture ();
170
_cairo_dock_set_alpha (pIcon->fAlpha);
171
_cairo_dock_set_blend_over ();
173
glBindTexture(GL_TEXTURE_2D, pIcon->iIconTexture);
177
if (myConfig.bEvaporateFromBottom)
179
glTexCoord2f(0., 0.); glVertex3f(-.5, .5, 0.); // Bottom Left Of The Texture and Quad
180
glTexCoord2f(1., 0.); glVertex3f( .5, .5, 0.); // Bottom Right Of The Texture and Quad
181
glTexCoord2f(1., 1 - pData->fEvaporatePercent); glVertex3f( .5, -.5 + pData->fEvaporatePercent, 0.); // Top Right Of The Texture and Quad
182
glTexCoord2f(0., 1 - pData->fEvaporatePercent); glVertex3f(-.5, -.5 + pData->fEvaporatePercent, 0.); // Top Left Of The Texture and Quad
186
glTexCoord2f(0., pData->fEvaporatePercent); glVertex3f(-.5, .5 - pData->fEvaporatePercent, 0.); // Bottom Left Of The Texture and Quad
187
glTexCoord2f(1., pData->fEvaporatePercent); glVertex3f( .5, .5 - pData->fEvaporatePercent, 0.); // Bottom Right Of The Texture and Quad
188
glTexCoord2f(1., 1.); glVertex3f( .5, -.5, 0.); // Top Right Of The Texture and Quad
189
glTexCoord2f(0., 1.); glVertex3f(-.5, -.5, 0.); // Top Left Of The Texture and Quad
195
/*if (pDock->bUseReflect)
198
double x0, y0, x1, y1;
199
double fReflectRatio = myIcons.fReflectSize * pDock->fRatio / pIcon->fHeight / pIcon->fScale;
200
double fOffsetY = pIcon->fHeight * pIcon->fScale/2 + (myIcons.fReflectSize/2 + pIcon->fDeltaYReflection) * pDock->fRatio;
201
if (pDock->bHorizontalDock)
203
if (pDock->bDirectionUp)
205
fOffsetY = pIcon->fHeight * pIcon->fScale + pIcon->fDeltaYReflection;
206
glTranslatef (0., - fOffsetY, 0.);
207
glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, - pIcon->fHeight * pIcon->fScale, 1.); // taille du reflet et on se retourne.
209
y0 = 1. - fReflectRatio;
215
glTranslatef (0., fOffsetY, 0.);
216
glScalef (pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, myIcons.fReflectSize * pDock->fRatio, 1.);
225
if (pDock->bDirectionUp)
227
glTranslatef (fOffsetY, 0., 0.);
228
glScalef (- myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
229
x0 = 1. - fReflectRatio;
236
glTranslatef (- fOffsetY, 0., 0.);
237
glScalef (myIcons.fReflectSize * pDock->fRatio, pIcon->fWidth * pIcon->fWidthFactor * pIcon->fScale, 1.);
244
//glEnableClientState(GL_COLOR_ARRAY);
246
//glColorPointer(4, GL_FLOAT, 0, pData->pColors);
247
//glDrawArrays (GL_TRIANGLE_FAN, 0, pData->iNumActiveNodes);
249
//glDisableClientState(GL_COLOR_ARRAY);
252
glActiveTexture(GL_TEXTURE0_ARB); // Go pour le multitexturing 1ere passe
253
glEnable(GL_TEXTURE_2D); // On active le texturing sur cette passe
254
glBindTexture(GL_TEXTURE_2D, pIcon->iIconTexture);
256
glColor4f(1., 1., 1., myIcons.fAlbedo * pIcon->fAlpha); // transparence du reflet.
259
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
261
glActiveTexture(GL_TEXTURE1_ARB); // Go pour le texturing 2eme passe
262
glEnable(GL_TEXTURE_2D);
263
glBindTexture(GL_TEXTURE_2D, g_pGradationTexture[pDock->bHorizontalDock]);
264
glColor4f(1., 1., 1., 1.); // transparence du reflet.
266
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
267
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Le mode de combinaison des textures
268
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); // multiplier les alpha.
269
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
270
glEnableClientState (GL_VERTEX_ARRAY);
272
glTexCoordPointer (2, GL_FLOAT, 0, pData->pCoords);
273
glVertexPointer (3, GL_FLOAT, 0, pData->pVertices);
275
glDrawArrays (GL_TRIANGLE_FAN, 0, pData->iNumActiveNodes);
277
glActiveTexture(GL_TEXTURE1_ARB);
278
glDisable(GL_TEXTURE_2D);
279
glDisableClientState (GL_TEXTURE_COORD_ARRAY);
280
glDisableClientState (GL_VERTEX_ARRAY);
281
glDisable(GL_TEXTURE_GEN_S);
282
glDisable(GL_TEXTURE_GEN_T);
283
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
284
glActiveTexture(GL_TEXTURE0_ARB);
285
glDisable(GL_TEXTURE_2D);
286
glDisable(GL_TEXTURE_GEN_S);
287
glDisable(GL_TEXTURE_GEN_T);
292
_cairo_dock_disable_texture ();
294
if (pData->fEvaporatePercent < 1 && pData->fEvaporatePercent > 0)
297
glTranslatef (0., - pIcon->fHeight * pIcon->fScale/2, 0.);
298
cairo_dock_render_particles (pData->pEvaporateSystem);