summaryrefslogtreecommitdiff
path: root/explode3d.c
blob: da5d5d4db79a58a67da6a8c3468ef089321dead6 (plain)
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
/*
 * Animation plugin for compiz/beryl
 *
 * animation.c
 *
 * Copyright : (C) 2006 Erkin Bahceci
 * E-mail    : erkinbah@gmail.com
 *
 * Based on Wobbly and Minimize plugins by
 *           : David Reveman
 * E-mail    : davidr@novell.com>
 *
 * Particle system added by : (C) 2006 Dennis Kasprzyk
 * E-mail                   : onestone@beryl-project.org
 *
 * Beam-Up added by : Florencio Guimaraes
 * E-mail           : florencio@nexcorp.com.br
 *
 * Hexagon tessellator added by : Mike Slegeir
 * E-mail                       : mikeslegeir@mail.utexas.edu>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "animationsim.h"

/*Bool
fxExplodeInit (CompWindow * w)
{
    CompScreen *s = w->screen;
    ANIMEG_DISPLAY (s->display);
    ANIMEG_WINDOW (w);

    if (!ad->animAddonFunc->polygonsAnimInit (w))
	return FALSE;

    switch (animGetI (w, ANIMEG_SCREEN_OPTION_EXPLODE_TESS))
    {
    case PolygonTessRect:
	if (!ad->animAddonFunc->tessellateIntoRectangles
	    (w, 
	     animGetI (w, ANIMEG_SCREEN_OPTION_EXPLODE_GRIDSIZE_X),
	     animGetI (w, ANIMEG_SCREEN_OPTION_EXPLODE_GRIDSIZE_Y),
	     animGetF (w, ANIMEG_SCREEN_OPTION_EXPLODE_THICKNESS)))
	    return FALSE;
	break;
    case PolygonTessHex:
	if (!ad->animAddonFunc->tessellateIntoHexagons
	    (w, 
	     animGetI (w, ANIMEG_SCREEN_OPTION_EXPLODE_GRIDSIZE_X),
	     animGetI (w, ANIMEG_SCREEN_OPTION_EXPLODE_GRIDSIZE_Y),
	     animGetF (w, ANIMEG_SCREEN_OPTION_EXPLODE_THICKNESS)))
	    return FALSE;
	break;
    default:
	return FALSE;
    }

    PolygonSet *pset = aw->eng->polygonSet;
    PolygonObject *p = pset->polygons;
    double sqrt2 = sqrt (2);

    int i;

    for (i = 0; i < pset->nPolygons; i++, p++)
    {
	p->rotAxis.x = RAND_FLOAT ();
	p->rotAxis.y = RAND_FLOAT ();
	p->rotAxis.z = RAND_FLOAT ();

	float screenSizeFactor = (0.8 * DEFAULT_Z_CAMERA * s->width);
	float speed = screenSizeFactor / 10 * (0.2 + RAND_FLOAT ());

	float xx = 2 * (p->centerRelPos.x - 0.5);
	float yy = 2 * (p->centerRelPos.y - 0.5);

	float x = speed * 2 * (xx + 0.5 * (RAND_FLOAT () - 0.5));
	float y = speed * 2 * (yy + 0.5 * (RAND_FLOAT () - 0.5));

	float distToCenter = sqrt (xx * xx + yy * yy) / sqrt2;
	float moveMult = 1 - distToCenter;
	moveMult = moveMult < 0 ? 0 : moveMult;
	float zbias = 0.1;
	float z = speed * 10 *
	    (zbias + RAND_FLOAT () *
	     pow (moveMult, 0.5));

	p->finalRelPos.x = x;
	p->finalRelPos.y = y;
	p->finalRelPos.z = z;
	p->finalRotAng = RAND_FLOAT () * 540 - 270;
    }
    pset->allFadeDuration = 0.3f;
    pset->doDepthTest = TRUE;
    pset->doLighting = TRUE;
    pset->correctPerspective = CorrectPerspectivePolygon;
    pset->backAndSidesFadeDur = 0.2f;

    aw->com->animTotalTime /= EXPLODE_PERCEIVED_T;
    aw->com->animRemainingTime = aw->com->animTotalTime;

    return TRUE;
}*/