2
* Animation plugin for compiz/beryl
6
* Copyright : (C) 2006 Erkin Bahceci
7
* E-mail : erkinbah@gmail.com
9
* Based on Wobbly and Minimize plugins by
11
* E-mail : davidr@novell.com>
13
* Particle system added by : (C) 2006 Dennis Kasprzyk
14
* E-mail : onestone@beryl-project.org
16
* Beam-Up added by : Florencio Guimaraes
17
* E-mail : florencio@nexcorp.com.br
19
* Hexagon tessellator added by : Mike Slegeir
20
* E-mail : mikeslegeir@mail.utexas.edu>
22
* This program is free software; you can redistribute it and/or
23
* modify it under the terms of the GNU General Public License
24
* as published by the Free Software Foundation; either version 2
25
* of the License, or (at your option) any later version.
27
* This program is distributed in the hope that it will be useful,
28
* but WITHOUT ANY WARRANTY; without even the implied warranty of
29
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
* GNU General Public License for more details.
32
* You should have received a copy of the GNU General Public License
33
* along with this program; if not, write to the Free Software
34
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
39
// ===================== Effect: Explode =========================
41
const float ExplodeAnim::kDurationFactor = 1.43;
43
ExplodeAnim::ExplodeAnim (CompWindow *w,
44
WindowEvent curWindowEvent,
46
const AnimEffect info,
47
const CompRect &icon) :
48
Animation::Animation (w, curWindowEvent, kDurationFactor * duration, info,
50
PolygonAnim::PolygonAnim (w, curWindowEvent, kDurationFactor * duration,
53
mAllFadeDuration = 0.3f;
56
mCorrectPerspective = CorrectPerspectivePolygon;
57
mBackAndSidesFadeDur = 0.2f;
63
switch (optValI (AnimationaddonOptions::ExplodeTessellation))
65
case AnimationaddonOptions::ExplodeTessellationRectangular:
66
if (!tessellateIntoRectangles (optValI (AnimationaddonOptions::ExplodeGridx),
67
optValI (AnimationaddonOptions::ExplodeGridy),
68
optValF (AnimationaddonOptions::ExplodeThickness)))
71
case AnimationaddonOptions::ExplodeTessellationHexagonal:
72
if (!tessellateIntoHexagons (optValI (AnimationaddonOptions::ExplodeGridx),
73
optValI (AnimationaddonOptions::ExplodeGridy),
74
optValF (AnimationaddonOptions::ExplodeThickness)))
77
case AnimationaddonOptions::ExplodeTessellationGlass:
78
if (!tessellateIntoGlass (optValI (AnimationaddonOptions::ExplodeSpokes),
79
optValI (AnimationaddonOptions::ExplodeTiers),
80
optValF (AnimationaddonOptions::ExplodeThickness)))
87
double sqrt2 = sqrt (2);
88
float screenSizeFactor = (0.8 * DEFAULT_Z_CAMERA * ::screen->width ());
90
foreach (PolygonObject *p, mPolygons)
92
p->rotAxis.set (RAND_FLOAT (), RAND_FLOAT (), RAND_FLOAT ());
94
float speed = screenSizeFactor / 10 * (0.2 + RAND_FLOAT ());
96
float xx = 2 * (p->centerRelPos.x () - 0.5);
97
float yy = 2 * (p->centerRelPos.y () - 0.5);
99
float x = speed * 2 * (xx + 0.5 * (RAND_FLOAT () - 0.5));
100
float y = speed * 2 * (yy + 0.5 * (RAND_FLOAT () - 0.5));
102
float distToCenter = sqrt (xx * xx + yy * yy) / sqrt2;
103
float moveMult = 1 - distToCenter;
104
moveMult = moveMult < 0 ? 0 : moveMult;
106
float z = speed * 10 *
107
(zbias + RAND_FLOAT () *
108
pow (moveMult, 0.5));
110
p->finalRelPos.set (x, y, z);
111
p->finalRotAng = RAND_FLOAT () * 540 - 270;