Merge lp:~mc-return/compiz/compiz.merge-plugin-animationjc into lp:compiz/0.9.8
- compiz.merge-plugin-animationjc
- Merge into 0.9.8
Status: | Superseded |
---|---|
Proposed branch: | lp:~mc-return/compiz/compiz.merge-plugin-animationjc |
Merge into: | lp:compiz/0.9.8 |
Diff against target: |
1369 lines (+1311/-0) 11 files modified
plugins/animationjc/CMakeLists.txt (+7/-0) plugins/animationjc/animationjc.xml.in (+154/-0) plugins/animationjc/compiz-animationjc.pc.in (+12/-0) plugins/animationjc/include/animationjc/animationjc.h (+343/-0) plugins/animationjc/src/animationjc.cpp (+145/-0) plugins/animationjc/src/blackhole.cpp (+79/-0) plugins/animationjc/src/flicker.cpp (+96/-0) plugins/animationjc/src/ghost.cpp (+98/-0) plugins/animationjc/src/popcorn.cpp (+60/-0) plugins/animationjc/src/private.h (+232/-0) plugins/animationjc/src/raindrop.cpp (+85/-0) |
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-plugin-animationjc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Needs Fixing | ||
Sam Spilsbury | Pending | ||
Review via email: mp+110677@code.launchpad.net |
This proposal has been superseded by a proposal from 2013-04-02.
Commit message
Added the unsupported, but fully working plug-in "animationjc" converted from git to bzr (including history) to Compiz 0.9.8.
Description of the change
Adds the unsupported, but fully working plug-in "animationjc" converted from git to bzr (including history) to Compiz 0.9.8.
Sam Spilsbury (smspillaz) wrote : | # |
MC Return (mc-return) wrote : | # |
Black Hole, Flicker, Ghost, Popcorn & Raindrop
MC Return (mc-return) wrote : | # |
Sam, I would fully agree on that.
I have a few other ideas regarding the simplification and optimization of CCSM in general as well: For example hiding plug-ins that depend on other plug-ins and make no sense being shown in CCSM and just confuse the user (like hiding all cube-related plug-ins in CCSM if the cube is disabled for example), but that is offtopic here and requires some other place of discussion I guess ;)
MC Return (mc-return) wrote : | # |
There is another animations-plug-in that is missing, but currently crashes latest Compiz versions (but did already work in 0.9.x series). It is called simple-animations (Animations that are easy on the eyes). What should we do with that one, Sam ?
MC Return (mc-return) wrote : | # |
I guess animations-add-on was just separated to introduce and define a "Animation Time Step For Intense Effects" which can differ from the "Animation Time Step" usually used, but this function could be moved to one plug-in also, so it won't get lost...
Sam Spilsbury (smspillaz) wrote : | # |
Animationaddon exist so that distributions don't have to ship huge binaries of stuff they don't use ;-)
In any case, I'll get around to looking at the best way to approach this soon. It will take a low priority though over the next few weeks since we really need to ramp up efforts to fix up the OpenGL|ES work before I go on holiday since I won't even have a computer -.- .
MC Return (mc-return) wrote : | # |
Thanks for looking into that issue.
Unfortunately I found out that exactly those plug-ins here, which I merged first, do not seem to work with latest Compiz 0.9.7.8 anymore. :(
I can enable "Animations Experimental" and change settings, but when I select one of those 5 plug-ins (Black Hole, Flicker, Ghost, Popcorn & Raindrop) in "Animations" (for the Open-animation for example) they simply do not work. They do not crash Compiz, but they seem to not be executed either. :(
Daniel van Vugt (vanvugt) wrote : | # |
This branch keeps failing to build (when merged with lp:compiz)
In file included from /home/dan/
/home/dan/
compilation terminated.
MC Return (mc-return) wrote : | # |
I tried to investigate what exactly is the problem here, but did not find out yet.
The strange thing about this error is that composite/
Another strangeness here is the fact that it compiles as standalone plug-in (but does not work then), but does not compile when merged with lp:compiz.
MC Return (mc-return) wrote : | # |
The PLUGINDEPS opengl and composite are missing to fix compilation here.
Unfortunately I am having problems to upload to launchpad since a few days, I hope I'll be able to fix this soonish though.
Unmerged revisions
- 3254. By MC Return
-
Fixed [-Werror=
maybe-uninitial ized] compiler warning for the float 'displacement' - 3253. By MC Return
-
Removed plugins/
animationjc/ VERSION - 3252. By MC Return
-
Added missing PLUGINDEPS composite and opengl to CMakeLists.txt to fix compilation
- 3251. By MC Return
-
Rebased on latest lp:compiz (r3285)
- 3250. By MC Return
-
Added the unsupported, but fully working plug-in "animationjc" converted from git to bzr (including history) to Compiz 0.9.8.
Preview Diff
1 | === added directory 'plugins/animationjc' | |||
2 | === added file 'plugins/animationjc/CMakeLists.txt' | |||
3 | --- plugins/animationjc/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4 | +++ plugins/animationjc/CMakeLists.txt 2012-08-15 14:25:28 +0000 | |||
5 | @@ -0,0 +1,7 @@ | |||
6 | 1 | find_package (Compiz REQUIRED) | ||
7 | 2 | include (CompizPlugin) | ||
8 | 3 | include (FindOpenGL) | ||
9 | 4 | |||
10 | 5 | if (OPENGL_GLU_FOUND) | ||
11 | 6 | compiz_plugin (animationjc PLUGINDEPS composite opengl animation LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR}) | ||
12 | 7 | endif (OPENGL_GLU_FOUND) | ||
13 | 0 | 8 | ||
14 | === added file 'plugins/animationjc/animationjc.xml.in' | |||
15 | --- plugins/animationjc/animationjc.xml.in 1970-01-01 00:00:00 +0000 | |||
16 | +++ plugins/animationjc/animationjc.xml.in 2012-08-15 14:25:28 +0000 | |||
17 | @@ -0,0 +1,154 @@ | |||
18 | 1 | <compiz> | ||
19 | 2 | <!-- animationaddon metadata --> | ||
20 | 3 | <plugin name="animationjc" useBcop="true"> | ||
21 | 4 | <_short>Animations Experimental</_short> | ||
22 | 5 | <_long>Extra window animations</_long> | ||
23 | 6 | <category>Effects</category> | ||
24 | 7 | <deps> | ||
25 | 8 | <requirement> | ||
26 | 9 | <plugin>opengl</plugin> | ||
27 | 10 | <plugin>animation</plugin> | ||
28 | 11 | </requirement> | ||
29 | 12 | <relation type="after"> | ||
30 | 13 | <plugin>opengl</plugin> | ||
31 | 14 | <plugin>composite</plugin> | ||
32 | 15 | <plugin>animation</plugin> | ||
33 | 16 | <plugin>decor</plugin> | ||
34 | 17 | </relation> | ||
35 | 18 | </deps> | ||
36 | 19 | |||
37 | 20 | <options> | ||
38 | 21 | <group> | ||
39 | 22 | <_short>Effect Settings</_short> | ||
40 | 23 | |||
41 | 24 | <subgroup> | ||
42 | 25 | <_short>Black Hole</_short> | ||
43 | 26 | <option name="blackhole_delay" type="float"> | ||
44 | 27 | <_short>Delay</_short> | ||
45 | 28 | <default>0.75</default> | ||
46 | 29 | <min>0.0</min> | ||
47 | 30 | <max>0.99</max> | ||
48 | 31 | <precision>0.01</precision> | ||
49 | 32 | </option> | ||
50 | 33 | </subgroup> | ||
51 | 34 | |||
52 | 35 | <subgroup> | ||
53 | 36 | <_short>Flicker</_short> | ||
54 | 37 | <option name="flicker_amplitude" type="int"> | ||
55 | 38 | <_short>Amplitude</_short> | ||
56 | 39 | <default>3</default> | ||
57 | 40 | <min>1</min> | ||
58 | 41 | <max>10</max> | ||
59 | 42 | </option> | ||
60 | 43 | </subgroup> | ||
61 | 44 | |||
62 | 45 | <subgroup> | ||
63 | 46 | <_short>Ghost</_short> | ||
64 | 47 | <option name="ghost_grid" type="int"> | ||
65 | 48 | <_short>Grid</_short> | ||
66 | 49 | <default>20</default> | ||
67 | 50 | <min>2</min> | ||
68 | 51 | <max>20</max> | ||
69 | 52 | </option> | ||
70 | 53 | |||
71 | 54 | <option name="ghost_saturation" type="float"> | ||
72 | 55 | <_short>Saturation</_short> | ||
73 | 56 | <default>0.0</default> | ||
74 | 57 | <min>0.0</min> | ||
75 | 58 | <max>1.0</max> | ||
76 | 59 | <precision>0.1</precision> | ||
77 | 60 | </option> | ||
78 | 61 | |||
79 | 62 | <option name="ghost_amplitude" type="float"> | ||
80 | 63 | <_short>Amplitude</_short> | ||
81 | 64 | <default>1.0</default> | ||
82 | 65 | <min>0.0</min> | ||
83 | 66 | <max>5.0</max> | ||
84 | 67 | </option> | ||
85 | 68 | |||
86 | 69 | <option name="ghost_wave_speed" type="float"> | ||
87 | 70 | <_short>Wave Speed</_short> | ||
88 | 71 | <default>1.0</default> | ||
89 | 72 | <min>0.0</min> | ||
90 | 73 | <max>5.0</max> | ||
91 | 74 | </option> | ||
92 | 75 | </subgroup> | ||
93 | 76 | |||
94 | 77 | <subgroup> | ||
95 | 78 | <_short>Popcorn</_short> | ||
96 | 79 | <option name="popcorn_kernel_height" type="float"> | ||
97 | 80 | <_short>Kernel Height</_short> | ||
98 | 81 | <default>1.0</default> | ||
99 | 82 | <min>0.0</min> | ||
100 | 83 | <max>5.0</max> | ||
101 | 84 | <precision>0.1</precision> | ||
102 | 85 | </option> | ||
103 | 86 | </subgroup> | ||
104 | 87 | |||
105 | 88 | <subgroup> | ||
106 | 89 | <_short>Raindrop</_short> | ||
107 | 90 | |||
108 | 91 | <option name="raindrop_amplitude" type="float"> | ||
109 | 92 | <_short>Amplitude</_short> | ||
110 | 93 | <default>1.0</default> | ||
111 | 94 | <min>-5.0</min> | ||
112 | 95 | <max>5.0</max> | ||
113 | 96 | <precision>0.1</precision> | ||
114 | 97 | </option> | ||
115 | 98 | |||
116 | 99 | <option name="raindrop_wavelength" type="float"> | ||
117 | 100 | <_short>Wavelength</_short> | ||
118 | 101 | <default>0.4</default> | ||
119 | 102 | <min>0.0</min> | ||
120 | 103 | <max>1.0</max> | ||
121 | 104 | <precision>0.05</precision> | ||
122 | 105 | </option> | ||
123 | 106 | |||
124 | 107 | <option name="raindrop_num_waves" type="int"> | ||
125 | 108 | <_short>Number of Waves</_short> | ||
126 | 109 | <default>1</default> | ||
127 | 110 | <min>1</min> | ||
128 | 111 | <max>5</max> | ||
129 | 112 | </option> | ||
130 | 113 | </subgroup> | ||
131 | 114 | </group> | ||
132 | 115 | </options> | ||
133 | 116 | |||
134 | 117 | <extension base_plugin="animation"> | ||
135 | 118 | <base_option>open_effects</base_option> | ||
136 | 119 | <base_option>open_random_effects</base_option> | ||
137 | 120 | <base_option>close_effects</base_option> | ||
138 | 121 | <base_option>close_random_effects</base_option> | ||
139 | 122 | <base_option>minimize_effects</base_option> | ||
140 | 123 | <base_option>minimize_random_effects</base_option> | ||
141 | 124 | <restriction> | ||
142 | 125 | <value>animationjc:Black Hole</value> | ||
143 | 126 | <_name>Black Hole</_name> | ||
144 | 127 | </restriction> | ||
145 | 128 | <restriction> | ||
146 | 129 | <value>animationjc:Ghost</value> | ||
147 | 130 | <_name>Ghost</_name> | ||
148 | 131 | </restriction> | ||
149 | 132 | <restriction> | ||
150 | 133 | <value>animationjc:Popcorn</value> | ||
151 | 134 | <_name>Popcorn</_name> | ||
152 | 135 | </restriction> | ||
153 | 136 | </extension> | ||
154 | 137 | |||
155 | 138 | <extension base_plugin="animation"> | ||
156 | 139 | <base_option>open_effects</base_option> | ||
157 | 140 | <base_option>open_random_effects</base_option> | ||
158 | 141 | <base_option>close_effects</base_option> | ||
159 | 142 | <base_option>close_random_effects</base_option> | ||
160 | 143 | <base_option>focus_effects</base_option> | ||
161 | 144 | <restriction> | ||
162 | 145 | <value>animationjc:Flicker</value> | ||
163 | 146 | <_name>Flicker</_name> | ||
164 | 147 | </restriction> | ||
165 | 148 | <restriction> | ||
166 | 149 | <value>animationjc:Raindrop</value> | ||
167 | 150 | <_name>Raindrop</_name> | ||
168 | 151 | </restriction> | ||
169 | 152 | </extension> | ||
170 | 153 | </plugin> | ||
171 | 154 | </compiz> | ||
172 | 0 | 155 | ||
173 | === added file 'plugins/animationjc/compiz-animationjc.pc.in' | |||
174 | --- plugins/animationjc/compiz-animationjc.pc.in 1970-01-01 00:00:00 +0000 | |||
175 | +++ plugins/animationjc/compiz-animationjc.pc.in 2012-08-15 14:25:28 +0000 | |||
176 | @@ -0,0 +1,12 @@ | |||
177 | 1 | prefix=@prefix@ | ||
178 | 2 | exec_prefix=@prefix@ | ||
179 | 3 | libdir=@libdir@ | ||
180 | 4 | includedir=@includedir@ | ||
181 | 5 | |||
182 | 6 | Name: compiz-animationjc | ||
183 | 7 | Description: Animation JC plugin for compiz | ||
184 | 8 | Version: @VERSION@ | ||
185 | 9 | |||
186 | 10 | Requires: compiz compiz-composite compiz-opengl compiz-animation | ||
187 | 11 | Libs: -L${libdir} -lanimationjc | ||
188 | 12 | Cflags: @COMPIZ_CFLAGS@ | ||
189 | 0 | 13 | ||
190 | === added directory 'plugins/animationjc/include' | |||
191 | === added directory 'plugins/animationjc/include/animationjc' | |||
192 | === added file 'plugins/animationjc/include/animationjc/animationjc.h' | |||
193 | --- plugins/animationjc/include/animationjc/animationjc.h 1970-01-01 00:00:00 +0000 | |||
194 | +++ plugins/animationjc/include/animationjc/animationjc.h 2012-08-15 14:25:28 +0000 | |||
195 | @@ -0,0 +1,343 @@ | |||
196 | 1 | #ifndef _COMPIZ_ANIMATIONJC_H | ||
197 | 2 | #define _COMPIZ_ANIMATIONJC_H | ||
198 | 3 | |||
199 | 4 | #define ANIMATIONADDON_ABI 20091206 | ||
200 | 5 | |||
201 | 6 | #include <core/pluginclasshandler.h> | ||
202 | 7 | |||
203 | 8 | #include <vector> | ||
204 | 9 | #include <boost/ptr_container/ptr_vector.hpp> | ||
205 | 10 | |||
206 | 11 | using namespace::std; | ||
207 | 12 | |||
208 | 13 | class PrivateAnimJCScreen; | ||
209 | 14 | |||
210 | 15 | /* | ||
211 | 16 | class AnimJCScreen : | ||
212 | 17 | public PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI>, | ||
213 | 18 | public CompOption::Class | ||
214 | 19 | { | ||
215 | 20 | public: | ||
216 | 21 | AnimJCScreen (CompScreen *); | ||
217 | 22 | ~AnimJCScreen (); | ||
218 | 23 | |||
219 | 24 | CompOption::Vector &getOptions (); | ||
220 | 25 | bool setOption (const CompString &name, CompOption::Value &value); | ||
221 | 26 | |||
222 | 27 | int getIntenseTimeStep (); | ||
223 | 28 | |||
224 | 29 | private: | ||
225 | 30 | PrivateAnimJCScreen *priv; | ||
226 | 31 | }; | ||
227 | 32 | */ | ||
228 | 33 | |||
229 | 34 | /// Base class for all polygon- and particle-based animations | ||
230 | 35 | class BaseAddonAnim : | ||
231 | 36 | virtual public Animation | ||
232 | 37 | { | ||
233 | 38 | public: | ||
234 | 39 | BaseAddonAnim (CompWindow *w, | ||
235 | 40 | WindowEvent curWindowEvent, | ||
236 | 41 | float duration, | ||
237 | 42 | const AnimEffect info, | ||
238 | 43 | const CompRect &icon); | ||
239 | 44 | ~BaseAddonAnim () {} | ||
240 | 45 | |||
241 | 46 | bool needsDepthTest () { return mDoDepthTest; } | ||
242 | 47 | |||
243 | 48 | protected: | ||
244 | 49 | /// Gets info about the extension plugin that implements this animation. | ||
245 | 50 | ExtensionPluginInfo *getExtensionPluginInfo (); | ||
246 | 51 | |||
247 | 52 | int mIntenseTimeStep; | ||
248 | 53 | |||
249 | 54 | CompositeScreen *mCScreen; | ||
250 | 55 | GLScreen *mGScreen; | ||
251 | 56 | |||
252 | 57 | bool mDoDepthTest; ///< Whether depth testing should be used in the effect | ||
253 | 58 | }; | ||
254 | 59 | |||
255 | 60 | // Particle stuff | ||
256 | 61 | |||
257 | 62 | class Particle | ||
258 | 63 | { | ||
259 | 64 | public: | ||
260 | 65 | Particle () : life (0.0f) {} | ||
261 | 66 | |||
262 | 67 | float life; ///< particle life | ||
263 | 68 | float fade; ///< fade speed | ||
264 | 69 | float width; ///< particle width | ||
265 | 70 | float height; ///< particle height | ||
266 | 71 | float w_mod; ///< particle size modification during life | ||
267 | 72 | float h_mod; ///< particle size modification during life | ||
268 | 73 | float r; ///< red value | ||
269 | 74 | float g; ///< green value | ||
270 | 75 | float b; ///< blue value | ||
271 | 76 | float a; ///< alpha value | ||
272 | 77 | float x; ///< X position | ||
273 | 78 | float y; ///< Y position | ||
274 | 79 | float z; ///< Z position | ||
275 | 80 | float xi; ///< X direction | ||
276 | 81 | float yi; ///< Y direction | ||
277 | 82 | float zi; ///< Z direction | ||
278 | 83 | float xg; ///< X gravity | ||
279 | 84 | float yg; ///< Y gravity | ||
280 | 85 | float zg; ///< Z gravity | ||
281 | 86 | float xo; ///< orginal X position | ||
282 | 87 | float yo; ///< orginal Y position | ||
283 | 88 | float zo; ///< orginal Z position | ||
284 | 89 | }; | ||
285 | 90 | |||
286 | 91 | class ParticleSystem | ||
287 | 92 | { | ||
288 | 93 | friend class ParticleAnim; | ||
289 | 94 | |||
290 | 95 | public: | ||
291 | 96 | ParticleSystem (int numParticles, | ||
292 | 97 | float slowdown, | ||
293 | 98 | float darkenAmount, | ||
294 | 99 | GLuint blendMode); | ||
295 | 100 | ~ParticleSystem (); | ||
296 | 101 | |||
297 | 102 | void draw (int offsetX = 0, int offsetY = 0); | ||
298 | 103 | void update (float time); | ||
299 | 104 | vector<Particle> &particles () { return mParticles; } | ||
300 | 105 | void activate () { mActive = true; } | ||
301 | 106 | bool active () { return mActive; } | ||
302 | 107 | void setOrigin (int x, int y) { mX = x; mY = y; } | ||
303 | 108 | |||
304 | 109 | protected: | ||
305 | 110 | CompWindow *mWindow; | ||
306 | 111 | |||
307 | 112 | vector<Particle> mParticles; | ||
308 | 113 | |||
309 | 114 | float mSlowDown; | ||
310 | 115 | float mDarkenAmount; | ||
311 | 116 | GLuint mBlendMode; | ||
312 | 117 | GLuint mTex; | ||
313 | 118 | bool mActive; | ||
314 | 119 | int mX, mY; | ||
315 | 120 | |||
316 | 121 | GLScreen *mGScreen; | ||
317 | 122 | |||
318 | 123 | vector<GLfloat> mVerticesCache; | ||
319 | 124 | vector<GLfloat> mCoordsCache; | ||
320 | 125 | vector<GLfloat> mColorsCache; | ||
321 | 126 | vector<GLfloat> mDColorsCache; | ||
322 | 127 | }; | ||
323 | 128 | |||
324 | 129 | class ParticleAnim : | ||
325 | 130 | public BaseAddonAnim, | ||
326 | 131 | public PartialWindowAnim | ||
327 | 132 | { | ||
328 | 133 | public: | ||
329 | 134 | ParticleAnim (CompWindow *w, | ||
330 | 135 | WindowEvent curWindowEvent, | ||
331 | 136 | float duration, | ||
332 | 137 | const AnimEffect info, | ||
333 | 138 | const CompRect &icon); | ||
334 | 139 | ~ParticleAnim () {} | ||
335 | 140 | void postPaintWindow (); | ||
336 | 141 | bool postPaintWindowUsed () { return true; } | ||
337 | 142 | void updateBB (CompOutput &output); | ||
338 | 143 | bool updateBBUsed () { return true; } | ||
339 | 144 | bool prePreparePaint (int msSinceLastPaint); | ||
340 | 145 | void initLightDarkParticles (int numLightParticles, | ||
341 | 146 | int numDarkParticles, | ||
342 | 147 | float lightSlowDown, | ||
343 | 148 | float darkSlowDown); | ||
344 | 149 | |||
345 | 150 | protected: | ||
346 | 151 | boost::ptr_vector<ParticleSystem> mParticleSystems; | ||
347 | 152 | }; | ||
348 | 153 | |||
349 | 154 | // Polygon stuff | ||
350 | 155 | |||
351 | 156 | typedef enum | ||
352 | 157 | { | ||
353 | 158 | CorrectPerspectiveNone = 0, | ||
354 | 159 | CorrectPerspectivePolygon, | ||
355 | 160 | CorrectPerspectiveWindow | ||
356 | 161 | } CorrectPerspective; | ||
357 | 162 | |||
358 | 163 | /// Base class for per-PolygonObject effect parameter classes | ||
359 | 164 | class PolygonEffectParameters | ||
360 | 165 | { | ||
361 | 166 | }; | ||
362 | 167 | |||
363 | 168 | /// This is intended to be a closed 3D piece of a window with convex polygon | ||
364 | 169 | /// faces and quad-strip sides. Since decoration texture is separate from | ||
365 | 170 | /// the window texture, it is more complicated than it would be with a single | ||
366 | 171 | /// texture: we use glClipPlane with the rectangles (clips) to clip 3D space | ||
367 | 172 | /// to the region falling within that clip. | ||
368 | 173 | /// If the polygon is on an edge/corner, it also has 2D shadow quad(s) | ||
369 | 174 | /// (to be faded out at the beginning of 3D animation if necessary). | ||
370 | 175 | class PolygonObject | ||
371 | 176 | { | ||
372 | 177 | public: | ||
373 | 178 | int nVertices; ///< number of total vertices (front + back) | ||
374 | 179 | int nSides; ///< number of sides | ||
375 | 180 | GLfloat *vertices; ///< Positions of vertices relative to center | ||
376 | 181 | GLushort *sideIndices; ///< Indices of quad strip for "sides" | ||
377 | 182 | GLfloat *normals; ///< Surface normals for 2+nSides faces | ||
378 | 183 | |||
379 | 184 | Boxf boundingBox; ///< Bound. box to test intersection with clips | ||
380 | 185 | |||
381 | 186 | // Animation effect parameters | ||
382 | 187 | |||
383 | 188 | Point3d centerPosStart; ///< Starting position of center | ||
384 | 189 | float rotAngleStart; ///< Starting rotation angle | ||
385 | 190 | |||
386 | 191 | Point3d centerPos; ///< Position of center | ||
387 | 192 | Vector3d rotAxis; ///< Rotation axis vector | ||
388 | 193 | float rotAngle; ///< Rotation angle | ||
389 | 194 | Point3d rotAxisOffset; ///< Rotation axis translate amount | ||
390 | 195 | |||
391 | 196 | Point centerRelPos; ///< Relative pos of center within the window | ||
392 | 197 | |||
393 | 198 | Vector3d finalRelPos; ///< Velocity factor for scripted movement | ||
394 | 199 | float finalRotAng; ///< Final rotation angle around rotAxis | ||
395 | 200 | |||
396 | 201 | float moveStartTime; ///< Movement starts at this time ([0-1] range) | ||
397 | 202 | float moveDuration; ///< Movement lasts this long ([0-1] range) | ||
398 | 203 | |||
399 | 204 | float fadeStartTime; ///< Fade out starts at this time ([0,1] range) | ||
400 | 205 | float fadeDuration; ///< Duration of fade out ([0,1] range) | ||
401 | 206 | |||
402 | 207 | /** Pointer to a struct that can contain | ||
403 | 208 | custom parameters for an individual effect */ | ||
404 | 209 | PolygonEffectParameters *effectParameters; | ||
405 | 210 | |||
406 | 211 | float boundSphereRadius; ///< Radius of bounding sphere | ||
407 | 212 | }; | ||
408 | 213 | |||
409 | 214 | /// Info about intersection of a polygon and clip | ||
410 | 215 | class PolygonClipInfo | ||
411 | 216 | { | ||
412 | 217 | public: | ||
413 | 218 | PolygonClipInfo (const PolygonObject *p); | ||
414 | 219 | |||
415 | 220 | const PolygonObject *p; ///< the intersecting polygon-object | ||
416 | 221 | |||
417 | 222 | /// Texture coord.s for each vertex of the polygon-object | ||
418 | 223 | /// ordered as: Front v1.x, y, v2.x, y, ..., | ||
419 | 224 | /// followed by back vertex texture coordinates. | ||
420 | 225 | vector<GLfloat> vertexTexCoords; | ||
421 | 226 | }; | ||
422 | 227 | |||
423 | 228 | class Clip4Polygons ///< Rectangular clips | ||
424 | 229 | { ///< (to hold clips passed to AddWindowGeometry) | ||
425 | 230 | public: | ||
426 | 231 | CompRect box; ///< Coords | ||
427 | 232 | Boxf boxf; ///< Float coords (for small clipping adjustment) | ||
428 | 233 | GLTexture::Matrix texMatrix;///< Corresponding texture coord. matrix | ||
429 | 234 | |||
430 | 235 | /// True if this clip likely intersects all polygons | ||
431 | 236 | /// (for the window-contents clip). Used for optimization purposes. | ||
432 | 237 | bool intersectsMostPolygons; | ||
433 | 238 | |||
434 | 239 | /// For polygons that intersect this clip. | ||
435 | 240 | /// Only used when intersectsMostPolygons is false. | ||
436 | 241 | list<PolygonClipInfo *> intersectingPolygonInfos; | ||
437 | 242 | |||
438 | 243 | /// Texture coord.s for each vertex of each polygon-object | ||
439 | 244 | /// ordered as: Front p1.v1.x, y, p1.v2.x, .y, p2.v1.x, .y, ..., | ||
440 | 245 | /// followed by back vertex texture coordinates. | ||
441 | 246 | /// Only used when intersectsMostPolygons is true. | ||
442 | 247 | vector<GLfloat> polygonVertexTexCoords; | ||
443 | 248 | }; | ||
444 | 249 | |||
445 | 250 | class PolygonAnim : | ||
446 | 251 | virtual public Animation, | ||
447 | 252 | public BaseAddonAnim | ||
448 | 253 | { | ||
449 | 254 | public: | ||
450 | 255 | PolygonAnim (CompWindow *w, | ||
451 | 256 | WindowEvent curWindowEvent, | ||
452 | 257 | float duration, | ||
453 | 258 | const AnimEffect info, | ||
454 | 259 | const CompRect &icon); | ||
455 | 260 | ~PolygonAnim (); | ||
456 | 261 | |||
457 | 262 | void step (); | ||
458 | 263 | void prePaintWindow (); | ||
459 | 264 | void postPaintWindow (); | ||
460 | 265 | bool postPaintWindowUsed () { return true; } | ||
461 | 266 | void addGeometry (const GLTexture::MatrixList &matrix, | ||
462 | 267 | const CompRegion ®ion, | ||
463 | 268 | const CompRegion &clipRegion, | ||
464 | 269 | unsigned int maxGridWidth, | ||
465 | 270 | unsigned int maxGridHeight); | ||
466 | 271 | void drawGeometry (); | ||
467 | 272 | virtual void updateBB (CompOutput &output); | ||
468 | 273 | bool updateBBUsed () { return true; } | ||
469 | 274 | bool prePreparePaint (int msSinceLastPaint); | ||
470 | 275 | bool moveUpdate (int dx, int dy); | ||
471 | 276 | |||
472 | 277 | virtual void stepPolygon (PolygonObject *p, | ||
473 | 278 | float forwardProgress); | ||
474 | 279 | virtual void transformPolygon (const PolygonObject *p) {} | ||
475 | 280 | |||
476 | 281 | /// For effects that have decel. motion | ||
477 | 282 | virtual bool deceleratingMotion () { return false; } | ||
478 | 283 | |||
479 | 284 | bool tessellateIntoRectangles (int gridSizeX, | ||
480 | 285 | int gridSizeY, | ||
481 | 286 | float thickness); | ||
482 | 287 | bool tessellateIntoHexagons (int gridSizeX, | ||
483 | 288 | int gridSizeY, | ||
484 | 289 | float thickness); | ||
485 | 290 | bool tessellateIntoGlass (int gridSizeX, | ||
486 | 291 | int gridSizeY, | ||
487 | 292 | float thickness); | ||
488 | 293 | |||
489 | 294 | void prePaintOutput (CompOutput *output); | ||
490 | 295 | void deceleratingAnimStepPolygon (PolygonObject *p, | ||
491 | 296 | float forwardProgress); | ||
492 | 297 | |||
493 | 298 | protected: | ||
494 | 299 | void getPerspectiveCorrectionMat (const PolygonObject *p, | ||
495 | 300 | GLfloat *mat, | ||
496 | 301 | GLMatrix *matf, | ||
497 | 302 | const CompOutput &output); | ||
498 | 303 | void processIntersectingPolygons (); | ||
499 | 304 | virtual void freePolygonObjects (); | ||
500 | 305 | void freeClipsPolygons (); | ||
501 | 306 | void prepareDrawingForAttrib (GLFragment::Attrib &attrib); | ||
502 | 307 | |||
503 | 308 | int mNumDrawGeometryCalls; | ||
504 | 309 | int mNumClipsPassed; /**< # of clips passed to animAddWindowGeometry so far | ||
505 | 310 | in this draw step */ | ||
506 | 311 | bool mClipsUpdated; ///< whether stored clips are updated in this anim step | ||
507 | 312 | |||
508 | 313 | vector<Clip4Polygons> mClips;///< Rect. clips collected in addGeometries | ||
509 | 314 | int mFirstNondrawnClip; | ||
510 | 315 | vector<int> mLastClipInGroup;/**< Index of the last clip in each group of clips | ||
511 | 316 | drawn in drawGeometry func. */ | ||
512 | 317 | |||
513 | 318 | bool mDoLighting; ///< Whether lighting should be used in the effect | ||
514 | 319 | CorrectPerspective mCorrectPerspective; | ||
515 | 320 | |||
516 | 321 | vector<PolygonObject *> mPolygons; ///< The polygons in this set | ||
517 | 322 | float mThickness; ///< Window thickness (depth along z axis) | ||
518 | 323 | int mNumTotalFrontVertices; ///< Total # of polygon vertices on front faces | ||
519 | 324 | float mBackAndSidesFadeDur; ///< How long side and back faces should fade in/out | ||
520 | 325 | float mAllFadeDuration; /**< Duration of fade out at the end in [0,1] range | ||
521 | 326 | when all polygons fade out at the same time. | ||
522 | 327 | If >-1, this overrides fadeDuration in PolygonObject */ | ||
523 | 328 | |||
524 | 329 | bool mIncludeShadows; ///< Whether to include shadows in polygon | ||
525 | 330 | |||
526 | 331 | private: | ||
527 | 332 | inline void drawPolygonClipIntersection (const PolygonObject *p, | ||
528 | 333 | const Clip4Polygons &c, | ||
529 | 334 | const GLfloat *vertexTexCoords, | ||
530 | 335 | int pass, | ||
531 | 336 | float forwardProgress, | ||
532 | 337 | GLdouble clipPlane[4][4], | ||
533 | 338 | const CompOutput &output, | ||
534 | 339 | float newOpacity, | ||
535 | 340 | bool decelerates, | ||
536 | 341 | GLfloat skewMat[16]); | ||
537 | 342 | }; | ||
538 | 343 | #endif | ||
539 | 0 | 344 | ||
540 | === added directory 'plugins/animationjc/src' | |||
541 | === added file 'plugins/animationjc/src/animationjc.cpp' | |||
542 | --- plugins/animationjc/src/animationjc.cpp 1970-01-01 00:00:00 +0000 | |||
543 | +++ plugins/animationjc/src/animationjc.cpp 2012-08-15 14:25:28 +0000 | |||
544 | @@ -0,0 +1,145 @@ | |||
545 | 1 | #include "private.h" | ||
546 | 2 | |||
547 | 3 | class AnimJCPluginVTable : | ||
548 | 4 | public CompPlugin::VTableForScreenAndWindow<AnimJCScreen, AnimJCWindow> | ||
549 | 5 | { | ||
550 | 6 | public: | ||
551 | 7 | bool init (); | ||
552 | 8 | }; | ||
553 | 9 | |||
554 | 10 | COMPIZ_PLUGIN_20090315 (animationjc, AnimJCPluginVTable); | ||
555 | 11 | |||
556 | 12 | AnimEffect animEffects[NUM_EFFECTS]; | ||
557 | 13 | |||
558 | 14 | ExtensionPluginAnimJC animJCExtPluginInfo (CompString ("animationjc"), | ||
559 | 15 | NUM_EFFECTS, animEffects, NULL, | ||
560 | 16 | NUM_NONEFFECT_OPTIONS); | ||
561 | 17 | |||
562 | 18 | AnimEffect AnimEffectBlackHole; | ||
563 | 19 | AnimEffect AnimEffectFlicker; | ||
564 | 20 | AnimEffect AnimEffectGhost; | ||
565 | 21 | AnimEffect AnimEffectPopcorn; | ||
566 | 22 | AnimEffect AnimEffectRaindrop; | ||
567 | 23 | |||
568 | 24 | ExtensionPluginInfo * | ||
569 | 25 | BaseAddonAnim::getExtensionPluginInfo () | ||
570 | 26 | { | ||
571 | 27 | return &animJCExtPluginInfo; | ||
572 | 28 | } | ||
573 | 29 | |||
574 | 30 | BaseAddonAnim::BaseAddonAnim (CompWindow *w, | ||
575 | 31 | WindowEvent curWindowEvent, | ||
576 | 32 | float duration, | ||
577 | 33 | const AnimEffect info, | ||
578 | 34 | const CompRect &icon) : | ||
579 | 35 | Animation::Animation (w, curWindowEvent, duration, info, icon), | ||
580 | 36 | mIntenseTimeStep (AnimJCScreen::get (::screen)->getIntenseTimeStep ()), | ||
581 | 37 | mCScreen (CompositeScreen::get (::screen)), | ||
582 | 38 | mGScreen (GLScreen::get (::screen)), | ||
583 | 39 | mDoDepthTest (false) | ||
584 | 40 | { | ||
585 | 41 | } | ||
586 | 42 | |||
587 | 43 | void | ||
588 | 44 | AnimJCScreen::initAnimationList () | ||
589 | 45 | { | ||
590 | 46 | int i = 0; | ||
591 | 47 | |||
592 | 48 | animEffects[i++] = AnimEffectBlackHole = | ||
593 | 49 | new AnimEffectInfo ("animationjc:Black Hole", | ||
594 | 50 | true, true, true, false, false, | ||
595 | 51 | &createAnimation<BlackHoleAnim>); | ||
596 | 52 | |||
597 | 53 | animEffects[i++] = AnimEffectFlicker = | ||
598 | 54 | new AnimEffectInfo ("animationjc:Flicker", | ||
599 | 55 | true, true, true, false, true, | ||
600 | 56 | &createAnimation<FlickerAnim>); | ||
601 | 57 | |||
602 | 58 | animEffects[i++] = AnimEffectGhost = | ||
603 | 59 | new AnimEffectInfo ("animationjc:Ghost", | ||
604 | 60 | true, true, true, false, false, | ||
605 | 61 | &createAnimation<GhostAnim>); | ||
606 | 62 | |||
607 | 63 | animEffects[i++] = AnimEffectPopcorn = | ||
608 | 64 | new AnimEffectInfo ("animationjc:Popcorn", | ||
609 | 65 | true, true, true, false, false, | ||
610 | 66 | &createAnimation<PopcornAnim>); | ||
611 | 67 | |||
612 | 68 | animEffects[i++] = AnimEffectRaindrop = | ||
613 | 69 | new AnimEffectInfo ("animationjc:Raindrop", | ||
614 | 70 | true, true, true, false, true, | ||
615 | 71 | &createAnimation<RaindropAnim>); | ||
616 | 72 | |||
617 | 73 | animJCExtPluginInfo.effectOptions = &getOptions (); | ||
618 | 74 | |||
619 | 75 | AnimScreen *as = AnimScreen::get (::screen); | ||
620 | 76 | |||
621 | 77 | // Extends animation plugin with this set of animation effects. | ||
622 | 78 | as->addExtension (&animJCExtPluginInfo); | ||
623 | 79 | } | ||
624 | 80 | |||
625 | 81 | PrivateAnimJCScreen::PrivateAnimJCScreen (CompScreen *s) : | ||
626 | 82 | mOutput (s->fullscreenOutput ()) | ||
627 | 83 | { | ||
628 | 84 | } | ||
629 | 85 | |||
630 | 86 | PrivateAnimJCScreen::~PrivateAnimJCScreen () | ||
631 | 87 | { | ||
632 | 88 | AnimScreen *as = AnimScreen::get (::screen); | ||
633 | 89 | |||
634 | 90 | as->removeExtension (&animJCExtPluginInfo); | ||
635 | 91 | |||
636 | 92 | for (int i = 0; i < NUM_EFFECTS; i++) | ||
637 | 93 | { | ||
638 | 94 | delete animEffects[i]; | ||
639 | 95 | animEffects[i] = NULL; | ||
640 | 96 | } | ||
641 | 97 | } | ||
642 | 98 | |||
643 | 99 | AnimJCScreen::AnimJCScreen (CompScreen *s) : | ||
644 | 100 | PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI> (s), | ||
645 | 101 | priv (new PrivateAnimJCScreen (s)) | ||
646 | 102 | { | ||
647 | 103 | initAnimationList (); | ||
648 | 104 | } | ||
649 | 105 | |||
650 | 106 | AnimJCScreen::~AnimJCScreen () | ||
651 | 107 | { | ||
652 | 108 | delete priv; | ||
653 | 109 | } | ||
654 | 110 | |||
655 | 111 | AnimJCWindow::AnimJCWindow (CompWindow *w) : | ||
656 | 112 | PluginClassHandler<AnimJCWindow, CompWindow> (w), | ||
657 | 113 | mWindow (w), | ||
658 | 114 | aWindow (AnimWindow::get (w)) | ||
659 | 115 | { | ||
660 | 116 | } | ||
661 | 117 | |||
662 | 118 | AnimJCWindow::~AnimJCWindow () | ||
663 | 119 | { | ||
664 | 120 | Animation *curAnim = aWindow->curAnimation (); | ||
665 | 121 | |||
666 | 122 | if (!curAnim) | ||
667 | 123 | return; | ||
668 | 124 | |||
669 | 125 | // We need to interrupt and clean up the animation currently being played | ||
670 | 126 | // by animationaddon for this window (if any) | ||
671 | 127 | if (curAnim->remainingTime () > 0 && | ||
672 | 128 | curAnim->getExtensionPluginInfo ()->name == | ||
673 | 129 | CompString ("animationjc")) | ||
674 | 130 | { | ||
675 | 131 | aWindow->postAnimationCleanUp (); | ||
676 | 132 | } | ||
677 | 133 | } | ||
678 | 134 | |||
679 | 135 | bool | ||
680 | 136 | AnimJCPluginVTable::init () | ||
681 | 137 | { | ||
682 | 138 | if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) | | ||
683 | 139 | !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) | | ||
684 | 140 | !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) | | ||
685 | 141 | !CompPlugin::checkPluginABI ("animation", ANIMATION_ABI)) | ||
686 | 142 | return false; | ||
687 | 143 | |||
688 | 144 | return true; | ||
689 | 145 | } | ||
690 | 0 | 146 | ||
691 | === added file 'plugins/animationjc/src/blackhole.cpp' | |||
692 | --- plugins/animationjc/src/blackhole.cpp 1970-01-01 00:00:00 +0000 | |||
693 | +++ plugins/animationjc/src/blackhole.cpp 2012-08-15 14:25:28 +0000 | |||
694 | @@ -0,0 +1,79 @@ | |||
695 | 1 | #include "private.h" | ||
696 | 2 | |||
697 | 3 | #include <algorithm> | ||
698 | 4 | |||
699 | 5 | BlackHoleAnim::BlackHoleAnim (CompWindow *w, | ||
700 | 6 | WindowEvent curWindowEvent, | ||
701 | 7 | float duration, | ||
702 | 8 | const AnimEffect info, | ||
703 | 9 | const CompRect &icon) : | ||
704 | 10 | Animation::Animation (w, curWindowEvent, duration, info, icon), | ||
705 | 11 | TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon), | ||
706 | 12 | GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info, | ||
707 | 13 | icon) | ||
708 | 14 | { | ||
709 | 15 | } | ||
710 | 16 | |||
711 | 17 | void | ||
712 | 18 | BlackHoleAnim::initGrid () | ||
713 | 19 | { | ||
714 | 20 | mGridWidth = 20; | ||
715 | 21 | mGridHeight = 20; | ||
716 | 22 | } | ||
717 | 23 | |||
718 | 24 | void | ||
719 | 25 | BlackHoleAnim::step () | ||
720 | 26 | { | ||
721 | 27 | CompRect winRect (mAWindow->savedRectsValid () ? | ||
722 | 28 | mAWindow->saveWinRect () : | ||
723 | 29 | mWindow->geometry ()); | ||
724 | 30 | CompRect outRect (mAWindow->savedRectsValid () ? | ||
725 | 31 | mAWindow->savedOutRect () : | ||
726 | 32 | mWindow->outputRect ()); | ||
727 | 33 | CompWindowExtents outExtents (mAWindow->savedRectsValid () ? | ||
728 | 34 | mAWindow->savedOutExtents () : | ||
729 | 35 | mWindow->output ()); | ||
730 | 36 | |||
731 | 37 | int wx = winRect.x (); | ||
732 | 38 | int wy = winRect.y (); | ||
733 | 39 | |||
734 | 40 | int owidth = outRect.width (); | ||
735 | 41 | int oheight = outRect.height (); | ||
736 | 42 | |||
737 | 43 | float centerx = wx + mModel->scale ().x () * | ||
738 | 44 | (owidth * 0.5 - outExtents.left); | ||
739 | 45 | float centery = wy + mModel->scale ().y () * | ||
740 | 46 | (oheight * 0.5 - outExtents.top); | ||
741 | 47 | |||
742 | 48 | float delay = AnimJCScreen::get (screen)->optionGetBlackholeDelay (); | ||
743 | 49 | float tau = (1. - delay) / 8.; | ||
744 | 50 | |||
745 | 51 | GridModel::GridObject *object = mModel->objects (); | ||
746 | 52 | unsigned int n = mModel->numObjects (); | ||
747 | 53 | for (unsigned int i = 0; i < n; i++, object++) | ||
748 | 54 | { | ||
749 | 55 | // find distance to center in grid terms, 0..1 | ||
750 | 56 | float gridDistance = 2 * max (fabs (object->gridPosition ().x ()-0.5), | ||
751 | 57 | fabs (object->gridPosition ().y ()-0.5)); | ||
752 | 58 | |||
753 | 59 | // use that and tau to find r | ||
754 | 60 | float cutoff = gridDistance * delay; | ||
755 | 61 | float r = 1; | ||
756 | 62 | if (getBlackHoleProgress () > cutoff) | ||
757 | 63 | r = exp (-(getBlackHoleProgress () - cutoff) / tau); | ||
758 | 64 | |||
759 | 65 | // find real original coordinates | ||
760 | 66 | float origx = wx + mModel->scale ().x () * | ||
761 | 67 | (owidth * object->gridPosition ().x () - | ||
762 | 68 | outExtents.left); | ||
763 | 69 | float origy = wy + mModel->scale ().y () * | ||
764 | 70 | (oheight * object->gridPosition ().y () - | ||
765 | 71 | outExtents.top); | ||
766 | 72 | |||
767 | 73 | // shrink toward center by r | ||
768 | 74 | Point3d &objPos = object->position (); | ||
769 | 75 | objPos.setX ((origx-centerx) * r + centerx); | ||
770 | 76 | objPos.setY ((origy-centery) * r + centery); | ||
771 | 77 | objPos.setZ (0); | ||
772 | 78 | } | ||
773 | 79 | } | ||
774 | 0 | 80 | ||
775 | === added file 'plugins/animationjc/src/flicker.cpp' | |||
776 | --- plugins/animationjc/src/flicker.cpp 1970-01-01 00:00:00 +0000 | |||
777 | +++ plugins/animationjc/src/flicker.cpp 2012-08-15 14:25:28 +0000 | |||
778 | @@ -0,0 +1,96 @@ | |||
779 | 1 | #include <private.h> | ||
780 | 2 | |||
781 | 3 | void | ||
782 | 4 | FlickerSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib) | ||
783 | 5 | { | ||
784 | 6 | int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow); | ||
785 | 7 | float o = 0.2; | ||
786 | 8 | attrib.opacity *= o / (1. - (4-layer)*o); | ||
787 | 9 | } | ||
788 | 10 | |||
789 | 11 | void | ||
790 | 12 | FlickerSingleAnim::initGrid () | ||
791 | 13 | { | ||
792 | 14 | mGridWidth = 2; | ||
793 | 15 | mGridHeight = 20; | ||
794 | 16 | } | ||
795 | 17 | |||
796 | 18 | void | ||
797 | 19 | FlickerSingleAnim::step () | ||
798 | 20 | { | ||
799 | 21 | int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow); | ||
800 | 22 | |||
801 | 23 | CompRect winRect (mAWindow->savedRectsValid () ? | ||
802 | 24 | mAWindow->saveWinRect () : | ||
803 | 25 | mWindow->geometry ()); | ||
804 | 26 | CompRect outRect (mAWindow->savedRectsValid () ? | ||
805 | 27 | mAWindow->savedOutRect () : | ||
806 | 28 | mWindow->outputRect ()); | ||
807 | 29 | CompWindowExtents outExtents (mAWindow->savedRectsValid () ? | ||
808 | 30 | mAWindow->savedOutExtents () : | ||
809 | 31 | mWindow->output ()); | ||
810 | 32 | |||
811 | 33 | int wx = winRect.x (); | ||
812 | 34 | int wy = winRect.y (); | ||
813 | 35 | int owidth = outRect.width (); | ||
814 | 36 | int oheight = outRect.height (); | ||
815 | 37 | |||
816 | 38 | float t = 1 - progressLinear (); | ||
817 | 39 | if (mCurWindowEvent == WindowEventClose) | ||
818 | 40 | t = 1 - t; | ||
819 | 41 | |||
820 | 42 | float amplitude = AnimJCScreen::get (screen)->optionGetFlickerAmplitude (); | ||
821 | 43 | float waveLength = 0.4; | ||
822 | 44 | float wavePosition = -waveLength + (1. + waveLength) * t; | ||
823 | 45 | |||
824 | 46 | float displacement = 0; | ||
825 | 47 | |||
826 | 48 | GridModel::GridObject *object = mModel->objects (); | ||
827 | 49 | unsigned int n = mModel->numObjects (); | ||
828 | 50 | for (unsigned int i = 0; i < n; i++, object++) | ||
829 | 51 | { | ||
830 | 52 | Point3d &objPos = object->position (); | ||
831 | 53 | |||
832 | 54 | if (i % 2 == 0) // left side; reuse old displacement on right side | ||
833 | 55 | { | ||
834 | 56 | float distFromWave = object->gridPosition ().y () - wavePosition; | ||
835 | 57 | |||
836 | 58 | if (distFromWave > 0 && distFromWave <= waveLength) | ||
837 | 59 | { | ||
838 | 60 | displacement = amplitude * sin (distFromWave/waveLength * M_PI); | ||
839 | 61 | } | ||
840 | 62 | else | ||
841 | 63 | { | ||
842 | 64 | displacement = 0; | ||
843 | 65 | } | ||
844 | 66 | } | ||
845 | 67 | |||
846 | 68 | float x = wx + mModel->scale ().x () * | ||
847 | 69 | (owidth * object->gridPosition ().x () - outExtents.left); | ||
848 | 70 | |||
849 | 71 | float y = wy + mModel->scale ().y () * | ||
850 | 72 | (oheight * object->gridPosition ().y () - outExtents.top); | ||
851 | 73 | |||
852 | 74 | switch (layer) | ||
853 | 75 | { | ||
854 | 76 | case 1: | ||
855 | 77 | x -= displacement; | ||
856 | 78 | break; | ||
857 | 79 | case 2: | ||
858 | 80 | x += displacement; | ||
859 | 81 | break; | ||
860 | 82 | case 3: | ||
861 | 83 | y -= displacement; | ||
862 | 84 | break; | ||
863 | 85 | case 4: | ||
864 | 86 | y += displacement; | ||
865 | 87 | break; | ||
866 | 88 | default: | ||
867 | 89 | break; | ||
868 | 90 | } | ||
869 | 91 | |||
870 | 92 | objPos.setX (x); | ||
871 | 93 | objPos.setY (y); | ||
872 | 94 | objPos.setZ (0); | ||
873 | 95 | } | ||
874 | 96 | } | ||
875 | 0 | 97 | ||
876 | === added file 'plugins/animationjc/src/ghost.cpp' | |||
877 | --- plugins/animationjc/src/ghost.cpp 1970-01-01 00:00:00 +0000 | |||
878 | +++ plugins/animationjc/src/ghost.cpp 2012-08-15 14:25:28 +0000 | |||
879 | @@ -0,0 +1,98 @@ | |||
880 | 1 | #include "private.h" | ||
881 | 2 | |||
882 | 3 | GhostAnim::GhostAnim (CompWindow *w, | ||
883 | 4 | WindowEvent curWindowEvent, | ||
884 | 5 | float duration, | ||
885 | 6 | const AnimEffect info, | ||
886 | 7 | const CompRect &icon) : | ||
887 | 8 | Animation::Animation (w, curWindowEvent, duration, info, icon), | ||
888 | 9 | TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon), | ||
889 | 10 | GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info, | ||
890 | 11 | icon) | ||
891 | 12 | { | ||
892 | 13 | } | ||
893 | 14 | |||
894 | 15 | void | ||
895 | 16 | GhostAnim::updateAttrib (GLWindowPaintAttrib &attrib) | ||
896 | 17 | { | ||
897 | 18 | AnimJCScreen *ajs = AnimJCScreen::get (screen); | ||
898 | 19 | attrib.opacity *= 1. - progressLinear (); | ||
899 | 20 | attrib.saturation *= ajs->optionGetGhostSaturation (); | ||
900 | 21 | } | ||
901 | 22 | |||
902 | 23 | void | ||
903 | 24 | GhostAnim::initGrid () | ||
904 | 25 | { | ||
905 | 26 | AnimJCScreen *ajs = AnimJCScreen::get (screen); | ||
906 | 27 | mGridWidth = ajs->optionGetGhostGrid (); | ||
907 | 28 | mGridHeight = ajs->optionGetGhostGrid (); | ||
908 | 29 | } | ||
909 | 30 | |||
910 | 31 | void | ||
911 | 32 | GhostAnim::step () | ||
912 | 33 | { | ||
913 | 34 | float t = 1. - progressLinear (); | ||
914 | 35 | if (mCurWindowEvent == WindowEventClose) | ||
915 | 36 | t = 1. - t; | ||
916 | 37 | |||
917 | 38 | CompRect winRect (mAWindow->savedRectsValid () ? | ||
918 | 39 | mAWindow->saveWinRect () : | ||
919 | 40 | mWindow->geometry ()); | ||
920 | 41 | CompRect outRect (mAWindow->savedRectsValid () ? | ||
921 | 42 | mAWindow->savedOutRect () : | ||
922 | 43 | mWindow->outputRect ()); | ||
923 | 44 | CompWindowExtents outExtents (mAWindow->savedRectsValid () ? | ||
924 | 45 | mAWindow->savedOutExtents () : | ||
925 | 46 | mWindow->output ()); | ||
926 | 47 | |||
927 | 48 | int wx = winRect.x (); | ||
928 | 49 | int wy = winRect.y (); | ||
929 | 50 | |||
930 | 51 | int owidth = outRect.width (); | ||
931 | 52 | int oheight = outRect.height (); | ||
932 | 53 | |||
933 | 54 | AnimJCScreen *ajs = AnimJCScreen::get (screen); | ||
934 | 55 | |||
935 | 56 | float waveAmp = 3 * ajs->optionGetGhostAmplitude (); | ||
936 | 57 | float waveLengthX1 = 0.4; | ||
937 | 58 | float waveLengthX2 = 0.3; | ||
938 | 59 | float waveLengthY1 = 0.45; | ||
939 | 60 | float waveLengthY2 = 0.35; | ||
940 | 61 | float wavePositionX1 = 0.25 * t * ajs->optionGetGhostWaveSpeed (); | ||
941 | 62 | float wavePositionX2 = -0.25 * t * ajs->optionGetGhostWaveSpeed (); | ||
942 | 63 | float wavePositionY1 = 0.25 * t * ajs->optionGetGhostWaveSpeed (); | ||
943 | 64 | float wavePositionY2 = -0.25 * t * ajs->optionGetGhostWaveSpeed (); | ||
944 | 65 | |||
945 | 66 | GridModel::GridObject *object = mModel->objects (); | ||
946 | 67 | unsigned int n = mModel->numObjects (); | ||
947 | 68 | for (unsigned int i = 0; i < n; i++, object++) | ||
948 | 69 | { | ||
949 | 70 | Point3d &objPos = object->position (); | ||
950 | 71 | |||
951 | 72 | float origx = wx + mModel->scale ().x () * | ||
952 | 73 | (owidth * object->gridPosition ().x () - | ||
953 | 74 | outExtents.left); | ||
954 | 75 | |||
955 | 76 | float origy = wy + mModel->scale ().y () * | ||
956 | 77 | (oheight * object->gridPosition ().y () - | ||
957 | 78 | outExtents.top); | ||
958 | 79 | |||
959 | 80 | float x = object->gridPosition ().x (); | ||
960 | 81 | float y = object->gridPosition ().y (); | ||
961 | 82 | |||
962 | 83 | float distFromWaveX1 = x - wavePositionX1; | ||
963 | 84 | float distFromWaveX2 = x - wavePositionX2; | ||
964 | 85 | float distFromWaveY1 = y - wavePositionY1; | ||
965 | 86 | float distFromWaveY2 = y - wavePositionY2; | ||
966 | 87 | |||
967 | 88 | objPos.setX (origx + | ||
968 | 89 | waveAmp * sin (distFromWaveX1 / waveLengthX1 * 2 * M_PI) + | ||
969 | 90 | waveAmp * sin (distFromWaveX2 / waveLengthX2 * 2 * M_PI)); | ||
970 | 91 | |||
971 | 92 | objPos.setY (origy + | ||
972 | 93 | waveAmp * sin (distFromWaveY1 / waveLengthY1 * 2 * M_PI) + | ||
973 | 94 | waveAmp * sin (distFromWaveY2 / waveLengthY2 * 2 * M_PI)); | ||
974 | 95 | |||
975 | 96 | objPos.setZ (0); | ||
976 | 97 | } | ||
977 | 98 | } | ||
978 | 0 | 99 | ||
979 | === added file 'plugins/animationjc/src/popcorn.cpp' | |||
980 | --- plugins/animationjc/src/popcorn.cpp 1970-01-01 00:00:00 +0000 | |||
981 | +++ plugins/animationjc/src/popcorn.cpp 2012-08-15 14:25:28 +0000 | |||
982 | @@ -0,0 +1,60 @@ | |||
983 | 1 | #include <private.h> | ||
984 | 2 | |||
985 | 3 | #define WIN_X(w) ((w)->x () - (w)->input ().left) | ||
986 | 4 | #define WIN_Y(w) ((w)->y () - (w)->input ().top) | ||
987 | 5 | #define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right) | ||
988 | 6 | #define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom) | ||
989 | 7 | |||
990 | 8 | float | ||
991 | 9 | PopcornSingleAnim::layerProgress (int layer) | ||
992 | 10 | { | ||
993 | 11 | if (layer == 0) | ||
994 | 12 | return 0; | ||
995 | 13 | |||
996 | 14 | float tStart = (5. - layer) / 6.; | ||
997 | 15 | float tEnd = tStart + 1./3.; | ||
998 | 16 | |||
999 | 17 | float t = progressLinear (); | ||
1000 | 18 | |||
1001 | 19 | if (t < tStart) | ||
1002 | 20 | return 0; | ||
1003 | 21 | |||
1004 | 22 | if (t > tEnd) | ||
1005 | 23 | return 1; | ||
1006 | 24 | |||
1007 | 25 | return (t - tStart) / (tEnd - tStart); | ||
1008 | 26 | } | ||
1009 | 27 | |||
1010 | 28 | void | ||
1011 | 29 | PopcornSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib) | ||
1012 | 30 | { | ||
1013 | 31 | int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow); | ||
1014 | 32 | |||
1015 | 33 | attrib.opacity *= 1. - progressLinear (); | ||
1016 | 34 | |||
1017 | 35 | attrib.opacity *= 1. - layerProgress (layer); | ||
1018 | 36 | } | ||
1019 | 37 | |||
1020 | 38 | void | ||
1021 | 39 | PopcornSingleAnim::applyTransform () | ||
1022 | 40 | { | ||
1023 | 41 | int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow); | ||
1024 | 42 | |||
1025 | 43 | if (layer == 0) return; | ||
1026 | 44 | |||
1027 | 45 | float p = layerProgress (layer); | ||
1028 | 46 | |||
1029 | 47 | float v = 40.; | ||
1030 | 48 | float theta = (54. + 144.*(layer-1)) / 180. * 3.14159265; | ||
1031 | 49 | float dx = v * cos (theta) * p; | ||
1032 | 50 | float dy = -v * sin (theta) * p; | ||
1033 | 51 | |||
1034 | 52 | mTransform.translate (dx, dy, | ||
1035 | 53 | 0.16*p*AnimJCScreen::get (screen)->optionGetPopcornKernelHeight ()); | ||
1036 | 54 | } | ||
1037 | 55 | |||
1038 | 56 | void | ||
1039 | 57 | PopcornSingleAnim::updateBB (CompOutput &output) | ||
1040 | 58 | { | ||
1041 | 59 | TransformAnim::updateBB (output); | ||
1042 | 60 | } | ||
1043 | 0 | 61 | ||
1044 | === added file 'plugins/animationjc/src/private.h' | |||
1045 | --- plugins/animationjc/src/private.h 1970-01-01 00:00:00 +0000 | |||
1046 | +++ plugins/animationjc/src/private.h 2012-08-15 14:25:28 +0000 | |||
1047 | @@ -0,0 +1,232 @@ | |||
1048 | 1 | #include <string.h> | ||
1049 | 2 | #include <stdlib.h> | ||
1050 | 3 | #include <math.h> | ||
1051 | 4 | |||
1052 | 5 | #include <core/core.h> | ||
1053 | 6 | #include <composite/composite.h> | ||
1054 | 7 | #include <opengl/opengl.h> | ||
1055 | 8 | |||
1056 | 9 | #include <boost/foreach.hpp> | ||
1057 | 10 | #define foreach BOOST_FOREACH | ||
1058 | 11 | |||
1059 | 12 | #include <animation/animation.h> | ||
1060 | 13 | #include <animationjc/animationjc.h> | ||
1061 | 14 | |||
1062 | 15 | #include "animationjc_options.h" | ||
1063 | 16 | |||
1064 | 17 | extern AnimEffect AnimEffectBlackHole; | ||
1065 | 18 | extern AnimEffect AnimEffectFlicker; | ||
1066 | 19 | extern AnimEffect AnimEffectGhost; | ||
1067 | 20 | extern AnimEffect AnimEffectPopcorn; | ||
1068 | 21 | extern AnimEffect AnimEffectRaindrop; | ||
1069 | 22 | |||
1070 | 23 | #define NUM_EFFECTS 5 | ||
1071 | 24 | |||
1072 | 25 | // This must have the value of the first "effect setting" above | ||
1073 | 26 | // in AnimJCScreenOptions | ||
1074 | 27 | #define NUM_NONEFFECT_OPTIONS 0 | ||
1075 | 28 | |||
1076 | 29 | class ExtensionPluginAnimJC : public ExtensionPluginInfo | ||
1077 | 30 | { | ||
1078 | 31 | public: | ||
1079 | 32 | ExtensionPluginAnimJC (const CompString &name, | ||
1080 | 33 | unsigned int nEffects, | ||
1081 | 34 | AnimEffect *effects, | ||
1082 | 35 | CompOption::Vector *effectOptions, | ||
1083 | 36 | unsigned int firstEffectOptionIndex) : | ||
1084 | 37 | ExtensionPluginInfo (name, nEffects, effects, effectOptions, | ||
1085 | 38 | firstEffectOptionIndex) {} | ||
1086 | 39 | ~ExtensionPluginAnimJC () {} | ||
1087 | 40 | |||
1088 | 41 | const CompOutput *output () { return mOutput; } | ||
1089 | 42 | |||
1090 | 43 | private: | ||
1091 | 44 | const CompOutput *mOutput; | ||
1092 | 45 | }; | ||
1093 | 46 | |||
1094 | 47 | class AnimJCScreen : | ||
1095 | 48 | public PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI>, | ||
1096 | 49 | public AnimationjcOptions | ||
1097 | 50 | { | ||
1098 | 51 | public: | ||
1099 | 52 | AnimJCScreen (CompScreen *); | ||
1100 | 53 | ~AnimJCScreen (); | ||
1101 | 54 | |||
1102 | 55 | int getIntenseTimeStep (); | ||
1103 | 56 | |||
1104 | 57 | void initAnimationList (); | ||
1105 | 58 | |||
1106 | 59 | private: | ||
1107 | 60 | PrivateAnimJCScreen *priv; | ||
1108 | 61 | }; | ||
1109 | 62 | |||
1110 | 63 | class PrivateAnimJCScreen | ||
1111 | 64 | { | ||
1112 | 65 | friend class AnimJCScreen; | ||
1113 | 66 | |||
1114 | 67 | public: | ||
1115 | 68 | PrivateAnimJCScreen (CompScreen *); | ||
1116 | 69 | ~PrivateAnimJCScreen (); | ||
1117 | 70 | |||
1118 | 71 | protected: | ||
1119 | 72 | CompOutput &mOutput; | ||
1120 | 73 | }; | ||
1121 | 74 | |||
1122 | 75 | class AnimJCWindow : | ||
1123 | 76 | public PluginClassHandler<AnimJCWindow, CompWindow> | ||
1124 | 77 | { | ||
1125 | 78 | public: | ||
1126 | 79 | AnimJCWindow (CompWindow *); | ||
1127 | 80 | ~AnimJCWindow (); | ||
1128 | 81 | |||
1129 | 82 | protected: | ||
1130 | 83 | CompWindow *mWindow; ///< Window being animated. | ||
1131 | 84 | AnimWindow *aWindow; | ||
1132 | 85 | }; | ||
1133 | 86 | |||
1134 | 87 | /*** BLACK HOLE **************************************************************/ | ||
1135 | 88 | |||
1136 | 89 | class BlackHoleAnim : | ||
1137 | 90 | public GridTransformAnim | ||
1138 | 91 | { | ||
1139 | 92 | public: | ||
1140 | 93 | BlackHoleAnim (CompWindow *w, | ||
1141 | 94 | WindowEvent curWindowEvent, | ||
1142 | 95 | float duration, | ||
1143 | 96 | const AnimEffect info, | ||
1144 | 97 | const CompRect &icon); | ||
1145 | 98 | |||
1146 | 99 | float getBlackHoleProgress () { return progressLinear (); } | ||
1147 | 100 | |||
1148 | 101 | void initGrid (); | ||
1149 | 102 | inline bool using3D () { return false; } | ||
1150 | 103 | void step (); | ||
1151 | 104 | }; | ||
1152 | 105 | |||
1153 | 106 | /*** RAINDROP ****************************************************************/ | ||
1154 | 107 | |||
1155 | 108 | class RaindropAnim : | ||
1156 | 109 | public GridTransformAnim | ||
1157 | 110 | { | ||
1158 | 111 | public: | ||
1159 | 112 | RaindropAnim (CompWindow *w, | ||
1160 | 113 | WindowEvent curWindowEvent, | ||
1161 | 114 | float duration, | ||
1162 | 115 | const AnimEffect info, | ||
1163 | 116 | const CompRect &icon); | ||
1164 | 117 | |||
1165 | 118 | void initGrid (); | ||
1166 | 119 | |||
1167 | 120 | inline bool using3D () { return true; } | ||
1168 | 121 | |||
1169 | 122 | void step (); | ||
1170 | 123 | }; | ||
1171 | 124 | |||
1172 | 125 | /*** POPCORN *****************************************************************/ | ||
1173 | 126 | |||
1174 | 127 | class PopcornSingleAnim : | ||
1175 | 128 | public TransformAnim | ||
1176 | 129 | { | ||
1177 | 130 | public: | ||
1178 | 131 | PopcornSingleAnim (CompWindow *w, | ||
1179 | 132 | WindowEvent curWindowEvent, | ||
1180 | 133 | float duration, | ||
1181 | 134 | const AnimEffect info, | ||
1182 | 135 | const CompRect &icon) : | ||
1183 | 136 | Animation::Animation | ||
1184 | 137 | (w, curWindowEvent, duration, info, icon), | ||
1185 | 138 | TransformAnim::TransformAnim | ||
1186 | 139 | (w, curWindowEvent, duration, info, icon) | ||
1187 | 140 | { | ||
1188 | 141 | } | ||
1189 | 142 | |||
1190 | 143 | float layerProgress (int); | ||
1191 | 144 | |||
1192 | 145 | void applyTransform (); | ||
1193 | 146 | |||
1194 | 147 | void updateAttrib (GLWindowPaintAttrib &); | ||
1195 | 148 | |||
1196 | 149 | void updateBB (CompOutput &output); | ||
1197 | 150 | bool updateBBUsed () { return true; } | ||
1198 | 151 | }; | ||
1199 | 152 | |||
1200 | 153 | class PopcornAnim : | ||
1201 | 154 | public MultiAnim <PopcornSingleAnim, 6> | ||
1202 | 155 | { | ||
1203 | 156 | public: | ||
1204 | 157 | PopcornAnim (CompWindow *w, | ||
1205 | 158 | WindowEvent curWindowEvent, | ||
1206 | 159 | float duration, | ||
1207 | 160 | const AnimEffect info, | ||
1208 | 161 | const CompRect &icon) : | ||
1209 | 162 | MultiAnim <PopcornSingleAnim, 6>::MultiAnim | ||
1210 | 163 | (w, curWindowEvent, duration, info, icon) | ||
1211 | 164 | { | ||
1212 | 165 | } | ||
1213 | 166 | }; | ||
1214 | 167 | |||
1215 | 168 | /*** GHOST *******************************************************************/ | ||
1216 | 169 | |||
1217 | 170 | class GhostAnim : | ||
1218 | 171 | public GridTransformAnim | ||
1219 | 172 | { | ||
1220 | 173 | public: | ||
1221 | 174 | GhostAnim (CompWindow *w, | ||
1222 | 175 | WindowEvent curWindowEvent, | ||
1223 | 176 | float duration, | ||
1224 | 177 | const AnimEffect info, | ||
1225 | 178 | const CompRect &icon); | ||
1226 | 179 | |||
1227 | 180 | void initGrid (); | ||
1228 | 181 | |||
1229 | 182 | inline bool using3D () { return true; } | ||
1230 | 183 | |||
1231 | 184 | void step (); | ||
1232 | 185 | |||
1233 | 186 | void updateAttrib (GLWindowPaintAttrib &); | ||
1234 | 187 | }; | ||
1235 | 188 | |||
1236 | 189 | /*** FLICKER *****************************************************************/ | ||
1237 | 190 | |||
1238 | 191 | class FlickerSingleAnim : | ||
1239 | 192 | public GridTransformAnim | ||
1240 | 193 | { | ||
1241 | 194 | public: | ||
1242 | 195 | FlickerSingleAnim (CompWindow *w, | ||
1243 | 196 | WindowEvent curWindowEvent, | ||
1244 | 197 | float duration, | ||
1245 | 198 | const AnimEffect info, | ||
1246 | 199 | const CompRect &icon) : | ||
1247 | 200 | Animation::Animation | ||
1248 | 201 | (w, curWindowEvent, duration, info, icon), | ||
1249 | 202 | TransformAnim::TransformAnim | ||
1250 | 203 | (w, curWindowEvent, duration, info, icon), | ||
1251 | 204 | GridTransformAnim::GridTransformAnim | ||
1252 | 205 | (w, curWindowEvent, duration, info, icon) | ||
1253 | 206 | { | ||
1254 | 207 | } | ||
1255 | 208 | |||
1256 | 209 | void updateAttrib (GLWindowPaintAttrib &); | ||
1257 | 210 | |||
1258 | 211 | void initGrid (); | ||
1259 | 212 | |||
1260 | 213 | void step (); | ||
1261 | 214 | |||
1262 | 215 | bool updateBBUsed () { return true; } | ||
1263 | 216 | void updateBB (CompOutput &output) { TransformAnim::updateBB (output); } | ||
1264 | 217 | }; | ||
1265 | 218 | |||
1266 | 219 | class FlickerAnim : | ||
1267 | 220 | public MultiAnim <FlickerSingleAnim, 5> | ||
1268 | 221 | { | ||
1269 | 222 | public: | ||
1270 | 223 | FlickerAnim (CompWindow *w, | ||
1271 | 224 | WindowEvent curWindowEvent, | ||
1272 | 225 | float duration, | ||
1273 | 226 | const AnimEffect info, | ||
1274 | 227 | const CompRect &icon) : | ||
1275 | 228 | MultiAnim <FlickerSingleAnim, 5>::MultiAnim | ||
1276 | 229 | (w, curWindowEvent, duration, info, icon) | ||
1277 | 230 | { | ||
1278 | 231 | } | ||
1279 | 232 | }; | ||
1280 | 0 | 233 | ||
1281 | === added file 'plugins/animationjc/src/raindrop.cpp' | |||
1282 | --- plugins/animationjc/src/raindrop.cpp 1970-01-01 00:00:00 +0000 | |||
1283 | +++ plugins/animationjc/src/raindrop.cpp 2012-08-15 14:25:28 +0000 | |||
1284 | @@ -0,0 +1,85 @@ | |||
1285 | 1 | #include "private.h" | ||
1286 | 2 | |||
1287 | 3 | #include <algorithm> | ||
1288 | 4 | |||
1289 | 5 | RaindropAnim::RaindropAnim (CompWindow *w, | ||
1290 | 6 | WindowEvent curWindowEvent, | ||
1291 | 7 | float duration, | ||
1292 | 8 | const AnimEffect info, | ||
1293 | 9 | const CompRect &icon) : | ||
1294 | 10 | Animation::Animation (w, curWindowEvent, duration, info, icon), | ||
1295 | 11 | TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon), | ||
1296 | 12 | GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info, | ||
1297 | 13 | icon) | ||
1298 | 14 | { | ||
1299 | 15 | } | ||
1300 | 16 | |||
1301 | 17 | void | ||
1302 | 18 | RaindropAnim::initGrid () | ||
1303 | 19 | { | ||
1304 | 20 | mGridWidth = 20; | ||
1305 | 21 | mGridHeight = 20; | ||
1306 | 22 | } | ||
1307 | 23 | |||
1308 | 24 | void | ||
1309 | 25 | RaindropAnim::step () | ||
1310 | 26 | { | ||
1311 | 27 | float t = 1. - progressLinear (); | ||
1312 | 28 | if (mCurWindowEvent == WindowEventClose) | ||
1313 | 29 | t = 1. - t; | ||
1314 | 30 | |||
1315 | 31 | CompRect winRect (mAWindow->savedRectsValid () ? | ||
1316 | 32 | mAWindow->saveWinRect () : | ||
1317 | 33 | mWindow->geometry ()); | ||
1318 | 34 | CompRect outRect (mAWindow->savedRectsValid () ? | ||
1319 | 35 | mAWindow->savedOutRect () : | ||
1320 | 36 | mWindow->outputRect ()); | ||
1321 | 37 | CompWindowExtents outExtents (mAWindow->savedRectsValid () ? | ||
1322 | 38 | mAWindow->savedOutExtents () : | ||
1323 | 39 | mWindow->output ()); | ||
1324 | 40 | |||
1325 | 41 | int wx = winRect.x (); | ||
1326 | 42 | int wy = winRect.y (); | ||
1327 | 43 | |||
1328 | 44 | int owidth = outRect.width (); | ||
1329 | 45 | int oheight = outRect.height (); | ||
1330 | 46 | |||
1331 | 47 | AnimJCScreen *ajs = AnimJCScreen::get (screen); | ||
1332 | 48 | |||
1333 | 49 | float waveLength = ajs->optionGetRaindropWavelength (); | ||
1334 | 50 | int numWaves = ajs->optionGetRaindropNumWaves (); | ||
1335 | 51 | float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) * 0.08) * | ||
1336 | 52 | ajs->optionGetRaindropAmplitude (); | ||
1337 | 53 | float wavePosition = -waveLength * numWaves + | ||
1338 | 54 | (1. + waveLength * numWaves) * t; | ||
1339 | 55 | |||
1340 | 56 | GridModel::GridObject *object = mModel->objects (); | ||
1341 | 57 | unsigned int n = mModel->numObjects (); | ||
1342 | 58 | for (unsigned int i = 0; i < n; i++, object++) | ||
1343 | 59 | { | ||
1344 | 60 | Point3d &objPos = object->position (); | ||
1345 | 61 | |||
1346 | 62 | float origx = wx + mModel->scale ().x () * | ||
1347 | 63 | (owidth * object->gridPosition ().x () - | ||
1348 | 64 | outExtents.left); | ||
1349 | 65 | objPos.setX (origx); | ||
1350 | 66 | |||
1351 | 67 | float origy = wy + mModel->scale ().y () * | ||
1352 | 68 | (oheight * object->gridPosition ().y () - | ||
1353 | 69 | outExtents.top); | ||
1354 | 70 | objPos.setY (origy); | ||
1355 | 71 | |||
1356 | 72 | // find distance to center in grid terms | ||
1357 | 73 | float gridDistance = sqrt (pow (object->gridPosition ().x ()-0.5, 2) + | ||
1358 | 74 | pow (object->gridPosition ().y ()-0.5, 2)) * | ||
1359 | 75 | sqrt (2); | ||
1360 | 76 | |||
1361 | 77 | float distFromWave = gridDistance - wavePosition; | ||
1362 | 78 | if (distFromWave < waveLength*numWaves && distFromWave > 0) | ||
1363 | 79 | objPos.setZ (waveAmp * | ||
1364 | 80 | sin (3.14159265 * distFromWave / waveLength / numWaves) * | ||
1365 | 81 | pow (sin (3.14159265 * distFromWave / waveLength), 2)); | ||
1366 | 82 | else | ||
1367 | 83 | objPos.setZ (0); | ||
1368 | 84 | } | ||
1369 | 85 | } |
I feel like animationjc and animationextra should probably be merged into either animation or animationaddon. Two less plugins to maintain. Thoughts?