Merge lp:~mc-return/compiz/compiz.merge-plugin-animationjc into lp:compiz/0.9.8

Proposed by MC Return
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
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.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

I feel like animationjc and animationextra should probably be merged into either animation or animationaddon. Two less plugins to maintain. Thoughts?

Revision history for this message
MC Return (mc-return) wrote :

Black Hole, Flicker, Ghost, Popcorn & Raindrop

Revision history for this message
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 ;)

Revision history for this message
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 ?

Revision history for this message
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...

Revision history for this message
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 -.- .

Revision history for this message
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. :(

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This branch keeps failing to build (when merged with lp:compiz)

In file included from /home/dan/bzr/compiz/tmp.jc/plugins/animationjc/src/popcorn.cpp:1:0:
/home/dan/bzr/compiz/tmp.jc/plugins/animationjc/src/private.h:6:33: fatal error: composite/composite.h: No such file or directory
compilation terminated.

review: Needs Fixing
3251. By MC Return

Rebased on latest lp:compiz (r3285)

Revision history for this message
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/composite.h should exist and the other animation plug-ins use almost the same code.
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.

Revision history for this message
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.

3252. By MC Return

Added missing PLUGINDEPS composite and opengl to CMakeLists.txt to fix compilation

3253. By MC Return

Removed plugins/animationjc/VERSION

3254. By MC Return

Fixed [-Werror=maybe-uninitialized] compiler warning for the float 'displacement'

Unmerged revisions

3254. By MC Return

Fixed [-Werror=maybe-uninitialized] 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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'plugins/animationjc'
=== added file 'plugins/animationjc/CMakeLists.txt'
--- plugins/animationjc/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/CMakeLists.txt 2012-08-15 14:25:28 +0000
@@ -0,0 +1,7 @@
1find_package (Compiz REQUIRED)
2include (CompizPlugin)
3include (FindOpenGL)
4
5if (OPENGL_GLU_FOUND)
6 compiz_plugin (animationjc PLUGINDEPS composite opengl animation LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
7endif (OPENGL_GLU_FOUND)
08
=== added file 'plugins/animationjc/animationjc.xml.in'
--- plugins/animationjc/animationjc.xml.in 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/animationjc.xml.in 2012-08-15 14:25:28 +0000
@@ -0,0 +1,154 @@
1<compiz>
2 <!-- animationaddon metadata -->
3 <plugin name="animationjc" useBcop="true">
4 <_short>Animations Experimental</_short>
5 <_long>Extra window animations</_long>
6 <category>Effects</category>
7 <deps>
8 <requirement>
9 <plugin>opengl</plugin>
10 <plugin>animation</plugin>
11 </requirement>
12 <relation type="after">
13 <plugin>opengl</plugin>
14 <plugin>composite</plugin>
15 <plugin>animation</plugin>
16 <plugin>decor</plugin>
17 </relation>
18 </deps>
19
20 <options>
21 <group>
22 <_short>Effect Settings</_short>
23
24 <subgroup>
25 <_short>Black Hole</_short>
26 <option name="blackhole_delay" type="float">
27 <_short>Delay</_short>
28 <default>0.75</default>
29 <min>0.0</min>
30 <max>0.99</max>
31 <precision>0.01</precision>
32 </option>
33 </subgroup>
34
35 <subgroup>
36 <_short>Flicker</_short>
37 <option name="flicker_amplitude" type="int">
38 <_short>Amplitude</_short>
39 <default>3</default>
40 <min>1</min>
41 <max>10</max>
42 </option>
43 </subgroup>
44
45 <subgroup>
46 <_short>Ghost</_short>
47 <option name="ghost_grid" type="int">
48 <_short>Grid</_short>
49 <default>20</default>
50 <min>2</min>
51 <max>20</max>
52 </option>
53
54 <option name="ghost_saturation" type="float">
55 <_short>Saturation</_short>
56 <default>0.0</default>
57 <min>0.0</min>
58 <max>1.0</max>
59 <precision>0.1</precision>
60 </option>
61
62 <option name="ghost_amplitude" type="float">
63 <_short>Amplitude</_short>
64 <default>1.0</default>
65 <min>0.0</min>
66 <max>5.0</max>
67 </option>
68
69 <option name="ghost_wave_speed" type="float">
70 <_short>Wave Speed</_short>
71 <default>1.0</default>
72 <min>0.0</min>
73 <max>5.0</max>
74 </option>
75 </subgroup>
76
77 <subgroup>
78 <_short>Popcorn</_short>
79 <option name="popcorn_kernel_height" type="float">
80 <_short>Kernel Height</_short>
81 <default>1.0</default>
82 <min>0.0</min>
83 <max>5.0</max>
84 <precision>0.1</precision>
85 </option>
86 </subgroup>
87
88 <subgroup>
89 <_short>Raindrop</_short>
90
91 <option name="raindrop_amplitude" type="float">
92 <_short>Amplitude</_short>
93 <default>1.0</default>
94 <min>-5.0</min>
95 <max>5.0</max>
96 <precision>0.1</precision>
97 </option>
98
99 <option name="raindrop_wavelength" type="float">
100 <_short>Wavelength</_short>
101 <default>0.4</default>
102 <min>0.0</min>
103 <max>1.0</max>
104 <precision>0.05</precision>
105 </option>
106
107 <option name="raindrop_num_waves" type="int">
108 <_short>Number of Waves</_short>
109 <default>1</default>
110 <min>1</min>
111 <max>5</max>
112 </option>
113 </subgroup>
114 </group>
115 </options>
116
117 <extension base_plugin="animation">
118 <base_option>open_effects</base_option>
119 <base_option>open_random_effects</base_option>
120 <base_option>close_effects</base_option>
121 <base_option>close_random_effects</base_option>
122 <base_option>minimize_effects</base_option>
123 <base_option>minimize_random_effects</base_option>
124 <restriction>
125 <value>animationjc:Black Hole</value>
126 <_name>Black Hole</_name>
127 </restriction>
128 <restriction>
129 <value>animationjc:Ghost</value>
130 <_name>Ghost</_name>
131 </restriction>
132 <restriction>
133 <value>animationjc:Popcorn</value>
134 <_name>Popcorn</_name>
135 </restriction>
136 </extension>
137
138 <extension base_plugin="animation">
139 <base_option>open_effects</base_option>
140 <base_option>open_random_effects</base_option>
141 <base_option>close_effects</base_option>
142 <base_option>close_random_effects</base_option>
143 <base_option>focus_effects</base_option>
144 <restriction>
145 <value>animationjc:Flicker</value>
146 <_name>Flicker</_name>
147 </restriction>
148 <restriction>
149 <value>animationjc:Raindrop</value>
150 <_name>Raindrop</_name>
151 </restriction>
152 </extension>
153 </plugin>
154</compiz>
0155
=== added file 'plugins/animationjc/compiz-animationjc.pc.in'
--- plugins/animationjc/compiz-animationjc.pc.in 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/compiz-animationjc.pc.in 2012-08-15 14:25:28 +0000
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: compiz-animationjc
7Description: Animation JC plugin for compiz
8Version: @VERSION@
9
10Requires: compiz compiz-composite compiz-opengl compiz-animation
11Libs: -L${libdir} -lanimationjc
12Cflags: @COMPIZ_CFLAGS@
013
=== added directory 'plugins/animationjc/include'
=== added directory 'plugins/animationjc/include/animationjc'
=== added file 'plugins/animationjc/include/animationjc/animationjc.h'
--- plugins/animationjc/include/animationjc/animationjc.h 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/include/animationjc/animationjc.h 2012-08-15 14:25:28 +0000
@@ -0,0 +1,343 @@
1#ifndef _COMPIZ_ANIMATIONJC_H
2#define _COMPIZ_ANIMATIONJC_H
3
4#define ANIMATIONADDON_ABI 20091206
5
6#include <core/pluginclasshandler.h>
7
8#include <vector>
9#include <boost/ptr_container/ptr_vector.hpp>
10
11using namespace::std;
12
13class PrivateAnimJCScreen;
14
15/*
16class AnimJCScreen :
17 public PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI>,
18 public CompOption::Class
19{
20public:
21 AnimJCScreen (CompScreen *);
22 ~AnimJCScreen ();
23
24 CompOption::Vector &getOptions ();
25 bool setOption (const CompString &name, CompOption::Value &value);
26
27 int getIntenseTimeStep ();
28
29private:
30 PrivateAnimJCScreen *priv;
31};
32*/
33
34/// Base class for all polygon- and particle-based animations
35class BaseAddonAnim :
36 virtual public Animation
37{
38public:
39 BaseAddonAnim (CompWindow *w,
40 WindowEvent curWindowEvent,
41 float duration,
42 const AnimEffect info,
43 const CompRect &icon);
44 ~BaseAddonAnim () {}
45
46 bool needsDepthTest () { return mDoDepthTest; }
47
48protected:
49 /// Gets info about the extension plugin that implements this animation.
50 ExtensionPluginInfo *getExtensionPluginInfo ();
51
52 int mIntenseTimeStep;
53
54 CompositeScreen *mCScreen;
55 GLScreen *mGScreen;
56
57 bool mDoDepthTest; ///< Whether depth testing should be used in the effect
58};
59
60// Particle stuff
61
62class Particle
63{
64public:
65 Particle () : life (0.0f) {}
66
67 float life; ///< particle life
68 float fade; ///< fade speed
69 float width; ///< particle width
70 float height; ///< particle height
71 float w_mod; ///< particle size modification during life
72 float h_mod; ///< particle size modification during life
73 float r; ///< red value
74 float g; ///< green value
75 float b; ///< blue value
76 float a; ///< alpha value
77 float x; ///< X position
78 float y; ///< Y position
79 float z; ///< Z position
80 float xi; ///< X direction
81 float yi; ///< Y direction
82 float zi; ///< Z direction
83 float xg; ///< X gravity
84 float yg; ///< Y gravity
85 float zg; ///< Z gravity
86 float xo; ///< orginal X position
87 float yo; ///< orginal Y position
88 float zo; ///< orginal Z position
89};
90
91class ParticleSystem
92{
93 friend class ParticleAnim;
94
95public:
96 ParticleSystem (int numParticles,
97 float slowdown,
98 float darkenAmount,
99 GLuint blendMode);
100 ~ParticleSystem ();
101
102 void draw (int offsetX = 0, int offsetY = 0);
103 void update (float time);
104 vector<Particle> &particles () { return mParticles; }
105 void activate () { mActive = true; }
106 bool active () { return mActive; }
107 void setOrigin (int x, int y) { mX = x; mY = y; }
108
109protected:
110 CompWindow *mWindow;
111
112 vector<Particle> mParticles;
113
114 float mSlowDown;
115 float mDarkenAmount;
116 GLuint mBlendMode;
117 GLuint mTex;
118 bool mActive;
119 int mX, mY;
120
121 GLScreen *mGScreen;
122
123 vector<GLfloat> mVerticesCache;
124 vector<GLfloat> mCoordsCache;
125 vector<GLfloat> mColorsCache;
126 vector<GLfloat> mDColorsCache;
127};
128
129class ParticleAnim :
130 public BaseAddonAnim,
131 public PartialWindowAnim
132{
133public:
134 ParticleAnim (CompWindow *w,
135 WindowEvent curWindowEvent,
136 float duration,
137 const AnimEffect info,
138 const CompRect &icon);
139 ~ParticleAnim () {}
140 void postPaintWindow ();
141 bool postPaintWindowUsed () { return true; }
142 void updateBB (CompOutput &output);
143 bool updateBBUsed () { return true; }
144 bool prePreparePaint (int msSinceLastPaint);
145 void initLightDarkParticles (int numLightParticles,
146 int numDarkParticles,
147 float lightSlowDown,
148 float darkSlowDown);
149
150protected:
151 boost::ptr_vector<ParticleSystem> mParticleSystems;
152};
153
154// Polygon stuff
155
156typedef enum
157{
158 CorrectPerspectiveNone = 0,
159 CorrectPerspectivePolygon,
160 CorrectPerspectiveWindow
161} CorrectPerspective;
162
163/// Base class for per-PolygonObject effect parameter classes
164class PolygonEffectParameters
165{
166};
167
168/// This is intended to be a closed 3D piece of a window with convex polygon
169/// faces and quad-strip sides. Since decoration texture is separate from
170/// the window texture, it is more complicated than it would be with a single
171/// texture: we use glClipPlane with the rectangles (clips) to clip 3D space
172/// to the region falling within that clip.
173/// If the polygon is on an edge/corner, it also has 2D shadow quad(s)
174/// (to be faded out at the beginning of 3D animation if necessary).
175class PolygonObject
176{
177public:
178 int nVertices; ///< number of total vertices (front + back)
179 int nSides; ///< number of sides
180 GLfloat *vertices; ///< Positions of vertices relative to center
181 GLushort *sideIndices; ///< Indices of quad strip for "sides"
182 GLfloat *normals; ///< Surface normals for 2+nSides faces
183
184 Boxf boundingBox; ///< Bound. box to test intersection with clips
185
186 // Animation effect parameters
187
188 Point3d centerPosStart; ///< Starting position of center
189 float rotAngleStart; ///< Starting rotation angle
190
191 Point3d centerPos; ///< Position of center
192 Vector3d rotAxis; ///< Rotation axis vector
193 float rotAngle; ///< Rotation angle
194 Point3d rotAxisOffset; ///< Rotation axis translate amount
195
196 Point centerRelPos; ///< Relative pos of center within the window
197
198 Vector3d finalRelPos; ///< Velocity factor for scripted movement
199 float finalRotAng; ///< Final rotation angle around rotAxis
200
201 float moveStartTime; ///< Movement starts at this time ([0-1] range)
202 float moveDuration; ///< Movement lasts this long ([0-1] range)
203
204 float fadeStartTime; ///< Fade out starts at this time ([0,1] range)
205 float fadeDuration; ///< Duration of fade out ([0,1] range)
206
207 /** Pointer to a struct that can contain
208 custom parameters for an individual effect */
209 PolygonEffectParameters *effectParameters;
210
211 float boundSphereRadius; ///< Radius of bounding sphere
212};
213
214/// Info about intersection of a polygon and clip
215class PolygonClipInfo
216{
217public:
218 PolygonClipInfo (const PolygonObject *p);
219
220 const PolygonObject *p; ///< the intersecting polygon-object
221
222 /// Texture coord.s for each vertex of the polygon-object
223 /// ordered as: Front v1.x, y, v2.x, y, ...,
224 /// followed by back vertex texture coordinates.
225 vector<GLfloat> vertexTexCoords;
226};
227
228class Clip4Polygons ///< Rectangular clips
229{ ///< (to hold clips passed to AddWindowGeometry)
230public:
231 CompRect box; ///< Coords
232 Boxf boxf; ///< Float coords (for small clipping adjustment)
233 GLTexture::Matrix texMatrix;///< Corresponding texture coord. matrix
234
235 /// True if this clip likely intersects all polygons
236 /// (for the window-contents clip). Used for optimization purposes.
237 bool intersectsMostPolygons;
238
239 /// For polygons that intersect this clip.
240 /// Only used when intersectsMostPolygons is false.
241 list<PolygonClipInfo *> intersectingPolygonInfos;
242
243 /// Texture coord.s for each vertex of each polygon-object
244 /// ordered as: Front p1.v1.x, y, p1.v2.x, .y, p2.v1.x, .y, ...,
245 /// followed by back vertex texture coordinates.
246 /// Only used when intersectsMostPolygons is true.
247 vector<GLfloat> polygonVertexTexCoords;
248};
249
250class PolygonAnim :
251 virtual public Animation,
252 public BaseAddonAnim
253{
254public:
255 PolygonAnim (CompWindow *w,
256 WindowEvent curWindowEvent,
257 float duration,
258 const AnimEffect info,
259 const CompRect &icon);
260 ~PolygonAnim ();
261
262 void step ();
263 void prePaintWindow ();
264 void postPaintWindow ();
265 bool postPaintWindowUsed () { return true; }
266 void addGeometry (const GLTexture::MatrixList &matrix,
267 const CompRegion &region,
268 const CompRegion &clipRegion,
269 unsigned int maxGridWidth,
270 unsigned int maxGridHeight);
271 void drawGeometry ();
272 virtual void updateBB (CompOutput &output);
273 bool updateBBUsed () { return true; }
274 bool prePreparePaint (int msSinceLastPaint);
275 bool moveUpdate (int dx, int dy);
276
277 virtual void stepPolygon (PolygonObject *p,
278 float forwardProgress);
279 virtual void transformPolygon (const PolygonObject *p) {}
280
281 /// For effects that have decel. motion
282 virtual bool deceleratingMotion () { return false; }
283
284 bool tessellateIntoRectangles (int gridSizeX,
285 int gridSizeY,
286 float thickness);
287 bool tessellateIntoHexagons (int gridSizeX,
288 int gridSizeY,
289 float thickness);
290 bool tessellateIntoGlass (int gridSizeX,
291 int gridSizeY,
292 float thickness);
293
294 void prePaintOutput (CompOutput *output);
295 void deceleratingAnimStepPolygon (PolygonObject *p,
296 float forwardProgress);
297
298protected:
299 void getPerspectiveCorrectionMat (const PolygonObject *p,
300 GLfloat *mat,
301 GLMatrix *matf,
302 const CompOutput &output);
303 void processIntersectingPolygons ();
304 virtual void freePolygonObjects ();
305 void freeClipsPolygons ();
306 void prepareDrawingForAttrib (GLFragment::Attrib &attrib);
307
308 int mNumDrawGeometryCalls;
309 int mNumClipsPassed; /**< # of clips passed to animAddWindowGeometry so far
310 in this draw step */
311 bool mClipsUpdated; ///< whether stored clips are updated in this anim step
312
313 vector<Clip4Polygons> mClips;///< Rect. clips collected in addGeometries
314 int mFirstNondrawnClip;
315 vector<int> mLastClipInGroup;/**< Index of the last clip in each group of clips
316 drawn in drawGeometry func. */
317
318 bool mDoLighting; ///< Whether lighting should be used in the effect
319 CorrectPerspective mCorrectPerspective;
320
321 vector<PolygonObject *> mPolygons; ///< The polygons in this set
322 float mThickness; ///< Window thickness (depth along z axis)
323 int mNumTotalFrontVertices; ///< Total # of polygon vertices on front faces
324 float mBackAndSidesFadeDur; ///< How long side and back faces should fade in/out
325 float mAllFadeDuration; /**< Duration of fade out at the end in [0,1] range
326 when all polygons fade out at the same time.
327 If >-1, this overrides fadeDuration in PolygonObject */
328
329 bool mIncludeShadows; ///< Whether to include shadows in polygon
330
331private:
332 inline void drawPolygonClipIntersection (const PolygonObject *p,
333 const Clip4Polygons &c,
334 const GLfloat *vertexTexCoords,
335 int pass,
336 float forwardProgress,
337 GLdouble clipPlane[4][4],
338 const CompOutput &output,
339 float newOpacity,
340 bool decelerates,
341 GLfloat skewMat[16]);
342};
343#endif
0344
=== added directory 'plugins/animationjc/src'
=== added file 'plugins/animationjc/src/animationjc.cpp'
--- plugins/animationjc/src/animationjc.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/animationjc.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,145 @@
1#include "private.h"
2
3class AnimJCPluginVTable :
4 public CompPlugin::VTableForScreenAndWindow<AnimJCScreen, AnimJCWindow>
5{
6public:
7 bool init ();
8};
9
10COMPIZ_PLUGIN_20090315 (animationjc, AnimJCPluginVTable);
11
12AnimEffect animEffects[NUM_EFFECTS];
13
14ExtensionPluginAnimJC animJCExtPluginInfo (CompString ("animationjc"),
15 NUM_EFFECTS, animEffects, NULL,
16 NUM_NONEFFECT_OPTIONS);
17
18AnimEffect AnimEffectBlackHole;
19AnimEffect AnimEffectFlicker;
20AnimEffect AnimEffectGhost;
21AnimEffect AnimEffectPopcorn;
22AnimEffect AnimEffectRaindrop;
23
24ExtensionPluginInfo *
25BaseAddonAnim::getExtensionPluginInfo ()
26{
27 return &animJCExtPluginInfo;
28}
29
30BaseAddonAnim::BaseAddonAnim (CompWindow *w,
31 WindowEvent curWindowEvent,
32 float duration,
33 const AnimEffect info,
34 const CompRect &icon) :
35 Animation::Animation (w, curWindowEvent, duration, info, icon),
36 mIntenseTimeStep (AnimJCScreen::get (::screen)->getIntenseTimeStep ()),
37 mCScreen (CompositeScreen::get (::screen)),
38 mGScreen (GLScreen::get (::screen)),
39 mDoDepthTest (false)
40{
41}
42
43void
44AnimJCScreen::initAnimationList ()
45{
46 int i = 0;
47
48 animEffects[i++] = AnimEffectBlackHole =
49 new AnimEffectInfo ("animationjc:Black Hole",
50 true, true, true, false, false,
51 &createAnimation<BlackHoleAnim>);
52
53 animEffects[i++] = AnimEffectFlicker =
54 new AnimEffectInfo ("animationjc:Flicker",
55 true, true, true, false, true,
56 &createAnimation<FlickerAnim>);
57
58 animEffects[i++] = AnimEffectGhost =
59 new AnimEffectInfo ("animationjc:Ghost",
60 true, true, true, false, false,
61 &createAnimation<GhostAnim>);
62
63 animEffects[i++] = AnimEffectPopcorn =
64 new AnimEffectInfo ("animationjc:Popcorn",
65 true, true, true, false, false,
66 &createAnimation<PopcornAnim>);
67
68 animEffects[i++] = AnimEffectRaindrop =
69 new AnimEffectInfo ("animationjc:Raindrop",
70 true, true, true, false, true,
71 &createAnimation<RaindropAnim>);
72
73 animJCExtPluginInfo.effectOptions = &getOptions ();
74
75 AnimScreen *as = AnimScreen::get (::screen);
76
77 // Extends animation plugin with this set of animation effects.
78 as->addExtension (&animJCExtPluginInfo);
79}
80
81PrivateAnimJCScreen::PrivateAnimJCScreen (CompScreen *s) :
82 mOutput (s->fullscreenOutput ())
83{
84}
85
86PrivateAnimJCScreen::~PrivateAnimJCScreen ()
87{
88 AnimScreen *as = AnimScreen::get (::screen);
89
90 as->removeExtension (&animJCExtPluginInfo);
91
92 for (int i = 0; i < NUM_EFFECTS; i++)
93 {
94 delete animEffects[i];
95 animEffects[i] = NULL;
96 }
97}
98
99AnimJCScreen::AnimJCScreen (CompScreen *s) :
100 PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI> (s),
101 priv (new PrivateAnimJCScreen (s))
102{
103 initAnimationList ();
104}
105
106AnimJCScreen::~AnimJCScreen ()
107{
108 delete priv;
109}
110
111AnimJCWindow::AnimJCWindow (CompWindow *w) :
112 PluginClassHandler<AnimJCWindow, CompWindow> (w),
113 mWindow (w),
114 aWindow (AnimWindow::get (w))
115{
116}
117
118AnimJCWindow::~AnimJCWindow ()
119{
120 Animation *curAnim = aWindow->curAnimation ();
121
122 if (!curAnim)
123 return;
124
125 // We need to interrupt and clean up the animation currently being played
126 // by animationaddon for this window (if any)
127 if (curAnim->remainingTime () > 0 &&
128 curAnim->getExtensionPluginInfo ()->name ==
129 CompString ("animationjc"))
130 {
131 aWindow->postAnimationCleanUp ();
132 }
133}
134
135bool
136AnimJCPluginVTable::init ()
137{
138 if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) |
139 !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) |
140 !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) |
141 !CompPlugin::checkPluginABI ("animation", ANIMATION_ABI))
142 return false;
143
144 return true;
145}
0146
=== added file 'plugins/animationjc/src/blackhole.cpp'
--- plugins/animationjc/src/blackhole.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/blackhole.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,79 @@
1#include "private.h"
2
3#include <algorithm>
4
5BlackHoleAnim::BlackHoleAnim (CompWindow *w,
6 WindowEvent curWindowEvent,
7 float duration,
8 const AnimEffect info,
9 const CompRect &icon) :
10 Animation::Animation (w, curWindowEvent, duration, info, icon),
11 TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
12 GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
13 icon)
14{
15}
16
17void
18BlackHoleAnim::initGrid ()
19{
20 mGridWidth = 20;
21 mGridHeight = 20;
22}
23
24void
25BlackHoleAnim::step ()
26{
27 CompRect winRect (mAWindow->savedRectsValid () ?
28 mAWindow->saveWinRect () :
29 mWindow->geometry ());
30 CompRect outRect (mAWindow->savedRectsValid () ?
31 mAWindow->savedOutRect () :
32 mWindow->outputRect ());
33 CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
34 mAWindow->savedOutExtents () :
35 mWindow->output ());
36
37 int wx = winRect.x ();
38 int wy = winRect.y ();
39
40 int owidth = outRect.width ();
41 int oheight = outRect.height ();
42
43 float centerx = wx + mModel->scale ().x () *
44 (owidth * 0.5 - outExtents.left);
45 float centery = wy + mModel->scale ().y () *
46 (oheight * 0.5 - outExtents.top);
47
48 float delay = AnimJCScreen::get (screen)->optionGetBlackholeDelay ();
49 float tau = (1. - delay) / 8.;
50
51 GridModel::GridObject *object = mModel->objects ();
52 unsigned int n = mModel->numObjects ();
53 for (unsigned int i = 0; i < n; i++, object++)
54 {
55 // find distance to center in grid terms, 0..1
56 float gridDistance = 2 * max (fabs (object->gridPosition ().x ()-0.5),
57 fabs (object->gridPosition ().y ()-0.5));
58
59 // use that and tau to find r
60 float cutoff = gridDistance * delay;
61 float r = 1;
62 if (getBlackHoleProgress () > cutoff)
63 r = exp (-(getBlackHoleProgress () - cutoff) / tau);
64
65 // find real original coordinates
66 float origx = wx + mModel->scale ().x () *
67 (owidth * object->gridPosition ().x () -
68 outExtents.left);
69 float origy = wy + mModel->scale ().y () *
70 (oheight * object->gridPosition ().y () -
71 outExtents.top);
72
73 // shrink toward center by r
74 Point3d &objPos = object->position ();
75 objPos.setX ((origx-centerx) * r + centerx);
76 objPos.setY ((origy-centery) * r + centery);
77 objPos.setZ (0);
78 }
79}
080
=== added file 'plugins/animationjc/src/flicker.cpp'
--- plugins/animationjc/src/flicker.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/flicker.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,96 @@
1#include <private.h>
2
3void
4FlickerSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib)
5{
6 int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);
7 float o = 0.2;
8 attrib.opacity *= o / (1. - (4-layer)*o);
9}
10
11void
12FlickerSingleAnim::initGrid ()
13{
14 mGridWidth = 2;
15 mGridHeight = 20;
16}
17
18void
19FlickerSingleAnim::step ()
20{
21 int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);
22
23 CompRect winRect (mAWindow->savedRectsValid () ?
24 mAWindow->saveWinRect () :
25 mWindow->geometry ());
26 CompRect outRect (mAWindow->savedRectsValid () ?
27 mAWindow->savedOutRect () :
28 mWindow->outputRect ());
29 CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
30 mAWindow->savedOutExtents () :
31 mWindow->output ());
32
33 int wx = winRect.x ();
34 int wy = winRect.y ();
35 int owidth = outRect.width ();
36 int oheight = outRect.height ();
37
38 float t = 1 - progressLinear ();
39 if (mCurWindowEvent == WindowEventClose)
40 t = 1 - t;
41
42 float amplitude = AnimJCScreen::get (screen)->optionGetFlickerAmplitude ();
43 float waveLength = 0.4;
44 float wavePosition = -waveLength + (1. + waveLength) * t;
45
46 float displacement = 0;
47
48 GridModel::GridObject *object = mModel->objects ();
49 unsigned int n = mModel->numObjects ();
50 for (unsigned int i = 0; i < n; i++, object++)
51 {
52 Point3d &objPos = object->position ();
53
54 if (i % 2 == 0) // left side; reuse old displacement on right side
55 {
56 float distFromWave = object->gridPosition ().y () - wavePosition;
57
58 if (distFromWave > 0 && distFromWave <= waveLength)
59 {
60 displacement = amplitude * sin (distFromWave/waveLength * M_PI);
61 }
62 else
63 {
64 displacement = 0;
65 }
66 }
67
68 float x = wx + mModel->scale ().x () *
69 (owidth * object->gridPosition ().x () - outExtents.left);
70
71 float y = wy + mModel->scale ().y () *
72 (oheight * object->gridPosition ().y () - outExtents.top);
73
74 switch (layer)
75 {
76 case 1:
77 x -= displacement;
78 break;
79 case 2:
80 x += displacement;
81 break;
82 case 3:
83 y -= displacement;
84 break;
85 case 4:
86 y += displacement;
87 break;
88 default:
89 break;
90 }
91
92 objPos.setX (x);
93 objPos.setY (y);
94 objPos.setZ (0);
95 }
96}
097
=== added file 'plugins/animationjc/src/ghost.cpp'
--- plugins/animationjc/src/ghost.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/ghost.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,98 @@
1#include "private.h"
2
3GhostAnim::GhostAnim (CompWindow *w,
4 WindowEvent curWindowEvent,
5 float duration,
6 const AnimEffect info,
7 const CompRect &icon) :
8 Animation::Animation (w, curWindowEvent, duration, info, icon),
9 TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
10 GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
11 icon)
12{
13}
14
15void
16GhostAnim::updateAttrib (GLWindowPaintAttrib &attrib)
17{
18 AnimJCScreen *ajs = AnimJCScreen::get (screen);
19 attrib.opacity *= 1. - progressLinear ();
20 attrib.saturation *= ajs->optionGetGhostSaturation ();
21}
22
23void
24GhostAnim::initGrid ()
25{
26 AnimJCScreen *ajs = AnimJCScreen::get (screen);
27 mGridWidth = ajs->optionGetGhostGrid ();
28 mGridHeight = ajs->optionGetGhostGrid ();
29}
30
31void
32GhostAnim::step ()
33{
34 float t = 1. - progressLinear ();
35 if (mCurWindowEvent == WindowEventClose)
36 t = 1. - t;
37
38 CompRect winRect (mAWindow->savedRectsValid () ?
39 mAWindow->saveWinRect () :
40 mWindow->geometry ());
41 CompRect outRect (mAWindow->savedRectsValid () ?
42 mAWindow->savedOutRect () :
43 mWindow->outputRect ());
44 CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
45 mAWindow->savedOutExtents () :
46 mWindow->output ());
47
48 int wx = winRect.x ();
49 int wy = winRect.y ();
50
51 int owidth = outRect.width ();
52 int oheight = outRect.height ();
53
54 AnimJCScreen *ajs = AnimJCScreen::get (screen);
55
56 float waveAmp = 3 * ajs->optionGetGhostAmplitude ();
57 float waveLengthX1 = 0.4;
58 float waveLengthX2 = 0.3;
59 float waveLengthY1 = 0.45;
60 float waveLengthY2 = 0.35;
61 float wavePositionX1 = 0.25 * t * ajs->optionGetGhostWaveSpeed ();
62 float wavePositionX2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
63 float wavePositionY1 = 0.25 * t * ajs->optionGetGhostWaveSpeed ();
64 float wavePositionY2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
65
66 GridModel::GridObject *object = mModel->objects ();
67 unsigned int n = mModel->numObjects ();
68 for (unsigned int i = 0; i < n; i++, object++)
69 {
70 Point3d &objPos = object->position ();
71
72 float origx = wx + mModel->scale ().x () *
73 (owidth * object->gridPosition ().x () -
74 outExtents.left);
75
76 float origy = wy + mModel->scale ().y () *
77 (oheight * object->gridPosition ().y () -
78 outExtents.top);
79
80 float x = object->gridPosition ().x ();
81 float y = object->gridPosition ().y ();
82
83 float distFromWaveX1 = x - wavePositionX1;
84 float distFromWaveX2 = x - wavePositionX2;
85 float distFromWaveY1 = y - wavePositionY1;
86 float distFromWaveY2 = y - wavePositionY2;
87
88 objPos.setX (origx +
89 waveAmp * sin (distFromWaveX1 / waveLengthX1 * 2 * M_PI) +
90 waveAmp * sin (distFromWaveX2 / waveLengthX2 * 2 * M_PI));
91
92 objPos.setY (origy +
93 waveAmp * sin (distFromWaveY1 / waveLengthY1 * 2 * M_PI) +
94 waveAmp * sin (distFromWaveY2 / waveLengthY2 * 2 * M_PI));
95
96 objPos.setZ (0);
97 }
98}
099
=== added file 'plugins/animationjc/src/popcorn.cpp'
--- plugins/animationjc/src/popcorn.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/popcorn.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,60 @@
1#include <private.h>
2
3#define WIN_X(w) ((w)->x () - (w)->input ().left)
4#define WIN_Y(w) ((w)->y () - (w)->input ().top)
5#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
6#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
7
8float
9PopcornSingleAnim::layerProgress (int layer)
10{
11 if (layer == 0)
12 return 0;
13
14 float tStart = (5. - layer) / 6.;
15 float tEnd = tStart + 1./3.;
16
17 float t = progressLinear ();
18
19 if (t < tStart)
20 return 0;
21
22 if (t > tEnd)
23 return 1;
24
25 return (t - tStart) / (tEnd - tStart);
26}
27
28void
29PopcornSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib)
30{
31 int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow);
32
33 attrib.opacity *= 1. - progressLinear ();
34
35 attrib.opacity *= 1. - layerProgress (layer);
36}
37
38void
39PopcornSingleAnim::applyTransform ()
40{
41 int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow);
42
43 if (layer == 0) return;
44
45 float p = layerProgress (layer);
46
47 float v = 40.;
48 float theta = (54. + 144.*(layer-1)) / 180. * 3.14159265;
49 float dx = v * cos (theta) * p;
50 float dy = -v * sin (theta) * p;
51
52 mTransform.translate (dx, dy,
53 0.16*p*AnimJCScreen::get (screen)->optionGetPopcornKernelHeight ());
54}
55
56void
57PopcornSingleAnim::updateBB (CompOutput &output)
58{
59 TransformAnim::updateBB (output);
60}
061
=== added file 'plugins/animationjc/src/private.h'
--- plugins/animationjc/src/private.h 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/private.h 2012-08-15 14:25:28 +0000
@@ -0,0 +1,232 @@
1#include <string.h>
2#include <stdlib.h>
3#include <math.h>
4
5#include <core/core.h>
6#include <composite/composite.h>
7#include <opengl/opengl.h>
8
9#include <boost/foreach.hpp>
10#define foreach BOOST_FOREACH
11
12#include <animation/animation.h>
13#include <animationjc/animationjc.h>
14
15#include "animationjc_options.h"
16
17extern AnimEffect AnimEffectBlackHole;
18extern AnimEffect AnimEffectFlicker;
19extern AnimEffect AnimEffectGhost;
20extern AnimEffect AnimEffectPopcorn;
21extern AnimEffect AnimEffectRaindrop;
22
23#define NUM_EFFECTS 5
24
25// This must have the value of the first "effect setting" above
26// in AnimJCScreenOptions
27#define NUM_NONEFFECT_OPTIONS 0
28
29class ExtensionPluginAnimJC : public ExtensionPluginInfo
30{
31public:
32 ExtensionPluginAnimJC (const CompString &name,
33 unsigned int nEffects,
34 AnimEffect *effects,
35 CompOption::Vector *effectOptions,
36 unsigned int firstEffectOptionIndex) :
37 ExtensionPluginInfo (name, nEffects, effects, effectOptions,
38 firstEffectOptionIndex) {}
39 ~ExtensionPluginAnimJC () {}
40
41 const CompOutput *output () { return mOutput; }
42
43private:
44 const CompOutput *mOutput;
45};
46
47class AnimJCScreen :
48 public PluginClassHandler<AnimJCScreen, CompScreen, ANIMATIONADDON_ABI>,
49 public AnimationjcOptions
50{
51public:
52 AnimJCScreen (CompScreen *);
53 ~AnimJCScreen ();
54
55 int getIntenseTimeStep ();
56
57 void initAnimationList ();
58
59private:
60 PrivateAnimJCScreen *priv;
61};
62
63class PrivateAnimJCScreen
64{
65 friend class AnimJCScreen;
66
67public:
68 PrivateAnimJCScreen (CompScreen *);
69 ~PrivateAnimJCScreen ();
70
71protected:
72 CompOutput &mOutput;
73};
74
75class AnimJCWindow :
76 public PluginClassHandler<AnimJCWindow, CompWindow>
77{
78public:
79 AnimJCWindow (CompWindow *);
80 ~AnimJCWindow ();
81
82protected:
83 CompWindow *mWindow; ///< Window being animated.
84 AnimWindow *aWindow;
85};
86
87/*** BLACK HOLE **************************************************************/
88
89class BlackHoleAnim :
90 public GridTransformAnim
91{
92public:
93 BlackHoleAnim (CompWindow *w,
94 WindowEvent curWindowEvent,
95 float duration,
96 const AnimEffect info,
97 const CompRect &icon);
98
99 float getBlackHoleProgress () { return progressLinear (); }
100
101 void initGrid ();
102 inline bool using3D () { return false; }
103 void step ();
104};
105
106/*** RAINDROP ****************************************************************/
107
108class RaindropAnim :
109 public GridTransformAnim
110{
111public:
112 RaindropAnim (CompWindow *w,
113 WindowEvent curWindowEvent,
114 float duration,
115 const AnimEffect info,
116 const CompRect &icon);
117
118 void initGrid ();
119
120 inline bool using3D () { return true; }
121
122 void step ();
123};
124
125/*** POPCORN *****************************************************************/
126
127class PopcornSingleAnim :
128 public TransformAnim
129{
130public:
131 PopcornSingleAnim (CompWindow *w,
132 WindowEvent curWindowEvent,
133 float duration,
134 const AnimEffect info,
135 const CompRect &icon) :
136 Animation::Animation
137 (w, curWindowEvent, duration, info, icon),
138 TransformAnim::TransformAnim
139 (w, curWindowEvent, duration, info, icon)
140 {
141 }
142
143 float layerProgress (int);
144
145 void applyTransform ();
146
147 void updateAttrib (GLWindowPaintAttrib &);
148
149 void updateBB (CompOutput &output);
150 bool updateBBUsed () { return true; }
151};
152
153class PopcornAnim :
154 public MultiAnim <PopcornSingleAnim, 6>
155{
156public:
157 PopcornAnim (CompWindow *w,
158 WindowEvent curWindowEvent,
159 float duration,
160 const AnimEffect info,
161 const CompRect &icon) :
162 MultiAnim <PopcornSingleAnim, 6>::MultiAnim
163 (w, curWindowEvent, duration, info, icon)
164 {
165 }
166};
167
168/*** GHOST *******************************************************************/
169
170class GhostAnim :
171 public GridTransformAnim
172{
173public:
174 GhostAnim (CompWindow *w,
175 WindowEvent curWindowEvent,
176 float duration,
177 const AnimEffect info,
178 const CompRect &icon);
179
180 void initGrid ();
181
182 inline bool using3D () { return true; }
183
184 void step ();
185
186 void updateAttrib (GLWindowPaintAttrib &);
187};
188
189/*** FLICKER *****************************************************************/
190
191class FlickerSingleAnim :
192 public GridTransformAnim
193{
194public:
195 FlickerSingleAnim (CompWindow *w,
196 WindowEvent curWindowEvent,
197 float duration,
198 const AnimEffect info,
199 const CompRect &icon) :
200 Animation::Animation
201 (w, curWindowEvent, duration, info, icon),
202 TransformAnim::TransformAnim
203 (w, curWindowEvent, duration, info, icon),
204 GridTransformAnim::GridTransformAnim
205 (w, curWindowEvent, duration, info, icon)
206 {
207 }
208
209 void updateAttrib (GLWindowPaintAttrib &);
210
211 void initGrid ();
212
213 void step ();
214
215 bool updateBBUsed () { return true; }
216 void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
217};
218
219class FlickerAnim :
220 public MultiAnim <FlickerSingleAnim, 5>
221{
222public:
223 FlickerAnim (CompWindow *w,
224 WindowEvent curWindowEvent,
225 float duration,
226 const AnimEffect info,
227 const CompRect &icon) :
228 MultiAnim <FlickerSingleAnim, 5>::MultiAnim
229 (w, curWindowEvent, duration, info, icon)
230 {
231 }
232};
0233
=== added file 'plugins/animationjc/src/raindrop.cpp'
--- plugins/animationjc/src/raindrop.cpp 1970-01-01 00:00:00 +0000
+++ plugins/animationjc/src/raindrop.cpp 2012-08-15 14:25:28 +0000
@@ -0,0 +1,85 @@
1#include "private.h"
2
3#include <algorithm>
4
5RaindropAnim::RaindropAnim (CompWindow *w,
6 WindowEvent curWindowEvent,
7 float duration,
8 const AnimEffect info,
9 const CompRect &icon) :
10 Animation::Animation (w, curWindowEvent, duration, info, icon),
11 TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
12 GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
13 icon)
14{
15}
16
17void
18RaindropAnim::initGrid ()
19{
20 mGridWidth = 20;
21 mGridHeight = 20;
22}
23
24void
25RaindropAnim::step ()
26{
27 float t = 1. - progressLinear ();
28 if (mCurWindowEvent == WindowEventClose)
29 t = 1. - t;
30
31 CompRect winRect (mAWindow->savedRectsValid () ?
32 mAWindow->saveWinRect () :
33 mWindow->geometry ());
34 CompRect outRect (mAWindow->savedRectsValid () ?
35 mAWindow->savedOutRect () :
36 mWindow->outputRect ());
37 CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
38 mAWindow->savedOutExtents () :
39 mWindow->output ());
40
41 int wx = winRect.x ();
42 int wy = winRect.y ();
43
44 int owidth = outRect.width ();
45 int oheight = outRect.height ();
46
47 AnimJCScreen *ajs = AnimJCScreen::get (screen);
48
49 float waveLength = ajs->optionGetRaindropWavelength ();
50 int numWaves = ajs->optionGetRaindropNumWaves ();
51 float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) * 0.08) *
52 ajs->optionGetRaindropAmplitude ();
53 float wavePosition = -waveLength * numWaves +
54 (1. + waveLength * numWaves) * t;
55
56 GridModel::GridObject *object = mModel->objects ();
57 unsigned int n = mModel->numObjects ();
58 for (unsigned int i = 0; i < n; i++, object++)
59 {
60 Point3d &objPos = object->position ();
61
62 float origx = wx + mModel->scale ().x () *
63 (owidth * object->gridPosition ().x () -
64 outExtents.left);
65 objPos.setX (origx);
66
67 float origy = wy + mModel->scale ().y () *
68 (oheight * object->gridPosition ().y () -
69 outExtents.top);
70 objPos.setY (origy);
71
72 // find distance to center in grid terms
73 float gridDistance = sqrt (pow (object->gridPosition ().x ()-0.5, 2) +
74 pow (object->gridPosition ().y ()-0.5, 2)) *
75 sqrt (2);
76
77 float distFromWave = gridDistance - wavePosition;
78 if (distFromWave < waveLength*numWaves && distFromWave > 0)
79 objPos.setZ (waveAmp *
80 sin (3.14159265 * distFromWave / waveLength / numWaves) *
81 pow (sin (3.14159265 * distFromWave / waveLength), 2));
82 else
83 objPos.setZ (0);
84 }
85}

Subscribers

People subscribed via source and target branches