1 |
d333eb6b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Distorted. //
|
5 |
|
|
// //
|
6 |
|
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
6a06a912
|
Leszek Koltunski
|
package org.distorted.library;
|
21 |
|
|
|
22 |
|
|
import android.opengl.GLES20;
|
23 |
|
|
|
24 |
e458a4ba
|
Leszek Koltunski
|
import org.distorted.library.message.EffectListener;
|
25 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Data1D;
|
26 |
f2fe7e28
|
Leszek Koltunski
|
import org.distorted.library.type.Data2D;
|
27 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Data3D;
|
28 |
|
|
import org.distorted.library.type.Data4D;
|
29 |
350cc2f5
|
Leszek Koltunski
|
import org.distorted.library.type.Data5D;
|
30 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
31 |
a4835695
|
Leszek Koltunski
|
|
32 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
b329f352
|
Leszek Koltunski
|
/**
|
34 |
4e2382f3
|
Leszek Koltunski
|
* Class containing {@link EffectTypes#LENGTH} queues, each a class derived from EffectQueue.
|
35 |
b73dcaa7
|
Leszek Koltunski
|
* <p>
|
36 |
4e2382f3
|
Leszek Koltunski
|
* The queues hold actual effects to be applied to a given (DistortedTexture,GridObject) combo.
|
37 |
b329f352
|
Leszek Koltunski
|
*/
|
38 |
4e2382f3
|
Leszek Koltunski
|
public class DistortedEffectQueues
|
39 |
d425545a
|
Leszek Koltunski
|
{
|
40 |
8e34674e
|
Leszek Koltunski
|
private static long mNextID =0;
|
41 |
4e2382f3
|
Leszek Koltunski
|
private long mID;
|
42 |
8e34674e
|
Leszek Koltunski
|
|
43 |
3d590d8d
|
Leszek Koltunski
|
private EffectQueueMatrix mM;
|
44 |
|
|
private EffectQueueFragment mF;
|
45 |
|
|
private EffectQueueVertex mV;
|
46 |
|
|
|
47 |
|
|
private boolean matrixCloned, vertexCloned, fragmentCloned;
|
48 |
985ea9c5
|
Leszek Koltunski
|
|
49 |
9361b337
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
6a06a912
|
Leszek Koltunski
|
|
51 |
4e2382f3
|
Leszek Koltunski
|
private void initializeEffectLists(DistortedEffectQueues d, int flags)
|
52 |
d425545a
|
Leszek Koltunski
|
{
|
53 |
015642fb
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_MATRIX) != 0 )
|
54 |
6a06a912
|
Leszek Koltunski
|
{
|
55 |
d425545a
|
Leszek Koltunski
|
mM = d.mM;
|
56 |
|
|
matrixCloned = true;
|
57 |
|
|
}
|
58 |
|
|
else
|
59 |
|
|
{
|
60 |
4e2382f3
|
Leszek Koltunski
|
mM = new EffectQueueMatrix(mID);
|
61 |
d425545a
|
Leszek Koltunski
|
matrixCloned = false;
|
62 |
|
|
}
|
63 |
6a06a912
|
Leszek Koltunski
|
|
64 |
d425545a
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_VERTEX) != 0 )
|
65 |
|
|
{
|
66 |
|
|
mV = d.mV;
|
67 |
|
|
vertexCloned = true;
|
68 |
|
|
}
|
69 |
|
|
else
|
70 |
|
|
{
|
71 |
4e2382f3
|
Leszek Koltunski
|
mV = new EffectQueueVertex(mID);
|
72 |
d425545a
|
Leszek Koltunski
|
vertexCloned = false;
|
73 |
|
|
}
|
74 |
6a06a912
|
Leszek Koltunski
|
|
75 |
d425545a
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
|
76 |
|
|
{
|
77 |
|
|
mF = d.mF;
|
78 |
|
|
fragmentCloned = true;
|
79 |
6a06a912
|
Leszek Koltunski
|
}
|
80 |
d425545a
|
Leszek Koltunski
|
else
|
81 |
|
|
{
|
82 |
4e2382f3
|
Leszek Koltunski
|
mF = new EffectQueueFragment(mID);
|
83 |
d425545a
|
Leszek Koltunski
|
fragmentCloned = false;
|
84 |
|
|
}
|
85 |
|
|
}
|
86 |
6a06a912
|
Leszek Koltunski
|
|
87 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88 |
|
|
|
89 |
4e2382f3
|
Leszek Koltunski
|
void drawPriv(long currTime, DistortedTexture tex, GridObject grid, DistortedFramebuffer df)
|
90 |
d425545a
|
Leszek Koltunski
|
{
|
91 |
ed13a5de
|
Leszek Koltunski
|
GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
|
92 |
0a046359
|
Leszek Koltunski
|
|
93 |
3ef3364d
|
Leszek Koltunski
|
float halfZ = tex.mHalfX*grid.zFactor;
|
94 |
|
|
|
95 |
d425545a
|
Leszek Koltunski
|
mM.compute(currTime);
|
96 |
3ef3364d
|
Leszek Koltunski
|
mM.send(df,tex.mHalfX,tex.mHalfY,halfZ);
|
97 |
6a06a912
|
Leszek Koltunski
|
|
98 |
d425545a
|
Leszek Koltunski
|
mV.compute(currTime);
|
99 |
3ef3364d
|
Leszek Koltunski
|
mV.send(tex.mHalfX,tex.mHalfY,halfZ);
|
100 |
6a06a912
|
Leszek Koltunski
|
|
101 |
d425545a
|
Leszek Koltunski
|
mF.compute(currTime);
|
102 |
4e2382f3
|
Leszek Koltunski
|
mF.send(tex.mHalfX,tex.mHalfY);
|
103 |
a56bc359
|
Leszek Koltunski
|
|
104 |
|
|
grid.draw();
|
105 |
d425545a
|
Leszek Koltunski
|
}
|
106 |
6a06a912
|
Leszek Koltunski
|
|
107 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108 |
|
|
|
109 |
4e2382f3
|
Leszek Koltunski
|
void drawNoEffectsPriv(DistortedTexture tex, GridObject grid, DistortedFramebuffer df)
|
110 |
d425545a
|
Leszek Koltunski
|
{
|
111 |
ed13a5de
|
Leszek Koltunski
|
GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
|
112 |
0a046359
|
Leszek Koltunski
|
|
113 |
3ef3364d
|
Leszek Koltunski
|
mM.sendZero(df,tex.mHalfX,tex.mHalfY,tex.mHalfX*grid.zFactor);
|
114 |
d425545a
|
Leszek Koltunski
|
mV.sendZero();
|
115 |
|
|
mF.sendZero();
|
116 |
a56bc359
|
Leszek Koltunski
|
|
117 |
|
|
grid.draw();
|
118 |
d425545a
|
Leszek Koltunski
|
}
|
119 |
6a06a912
|
Leszek Koltunski
|
|
120 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121 |
|
|
|
122 |
8e34674e
|
Leszek Koltunski
|
private void releasePriv()
|
123 |
d425545a
|
Leszek Koltunski
|
{
|
124 |
8e34674e
|
Leszek Koltunski
|
if( !matrixCloned ) mM.abortAll(false);
|
125 |
|
|
if( !vertexCloned ) mV.abortAll(false);
|
126 |
|
|
if( !fragmentCloned) mF.abortAll(false);
|
127 |
d425545a
|
Leszek Koltunski
|
|
128 |
4e2382f3
|
Leszek Koltunski
|
mM = null;
|
129 |
|
|
mV = null;
|
130 |
|
|
mF = null;
|
131 |
8e34674e
|
Leszek Koltunski
|
}
|
132 |
|
|
|
133 |
1942537e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
7b8086eb
|
Leszek Koltunski
|
static void onDestroy()
|
136 |
1942537e
|
Leszek Koltunski
|
{
|
137 |
|
|
mNextID = 0;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
8e34674e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141 |
|
|
// PUBLIC API
|
142 |
ada90d33
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
143 |
d425545a
|
Leszek Koltunski
|
/**
|
144 |
4e2382f3
|
Leszek Koltunski
|
* Create empty effect queue.
|
145 |
d425545a
|
Leszek Koltunski
|
*/
|
146 |
4e2382f3
|
Leszek Koltunski
|
public DistortedEffectQueues()
|
147 |
d425545a
|
Leszek Koltunski
|
{
|
148 |
4e2382f3
|
Leszek Koltunski
|
mID = mNextID++;
|
149 |
|
|
initializeEffectLists(this,0);
|
150 |
d425545a
|
Leszek Koltunski
|
}
|
151 |
ada90d33
|
Leszek Koltunski
|
|
152 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
153 |
d425545a
|
Leszek Koltunski
|
/**
|
154 |
4e2382f3
|
Leszek Koltunski
|
* Copy constructor.
|
155 |
d425545a
|
Leszek Koltunski
|
* <p>
|
156 |
|
|
* Whatever we do not clone gets created just like in the default constructor.
|
157 |
|
|
* We only call this from the descendant's classes' constructors where we have to pay attention
|
158 |
|
|
* to give it the appropriate type of a DistortedObject!
|
159 |
|
|
*
|
160 |
|
|
* @param dc Source object to create our object from
|
161 |
|
|
* @param flags A bitmask of values specifying what to copy.
|
162 |
e6ab30eb
|
Leszek Koltunski
|
* For example, CLONE_VERTEX | CLONE_MATRIX.
|
163 |
d425545a
|
Leszek Koltunski
|
*/
|
164 |
4e2382f3
|
Leszek Koltunski
|
public DistortedEffectQueues(DistortedEffectQueues dc, int flags)
|
165 |
d425545a
|
Leszek Koltunski
|
{
|
166 |
8e34674e
|
Leszek Koltunski
|
mID = mNextID++;
|
167 |
4e2382f3
|
Leszek Koltunski
|
initializeEffectLists(dc,flags);
|
168 |
d425545a
|
Leszek Koltunski
|
}
|
169 |
ada90d33
|
Leszek Koltunski
|
|
170 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
171 |
|
|
/**
|
172 |
|
|
* Draw the DistortedObject to the location specified by current Matrix effects.
|
173 |
6537ba91
|
Leszek Koltunski
|
* <p>
|
174 |
|
|
* Must be called from a thread holding OpenGL Context
|
175 |
|
|
*
|
176 |
d1e740c5
|
Leszek Koltunski
|
* @param currTime current time, in milliseconds.
|
177 |
5d923c17
|
Leszek Koltunski
|
* This gets passed on to Dynamics inside the Effects that are currently applied to the
|
178 |
6a06a912
|
Leszek Koltunski
|
* Object.
|
179 |
|
|
*/
|
180 |
4e2382f3
|
Leszek Koltunski
|
public void draw(long currTime, DistortedTexture tex, GridObject grid)
|
181 |
d425545a
|
Leszek Koltunski
|
{
|
182 |
1942537e
|
Leszek Koltunski
|
tex.createTexture();
|
183 |
d425545a
|
Leszek Koltunski
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
|
184 |
4e2382f3
|
Leszek Koltunski
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.mTextureDataH[0]);
|
185 |
|
|
drawPriv(currTime, tex, grid, Distorted.mFramebuffer);
|
186 |
1942537e
|
Leszek Koltunski
|
DistortedFramebuffer.deleteAllMarked();
|
187 |
|
|
DistortedTexture.deleteAllMarked();
|
188 |
d425545a
|
Leszek Koltunski
|
}
|
189 |
d1e740c5
|
Leszek Koltunski
|
|
190 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
|
|
/**
|
192 |
|
|
* Draw the DistortedObject to the Framebuffer passed.
|
193 |
6537ba91
|
Leszek Koltunski
|
* <p>
|
194 |
|
|
* Must be called from a thread holding OpenGL Context
|
195 |
d1e740c5
|
Leszek Koltunski
|
*
|
196 |
|
|
* @param currTime Current time, in milliseconds.
|
197 |
|
|
* @param df Framebuffer to render this to.
|
198 |
|
|
*/
|
199 |
4e2382f3
|
Leszek Koltunski
|
public void draw(long currTime, DistortedTexture tex, GridObject grid, DistortedFramebuffer df)
|
200 |
d1e740c5
|
Leszek Koltunski
|
{
|
201 |
1942537e
|
Leszek Koltunski
|
tex.createTexture();
|
202 |
7cf783cb
|
Leszek Koltunski
|
df.createFBO();
|
203 |
|
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]);
|
204 |
4e2382f3
|
Leszek Koltunski
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.mTextureDataH[0]);
|
205 |
|
|
drawPriv(currTime, tex, grid, df);
|
206 |
1942537e
|
Leszek Koltunski
|
DistortedFramebuffer.deleteAllMarked();
|
207 |
|
|
DistortedTexture.deleteAllMarked();
|
208 |
d1e740c5
|
Leszek Koltunski
|
}
|
209 |
|
|
|
210 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
211 |
|
|
/**
|
212 |
07305c87
|
Leszek Koltunski
|
* Releases all resources. After this call, the queue should not be used anymore.
|
213 |
6a06a912
|
Leszek Koltunski
|
*/
|
214 |
8e34674e
|
Leszek Koltunski
|
public synchronized void delete()
|
215 |
d425545a
|
Leszek Koltunski
|
{
|
216 |
|
|
releasePriv();
|
217 |
|
|
}
|
218 |
6a06a912
|
Leszek Koltunski
|
|
219 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220 |
|
|
/**
|
221 |
4e2382f3
|
Leszek Koltunski
|
* Returns unique ID of this instance.
|
222 |
|
|
*
|
223 |
|
|
* @return ID of the object.
|
224 |
6a06a912
|
Leszek Koltunski
|
*/
|
225 |
4e2382f3
|
Leszek Koltunski
|
public long getID()
|
226 |
d425545a
|
Leszek Koltunski
|
{
|
227 |
4e2382f3
|
Leszek Koltunski
|
return mID;
|
228 |
d425545a
|
Leszek Koltunski
|
}
|
229 |
4e2382f3
|
Leszek Koltunski
|
|
230 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
231 |
|
|
/**
|
232 |
|
|
* Adds the calling class to the list of Listeners that get notified each time some event happens
|
233 |
07305c87
|
Leszek Koltunski
|
* to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
|
234 |
6a06a912
|
Leszek Koltunski
|
*
|
235 |
|
|
* @param el A class implementing the EffectListener interface that wants to get notifications.
|
236 |
|
|
*/
|
237 |
3fc994b2
|
Leszek Koltunski
|
public void registerForMessages(EffectListener el)
|
238 |
d425545a
|
Leszek Koltunski
|
{
|
239 |
3fc994b2
|
Leszek Koltunski
|
mV.registerForMessages(el);
|
240 |
|
|
mF.registerForMessages(el);
|
241 |
|
|
mM.registerForMessages(el);
|
242 |
d425545a
|
Leszek Koltunski
|
}
|
243 |
6a06a912
|
Leszek Koltunski
|
|
244 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
245 |
|
|
/**
|
246 |
|
|
* Removes the calling class from the list of Listeners.
|
247 |
|
|
*
|
248 |
|
|
* @param el A class implementing the EffectListener interface that no longer wants to get notifications.
|
249 |
|
|
*/
|
250 |
3fc994b2
|
Leszek Koltunski
|
public void deregisterForMessages(EffectListener el)
|
251 |
d425545a
|
Leszek Koltunski
|
{
|
252 |
3fc994b2
|
Leszek Koltunski
|
mV.deregisterForMessages(el);
|
253 |
|
|
mF.deregisterForMessages(el);
|
254 |
|
|
mM.deregisterForMessages(el);
|
255 |
d425545a
|
Leszek Koltunski
|
}
|
256 |
6a06a912
|
Leszek Koltunski
|
|
257 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
258 |
|
|
/**
|
259 |
d07f2950
|
Leszek Koltunski
|
* Aborts all Effects.
|
260 |
|
|
* @return Number of effects aborted.
|
261 |
6a06a912
|
Leszek Koltunski
|
*/
|
262 |
d425545a
|
Leszek Koltunski
|
public int abortAllEffects()
|
263 |
6a06a912
|
Leszek Koltunski
|
{
|
264 |
0df17fad
|
Leszek Koltunski
|
return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
|
265 |
6a06a912
|
Leszek Koltunski
|
}
|
266 |
|
|
|
267 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
268 |
|
|
/**
|
269 |
d07f2950
|
Leszek Koltunski
|
* Aborts all Effects of a given type, for example all MATRIX Effects.
|
270 |
6a06a912
|
Leszek Koltunski
|
*
|
271 |
d07f2950
|
Leszek Koltunski
|
* @param type one of the constants defined in {@link EffectTypes}
|
272 |
|
|
* @return Number of effects aborted.
|
273 |
6a06a912
|
Leszek Koltunski
|
*/
|
274 |
d425545a
|
Leszek Koltunski
|
public int abortEffects(EffectTypes type)
|
275 |
|
|
{
|
276 |
|
|
switch(type)
|
277 |
6a06a912
|
Leszek Koltunski
|
{
|
278 |
0df17fad
|
Leszek Koltunski
|
case MATRIX : return mM.abortAll(true);
|
279 |
|
|
case VERTEX : return mV.abortAll(true);
|
280 |
|
|
case FRAGMENT: return mF.abortAll(true);
|
281 |
d425545a
|
Leszek Koltunski
|
default : return 0;
|
282 |
6a06a912
|
Leszek Koltunski
|
}
|
283 |
d425545a
|
Leszek Koltunski
|
}
|
284 |
6a06a912
|
Leszek Koltunski
|
|
285 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
286 |
|
|
/**
|
287 |
|
|
* Aborts a single Effect.
|
288 |
|
|
*
|
289 |
|
|
* @param id ID of the Effect we want to abort.
|
290 |
476bbc81
|
Leszek Koltunski
|
* @return number of Effects aborted. Always either 0 or 1.
|
291 |
6a06a912
|
Leszek Koltunski
|
*/
|
292 |
d425545a
|
Leszek Koltunski
|
public int abortEffect(long id)
|
293 |
|
|
{
|
294 |
|
|
int type = (int)(id&EffectTypes.MASK);
|
295 |
1e438fc7
|
Leszek Koltunski
|
|
296 |
d425545a
|
Leszek Koltunski
|
if( type==EffectTypes.MATRIX.type ) return mM.removeByID(id>>EffectTypes.LENGTH);
|
297 |
|
|
if( type==EffectTypes.VERTEX.type ) return mV.removeByID(id>>EffectTypes.LENGTH);
|
298 |
|
|
if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
|
299 |
1e438fc7
|
Leszek Koltunski
|
|
300 |
d425545a
|
Leszek Koltunski
|
return 0;
|
301 |
|
|
}
|
302 |
6a06a912
|
Leszek Koltunski
|
|
303 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304 |
|
|
/**
|
305 |
e8c81a8e
|
Leszek Koltunski
|
* Abort all Effects of a given name, for example all rotations.
|
306 |
6a06a912
|
Leszek Koltunski
|
*
|
307 |
d07f2950
|
Leszek Koltunski
|
* @param name one of the constants defined in {@link EffectNames}
|
308 |
476bbc81
|
Leszek Koltunski
|
* @return number of Effects aborted.
|
309 |
6a06a912
|
Leszek Koltunski
|
*/
|
310 |
d425545a
|
Leszek Koltunski
|
public int abortEffects(EffectNames name)
|
311 |
|
|
{
|
312 |
|
|
switch(name.getType())
|
313 |
6a06a912
|
Leszek Koltunski
|
{
|
314 |
d425545a
|
Leszek Koltunski
|
case MATRIX : return mM.removeByType(name);
|
315 |
|
|
case VERTEX : return mV.removeByType(name);
|
316 |
|
|
case FRAGMENT: return mF.removeByType(name);
|
317 |
|
|
default : return 0;
|
318 |
6a06a912
|
Leszek Koltunski
|
}
|
319 |
d425545a
|
Leszek Koltunski
|
}
|
320 |
6a06a912
|
Leszek Koltunski
|
|
321 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
322 |
|
|
/**
|
323 |
|
|
* Print some info about a given Effect to Android's standard out. Used for debugging only.
|
324 |
|
|
*
|
325 |
|
|
* @param id Effect ID we want to print info about
|
326 |
|
|
* @return <code>true</code> if a single Effect of type effectType has been found.
|
327 |
|
|
*/
|
328 |
|
|
|
329 |
d425545a
|
Leszek Koltunski
|
public boolean printEffect(long id)
|
330 |
|
|
{
|
331 |
|
|
int type = (int)(id&EffectTypes.MASK);
|
332 |
1e438fc7
|
Leszek Koltunski
|
|
333 |
d425545a
|
Leszek Koltunski
|
if( type==EffectTypes.MATRIX.type ) return mM.printByID(id>>EffectTypes.LENGTH);
|
334 |
|
|
if( type==EffectTypes.VERTEX.type ) return mV.printByID(id>>EffectTypes.LENGTH);
|
335 |
|
|
if( type==EffectTypes.FRAGMENT.type ) return mF.printByID(id>>EffectTypes.LENGTH);
|
336 |
1e438fc7
|
Leszek Koltunski
|
|
337 |
d425545a
|
Leszek Koltunski
|
return false;
|
338 |
|
|
}
|
339 |
6a06a912
|
Leszek Koltunski
|
|
340 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
342 |
|
|
// Individual effect functions.
|
343 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
344 |
|
|
// Matrix-based effects
|
345 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
346 |
|
|
/**
|
347 |
e8c81a8e
|
Leszek Koltunski
|
* Moves the Object by a (possibly changing in time) vector.
|
348 |
6a06a912
|
Leszek Koltunski
|
*
|
349 |
568b29d8
|
Leszek Koltunski
|
* @param vector 3-dimensional Data which at any given time will return a Static3D
|
350 |
e0a16874
|
Leszek Koltunski
|
* representing the current coordinates of the vector we want to move the Object with.
|
351 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
352 |
6a06a912
|
Leszek Koltunski
|
*/
|
353 |
568b29d8
|
Leszek Koltunski
|
public long move(Data3D vector)
|
354 |
6a06a912
|
Leszek Koltunski
|
{
|
355 |
e0a16874
|
Leszek Koltunski
|
return mM.add(EffectNames.MOVE,vector);
|
356 |
6a06a912
|
Leszek Koltunski
|
}
|
357 |
|
|
|
358 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
359 |
|
|
/**
|
360 |
e8c81a8e
|
Leszek Koltunski
|
* Scales the Object by (possibly changing in time) 3D scale factors.
|
361 |
6a06a912
|
Leszek Koltunski
|
*
|
362 |
d1e740c5
|
Leszek Koltunski
|
* @param scale 3-dimensional Data which at any given time returns a Static3D
|
363 |
e0a16874
|
Leszek Koltunski
|
* representing the current x- , y- and z- scale factors.
|
364 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
365 |
6a06a912
|
Leszek Koltunski
|
*/
|
366 |
568b29d8
|
Leszek Koltunski
|
public long scale(Data3D scale)
|
367 |
6a06a912
|
Leszek Koltunski
|
{
|
368 |
e0a16874
|
Leszek Koltunski
|
return mM.add(EffectNames.SCALE,scale);
|
369 |
6a06a912
|
Leszek Koltunski
|
}
|
370 |
|
|
|
371 |
2fce34f4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
372 |
|
|
/**
|
373 |
e8c81a8e
|
Leszek Koltunski
|
* Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
|
374 |
2fce34f4
|
Leszek Koltunski
|
*
|
375 |
|
|
* @param scale The factor to scale all 3 dimensions with.
|
376 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
377 |
|
|
*/
|
378 |
d425545a
|
Leszek Koltunski
|
public long scale(float scale)
|
379 |
|
|
{
|
380 |
|
|
return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
|
381 |
|
|
}
|
382 |
2fce34f4
|
Leszek Koltunski
|
|
383 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
384 |
|
|
/**
|
385 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by 'angle' degrees around the center.
|
386 |
|
|
* Static axis of rotation is given by the last parameter.
|
387 |
|
|
*
|
388 |
9351ad55
|
Leszek Koltunski
|
* @param angle Angle that we want to rotate the Object to. Unit: degrees
|
389 |
568b29d8
|
Leszek Koltunski
|
* @param axis Axis of rotation
|
390 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
391 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
392 |
|
|
*/
|
393 |
0df17fad
|
Leszek Koltunski
|
public long rotate(Data1D angle, Static3D axis, Data3D center )
|
394 |
6a06a912
|
Leszek Koltunski
|
{
|
395 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.ROTATE, angle, axis, center);
|
396 |
6a06a912
|
Leszek Koltunski
|
}
|
397 |
|
|
|
398 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
399 |
|
|
/**
|
400 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by 'angle' degrees around the center.
|
401 |
2fce34f4
|
Leszek Koltunski
|
* Here both angle and axis can dynamically change.
|
402 |
568b29d8
|
Leszek Koltunski
|
*
|
403 |
|
|
* @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
|
404 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
405 |
568b29d8
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
406 |
e0a16874
|
Leszek Koltunski
|
*/
|
407 |
0df17fad
|
Leszek Koltunski
|
public long rotate(Data4D angleaxis, Data3D center)
|
408 |
568b29d8
|
Leszek Koltunski
|
{
|
409 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.ROTATE, angleaxis, center);
|
410 |
6a06a912
|
Leszek Koltunski
|
}
|
411 |
|
|
|
412 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
413 |
|
|
/**
|
414 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by quaternion.
|
415 |
0df17fad
|
Leszek Koltunski
|
*
|
416 |
568b29d8
|
Leszek Koltunski
|
* @param quaternion The quaternion describing the rotation.
|
417 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
418 |
568b29d8
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
419 |
6a06a912
|
Leszek Koltunski
|
*/
|
420 |
0df17fad
|
Leszek Koltunski
|
public long quaternion(Data4D quaternion, Data3D center )
|
421 |
568b29d8
|
Leszek Koltunski
|
{
|
422 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.QUATERNION,quaternion,center);
|
423 |
6a06a912
|
Leszek Koltunski
|
}
|
424 |
|
|
|
425 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
426 |
|
|
/**
|
427 |
568b29d8
|
Leszek Koltunski
|
* Shears the Object.
|
428 |
6a06a912
|
Leszek Koltunski
|
*
|
429 |
8c3cdec5
|
Leszek Koltunski
|
* @param shear The 3-tuple of shear factors. The first controls level
|
430 |
|
|
* of shearing in the X-axis, second - Y-axis and the third -
|
431 |
|
|
* Z-axis. Each is the tangens of the shear angle, i.e 0 -
|
432 |
|
|
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
|
433 |
0df17fad
|
Leszek Koltunski
|
* @param center Center of shearing, i.e. the point which stays unmoved.
|
434 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
435 |
6a06a912
|
Leszek Koltunski
|
*/
|
436 |
0df17fad
|
Leszek Koltunski
|
public long shear(Data3D shear, Data3D center)
|
437 |
6a06a912
|
Leszek Koltunski
|
{
|
438 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.SHEAR, shear, center);
|
439 |
6a06a912
|
Leszek Koltunski
|
}
|
440 |
|
|
|
441 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
442 |
|
|
// Fragment-based effects
|
443 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
444 |
|
|
/**
|
445 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change all three of its RGB components.
|
446 |
6a06a912
|
Leszek Koltunski
|
*
|
447 |
2fce34f4
|
Leszek Koltunski
|
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be
|
448 |
e4878781
|
Leszek Koltunski
|
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
|
449 |
|
|
* Valid range: <0,1>
|
450 |
b1e91f2c
|
Leszek Koltunski
|
* @param color Color to mix. (1,0,0) is RED.
|
451 |
2fce34f4
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
452 |
|
|
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
|
453 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
454 |
6a06a912
|
Leszek Koltunski
|
*/
|
455 |
8c893ffc
|
Leszek Koltunski
|
public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
|
456 |
6a06a912
|
Leszek Koltunski
|
{
|
457 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
|
458 |
6a06a912
|
Leszek Koltunski
|
}
|
459 |
|
|
|
460 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
461 |
|
|
/**
|
462 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change all three of its RGB components.
|
463 |
|
|
*
|
464 |
|
|
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be
|
465 |
e4878781
|
Leszek Koltunski
|
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
|
466 |
|
|
* Valid range: <0,1>
|
467 |
b1e91f2c
|
Leszek Koltunski
|
* @param color Color to mix. (1,0,0) is RED.
|
468 |
2fce34f4
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
469 |
6a06a912
|
Leszek Koltunski
|
*/
|
470 |
8c893ffc
|
Leszek Koltunski
|
public long chroma(Data1D blend, Data3D color)
|
471 |
6a06a912
|
Leszek Koltunski
|
{
|
472 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.CHROMA, blend, color);
|
473 |
6a06a912
|
Leszek Koltunski
|
}
|
474 |
|
|
|
475 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
476 |
|
|
/**
|
477 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its transparency level.
|
478 |
6a06a912
|
Leszek Koltunski
|
*
|
479 |
2fce34f4
|
Leszek Koltunski
|
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any given
|
480 |
e4878781
|
Leszek Koltunski
|
* moment: pixel.a *= alpha.
|
481 |
|
|
* Valid range: <0,1>
|
482 |
d7bbef2f
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
483 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
|
484 |
d7bbef2f
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
485 |
6a06a912
|
Leszek Koltunski
|
*/
|
486 |
2fce34f4
|
Leszek Koltunski
|
public long alpha(Data1D alpha, Data4D region, boolean smooth)
|
487 |
6a06a912
|
Leszek Koltunski
|
{
|
488 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
|
489 |
6a06a912
|
Leszek Koltunski
|
}
|
490 |
|
|
|
491 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
492 |
|
|
/**
|
493 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its transparency level.
|
494 |
|
|
*
|
495 |
|
|
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any
|
496 |
e4878781
|
Leszek Koltunski
|
* given moment: pixel.a *= alpha.
|
497 |
|
|
* Valid range: <0,1>
|
498 |
2fce34f4
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
499 |
6a06a912
|
Leszek Koltunski
|
*/
|
500 |
2fce34f4
|
Leszek Koltunski
|
public long alpha(Data1D alpha)
|
501 |
6a06a912
|
Leszek Koltunski
|
{
|
502 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.ALPHA, alpha);
|
503 |
6a06a912
|
Leszek Koltunski
|
}
|
504 |
|
|
|
505 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
506 |
|
|
/**
|
507 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its brightness level.
|
508 |
6a06a912
|
Leszek Koltunski
|
*
|
509 |
2fce34f4
|
Leszek Koltunski
|
* @param brightness 1-dimensional Data that returns the level of brightness we want to have
|
510 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
511 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
512 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
|
513 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
514 |
6a06a912
|
Leszek Koltunski
|
*/
|
515 |
2fce34f4
|
Leszek Koltunski
|
public long brightness(Data1D brightness, Data4D region, boolean smooth)
|
516 |
6a06a912
|
Leszek Koltunski
|
{
|
517 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
|
518 |
6a06a912
|
Leszek Koltunski
|
}
|
519 |
|
|
|
520 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
521 |
|
|
/**
|
522 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its brightness level.
|
523 |
|
|
*
|
524 |
|
|
* @param brightness 1-dimensional Data that returns the level of brightness we want to have
|
525 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
526 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
527 |
6a06a912
|
Leszek Koltunski
|
*/
|
528 |
2fce34f4
|
Leszek Koltunski
|
public long brightness(Data1D brightness)
|
529 |
6a06a912
|
Leszek Koltunski
|
{
|
530 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.BRIGHTNESS, brightness);
|
531 |
6a06a912
|
Leszek Koltunski
|
}
|
532 |
|
|
|
533 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
534 |
|
|
/**
|
535 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its contrast level.
|
536 |
6a06a912
|
Leszek Koltunski
|
*
|
537 |
2fce34f4
|
Leszek Koltunski
|
* @param contrast 1-dimensional Data that returns the level of contrast we want to have
|
538 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
539 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
540 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
|
541 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
542 |
6a06a912
|
Leszek Koltunski
|
*/
|
543 |
2fce34f4
|
Leszek Koltunski
|
public long contrast(Data1D contrast, Data4D region, boolean smooth)
|
544 |
6a06a912
|
Leszek Koltunski
|
{
|
545 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
|
546 |
6a06a912
|
Leszek Koltunski
|
}
|
547 |
|
|
|
548 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
549 |
|
|
/**
|
550 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its contrast level.
|
551 |
|
|
*
|
552 |
|
|
* @param contrast 1-dimensional Data that returns the level of contrast we want to have
|
553 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
554 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
555 |
6a06a912
|
Leszek Koltunski
|
*/
|
556 |
2fce34f4
|
Leszek Koltunski
|
public long contrast(Data1D contrast)
|
557 |
6a06a912
|
Leszek Koltunski
|
{
|
558 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.CONTRAST, contrast);
|
559 |
6a06a912
|
Leszek Koltunski
|
}
|
560 |
|
|
|
561 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
562 |
|
|
/**
|
563 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its saturation level.
|
564 |
6a06a912
|
Leszek Koltunski
|
*
|
565 |
2fce34f4
|
Leszek Koltunski
|
* @param saturation 1-dimensional Data that returns the level of saturation we want to have
|
566 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
567 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
568 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
|
569 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
570 |
6a06a912
|
Leszek Koltunski
|
*/
|
571 |
2fce34f4
|
Leszek Koltunski
|
public long saturation(Data1D saturation, Data4D region, boolean smooth)
|
572 |
6a06a912
|
Leszek Koltunski
|
{
|
573 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
|
574 |
6a06a912
|
Leszek Koltunski
|
}
|
575 |
|
|
|
576 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
577 |
|
|
/**
|
578 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its saturation level.
|
579 |
|
|
*
|
580 |
|
|
* @param saturation 1-dimensional Data that returns the level of saturation we want to have
|
581 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
582 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
583 |
6a06a912
|
Leszek Koltunski
|
*/
|
584 |
2fce34f4
|
Leszek Koltunski
|
public long saturation(Data1D saturation)
|
585 |
6a06a912
|
Leszek Koltunski
|
{
|
586 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.SATURATION, saturation);
|
587 |
6a06a912
|
Leszek Koltunski
|
}
|
588 |
|
|
|
589 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
590 |
|
|
// Vertex-based effects
|
591 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
592 |
|
|
/**
|
593 |
e0a16874
|
Leszek Koltunski
|
* Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
|
594 |
f2fe7e28
|
Leszek Koltunski
|
*
|
595 |
|
|
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is
|
596 |
|
|
* currently being dragged with.
|
597 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
598 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
599 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
600 |
6a06a912
|
Leszek Koltunski
|
*/
|
601 |
fa6c352d
|
Leszek Koltunski
|
public long distort(Data3D vector, Data3D center, Data4D region)
|
602 |
6a06a912
|
Leszek Koltunski
|
{
|
603 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.DISTORT, vector, center, region);
|
604 |
6a06a912
|
Leszek Koltunski
|
}
|
605 |
|
|
|
606 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
607 |
|
|
/**
|
608 |
e0a16874
|
Leszek Koltunski
|
* Distort the whole Object by a (possibly changing in time) vector of force.
|
609 |
f2fe7e28
|
Leszek Koltunski
|
*
|
610 |
|
|
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is
|
611 |
|
|
* currently being dragged with.
|
612 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
613 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
614 |
6a06a912
|
Leszek Koltunski
|
*/
|
615 |
fa6c352d
|
Leszek Koltunski
|
public long distort(Data3D vector, Data3D center)
|
616 |
d425545a
|
Leszek Koltunski
|
{
|
617 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.DISTORT, vector, center, null);
|
618 |
d425545a
|
Leszek Koltunski
|
}
|
619 |
6a06a912
|
Leszek Koltunski
|
|
620 |
6ebdbbf1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
621 |
|
|
/**
|
622 |
|
|
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
|
623 |
|
|
* a (possibly changing in time) point on the Object.
|
624 |
|
|
*
|
625 |
|
|
* @param vector Vector of force that deforms the shape of the whole Object.
|
626 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
627 |
|
|
* @param region Region that masks the Effect.
|
628 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
629 |
|
|
*/
|
630 |
|
|
public long deform(Data3D vector, Data3D center, Data4D region)
|
631 |
|
|
{
|
632 |
|
|
return mV.add(EffectNames.DEFORM, vector, center, region);
|
633 |
|
|
}
|
634 |
|
|
|
635 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
636 |
|
|
/**
|
637 |
e0a16874
|
Leszek Koltunski
|
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
|
638 |
9351ad55
|
Leszek Koltunski
|
* a (possibly changing in time) point on the Object.
|
639 |
6a06a912
|
Leszek Koltunski
|
*
|
640 |
f2fe7e28
|
Leszek Koltunski
|
* @param vector Vector of force that deforms the shape of the whole Object.
|
641 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
642 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
643 |
6a06a912
|
Leszek Koltunski
|
*/
|
644 |
fa6c352d
|
Leszek Koltunski
|
public long deform(Data3D vector, Data3D center)
|
645 |
6a06a912
|
Leszek Koltunski
|
{
|
646 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.DEFORM, vector, center, null);
|
647 |
6a06a912
|
Leszek Koltunski
|
}
|
648 |
|
|
|
649 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
650 |
|
|
/**
|
651 |
f2fe7e28
|
Leszek Koltunski
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
652 |
6a06a912
|
Leszek Koltunski
|
* away from the center (degree<=1)
|
653 |
f2fe7e28
|
Leszek Koltunski
|
*
|
654 |
|
|
* @param sink The current degree of the Effect.
|
655 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
656 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
657 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
658 |
6a06a912
|
Leszek Koltunski
|
*/
|
659 |
fa6c352d
|
Leszek Koltunski
|
public long sink(Data1D sink, Data3D center, Data4D region)
|
660 |
6a06a912
|
Leszek Koltunski
|
{
|
661 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.SINK, sink, center, region);
|
662 |
6a06a912
|
Leszek Koltunski
|
}
|
663 |
|
|
|
664 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
665 |
|
|
/**
|
666 |
f2fe7e28
|
Leszek Koltunski
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
667 |
|
|
* away from the center (degree<=1)
|
668 |
|
|
*
|
669 |
|
|
* @param sink The current degree of the Effect.
|
670 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
671 |
f2fe7e28
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
672 |
6a06a912
|
Leszek Koltunski
|
*/
|
673 |
fa6c352d
|
Leszek Koltunski
|
public long sink(Data1D sink, Data3D center)
|
674 |
d425545a
|
Leszek Koltunski
|
{
|
675 |
|
|
return mV.add(EffectNames.SINK, sink, center);
|
676 |
|
|
}
|
677 |
6a06a912
|
Leszek Koltunski
|
|
678 |
82ee855a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
679 |
|
|
/**
|
680 |
|
|
* Pull all points around the center of the Effect towards a line passing through the center
|
681 |
|
|
* (that's if degree>=1) or push them away from the line (degree<=1)
|
682 |
|
|
*
|
683 |
|
|
* @param pinch The current degree of the Effect + angle the line forms with X-axis
|
684 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
685 |
|
|
* @param region Region that masks the Effect.
|
686 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
687 |
|
|
*/
|
688 |
|
|
public long pinch(Data2D pinch, Data3D center, Data4D region)
|
689 |
|
|
{
|
690 |
|
|
return mV.add(EffectNames.PINCH, pinch, center, region);
|
691 |
|
|
}
|
692 |
|
|
|
693 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
694 |
|
|
/**
|
695 |
|
|
* Pull all points around the center of the Effect towards a line passing through the center
|
696 |
|
|
* (that's if degree>=1) or push them away from the line (degree<=1)
|
697 |
|
|
*
|
698 |
|
|
* @param pinch The current degree of the Effect + angle the line forms with X-axis
|
699 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
700 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
701 |
|
|
*/
|
702 |
|
|
public long pinch(Data2D pinch, Data3D center)
|
703 |
|
|
{
|
704 |
|
|
return mV.add(EffectNames.PINCH, pinch, center);
|
705 |
|
|
}
|
706 |
|
|
|
707 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
708 |
|
|
/**
|
709 |
f2fe7e28
|
Leszek Koltunski
|
* Rotate part of the Object around the Center of the Effect by a certain angle.
|
710 |
|
|
*
|
711 |
4fde55a0
|
Leszek Koltunski
|
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise.
|
712 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
713 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
714 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
715 |
6a06a912
|
Leszek Koltunski
|
*/
|
716 |
fa6c352d
|
Leszek Koltunski
|
public long swirl(Data1D swirl, Data3D center, Data4D region)
|
717 |
6a06a912
|
Leszek Koltunski
|
{
|
718 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.SWIRL, swirl, center, region);
|
719 |
6a06a912
|
Leszek Koltunski
|
}
|
720 |
|
|
|
721 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
722 |
|
|
/**
|
723 |
f2fe7e28
|
Leszek Koltunski
|
* Rotate the whole Object around the Center of the Effect by a certain angle.
|
724 |
|
|
*
|
725 |
4fde55a0
|
Leszek Koltunski
|
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise.
|
726 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
727 |
f2fe7e28
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
728 |
6a06a912
|
Leszek Koltunski
|
*/
|
729 |
fa6c352d
|
Leszek Koltunski
|
public long swirl(Data1D swirl, Data3D center)
|
730 |
d425545a
|
Leszek Koltunski
|
{
|
731 |
|
|
return mV.add(EffectNames.SWIRL, swirl, center);
|
732 |
|
|
}
|
733 |
4fde55a0
|
Leszek Koltunski
|
|
734 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
735 |
|
|
/**
|
736 |
|
|
* Directional, sinusoidal wave effect.
|
737 |
|
|
*
|
738 |
350cc2f5
|
Leszek Koltunski
|
* @param wave A 5-dimensional data structure describing the wave: first member is the amplitude,
|
739 |
ea16dc89
|
Leszek Koltunski
|
* second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
|
740 |
350cc2f5
|
Leszek Koltunski
|
* wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
|
741 |
|
|
* describe the 'direction' of the wave.
|
742 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
743 |
d0c902b8
|
Leszek Koltunski
|
* Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
|
744 |
|
|
* need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
|
745 |
|
|
* forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
|
746 |
|
|
* the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
|
747 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
748 |
|
|
* <p>
|
749 |
d0c902b8
|
Leszek Koltunski
|
* Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
|
750 |
|
|
* in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
|
751 |
|
|
* will be sine shapes.
|
752 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
753 |
d0c902b8
|
Leszek Koltunski
|
* Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
|
754 |
|
|
* but this time it waves in the Y-direction, i.e. cross sections of the surface and the
|
755 |
|
|
* YZ-plane with be sine shapes.
|
756 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
757 |
d0c902b8
|
Leszek Koltunski
|
* Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
|
758 |
350cc2f5
|
Leszek Koltunski
|
* is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
|
759 |
|
|
* value if sin at this point.
|
760 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
761 |
4fde55a0
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
762 |
|
|
*/
|
763 |
fa6c352d
|
Leszek Koltunski
|
public long wave(Data5D wave, Data3D center)
|
764 |
4fde55a0
|
Leszek Koltunski
|
{
|
765 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.WAVE, wave, center, null);
|
766 |
4fde55a0
|
Leszek Koltunski
|
}
|
767 |
|
|
|
768 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
769 |
|
|
/**
|
770 |
|
|
* Directional, sinusoidal wave effect.
|
771 |
|
|
*
|
772 |
3ef3364d
|
Leszek Koltunski
|
* @param wave see {@link DistortedEffectQueues#wave(Data5D,Data3D)}
|
773 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
774 |
4fde55a0
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
775 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
776 |
|
|
*/
|
777 |
fa6c352d
|
Leszek Koltunski
|
public long wave(Data5D wave, Data3D center, Data4D region)
|
778 |
4fde55a0
|
Leszek Koltunski
|
{
|
779 |
|
|
return mV.add(EffectNames.WAVE, wave, center, region);
|
780 |
|
|
}
|
781 |
f2fe7e28
|
Leszek Koltunski
|
}
|