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 |
c90b9e01
|
Leszek Koltunski
|
import android.content.res.Resources;
|
23 |
194ab46f
|
Leszek Koltunski
|
import android.opengl.GLES30;
|
24 |
8fa96e69
|
Leszek Koltunski
|
import android.opengl.Matrix;
|
25 |
6a06a912
|
Leszek Koltunski
|
|
26 |
e458a4ba
|
Leszek Koltunski
|
import org.distorted.library.message.EffectListener;
|
27 |
55c14a19
|
Leszek Koltunski
|
import org.distorted.library.program.DistortedProgram;
|
28 |
c90b9e01
|
Leszek Koltunski
|
import org.distorted.library.program.FragmentCompilationException;
|
29 |
|
|
import org.distorted.library.program.FragmentUniformsException;
|
30 |
|
|
import org.distorted.library.program.LinkingException;
|
31 |
|
|
import org.distorted.library.program.VertexCompilationException;
|
32 |
|
|
import org.distorted.library.program.VertexUniformsException;
|
33 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Data1D;
|
34 |
f2fe7e28
|
Leszek Koltunski
|
import org.distorted.library.type.Data2D;
|
35 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Data3D;
|
36 |
|
|
import org.distorted.library.type.Data4D;
|
37 |
350cc2f5
|
Leszek Koltunski
|
import org.distorted.library.type.Data5D;
|
38 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
39 |
a4835695
|
Leszek Koltunski
|
|
40 |
c90b9e01
|
Leszek Koltunski
|
import java.io.InputStream;
|
41 |
c638c1b0
|
Leszek Koltunski
|
import java.nio.ByteBuffer;
|
42 |
|
|
import java.nio.ByteOrder;
|
43 |
|
|
import java.nio.FloatBuffer;
|
44 |
|
|
|
45 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46 |
b329f352
|
Leszek Koltunski
|
/**
|
47 |
4e2382f3
|
Leszek Koltunski
|
* Class containing {@link EffectTypes#LENGTH} queues, each a class derived from EffectQueue.
|
48 |
b73dcaa7
|
Leszek Koltunski
|
* <p>
|
49 |
26df012c
|
Leszek Koltunski
|
* The queues hold actual effects to be applied to a given (DistortedTexture,MeshObject) combo.
|
50 |
b329f352
|
Leszek Koltunski
|
*/
|
51 |
421c2728
|
Leszek Koltunski
|
public class DistortedEffects
|
52 |
d425545a
|
Leszek Koltunski
|
{
|
53 |
8fa96e69
|
Leszek Koltunski
|
private static final int POSITION_DATA_SIZE= 3; // Main Program: size of the position data in elements
|
54 |
|
|
private static final int NORMAL_DATA_SIZE = 3; // Main Program: size of the normal data in elements
|
55 |
|
|
private static final int TEX_DATA_SIZE = 2; // Main Program: size of the texture coordinate data in elements.
|
56 |
55c14a19
|
Leszek Koltunski
|
|
57 |
8fa96e69
|
Leszek Koltunski
|
private static DistortedProgram mProgram;
|
58 |
|
|
|
59 |
c90b9e01
|
Leszek Koltunski
|
/// DEBUG ONLY /////
|
60 |
|
|
private static DistortedProgram mDebugProgram;
|
61 |
|
|
private static final FloatBuffer mQuadPositions;
|
62 |
|
|
|
63 |
|
|
static
|
64 |
|
|
{
|
65 |
|
|
float[] positionData= { -0.5f, -0.5f, -0.5f, 0.5f, 0.5f,-0.5f, 0.5f, 0.5f };
|
66 |
|
|
mQuadPositions = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
67 |
|
|
mQuadPositions.put(positionData).position(0);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
private static int mObjDH;
|
71 |
|
|
private static int mMVPMatrixH;
|
72 |
|
|
/// END DEBUG //////
|
73 |
|
|
|
74 |
8fa96e69
|
Leszek Koltunski
|
private static float[] mMVPMatrix = new float[16];
|
75 |
|
|
private static float[] mTmpMatrix = new float[16];
|
76 |
c638c1b0
|
Leszek Koltunski
|
|
77 |
8e34674e
|
Leszek Koltunski
|
private static long mNextID =0;
|
78 |
4e2382f3
|
Leszek Koltunski
|
private long mID;
|
79 |
8e34674e
|
Leszek Koltunski
|
|
80 |
8fa96e69
|
Leszek Koltunski
|
private static DistortedFramebuffer mBufferFBO = new DistortedFramebuffer(1,1);
|
81 |
86eb00a9
|
Leszek Koltunski
|
|
82 |
d6e94c84
|
Leszek Koltunski
|
private EffectQueueMatrix mM;
|
83 |
|
|
private EffectQueueFragment mF;
|
84 |
|
|
private EffectQueueVertex mV;
|
85 |
|
|
private EffectQueuePostprocess mP;
|
86 |
3d590d8d
|
Leszek Koltunski
|
|
87 |
d6e94c84
|
Leszek Koltunski
|
private boolean matrixCloned, vertexCloned, fragmentCloned, postprocessCloned;
|
88 |
985ea9c5
|
Leszek Koltunski
|
|
89 |
9361b337
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90 |
55c14a19
|
Leszek Koltunski
|
|
91 |
c90b9e01
|
Leszek Koltunski
|
static void createProgram(Resources resources)
|
92 |
|
|
throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
|
93 |
55c14a19
|
Leszek Koltunski
|
{
|
94 |
c90b9e01
|
Leszek Koltunski
|
final InputStream mainVertexStream = resources.openRawResource(R.raw.main_vertex_shader);
|
95 |
|
|
final InputStream mainFragmentStream = resources.openRawResource(R.raw.main_fragment_shader);
|
96 |
|
|
|
97 |
|
|
String mainVertexHeader= ("#version 100\n#define NUM_VERTEX " + getMaxVertex()+"\n");
|
98 |
|
|
|
99 |
|
|
for(EffectNames name: EffectNames.values() )
|
100 |
|
|
{
|
101 |
|
|
if( name.getType()== EffectTypes.VERTEX)
|
102 |
|
|
mainVertexHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
String mainFragmentHeader= ("#version 100\n#define NUM_FRAGMENT " + getMaxFragment()+"\n");
|
106 |
|
|
|
107 |
|
|
for(EffectNames name: EffectNames.values() )
|
108 |
|
|
{
|
109 |
|
|
if( name.getType()== EffectTypes.FRAGMENT)
|
110 |
|
|
mainFragmentHeader += ("#define "+name.name()+" "+name.ordinal()+"\n");
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
mProgram = new DistortedProgram(mainVertexStream,mainFragmentStream, mainVertexHeader, mainFragmentHeader);
|
114 |
|
|
|
115 |
|
|
int mainProgramH = mProgram.getProgramHandle();
|
116 |
|
|
EffectQueueFragment.getUniforms(mainProgramH);
|
117 |
|
|
EffectQueueVertex.getUniforms(mainProgramH);
|
118 |
|
|
EffectQueueMatrix.getUniforms(mainProgramH);
|
119 |
|
|
DistortedTexture.getUniforms(mainProgramH);
|
120 |
|
|
|
121 |
|
|
// DEBUG ONLY //////////////////////////////////////
|
122 |
|
|
final InputStream debugVertexStream = resources.openRawResource(R.raw.test_vertex_shader);
|
123 |
|
|
final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
|
124 |
|
|
|
125 |
|
|
mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, "#version 100\n", "#version 100\n");
|
126 |
|
|
|
127 |
|
|
int debugProgramH = mDebugProgram.getProgramHandle();
|
128 |
194ab46f
|
Leszek Koltunski
|
mObjDH = GLES30.glGetUniformLocation( debugProgramH, "u_objD");
|
129 |
|
|
mMVPMatrixH = GLES30.glGetUniformLocation( debugProgramH, "u_MVPMatrix");
|
130 |
c90b9e01
|
Leszek Koltunski
|
// END DEBUG //////////////////////////////////////
|
131 |
55c14a19
|
Leszek Koltunski
|
}
|
132 |
|
|
|
133 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134 |
|
|
|
135 |
421c2728
|
Leszek Koltunski
|
private void initializeEffectLists(DistortedEffects d, int flags)
|
136 |
d425545a
|
Leszek Koltunski
|
{
|
137 |
015642fb
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_MATRIX) != 0 )
|
138 |
6a06a912
|
Leszek Koltunski
|
{
|
139 |
d425545a
|
Leszek Koltunski
|
mM = d.mM;
|
140 |
|
|
matrixCloned = true;
|
141 |
|
|
}
|
142 |
|
|
else
|
143 |
|
|
{
|
144 |
4e2382f3
|
Leszek Koltunski
|
mM = new EffectQueueMatrix(mID);
|
145 |
d425545a
|
Leszek Koltunski
|
matrixCloned = false;
|
146 |
|
|
}
|
147 |
6a06a912
|
Leszek Koltunski
|
|
148 |
d425545a
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_VERTEX) != 0 )
|
149 |
|
|
{
|
150 |
|
|
mV = d.mV;
|
151 |
|
|
vertexCloned = true;
|
152 |
|
|
}
|
153 |
|
|
else
|
154 |
|
|
{
|
155 |
4e2382f3
|
Leszek Koltunski
|
mV = new EffectQueueVertex(mID);
|
156 |
d425545a
|
Leszek Koltunski
|
vertexCloned = false;
|
157 |
|
|
}
|
158 |
6a06a912
|
Leszek Koltunski
|
|
159 |
d425545a
|
Leszek Koltunski
|
if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
|
160 |
|
|
{
|
161 |
|
|
mF = d.mF;
|
162 |
|
|
fragmentCloned = true;
|
163 |
6a06a912
|
Leszek Koltunski
|
}
|
164 |
d425545a
|
Leszek Koltunski
|
else
|
165 |
|
|
{
|
166 |
4e2382f3
|
Leszek Koltunski
|
mF = new EffectQueueFragment(mID);
|
167 |
d425545a
|
Leszek Koltunski
|
fragmentCloned = false;
|
168 |
|
|
}
|
169 |
d6e94c84
|
Leszek Koltunski
|
|
170 |
|
|
if( (flags & Distorted.CLONE_POSTPROCESS) != 0 )
|
171 |
|
|
{
|
172 |
|
|
mP = d.mP;
|
173 |
|
|
postprocessCloned = true;
|
174 |
|
|
}
|
175 |
|
|
else
|
176 |
|
|
{
|
177 |
|
|
mP = new EffectQueuePostprocess(mID);
|
178 |
|
|
postprocessCloned = false;
|
179 |
|
|
}
|
180 |
d425545a
|
Leszek Koltunski
|
}
|
181 |
6a06a912
|
Leszek Koltunski
|
|
182 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
183 |
c90b9e01
|
Leszek Koltunski
|
// DEBUG ONLY
|
184 |
|
|
|
185 |
e8b2f311
|
Leszek Koltunski
|
@SuppressWarnings("unused")
|
186 |
c90b9e01
|
Leszek Koltunski
|
private void displayBoundingRect(float halfX, float halfY, float halfZ, DistortedFramebuffer df, float[] mvp, float[] vertices)
|
187 |
|
|
{
|
188 |
|
|
int len = vertices.length/3;
|
189 |
|
|
int minx = Integer.MAX_VALUE;
|
190 |
|
|
int maxx = Integer.MIN_VALUE;
|
191 |
|
|
int miny = Integer.MAX_VALUE;
|
192 |
|
|
int maxy = Integer.MIN_VALUE;
|
193 |
|
|
int wx,wy;
|
194 |
|
|
|
195 |
|
|
float x,y,z, X,Y,W, ndcX,ndcY;
|
196 |
|
|
|
197 |
|
|
for(int i=0; i<len; i++)
|
198 |
|
|
{
|
199 |
|
|
x = 2*halfX*vertices[3*i ];
|
200 |
|
|
y = 2*halfY*vertices[3*i+1];
|
201 |
|
|
z = 2*halfZ*vertices[3*i+2];
|
202 |
|
|
|
203 |
|
|
X = mvp[ 0]*x + mvp[ 4]*y + mvp[ 8]*z + mvp[12];
|
204 |
|
|
Y = mvp[ 1]*x + mvp[ 5]*y + mvp[ 9]*z + mvp[13];
|
205 |
|
|
W = mvp[ 3]*x + mvp[ 7]*y + mvp[11]*z + mvp[15];
|
206 |
|
|
|
207 |
|
|
ndcX = X/W;
|
208 |
|
|
ndcY = Y/W;
|
209 |
|
|
|
210 |
|
|
wx = (int)(df.mWidth *(ndcX+1)/2);
|
211 |
|
|
wy = (int)(df.mHeight*(ndcY+1)/2);
|
212 |
|
|
|
213 |
e8b2f311
|
Leszek Koltunski
|
if( wx<minx ) minx = wx;
|
214 |
|
|
if( wx>maxx ) maxx = wx;
|
215 |
|
|
if( wy<miny ) miny = wy;
|
216 |
|
|
if( wy>maxy ) maxy = wy;
|
217 |
c90b9e01
|
Leszek Koltunski
|
}
|
218 |
|
|
|
219 |
|
|
mDebugProgram.useProgram();
|
220 |
|
|
df.setAsOutput();
|
221 |
|
|
|
222 |
c318fb14
|
Leszek Koltunski
|
Matrix.setIdentityM( mTmpMatrix, 0);
|
223 |
|
|
Matrix.translateM ( mTmpMatrix, 0, minx-df.mWidth/2, maxy-df.mHeight/2, -df.mDistance);
|
224 |
|
|
Matrix.scaleM ( mTmpMatrix, 0, (float)(maxx-minx)/(2*halfX), (float)(maxy-miny)/(2*halfY), 1.0f);
|
225 |
|
|
Matrix.translateM ( mTmpMatrix, 0, halfX,-halfY, 0);
|
226 |
|
|
Matrix.multiplyMM ( mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
|
227 |
c90b9e01
|
Leszek Koltunski
|
|
228 |
194ab46f
|
Leszek Koltunski
|
GLES30.glUniform2f( mObjDH , 2*halfX, 2*halfY);
|
229 |
|
|
GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
|
230 |
c90b9e01
|
Leszek Koltunski
|
|
231 |
194ab46f
|
Leszek Koltunski
|
GLES30.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
|
232 |
|
|
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
|
233 |
c90b9e01
|
Leszek Koltunski
|
}
|
234 |
|
|
|
235 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
236 |
|
|
|
237 |
05403bba
|
Leszek Koltunski
|
void drawPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df, long currTime)
|
238 |
d425545a
|
Leszek Koltunski
|
{
|
239 |
|
|
mM.compute(currTime);
|
240 |
|
|
mV.compute(currTime);
|
241 |
|
|
mF.compute(currTime);
|
242 |
d6e94c84
|
Leszek Koltunski
|
mP.compute(currTime);
|
243 |
a56bc359
|
Leszek Koltunski
|
|
244 |
d6e94c84
|
Leszek Koltunski
|
float halfZ = halfInputW*mesh.zFactor;
|
245 |
194ab46f
|
Leszek Koltunski
|
GLES30.glViewport(0, 0, df.mWidth, df.mHeight);
|
246 |
d6e94c84
|
Leszek Koltunski
|
|
247 |
|
|
if( mP.mNumEffects==0 )
|
248 |
|
|
{
|
249 |
8fa96e69
|
Leszek Koltunski
|
mProgram.useProgram();
|
250 |
|
|
df.setAsOutput();
|
251 |
d6e94c84
|
Leszek Koltunski
|
mM.send(df,halfInputW,halfInputH,halfZ);
|
252 |
|
|
mV.send(halfInputW,halfInputH,halfZ);
|
253 |
|
|
mF.send(halfInputW,halfInputH);
|
254 |
194ab46f
|
Leszek Koltunski
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mesh.mMeshPositions);
|
255 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshNormals);
|
256 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshTexture);
|
257 |
|
|
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
|
258 |
d6e94c84
|
Leszek Koltunski
|
}
|
259 |
|
|
else
|
260 |
|
|
{
|
261 |
69ed1eb4
|
Leszek Koltunski
|
if( mV.mNumEffects==0 && mF.mNumEffects==0 && (mesh instanceof MeshFlat) && mM.canUseShortcut() )
|
262 |
11fb6ce0
|
Leszek Koltunski
|
{
|
263 |
|
|
mM.constructMatrices(df,halfInputW,halfInputH);
|
264 |
|
|
mP.render(2*halfInputW, 2*halfInputH, mM.getMVP(), df);
|
265 |
|
|
}
|
266 |
|
|
else
|
267 |
2b942cd0
|
Leszek Koltunski
|
{
|
268 |
8fa96e69
|
Leszek Koltunski
|
mProgram.useProgram();
|
269 |
2b942cd0
|
Leszek Koltunski
|
mBufferFBO.resizeFast(df.mWidth, df.mHeight);
|
270 |
|
|
mBufferFBO.setAsOutput();
|
271 |
194ab46f
|
Leszek Koltunski
|
GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
272 |
|
|
GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
|
273 |
2b942cd0
|
Leszek Koltunski
|
mM.send(mBufferFBO,halfInputW,halfInputH,halfZ);
|
274 |
|
|
mV.send(halfInputW,halfInputH,halfZ);
|
275 |
|
|
mF.send(halfInputW,halfInputH);
|
276 |
194ab46f
|
Leszek Koltunski
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mesh.mMeshPositions);
|
277 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshNormals);
|
278 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshTexture);
|
279 |
|
|
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
|
280 |
2b942cd0
|
Leszek Koltunski
|
|
281 |
8fa96e69
|
Leszek Koltunski
|
Matrix.setIdentityM(mTmpMatrix, 0);
|
282 |
|
|
Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
|
283 |
|
|
Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
|
284 |
|
|
|
285 |
2b942cd0
|
Leszek Koltunski
|
mBufferFBO.setAsInput();
|
286 |
8fa96e69
|
Leszek Koltunski
|
mP.render(df.mWidth, df.mHeight, mMVPMatrix, df);
|
287 |
2b942cd0
|
Leszek Koltunski
|
}
|
288 |
d6e94c84
|
Leszek Koltunski
|
}
|
289 |
c90b9e01
|
Leszek Koltunski
|
|
290 |
|
|
/// DEBUG ONLY //////
|
291 |
dbe8ea80
|
Leszek Koltunski
|
// displayBoundingRect(halfInputW, halfInputH, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
|
292 |
c90b9e01
|
Leszek Koltunski
|
/// END DEBUG ///////
|
293 |
d425545a
|
Leszek Koltunski
|
}
|
294 |
6a06a912
|
Leszek Koltunski
|
|
295 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
296 |
|
|
|
297 |
d6e94c84
|
Leszek Koltunski
|
static void drawNoEffectsPriv(float halfInputW, float halfInputH, MeshObject mesh, DistortedFramebuffer df)
|
298 |
d425545a
|
Leszek Koltunski
|
{
|
299 |
194ab46f
|
Leszek Koltunski
|
GLES30.glViewport(0, 0, df.mWidth, df.mHeight);
|
300 |
0a046359
|
Leszek Koltunski
|
|
301 |
8fa96e69
|
Leszek Koltunski
|
Matrix.setIdentityM(mTmpMatrix, 0);
|
302 |
|
|
Matrix.translateM(mTmpMatrix, 0, 0, 0, -df.mDistance);
|
303 |
|
|
Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
|
304 |
|
|
|
305 |
d6e94c84
|
Leszek Koltunski
|
EffectQueueMatrix.sendZero(df,halfInputW,halfInputH,halfInputW*mesh.zFactor);
|
306 |
|
|
EffectQueueVertex.sendZero();
|
307 |
|
|
EffectQueueFragment.sendZero();
|
308 |
a56bc359
|
Leszek Koltunski
|
|
309 |
194ab46f
|
Leszek Koltunski
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mesh.mMeshPositions);
|
310 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[1], NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshNormals);
|
311 |
|
|
GLES30.glVertexAttribPointer(mProgram.mAttribute[2], TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, mesh.mMeshTexture);
|
312 |
|
|
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
|
313 |
d425545a
|
Leszek Koltunski
|
}
|
314 |
6a06a912
|
Leszek Koltunski
|
|
315 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
316 |
|
|
|
317 |
8e34674e
|
Leszek Koltunski
|
private void releasePriv()
|
318 |
d425545a
|
Leszek Koltunski
|
{
|
319 |
d6e94c84
|
Leszek Koltunski
|
if( !matrixCloned ) mM.abortAll(false);
|
320 |
|
|
if( !vertexCloned ) mV.abortAll(false);
|
321 |
|
|
if( !fragmentCloned ) mF.abortAll(false);
|
322 |
|
|
if( !postprocessCloned) mP.abortAll(false);
|
323 |
d425545a
|
Leszek Koltunski
|
|
324 |
4e2382f3
|
Leszek Koltunski
|
mM = null;
|
325 |
|
|
mV = null;
|
326 |
|
|
mF = null;
|
327 |
d6e94c84
|
Leszek Koltunski
|
mP = null;
|
328 |
8e34674e
|
Leszek Koltunski
|
}
|
329 |
|
|
|
330 |
1942537e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
331 |
|
|
|
332 |
7b8086eb
|
Leszek Koltunski
|
static void onDestroy()
|
333 |
1942537e
|
Leszek Koltunski
|
{
|
334 |
|
|
mNextID = 0;
|
335 |
|
|
}
|
336 |
|
|
|
337 |
8e34674e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338 |
|
|
// PUBLIC API
|
339 |
ada90d33
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
340 |
d425545a
|
Leszek Koltunski
|
/**
|
341 |
4e2382f3
|
Leszek Koltunski
|
* Create empty effect queue.
|
342 |
d425545a
|
Leszek Koltunski
|
*/
|
343 |
421c2728
|
Leszek Koltunski
|
public DistortedEffects()
|
344 |
d425545a
|
Leszek Koltunski
|
{
|
345 |
4e2382f3
|
Leszek Koltunski
|
mID = mNextID++;
|
346 |
|
|
initializeEffectLists(this,0);
|
347 |
d425545a
|
Leszek Koltunski
|
}
|
348 |
ada90d33
|
Leszek Koltunski
|
|
349 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
350 |
d425545a
|
Leszek Koltunski
|
/**
|
351 |
4e2382f3
|
Leszek Koltunski
|
* Copy constructor.
|
352 |
d425545a
|
Leszek Koltunski
|
* <p>
|
353 |
|
|
* Whatever we do not clone gets created just like in the default constructor.
|
354 |
|
|
*
|
355 |
|
|
* @param dc Source object to create our object from
|
356 |
|
|
* @param flags A bitmask of values specifying what to copy.
|
357 |
e6ab30eb
|
Leszek Koltunski
|
* For example, CLONE_VERTEX | CLONE_MATRIX.
|
358 |
d425545a
|
Leszek Koltunski
|
*/
|
359 |
421c2728
|
Leszek Koltunski
|
public DistortedEffects(DistortedEffects dc, int flags)
|
360 |
d425545a
|
Leszek Koltunski
|
{
|
361 |
8e34674e
|
Leszek Koltunski
|
mID = mNextID++;
|
362 |
4e2382f3
|
Leszek Koltunski
|
initializeEffectLists(dc,flags);
|
363 |
d425545a
|
Leszek Koltunski
|
}
|
364 |
ada90d33
|
Leszek Koltunski
|
|
365 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
366 |
|
|
/**
|
367 |
07305c87
|
Leszek Koltunski
|
* Releases all resources. After this call, the queue should not be used anymore.
|
368 |
6a06a912
|
Leszek Koltunski
|
*/
|
369 |
8e34674e
|
Leszek Koltunski
|
public synchronized void delete()
|
370 |
d425545a
|
Leszek Koltunski
|
{
|
371 |
|
|
releasePriv();
|
372 |
|
|
}
|
373 |
6a06a912
|
Leszek Koltunski
|
|
374 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
375 |
|
|
/**
|
376 |
4e2382f3
|
Leszek Koltunski
|
* Returns unique ID of this instance.
|
377 |
|
|
*
|
378 |
|
|
* @return ID of the object.
|
379 |
6a06a912
|
Leszek Koltunski
|
*/
|
380 |
4e2382f3
|
Leszek Koltunski
|
public long getID()
|
381 |
d425545a
|
Leszek Koltunski
|
{
|
382 |
4e2382f3
|
Leszek Koltunski
|
return mID;
|
383 |
d425545a
|
Leszek Koltunski
|
}
|
384 |
4e2382f3
|
Leszek Koltunski
|
|
385 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
386 |
|
|
/**
|
387 |
|
|
* Adds the calling class to the list of Listeners that get notified each time some event happens
|
388 |
07305c87
|
Leszek Koltunski
|
* to one of the Effects in those queues. Nothing will happen if 'el' is already in the list.
|
389 |
6a06a912
|
Leszek Koltunski
|
*
|
390 |
|
|
* @param el A class implementing the EffectListener interface that wants to get notifications.
|
391 |
|
|
*/
|
392 |
3fc994b2
|
Leszek Koltunski
|
public void registerForMessages(EffectListener el)
|
393 |
d425545a
|
Leszek Koltunski
|
{
|
394 |
3fc994b2
|
Leszek Koltunski
|
mV.registerForMessages(el);
|
395 |
|
|
mF.registerForMessages(el);
|
396 |
|
|
mM.registerForMessages(el);
|
397 |
d6e94c84
|
Leszek Koltunski
|
mP.registerForMessages(el);
|
398 |
d425545a
|
Leszek Koltunski
|
}
|
399 |
6a06a912
|
Leszek Koltunski
|
|
400 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
401 |
|
|
/**
|
402 |
|
|
* Removes the calling class from the list of Listeners.
|
403 |
|
|
*
|
404 |
|
|
* @param el A class implementing the EffectListener interface that no longer wants to get notifications.
|
405 |
|
|
*/
|
406 |
3fc994b2
|
Leszek Koltunski
|
public void deregisterForMessages(EffectListener el)
|
407 |
d425545a
|
Leszek Koltunski
|
{
|
408 |
3fc994b2
|
Leszek Koltunski
|
mV.deregisterForMessages(el);
|
409 |
|
|
mF.deregisterForMessages(el);
|
410 |
|
|
mM.deregisterForMessages(el);
|
411 |
d6e94c84
|
Leszek Koltunski
|
mP.deregisterForMessages(el);
|
412 |
d425545a
|
Leszek Koltunski
|
}
|
413 |
6a06a912
|
Leszek Koltunski
|
|
414 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
415 |
|
|
/**
|
416 |
d07f2950
|
Leszek Koltunski
|
* Aborts all Effects.
|
417 |
|
|
* @return Number of effects aborted.
|
418 |
6a06a912
|
Leszek Koltunski
|
*/
|
419 |
d425545a
|
Leszek Koltunski
|
public int abortAllEffects()
|
420 |
6a06a912
|
Leszek Koltunski
|
{
|
421 |
d6e94c84
|
Leszek Koltunski
|
return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true) + mP.abortAll(true);
|
422 |
6a06a912
|
Leszek Koltunski
|
}
|
423 |
|
|
|
424 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
425 |
|
|
/**
|
426 |
d07f2950
|
Leszek Koltunski
|
* Aborts all Effects of a given type, for example all MATRIX Effects.
|
427 |
6a06a912
|
Leszek Koltunski
|
*
|
428 |
d07f2950
|
Leszek Koltunski
|
* @param type one of the constants defined in {@link EffectTypes}
|
429 |
|
|
* @return Number of effects aborted.
|
430 |
6a06a912
|
Leszek Koltunski
|
*/
|
431 |
d425545a
|
Leszek Koltunski
|
public int abortEffects(EffectTypes type)
|
432 |
|
|
{
|
433 |
|
|
switch(type)
|
434 |
6a06a912
|
Leszek Koltunski
|
{
|
435 |
d6e94c84
|
Leszek Koltunski
|
case MATRIX : return mM.abortAll(true);
|
436 |
|
|
case VERTEX : return mV.abortAll(true);
|
437 |
|
|
case FRAGMENT : return mF.abortAll(true);
|
438 |
|
|
case POSTPROCESS: return mP.abortAll(true);
|
439 |
|
|
default : return 0;
|
440 |
6a06a912
|
Leszek Koltunski
|
}
|
441 |
d425545a
|
Leszek Koltunski
|
}
|
442 |
6a06a912
|
Leszek Koltunski
|
|
443 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
444 |
|
|
/**
|
445 |
|
|
* Aborts a single Effect.
|
446 |
|
|
*
|
447 |
|
|
* @param id ID of the Effect we want to abort.
|
448 |
476bbc81
|
Leszek Koltunski
|
* @return number of Effects aborted. Always either 0 or 1.
|
449 |
6a06a912
|
Leszek Koltunski
|
*/
|
450 |
d425545a
|
Leszek Koltunski
|
public int abortEffect(long id)
|
451 |
|
|
{
|
452 |
|
|
int type = (int)(id&EffectTypes.MASK);
|
453 |
1e438fc7
|
Leszek Koltunski
|
|
454 |
d6e94c84
|
Leszek Koltunski
|
if( type==EffectTypes.MATRIX.type ) return mM.removeByID(id>>EffectTypes.LENGTH);
|
455 |
|
|
if( type==EffectTypes.VERTEX.type ) return mV.removeByID(id>>EffectTypes.LENGTH);
|
456 |
|
|
if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
|
457 |
|
|
if( type==EffectTypes.POSTPROCESS.type ) return mP.removeByID(id>>EffectTypes.LENGTH);
|
458 |
1e438fc7
|
Leszek Koltunski
|
|
459 |
d425545a
|
Leszek Koltunski
|
return 0;
|
460 |
|
|
}
|
461 |
6a06a912
|
Leszek Koltunski
|
|
462 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
463 |
|
|
/**
|
464 |
e8c81a8e
|
Leszek Koltunski
|
* Abort all Effects of a given name, for example all rotations.
|
465 |
6a06a912
|
Leszek Koltunski
|
*
|
466 |
d07f2950
|
Leszek Koltunski
|
* @param name one of the constants defined in {@link EffectNames}
|
467 |
476bbc81
|
Leszek Koltunski
|
* @return number of Effects aborted.
|
468 |
6a06a912
|
Leszek Koltunski
|
*/
|
469 |
d425545a
|
Leszek Koltunski
|
public int abortEffects(EffectNames name)
|
470 |
|
|
{
|
471 |
|
|
switch(name.getType())
|
472 |
6a06a912
|
Leszek Koltunski
|
{
|
473 |
d6e94c84
|
Leszek Koltunski
|
case MATRIX : return mM.removeByType(name);
|
474 |
|
|
case VERTEX : return mV.removeByType(name);
|
475 |
|
|
case FRAGMENT : return mF.removeByType(name);
|
476 |
|
|
case POSTPROCESS: return mP.removeByType(name);
|
477 |
|
|
default : return 0;
|
478 |
6a06a912
|
Leszek Koltunski
|
}
|
479 |
d425545a
|
Leszek Koltunski
|
}
|
480 |
6a06a912
|
Leszek Koltunski
|
|
481 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
482 |
|
|
/**
|
483 |
|
|
* Print some info about a given Effect to Android's standard out. Used for debugging only.
|
484 |
|
|
*
|
485 |
|
|
* @param id Effect ID we want to print info about
|
486 |
|
|
* @return <code>true</code> if a single Effect of type effectType has been found.
|
487 |
|
|
*/
|
488 |
|
|
|
489 |
d425545a
|
Leszek Koltunski
|
public boolean printEffect(long id)
|
490 |
|
|
{
|
491 |
|
|
int type = (int)(id&EffectTypes.MASK);
|
492 |
1e438fc7
|
Leszek Koltunski
|
|
493 |
d6e94c84
|
Leszek Koltunski
|
if( type==EffectTypes.MATRIX.type ) return mM.printByID(id>>EffectTypes.LENGTH);
|
494 |
|
|
if( type==EffectTypes.VERTEX.type ) return mV.printByID(id>>EffectTypes.LENGTH);
|
495 |
|
|
if( type==EffectTypes.FRAGMENT.type ) return mF.printByID(id>>EffectTypes.LENGTH);
|
496 |
|
|
if( type==EffectTypes.POSTPROCESS.type ) return mP.printByID(id>>EffectTypes.LENGTH);
|
497 |
1e438fc7
|
Leszek Koltunski
|
|
498 |
d425545a
|
Leszek Koltunski
|
return false;
|
499 |
|
|
}
|
500 |
432442f9
|
Leszek Koltunski
|
|
501 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
502 |
|
|
/**
|
503 |
|
|
* Returns the maximum number of Matrix effects.
|
504 |
|
|
*
|
505 |
|
|
* @return The maximum number of Matrix effects
|
506 |
|
|
*/
|
507 |
|
|
public static int getMaxMatrix()
|
508 |
|
|
{
|
509 |
|
|
return EffectQueue.getMax(EffectTypes.MATRIX.ordinal());
|
510 |
|
|
}
|
511 |
|
|
|
512 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
513 |
|
|
/**
|
514 |
|
|
* Returns the maximum number of Vertex effects.
|
515 |
|
|
*
|
516 |
|
|
* @return The maximum number of Vertex effects
|
517 |
|
|
*/
|
518 |
|
|
public static int getMaxVertex()
|
519 |
|
|
{
|
520 |
|
|
return EffectQueue.getMax(EffectTypes.VERTEX.ordinal());
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
524 |
|
|
/**
|
525 |
|
|
* Returns the maximum number of Fragment effects.
|
526 |
|
|
*
|
527 |
|
|
* @return The maximum number of Fragment effects
|
528 |
|
|
*/
|
529 |
|
|
public static int getMaxFragment()
|
530 |
|
|
{
|
531 |
|
|
return EffectQueue.getMax(EffectTypes.FRAGMENT.ordinal());
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
535 |
|
|
/**
|
536 |
|
|
* Returns the maximum number of Postprocess effects.
|
537 |
|
|
*
|
538 |
|
|
* @return The maximum number of Postprocess effects
|
539 |
|
|
*/
|
540 |
|
|
public static int getMaxPostprocess()
|
541 |
|
|
{
|
542 |
|
|
return EffectQueue.getMax(EffectTypes.POSTPROCESS.ordinal());
|
543 |
|
|
}
|
544 |
|
|
|
545 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
546 |
|
|
/**
|
547 |
|
|
* Sets the maximum number of Matrix effects that can be stored in a single EffectQueue at one time.
|
548 |
|
|
* This can fail if:
|
549 |
|
|
* <ul>
|
550 |
|
|
* <li>the value of 'max' is outside permitted range (0 ≤ max ≤ Byte.MAX_VALUE)
|
551 |
|
|
* <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
|
552 |
|
|
* before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
|
553 |
|
|
* time only decreasing the value of 'max' is permitted.
|
554 |
|
|
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
|
555 |
|
|
* </ul>
|
556 |
|
|
*
|
557 |
|
|
* @param max new maximum number of simultaneous Matrix Effects. Has to be a non-negative number not greater
|
558 |
|
|
* than Byte.MAX_VALUE
|
559 |
|
|
* @return <code>true</code> if operation was successful, <code>false</code> otherwise.
|
560 |
|
|
*/
|
561 |
|
|
public static boolean setMaxMatrix(int max)
|
562 |
|
|
{
|
563 |
|
|
return EffectQueue.setMax(EffectTypes.MATRIX.ordinal(),max);
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
567 |
|
|
/**
|
568 |
|
|
* Sets the maximum number of Vertex effects that can be stored in a single EffectQueue at one time.
|
569 |
|
|
* This can fail if:
|
570 |
|
|
* <ul>
|
571 |
|
|
* <li>the value of 'max' is outside permitted range (0 ≤ max ≤ Byte.MAX_VALUE)
|
572 |
|
|
* <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
|
573 |
|
|
* before the Vertex Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
|
574 |
|
|
* time only decreasing the value of 'max' is permitted.
|
575 |
|
|
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
|
576 |
|
|
* </ul>
|
577 |
|
|
*
|
578 |
|
|
* @param max new maximum number of simultaneous Vertex Effects. Has to be a non-negative number not greater
|
579 |
|
|
* than Byte.MAX_VALUE
|
580 |
|
|
* @return <code>true</code> if operation was successful, <code>false</code> otherwise.
|
581 |
|
|
*/
|
582 |
|
|
public static boolean setMaxVertex(int max)
|
583 |
|
|
{
|
584 |
|
|
return EffectQueue.setMax(EffectTypes.VERTEX.ordinal(),max);
|
585 |
|
|
}
|
586 |
|
|
|
587 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
588 |
|
|
/**
|
589 |
|
|
* Sets the maximum number of Fragment effects that can be stored in a single EffectQueue at one time.
|
590 |
|
|
* This can fail if:
|
591 |
|
|
* <ul>
|
592 |
|
|
* <li>the value of 'max' is outside permitted range (0 ≤ max ≤ Byte.MAX_VALUE)
|
593 |
|
|
* <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
|
594 |
|
|
* before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
|
595 |
|
|
* time only decreasing the value of 'max' is permitted.
|
596 |
|
|
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
|
597 |
|
|
* </ul>
|
598 |
|
|
*
|
599 |
|
|
* @param max new maximum number of simultaneous Fragment Effects. Has to be a non-negative number not greater
|
600 |
|
|
* than Byte.MAX_VALUE
|
601 |
|
|
* @return <code>true</code> if operation was successful, <code>false</code> otherwise.
|
602 |
|
|
*/
|
603 |
|
|
public static boolean setMaxFragment(int max)
|
604 |
|
|
{
|
605 |
|
|
return EffectQueue.setMax(EffectTypes.FRAGMENT.ordinal(),max);
|
606 |
|
|
}
|
607 |
|
|
|
608 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
609 |
|
|
/**
|
610 |
|
|
* Sets the maximum number of Postprocess effects that can be stored in a single EffectQueue at one time.
|
611 |
|
|
* This can fail if:
|
612 |
|
|
* <ul>
|
613 |
|
|
* <li>the value of 'max' is outside permitted range (0 ≤ max ≤ Byte.MAX_VALUE)
|
614 |
|
|
* <li>We try to increase the value of 'max' when it is too late to do so already. It needs to be called
|
615 |
|
|
* before the Fragment Shader gets compiled, i.e. before the call to {@link Distorted#onCreate}. After this
|
616 |
|
|
* time only decreasing the value of 'max' is permitted.
|
617 |
|
|
* <li>Furthermore, this needs to be called before any instances of the DistortedEffects class get created.
|
618 |
|
|
* </ul>
|
619 |
|
|
*
|
620 |
|
|
* @param max new maximum number of simultaneous Postprocess Effects. Has to be a non-negative number not greater
|
621 |
|
|
* than Byte.MAX_VALUE
|
622 |
|
|
* @return <code>true</code> if operation was successful, <code>false</code> otherwise.
|
623 |
|
|
*/
|
624 |
|
|
public static boolean setMaxPostprocess(int max)
|
625 |
|
|
{
|
626 |
|
|
return EffectQueue.setMax(EffectTypes.POSTPROCESS.ordinal(),max);
|
627 |
|
|
}
|
628 |
|
|
|
629 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
630 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
631 |
|
|
// Individual effect functions.
|
632 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
633 |
|
|
// Matrix-based effects
|
634 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
635 |
|
|
/**
|
636 |
e8c81a8e
|
Leszek Koltunski
|
* Moves the Object by a (possibly changing in time) vector.
|
637 |
6a06a912
|
Leszek Koltunski
|
*
|
638 |
568b29d8
|
Leszek Koltunski
|
* @param vector 3-dimensional Data which at any given time will return a Static3D
|
639 |
e0a16874
|
Leszek Koltunski
|
* representing the current coordinates of the vector we want to move the Object with.
|
640 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
641 |
6a06a912
|
Leszek Koltunski
|
*/
|
642 |
568b29d8
|
Leszek Koltunski
|
public long move(Data3D vector)
|
643 |
6a06a912
|
Leszek Koltunski
|
{
|
644 |
e0a16874
|
Leszek Koltunski
|
return mM.add(EffectNames.MOVE,vector);
|
645 |
6a06a912
|
Leszek Koltunski
|
}
|
646 |
|
|
|
647 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
648 |
|
|
/**
|
649 |
e8c81a8e
|
Leszek Koltunski
|
* Scales the Object by (possibly changing in time) 3D scale factors.
|
650 |
6a06a912
|
Leszek Koltunski
|
*
|
651 |
d1e740c5
|
Leszek Koltunski
|
* @param scale 3-dimensional Data which at any given time returns a Static3D
|
652 |
e0a16874
|
Leszek Koltunski
|
* representing the current x- , y- and z- scale factors.
|
653 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
654 |
6a06a912
|
Leszek Koltunski
|
*/
|
655 |
568b29d8
|
Leszek Koltunski
|
public long scale(Data3D scale)
|
656 |
6a06a912
|
Leszek Koltunski
|
{
|
657 |
e0a16874
|
Leszek Koltunski
|
return mM.add(EffectNames.SCALE,scale);
|
658 |
6a06a912
|
Leszek Koltunski
|
}
|
659 |
|
|
|
660 |
2fce34f4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
661 |
|
|
/**
|
662 |
e8c81a8e
|
Leszek Koltunski
|
* Scales the Object by one uniform, constant factor in all 3 dimensions. Convenience function.
|
663 |
2fce34f4
|
Leszek Koltunski
|
*
|
664 |
|
|
* @param scale The factor to scale all 3 dimensions with.
|
665 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
666 |
|
|
*/
|
667 |
d425545a
|
Leszek Koltunski
|
public long scale(float scale)
|
668 |
|
|
{
|
669 |
|
|
return mM.add(EffectNames.SCALE, new Static3D(scale,scale,scale));
|
670 |
|
|
}
|
671 |
2fce34f4
|
Leszek Koltunski
|
|
672 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
673 |
|
|
/**
|
674 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by 'angle' degrees around the center.
|
675 |
|
|
* Static axis of rotation is given by the last parameter.
|
676 |
|
|
*
|
677 |
9351ad55
|
Leszek Koltunski
|
* @param angle Angle that we want to rotate the Object to. Unit: degrees
|
678 |
568b29d8
|
Leszek Koltunski
|
* @param axis Axis of rotation
|
679 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
680 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
681 |
|
|
*/
|
682 |
0df17fad
|
Leszek Koltunski
|
public long rotate(Data1D angle, Static3D axis, Data3D center )
|
683 |
6a06a912
|
Leszek Koltunski
|
{
|
684 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.ROTATE, angle, axis, center);
|
685 |
6a06a912
|
Leszek Koltunski
|
}
|
686 |
|
|
|
687 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
688 |
|
|
/**
|
689 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by 'angle' degrees around the center.
|
690 |
2fce34f4
|
Leszek Koltunski
|
* Here both angle and axis can dynamically change.
|
691 |
568b29d8
|
Leszek Koltunski
|
*
|
692 |
|
|
* @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
|
693 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
694 |
568b29d8
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
695 |
e0a16874
|
Leszek Koltunski
|
*/
|
696 |
0df17fad
|
Leszek Koltunski
|
public long rotate(Data4D angleaxis, Data3D center)
|
697 |
568b29d8
|
Leszek Koltunski
|
{
|
698 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.ROTATE, angleaxis, center);
|
699 |
6a06a912
|
Leszek Koltunski
|
}
|
700 |
|
|
|
701 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
702 |
|
|
/**
|
703 |
568b29d8
|
Leszek Koltunski
|
* Rotates the Object by quaternion.
|
704 |
0df17fad
|
Leszek Koltunski
|
*
|
705 |
568b29d8
|
Leszek Koltunski
|
* @param quaternion The quaternion describing the rotation.
|
706 |
0df17fad
|
Leszek Koltunski
|
* @param center Coordinates of the Point we are rotating around.
|
707 |
568b29d8
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
708 |
6a06a912
|
Leszek Koltunski
|
*/
|
709 |
0df17fad
|
Leszek Koltunski
|
public long quaternion(Data4D quaternion, Data3D center )
|
710 |
568b29d8
|
Leszek Koltunski
|
{
|
711 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.QUATERNION,quaternion,center);
|
712 |
6a06a912
|
Leszek Koltunski
|
}
|
713 |
|
|
|
714 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
715 |
|
|
/**
|
716 |
568b29d8
|
Leszek Koltunski
|
* Shears the Object.
|
717 |
6a06a912
|
Leszek Koltunski
|
*
|
718 |
8c3cdec5
|
Leszek Koltunski
|
* @param shear The 3-tuple of shear factors. The first controls level
|
719 |
|
|
* of shearing in the X-axis, second - Y-axis and the third -
|
720 |
|
|
* Z-axis. Each is the tangens of the shear angle, i.e 0 -
|
721 |
|
|
* no shear, 1 - shear by 45 degrees (tan(45deg)=1) etc.
|
722 |
0df17fad
|
Leszek Koltunski
|
* @param center Center of shearing, i.e. the point which stays unmoved.
|
723 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
724 |
6a06a912
|
Leszek Koltunski
|
*/
|
725 |
0df17fad
|
Leszek Koltunski
|
public long shear(Data3D shear, Data3D center)
|
726 |
6a06a912
|
Leszek Koltunski
|
{
|
727 |
0df17fad
|
Leszek Koltunski
|
return mM.add(EffectNames.SHEAR, shear, center);
|
728 |
6a06a912
|
Leszek Koltunski
|
}
|
729 |
|
|
|
730 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
731 |
|
|
// Fragment-based effects
|
732 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
733 |
|
|
/**
|
734 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change all three of its RGB components.
|
735 |
6a06a912
|
Leszek Koltunski
|
*
|
736 |
2fce34f4
|
Leszek Koltunski
|
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be
|
737 |
e4878781
|
Leszek Koltunski
|
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
|
738 |
|
|
* Valid range: <0,1>
|
739 |
b1e91f2c
|
Leszek Koltunski
|
* @param color Color to mix. (1,0,0) is RED.
|
740 |
2fce34f4
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
741 |
|
|
* @param smooth If true, the level of 'blend' will smoothly fade out towards the edges of the region.
|
742 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
743 |
6a06a912
|
Leszek Koltunski
|
*/
|
744 |
8c893ffc
|
Leszek Koltunski
|
public long chroma(Data1D blend, Data3D color, Data4D region, boolean smooth)
|
745 |
6a06a912
|
Leszek Koltunski
|
{
|
746 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth? EffectNames.SMOOTH_CHROMA:EffectNames.CHROMA, blend, color, region);
|
747 |
6a06a912
|
Leszek Koltunski
|
}
|
748 |
|
|
|
749 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
750 |
|
|
/**
|
751 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change all three of its RGB components.
|
752 |
|
|
*
|
753 |
|
|
* @param blend 1-dimensional Data that returns the level of blend a given pixel will be
|
754 |
e4878781
|
Leszek Koltunski
|
* mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color.
|
755 |
|
|
* Valid range: <0,1>
|
756 |
b1e91f2c
|
Leszek Koltunski
|
* @param color Color to mix. (1,0,0) is RED.
|
757 |
2fce34f4
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
758 |
6a06a912
|
Leszek Koltunski
|
*/
|
759 |
8c893ffc
|
Leszek Koltunski
|
public long chroma(Data1D blend, Data3D color)
|
760 |
6a06a912
|
Leszek Koltunski
|
{
|
761 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.CHROMA, blend, color);
|
762 |
6a06a912
|
Leszek Koltunski
|
}
|
763 |
|
|
|
764 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
765 |
|
|
/**
|
766 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its transparency level.
|
767 |
6a06a912
|
Leszek Koltunski
|
*
|
768 |
2fce34f4
|
Leszek Koltunski
|
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any given
|
769 |
e4878781
|
Leszek Koltunski
|
* moment: pixel.a *= alpha.
|
770 |
|
|
* Valid range: <0,1>
|
771 |
d7bbef2f
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
772 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
|
773 |
d7bbef2f
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
774 |
6a06a912
|
Leszek Koltunski
|
*/
|
775 |
2fce34f4
|
Leszek Koltunski
|
public long alpha(Data1D alpha, Data4D region, boolean smooth)
|
776 |
6a06a912
|
Leszek Koltunski
|
{
|
777 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth? EffectNames.SMOOTH_ALPHA:EffectNames.ALPHA, alpha, region);
|
778 |
6a06a912
|
Leszek Koltunski
|
}
|
779 |
|
|
|
780 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
781 |
|
|
/**
|
782 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its transparency level.
|
783 |
|
|
*
|
784 |
|
|
* @param alpha 1-dimensional Data that returns the level of transparency we want to have at any
|
785 |
e4878781
|
Leszek Koltunski
|
* given moment: pixel.a *= alpha.
|
786 |
|
|
* Valid range: <0,1>
|
787 |
2fce34f4
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
788 |
6a06a912
|
Leszek Koltunski
|
*/
|
789 |
2fce34f4
|
Leszek Koltunski
|
public long alpha(Data1D alpha)
|
790 |
6a06a912
|
Leszek Koltunski
|
{
|
791 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.ALPHA, alpha);
|
792 |
6a06a912
|
Leszek Koltunski
|
}
|
793 |
|
|
|
794 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
795 |
|
|
/**
|
796 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its brightness level.
|
797 |
6a06a912
|
Leszek Koltunski
|
*
|
798 |
2fce34f4
|
Leszek Koltunski
|
* @param brightness 1-dimensional Data that returns the level of brightness we want to have
|
799 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
800 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
801 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'brightness' will smoothly fade out towards the edges of the region.
|
802 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
803 |
6a06a912
|
Leszek Koltunski
|
*/
|
804 |
2fce34f4
|
Leszek Koltunski
|
public long brightness(Data1D brightness, Data4D region, boolean smooth)
|
805 |
6a06a912
|
Leszek Koltunski
|
{
|
806 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_BRIGHTNESS: EffectNames.BRIGHTNESS, brightness, region);
|
807 |
6a06a912
|
Leszek Koltunski
|
}
|
808 |
|
|
|
809 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
810 |
|
|
/**
|
811 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its brightness level.
|
812 |
|
|
*
|
813 |
|
|
* @param brightness 1-dimensional Data that returns the level of brightness we want to have
|
814 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
815 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
816 |
6a06a912
|
Leszek Koltunski
|
*/
|
817 |
2fce34f4
|
Leszek Koltunski
|
public long brightness(Data1D brightness)
|
818 |
6a06a912
|
Leszek Koltunski
|
{
|
819 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.BRIGHTNESS, brightness);
|
820 |
6a06a912
|
Leszek Koltunski
|
}
|
821 |
|
|
|
822 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
823 |
|
|
/**
|
824 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its contrast level.
|
825 |
6a06a912
|
Leszek Koltunski
|
*
|
826 |
2fce34f4
|
Leszek Koltunski
|
* @param contrast 1-dimensional Data that returns the level of contrast we want to have
|
827 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
828 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
829 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
|
830 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
831 |
6a06a912
|
Leszek Koltunski
|
*/
|
832 |
2fce34f4
|
Leszek Koltunski
|
public long contrast(Data1D contrast, Data4D region, boolean smooth)
|
833 |
6a06a912
|
Leszek Koltunski
|
{
|
834 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_CONTRAST:EffectNames.CONTRAST, contrast, region);
|
835 |
6a06a912
|
Leszek Koltunski
|
}
|
836 |
|
|
|
837 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
838 |
|
|
/**
|
839 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its contrast level.
|
840 |
|
|
*
|
841 |
|
|
* @param contrast 1-dimensional Data that returns the level of contrast we want to have
|
842 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
843 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
844 |
6a06a912
|
Leszek Koltunski
|
*/
|
845 |
2fce34f4
|
Leszek Koltunski
|
public long contrast(Data1D contrast)
|
846 |
6a06a912
|
Leszek Koltunski
|
{
|
847 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.CONTRAST, contrast);
|
848 |
6a06a912
|
Leszek Koltunski
|
}
|
849 |
|
|
|
850 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
851 |
|
|
/**
|
852 |
e0a16874
|
Leszek Koltunski
|
* Makes a certain sub-region of the Object smoothly change its saturation level.
|
853 |
6a06a912
|
Leszek Koltunski
|
*
|
854 |
2fce34f4
|
Leszek Koltunski
|
* @param saturation 1-dimensional Data that returns the level of saturation we want to have
|
855 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
856 |
e0a16874
|
Leszek Koltunski
|
* @param region Region this Effect is limited to.
|
857 |
2fce34f4
|
Leszek Koltunski
|
* @param smooth If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
|
858 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
859 |
6a06a912
|
Leszek Koltunski
|
*/
|
860 |
2fce34f4
|
Leszek Koltunski
|
public long saturation(Data1D saturation, Data4D region, boolean smooth)
|
861 |
6a06a912
|
Leszek Koltunski
|
{
|
862 |
2fce34f4
|
Leszek Koltunski
|
return mF.add( smooth ? EffectNames.SMOOTH_SATURATION:EffectNames.SATURATION, saturation, region);
|
863 |
6a06a912
|
Leszek Koltunski
|
}
|
864 |
|
|
|
865 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
866 |
|
|
/**
|
867 |
2fce34f4
|
Leszek Koltunski
|
* Makes the whole Object smoothly change its saturation level.
|
868 |
|
|
*
|
869 |
|
|
* @param saturation 1-dimensional Data that returns the level of saturation we want to have
|
870 |
e4878781
|
Leszek Koltunski
|
* at any given moment. Valid range: <0,infinity)
|
871 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
872 |
6a06a912
|
Leszek Koltunski
|
*/
|
873 |
2fce34f4
|
Leszek Koltunski
|
public long saturation(Data1D saturation)
|
874 |
6a06a912
|
Leszek Koltunski
|
{
|
875 |
2fce34f4
|
Leszek Koltunski
|
return mF.add(EffectNames.SATURATION, saturation);
|
876 |
6a06a912
|
Leszek Koltunski
|
}
|
877 |
|
|
|
878 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
879 |
|
|
// Vertex-based effects
|
880 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
881 |
|
|
/**
|
882 |
e0a16874
|
Leszek Koltunski
|
* Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
|
883 |
f2fe7e28
|
Leszek Koltunski
|
*
|
884 |
|
|
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is
|
885 |
|
|
* currently being dragged with.
|
886 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
887 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
888 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
889 |
6a06a912
|
Leszek Koltunski
|
*/
|
890 |
fa6c352d
|
Leszek Koltunski
|
public long distort(Data3D vector, Data3D center, Data4D region)
|
891 |
6a06a912
|
Leszek Koltunski
|
{
|
892 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.DISTORT, vector, center, region);
|
893 |
6a06a912
|
Leszek Koltunski
|
}
|
894 |
|
|
|
895 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
896 |
|
|
/**
|
897 |
e0a16874
|
Leszek Koltunski
|
* Distort the whole Object by a (possibly changing in time) vector of force.
|
898 |
f2fe7e28
|
Leszek Koltunski
|
*
|
899 |
|
|
* @param vector 3-dimensional Vector which represents the force the Center of the Effect is
|
900 |
|
|
* currently being dragged with.
|
901 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
902 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
903 |
6a06a912
|
Leszek Koltunski
|
*/
|
904 |
fa6c352d
|
Leszek Koltunski
|
public long distort(Data3D vector, Data3D center)
|
905 |
d425545a
|
Leszek Koltunski
|
{
|
906 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.DISTORT, vector, center, null);
|
907 |
d425545a
|
Leszek Koltunski
|
}
|
908 |
6a06a912
|
Leszek Koltunski
|
|
909 |
6ebdbbf1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
910 |
|
|
/**
|
911 |
|
|
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
|
912 |
|
|
* a (possibly changing in time) point on the Object.
|
913 |
|
|
*
|
914 |
|
|
* @param vector Vector of force that deforms the shape of the whole Object.
|
915 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
916 |
|
|
* @param region Region that masks the Effect.
|
917 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
918 |
|
|
*/
|
919 |
|
|
public long deform(Data3D vector, Data3D center, Data4D region)
|
920 |
|
|
{
|
921 |
|
|
return mV.add(EffectNames.DEFORM, vector, center, region);
|
922 |
|
|
}
|
923 |
|
|
|
924 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
925 |
|
|
/**
|
926 |
e0a16874
|
Leszek Koltunski
|
* Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
|
927 |
9351ad55
|
Leszek Koltunski
|
* a (possibly changing in time) point on the Object.
|
928 |
6a06a912
|
Leszek Koltunski
|
*
|
929 |
f2fe7e28
|
Leszek Koltunski
|
* @param vector Vector of force that deforms the shape of the whole Object.
|
930 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
931 |
e0a16874
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
932 |
6a06a912
|
Leszek Koltunski
|
*/
|
933 |
fa6c352d
|
Leszek Koltunski
|
public long deform(Data3D vector, Data3D center)
|
934 |
6a06a912
|
Leszek Koltunski
|
{
|
935 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.DEFORM, vector, center, null);
|
936 |
6a06a912
|
Leszek Koltunski
|
}
|
937 |
|
|
|
938 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
939 |
|
|
/**
|
940 |
f2fe7e28
|
Leszek Koltunski
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
941 |
6a06a912
|
Leszek Koltunski
|
* away from the center (degree<=1)
|
942 |
f2fe7e28
|
Leszek Koltunski
|
*
|
943 |
|
|
* @param sink The current degree of the Effect.
|
944 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
945 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
946 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
947 |
6a06a912
|
Leszek Koltunski
|
*/
|
948 |
fa6c352d
|
Leszek Koltunski
|
public long sink(Data1D sink, Data3D center, Data4D region)
|
949 |
6a06a912
|
Leszek Koltunski
|
{
|
950 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.SINK, sink, center, region);
|
951 |
6a06a912
|
Leszek Koltunski
|
}
|
952 |
|
|
|
953 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
954 |
|
|
/**
|
955 |
f2fe7e28
|
Leszek Koltunski
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
956 |
|
|
* away from the center (degree<=1)
|
957 |
|
|
*
|
958 |
|
|
* @param sink The current degree of the Effect.
|
959 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
960 |
f2fe7e28
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
961 |
6a06a912
|
Leszek Koltunski
|
*/
|
962 |
fa6c352d
|
Leszek Koltunski
|
public long sink(Data1D sink, Data3D center)
|
963 |
d425545a
|
Leszek Koltunski
|
{
|
964 |
|
|
return mV.add(EffectNames.SINK, sink, center);
|
965 |
|
|
}
|
966 |
6a06a912
|
Leszek Koltunski
|
|
967 |
82ee855a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
968 |
|
|
/**
|
969 |
|
|
* Pull all points around the center of the Effect towards a line passing through the center
|
970 |
|
|
* (that's if degree>=1) or push them away from the line (degree<=1)
|
971 |
|
|
*
|
972 |
|
|
* @param pinch The current degree of the Effect + angle the line forms with X-axis
|
973 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
974 |
|
|
* @param region Region that masks the Effect.
|
975 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
976 |
|
|
*/
|
977 |
|
|
public long pinch(Data2D pinch, Data3D center, Data4D region)
|
978 |
|
|
{
|
979 |
|
|
return mV.add(EffectNames.PINCH, pinch, center, region);
|
980 |
|
|
}
|
981 |
|
|
|
982 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
983 |
|
|
/**
|
984 |
|
|
* Pull all points around the center of the Effect towards a line passing through the center
|
985 |
|
|
* (that's if degree>=1) or push them away from the line (degree<=1)
|
986 |
|
|
*
|
987 |
|
|
* @param pinch The current degree of the Effect + angle the line forms with X-axis
|
988 |
|
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
989 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
990 |
|
|
*/
|
991 |
|
|
public long pinch(Data2D pinch, Data3D center)
|
992 |
|
|
{
|
993 |
|
|
return mV.add(EffectNames.PINCH, pinch, center);
|
994 |
|
|
}
|
995 |
|
|
|
996 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
997 |
|
|
/**
|
998 |
f2fe7e28
|
Leszek Koltunski
|
* Rotate part of the Object around the Center of the Effect by a certain angle.
|
999 |
|
|
*
|
1000 |
4fde55a0
|
Leszek Koltunski
|
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise.
|
1001 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
1002 |
f2fe7e28
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
1003 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
1004 |
6a06a912
|
Leszek Koltunski
|
*/
|
1005 |
fa6c352d
|
Leszek Koltunski
|
public long swirl(Data1D swirl, Data3D center, Data4D region)
|
1006 |
6a06a912
|
Leszek Koltunski
|
{
|
1007 |
f2fe7e28
|
Leszek Koltunski
|
return mV.add(EffectNames.SWIRL, swirl, center, region);
|
1008 |
6a06a912
|
Leszek Koltunski
|
}
|
1009 |
|
|
|
1010 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1011 |
|
|
/**
|
1012 |
f2fe7e28
|
Leszek Koltunski
|
* Rotate the whole Object around the Center of the Effect by a certain angle.
|
1013 |
|
|
*
|
1014 |
4fde55a0
|
Leszek Koltunski
|
* @param swirl The angle of Swirl (in degrees). Positive values swirl clockwise.
|
1015 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
1016 |
f2fe7e28
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
1017 |
6a06a912
|
Leszek Koltunski
|
*/
|
1018 |
fa6c352d
|
Leszek Koltunski
|
public long swirl(Data1D swirl, Data3D center)
|
1019 |
d425545a
|
Leszek Koltunski
|
{
|
1020 |
|
|
return mV.add(EffectNames.SWIRL, swirl, center);
|
1021 |
|
|
}
|
1022 |
4fde55a0
|
Leszek Koltunski
|
|
1023 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1024 |
|
|
/**
|
1025 |
|
|
* Directional, sinusoidal wave effect.
|
1026 |
|
|
*
|
1027 |
350cc2f5
|
Leszek Koltunski
|
* @param wave A 5-dimensional data structure describing the wave: first member is the amplitude,
|
1028 |
ea16dc89
|
Leszek Koltunski
|
* second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
|
1029 |
350cc2f5
|
Leszek Koltunski
|
* wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
|
1030 |
|
|
* describe the 'direction' of the wave.
|
1031 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
1032 |
d0c902b8
|
Leszek Koltunski
|
* Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
|
1033 |
|
|
* need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
|
1034 |
|
|
* forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
|
1035 |
|
|
* the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
|
1036 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
1037 |
|
|
* <p>
|
1038 |
d0c902b8
|
Leszek Koltunski
|
* Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
|
1039 |
|
|
* in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
|
1040 |
|
|
* will be sine shapes.
|
1041 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
1042 |
d0c902b8
|
Leszek Koltunski
|
* Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
|
1043 |
|
|
* but this time it waves in the Y-direction, i.e. cross sections of the surface and the
|
1044 |
|
|
* YZ-plane with be sine shapes.
|
1045 |
3695d6fa
|
Leszek Koltunski
|
* <p>
|
1046 |
d0c902b8
|
Leszek Koltunski
|
* Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
|
1047 |
350cc2f5
|
Leszek Koltunski
|
* is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
|
1048 |
|
|
* value if sin at this point.
|
1049 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
1050 |
4fde55a0
|
Leszek Koltunski
|
* @return ID of the effect added, or -1 if we failed to add one.
|
1051 |
|
|
*/
|
1052 |
fa6c352d
|
Leszek Koltunski
|
public long wave(Data5D wave, Data3D center)
|
1053 |
4fde55a0
|
Leszek Koltunski
|
{
|
1054 |
02ef26bc
|
Leszek Koltunski
|
return mV.add(EffectNames.WAVE, wave, center, null);
|
1055 |
4fde55a0
|
Leszek Koltunski
|
}
|
1056 |
|
|
|
1057 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1058 |
|
|
/**
|
1059 |
|
|
* Directional, sinusoidal wave effect.
|
1060 |
|
|
*
|
1061 |
421c2728
|
Leszek Koltunski
|
* @param wave see {@link DistortedEffects#wave(Data5D,Data3D)}
|
1062 |
fa6c352d
|
Leszek Koltunski
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
1063 |
4fde55a0
|
Leszek Koltunski
|
* @param region Region that masks the Effect.
|
1064 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
1065 |
|
|
*/
|
1066 |
fa6c352d
|
Leszek Koltunski
|
public long wave(Data5D wave, Data3D center, Data4D region)
|
1067 |
4fde55a0
|
Leszek Koltunski
|
{
|
1068 |
|
|
return mV.add(EffectNames.WAVE, wave, center, region);
|
1069 |
|
|
}
|
1070 |
d6e94c84
|
Leszek Koltunski
|
|
1071 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1072 |
|
|
// Postprocess-based effects
|
1073 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1074 |
|
|
/**
|
1075 |
|
|
* Blur the object.
|
1076 |
|
|
*
|
1077 |
|
|
* @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
|
1078 |
|
|
* take into account 10 pixels in each direction.
|
1079 |
|
|
* @return ID of the effect added, or -1 if we failed to add one.
|
1080 |
|
|
*/
|
1081 |
85cbbc5e
|
Leszek Koltunski
|
public long blur(Data1D radius)
|
1082 |
d6e94c84
|
Leszek Koltunski
|
{
|
1083 |
85cbbc5e
|
Leszek Koltunski
|
return mP.add(EffectNames.BLUR, radius);
|
1084 |
d6e94c84
|
Leszek Koltunski
|
}
|
1085 |
f2fe7e28
|
Leszek Koltunski
|
}
|