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 |
194ab46f
|
Leszek Koltunski
|
import android.opengl.GLES30;
|
23 |
6a06a912
|
Leszek Koltunski
|
import android.opengl.Matrix;
|
24 |
|
|
|
25 |
e458a4ba
|
Leszek Koltunski
|
import org.distorted.library.message.EffectMessage;
|
26 |
568b29d8
|
Leszek Koltunski
|
import org.distorted.library.type.Data1D;
|
27 |
|
|
import org.distorted.library.type.Data3D;
|
28 |
|
|
import org.distorted.library.type.Data4D;
|
29 |
|
|
import org.distorted.library.type.Dynamic1D;
|
30 |
|
|
import org.distorted.library.type.Dynamic3D;
|
31 |
|
|
import org.distorted.library.type.Dynamic4D;
|
32 |
|
|
import org.distorted.library.type.DynamicQuat;
|
33 |
|
|
import org.distorted.library.type.Static1D;
|
34 |
|
|
import org.distorted.library.type.Static3D;
|
35 |
|
|
import org.distorted.library.type.Static4D;
|
36 |
a4835695
|
Leszek Koltunski
|
|
37 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
d07f2950
|
Leszek Koltunski
|
class EffectQueueMatrix extends EffectQueue
|
40 |
6a06a912
|
Leszek Koltunski
|
{
|
41 |
1e438fc7
|
Leszek Koltunski
|
private static final int NUM_UNIFORMS = 7;
|
42 |
0a046359
|
Leszek Koltunski
|
private static final int NUM_CACHE = 0;
|
43 |
1e438fc7
|
Leszek Koltunski
|
private static final int INDEX = EffectTypes.MATRIX.ordinal();
|
44 |
1a940548
|
Leszek Koltunski
|
|
45 |
|
|
private static float[] mMVPMatrix = new float[16];
|
46 |
|
|
private static float[] mTmpMatrix = new float[16];
|
47 |
|
|
private static float[] mViewMatrix= new float[16];
|
48 |
|
|
|
49 |
8aac2acc
|
Leszek Koltunski
|
private static int mObjDH; // This is a handle to half a Object dimensions
|
50 |
6a06a912
|
Leszek Koltunski
|
private static int mDepthH; // Handle to the max Depth, i.e (farplane-nearplane)/2
|
51 |
|
|
private static int mMVPMatrixH; // pass in the transformation matrix
|
52 |
|
|
private static int mMVMatrixH; // pass in the modelview matrix.
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
55 |
|
|
|
56 |
0a046359
|
Leszek Koltunski
|
EffectQueueMatrix(long id)
|
57 |
6a06a912
|
Leszek Koltunski
|
{
|
58 |
0a046359
|
Leszek Koltunski
|
super(id,NUM_UNIFORMS,NUM_CACHE,INDEX );
|
59 |
6a06a912
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
|
63 |
|
|
private static void multiplyByQuat(float[] matrix, float X, float Y, float Z, float W)
|
64 |
|
|
{
|
65 |
|
|
float xx= X * X;
|
66 |
|
|
float xy= X * Y;
|
67 |
|
|
float xz= X * Z;
|
68 |
|
|
float xw= X * W;
|
69 |
|
|
float yy= Y * Y;
|
70 |
|
|
float yz= Y * Z;
|
71 |
|
|
float yw= Y * W;
|
72 |
|
|
float zz= Z * Z;
|
73 |
|
|
float zw= Z * W;
|
74 |
|
|
|
75 |
|
|
mTmpMatrix[0] = 1 - 2 * ( yy + zz );
|
76 |
|
|
mTmpMatrix[1] = 2 * ( xy - zw );
|
77 |
|
|
mTmpMatrix[2] = 2 * ( xz + yw );
|
78 |
|
|
mTmpMatrix[4] = 2 * ( xy + zw );
|
79 |
|
|
mTmpMatrix[5] = 1 - 2 * ( xx + zz );
|
80 |
|
|
mTmpMatrix[6] = 2 * ( yz - xw );
|
81 |
|
|
mTmpMatrix[8] = 2 * ( xz - yw );
|
82 |
|
|
mTmpMatrix[9] = 2 * ( yz + xw );
|
83 |
|
|
mTmpMatrix[10] = 1 - 2 * ( xx + yy );
|
84 |
|
|
mTmpMatrix[3] = mTmpMatrix[7] = mTmpMatrix[11] = mTmpMatrix[12] = mTmpMatrix[13] = mTmpMatrix[14] = 0;
|
85 |
|
|
mTmpMatrix[15] = 1;
|
86 |
|
|
|
87 |
|
|
Matrix.multiplyMM(mMVPMatrix, 0, matrix, 0, mTmpMatrix, 0);
|
88 |
ab12f06b
|
Leszek Koltunski
|
|
89 |
|
|
matrix[ 0] = mMVPMatrix[ 0];
|
90 |
|
|
matrix[ 1] = mMVPMatrix[ 1];
|
91 |
|
|
matrix[ 2] = mMVPMatrix[ 2];
|
92 |
|
|
matrix[ 3] = mMVPMatrix[ 3];
|
93 |
|
|
matrix[ 4] = mMVPMatrix[ 4];
|
94 |
|
|
matrix[ 5] = mMVPMatrix[ 5];
|
95 |
|
|
matrix[ 6] = mMVPMatrix[ 6];
|
96 |
|
|
matrix[ 7] = mMVPMatrix[ 7];
|
97 |
|
|
matrix[ 8] = mMVPMatrix[ 8];
|
98 |
|
|
matrix[ 9] = mMVPMatrix[ 9];
|
99 |
|
|
matrix[10] = mMVPMatrix[10];
|
100 |
|
|
matrix[11] = mMVPMatrix[11];
|
101 |
|
|
matrix[12] = mMVPMatrix[12];
|
102 |
|
|
matrix[13] = mMVPMatrix[13];
|
103 |
|
|
matrix[14] = mMVPMatrix[14];
|
104 |
|
|
matrix[15] = mMVPMatrix[15];
|
105 |
6a06a912
|
Leszek Koltunski
|
}
|
106 |
|
|
|
107 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
108 |
02de77c9
|
Leszek Koltunski
|
// here construct the ModelView and the ModelViewProjection Matrices
|
109 |
6a06a912
|
Leszek Koltunski
|
|
110 |
02de77c9
|
Leszek Koltunski
|
void constructMatrices(DistortedFramebuffer df, float halfX, float halfY)
|
111 |
6a06a912
|
Leszek Koltunski
|
{
|
112 |
1a940548
|
Leszek Koltunski
|
Matrix.setIdentityM(mViewMatrix, 0);
|
113 |
ed13a5de
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, -df.mWidth/2, df.mHeight/2, -df.mDistance);
|
114 |
02de77c9
|
Leszek Koltunski
|
|
115 |
a595ee16
|
Leszek Koltunski
|
float x,y,z, sx,sy,sz;
|
116 |
02de77c9
|
Leszek Koltunski
|
|
117 |
6a06a912
|
Leszek Koltunski
|
for(int i=0; i<mNumEffects; i++)
|
118 |
|
|
{
|
119 |
e8c81a8e
|
Leszek Koltunski
|
if (mName[i] == EffectNames.ROTATE.ordinal() )
|
120 |
6a06a912
|
Leszek Koltunski
|
{
|
121 |
0df17fad
|
Leszek Koltunski
|
x = mUniforms[NUM_UNIFORMS*i+4];
|
122 |
|
|
y = mUniforms[NUM_UNIFORMS*i+5];
|
123 |
|
|
z = mUniforms[NUM_UNIFORMS*i+6];
|
124 |
568b29d8
|
Leszek Koltunski
|
|
125 |
1a940548
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, x,-y, z);
|
126 |
|
|
Matrix.rotateM( mViewMatrix, 0, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
|
127 |
|
|
Matrix.translateM(mViewMatrix, 0,-x, y,-z);
|
128 |
6a06a912
|
Leszek Koltunski
|
}
|
129 |
e8c81a8e
|
Leszek Koltunski
|
else if(mName[i] == EffectNames.QUATERNION.ordinal() )
|
130 |
6a06a912
|
Leszek Koltunski
|
{
|
131 |
0df17fad
|
Leszek Koltunski
|
x = mUniforms[NUM_UNIFORMS*i+4];
|
132 |
|
|
y = mUniforms[NUM_UNIFORMS*i+5];
|
133 |
|
|
z = mUniforms[NUM_UNIFORMS*i+6];
|
134 |
02de77c9
|
Leszek Koltunski
|
|
135 |
1a940548
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, x,-y, z);
|
136 |
|
|
multiplyByQuat(mViewMatrix, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
|
137 |
|
|
Matrix.translateM(mViewMatrix, 0,-x, y,-z);
|
138 |
6a06a912
|
Leszek Koltunski
|
}
|
139 |
e8c81a8e
|
Leszek Koltunski
|
else if(mName[i] == EffectNames.MOVE.ordinal() )
|
140 |
6a06a912
|
Leszek Koltunski
|
{
|
141 |
0df17fad
|
Leszek Koltunski
|
sx = mUniforms[NUM_UNIFORMS*i ];
|
142 |
|
|
sy = mUniforms[NUM_UNIFORMS*i+1];
|
143 |
|
|
sz = mUniforms[NUM_UNIFORMS*i+2];
|
144 |
02de77c9
|
Leszek Koltunski
|
|
145 |
1a940548
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, sx,-sy, sz);
|
146 |
6a06a912
|
Leszek Koltunski
|
}
|
147 |
e8c81a8e
|
Leszek Koltunski
|
else if(mName[i] == EffectNames.SCALE.ordinal() )
|
148 |
6a06a912
|
Leszek Koltunski
|
{
|
149 |
0df17fad
|
Leszek Koltunski
|
sx = mUniforms[NUM_UNIFORMS*i ];
|
150 |
|
|
sy = mUniforms[NUM_UNIFORMS*i+1];
|
151 |
|
|
sz = mUniforms[NUM_UNIFORMS*i+2];
|
152 |
6a06a912
|
Leszek Koltunski
|
|
153 |
1a940548
|
Leszek Koltunski
|
Matrix.scaleM(mViewMatrix, 0, sx, sy, sz);
|
154 |
6a06a912
|
Leszek Koltunski
|
}
|
155 |
e8c81a8e
|
Leszek Koltunski
|
else if(mName[i] == EffectNames.SHEAR.ordinal() )
|
156 |
6a06a912
|
Leszek Koltunski
|
{
|
157 |
0df17fad
|
Leszek Koltunski
|
sx = mUniforms[NUM_UNIFORMS*i ];
|
158 |
|
|
sy = mUniforms[NUM_UNIFORMS*i+1];
|
159 |
|
|
sz = mUniforms[NUM_UNIFORMS*i+2];
|
160 |
|
|
|
161 |
|
|
x = mUniforms[NUM_UNIFORMS*i+4];
|
162 |
|
|
y = mUniforms[NUM_UNIFORMS*i+5];
|
163 |
|
|
z = mUniforms[NUM_UNIFORMS*i+6];
|
164 |
|
|
|
165 |
1a940548
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, x,-y, z);
|
166 |
02de77c9
|
Leszek Koltunski
|
|
167 |
1a940548
|
Leszek Koltunski
|
mViewMatrix[4] += sx*mViewMatrix[0]; // Multiply viewMatrix by 1 x 0 0 , i.e. X-shear.
|
168 |
|
|
mViewMatrix[5] += sx*mViewMatrix[1]; // 0 1 0 0
|
169 |
|
|
mViewMatrix[6] += sx*mViewMatrix[2]; // 0 0 1 0
|
170 |
|
|
mViewMatrix[7] += sx*mViewMatrix[3]; // 0 0 0 1
|
171 |
02de77c9
|
Leszek Koltunski
|
|
172 |
1a940548
|
Leszek Koltunski
|
mViewMatrix[0] += sy*mViewMatrix[4]; // Multiply viewMatrix by 1 0 0 0 , i.e. Y-shear.
|
173 |
|
|
mViewMatrix[1] += sy*mViewMatrix[5]; // y 1 0 0
|
174 |
|
|
mViewMatrix[2] += sy*mViewMatrix[6]; // 0 0 1 0
|
175 |
|
|
mViewMatrix[3] += sy*mViewMatrix[7]; // 0 0 0 1
|
176 |
02de77c9
|
Leszek Koltunski
|
|
177 |
1a940548
|
Leszek Koltunski
|
mViewMatrix[4] += sz*mViewMatrix[8]; // Multiply viewMatrix by 1 0 0 0 , i.e. Z-shear.
|
178 |
|
|
mViewMatrix[5] += sz*mViewMatrix[9]; // 0 1 0 0
|
179 |
|
|
mViewMatrix[6] += sz*mViewMatrix[10];// 0 z 1 0
|
180 |
|
|
mViewMatrix[7] += sz*mViewMatrix[11];// 0 0 0 1
|
181 |
beb70e07
|
Leszek Koltunski
|
|
182 |
1a940548
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0,-x, y, -z);
|
183 |
6a06a912
|
Leszek Koltunski
|
}
|
184 |
|
|
}
|
185 |
02de77c9
|
Leszek Koltunski
|
|
186 |
0a046359
|
Leszek Koltunski
|
Matrix.translateM(mViewMatrix, 0, halfX,-halfY, 0);
|
187 |
ed13a5de
|
Leszek Koltunski
|
Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mViewMatrix, 0);
|
188 |
02de77c9
|
Leszek Koltunski
|
}
|
189 |
|
|
|
190 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
|
|
|
192 |
|
|
static void getUniforms(int mProgramH)
|
193 |
|
|
{
|
194 |
194ab46f
|
Leszek Koltunski
|
mObjDH = GLES30.glGetUniformLocation(mProgramH, "u_objD");
|
195 |
|
|
mDepthH = GLES30.glGetUniformLocation(mProgramH, "u_Depth");
|
196 |
|
|
mMVPMatrixH= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
197 |
|
|
mMVMatrixH = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
198 |
02de77c9
|
Leszek Koltunski
|
}
|
199 |
|
|
|
200 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201 |
|
|
|
202 |
|
|
float[] getMVP()
|
203 |
|
|
{
|
204 |
|
|
return mMVPMatrix;
|
205 |
|
|
}
|
206 |
|
|
|
207 |
69ed1eb4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208 |
|
|
// return true if in the queue there are only translations, scales, x- and y-shears, and rotations along
|
209 |
|
|
// a vector which is perpendicular to the screen, i.e. if the resulting matrix keeps the front wall of the
|
210 |
|
|
// Mesh parallel to the screen.
|
211 |
|
|
|
212 |
|
|
boolean canUseShortcut()
|
213 |
|
|
{
|
214 |
|
|
for(int i=0; i<mNumEffects; i++)
|
215 |
|
|
{
|
216 |
|
|
if (mName[i] == EffectNames.ROTATE.ordinal() )
|
217 |
|
|
{
|
218 |
|
|
if( mUniforms[NUM_UNIFORMS*i] != 0.0f || mUniforms[NUM_UNIFORMS*i+1] != 0.0f ) return false; // rotation along vector with x or y non-zero
|
219 |
|
|
}
|
220 |
|
|
else if(mName[i] == EffectNames.QUATERNION.ordinal() )
|
221 |
|
|
{
|
222 |
|
|
if( mUniforms[NUM_UNIFORMS*i] != 0.0f || mUniforms[NUM_UNIFORMS*i+1] != 0.0f ) return false; // quaternion rotation along vector with x or y non-zero
|
223 |
|
|
}
|
224 |
|
|
else if(mName[i] == EffectNames.SHEAR.ordinal() )
|
225 |
|
|
{
|
226 |
|
|
if( mUniforms[NUM_UNIFORMS*i+2] != 0.0f ) return false; // shear with non-zero Z
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
return true;
|
231 |
|
|
}
|
232 |
|
|
|
233 |
02de77c9
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
234 |
|
|
|
235 |
|
|
synchronized void compute(long currTime)
|
236 |
|
|
{
|
237 |
|
|
if( currTime==mTime ) return;
|
238 |
|
|
if( mTime==0 ) mTime = currTime;
|
239 |
|
|
long step = (currTime-mTime);
|
240 |
|
|
|
241 |
|
|
for(int i=0; i<mNumEffects; i++)
|
242 |
|
|
{
|
243 |
|
|
if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) )
|
244 |
|
|
{
|
245 |
|
|
for(int j=0; j<mNumListeners; j++)
|
246 |
|
|
EffectMessageSender.newMessage( mListeners.elementAt(j),
|
247 |
|
|
EffectMessage.EFFECT_FINISHED,
|
248 |
|
|
(mID[i]<<EffectTypes.LENGTH)+EffectTypes.MATRIX.type,
|
249 |
|
|
mName[i],
|
250 |
|
|
mObjectID);
|
251 |
|
|
|
252 |
|
|
if( EffectNames.isUnity(mName[i], mUniforms, NUM_UNIFORMS*i) )
|
253 |
|
|
{
|
254 |
|
|
remove(i);
|
255 |
|
|
i--;
|
256 |
|
|
continue;
|
257 |
|
|
}
|
258 |
|
|
else mInter[0][i] = null;
|
259 |
|
|
}
|
260 |
|
|
|
261 |
|
|
if( mInter[1][i]!=null )
|
262 |
|
|
{
|
263 |
|
|
mInter[1][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+4, mCurrentDuration[i], step);
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
mCurrentDuration[i] += step;
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
mTime = currTime;
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
273 |
|
|
|
274 |
|
|
protected void moveEffect(int index)
|
275 |
|
|
{
|
276 |
|
|
mUniforms[NUM_UNIFORMS*index ] = mUniforms[NUM_UNIFORMS*(index+1) ];
|
277 |
|
|
mUniforms[NUM_UNIFORMS*index+1] = mUniforms[NUM_UNIFORMS*(index+1)+1];
|
278 |
|
|
mUniforms[NUM_UNIFORMS*index+2] = mUniforms[NUM_UNIFORMS*(index+1)+2];
|
279 |
|
|
mUniforms[NUM_UNIFORMS*index+3] = mUniforms[NUM_UNIFORMS*(index+1)+3];
|
280 |
|
|
mUniforms[NUM_UNIFORMS*index+4] = mUniforms[NUM_UNIFORMS*(index+1)+4];
|
281 |
|
|
mUniforms[NUM_UNIFORMS*index+5] = mUniforms[NUM_UNIFORMS*(index+1)+5];
|
282 |
|
|
mUniforms[NUM_UNIFORMS*index+6] = mUniforms[NUM_UNIFORMS*(index+1)+6];
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
286 |
|
|
|
287 |
|
|
synchronized void send(DistortedFramebuffer df, float halfX, float halfY, float halfZ)
|
288 |
|
|
{
|
289 |
|
|
constructMatrices(df,halfX,halfY);
|
290 |
|
|
|
291 |
194ab46f
|
Leszek Koltunski
|
GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ);
|
292 |
|
|
GLES30.glUniform1f( mDepthH, df.mDepth);
|
293 |
|
|
GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);
|
294 |
|
|
GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
|
295 |
6a06a912
|
Leszek Koltunski
|
}
|
296 |
|
|
|
297 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
298 |
|
|
// here construct the ModelView Matrix, but without any effects
|
299 |
|
|
|
300 |
d6e94c84
|
Leszek Koltunski
|
synchronized static void sendZero(DistortedFramebuffer df, float halfX, float halfY, float halfZ)
|
301 |
6a06a912
|
Leszek Koltunski
|
{
|
302 |
|
|
Matrix.setIdentityM(mTmpMatrix, 0);
|
303 |
0a046359
|
Leszek Koltunski
|
Matrix.translateM(mTmpMatrix, 0, halfX-df.mWidth/2, df.mHeight/2-halfY, -df.mDistance);
|
304 |
ed13a5de
|
Leszek Koltunski
|
Matrix.multiplyMM(mMVPMatrix, 0, df.mProjectionMatrix, 0, mTmpMatrix, 0);
|
305 |
6a06a912
|
Leszek Koltunski
|
|
306 |
194ab46f
|
Leszek Koltunski
|
GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ);
|
307 |
|
|
GLES30.glUniform1f( mDepthH, df.mDepth);
|
308 |
|
|
GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mTmpMatrix, 0);
|
309 |
|
|
GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix, 0);
|
310 |
6a06a912
|
Leszek Koltunski
|
}
|
311 |
|
|
|
312 |
e0a16874
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
313 |
568b29d8
|
Leszek Koltunski
|
// move, scale
|
314 |
e0a16874
|
Leszek Koltunski
|
|
315 |
568b29d8
|
Leszek Koltunski
|
synchronized long add(EffectNames eln, Data3D vector)
|
316 |
e0a16874
|
Leszek Koltunski
|
{
|
317 |
|
|
if( mMax[INDEX]>mNumEffects )
|
318 |
|
|
{
|
319 |
d425545a
|
Leszek Koltunski
|
mInter[1][mNumEffects] = null;
|
320 |
568b29d8
|
Leszek Koltunski
|
|
321 |
bdb341bc
|
Leszek Koltunski
|
if( vector instanceof Dynamic3D)
|
322 |
|
|
{
|
323 |
|
|
mInter[0][mNumEffects] = (Dynamic3D)vector;
|
324 |
|
|
}
|
325 |
568b29d8
|
Leszek Koltunski
|
else if( vector instanceof Static3D )
|
326 |
|
|
{
|
327 |
d425545a
|
Leszek Koltunski
|
mInter[0][mNumEffects] = null;
|
328 |
0df17fad
|
Leszek Koltunski
|
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)vector).getX();
|
329 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)vector).getY();
|
330 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)vector).getZ();
|
331 |
568b29d8
|
Leszek Koltunski
|
}
|
332 |
|
|
else return -1;
|
333 |
e0a16874
|
Leszek Koltunski
|
|
334 |
|
|
return addBase(eln);
|
335 |
|
|
}
|
336 |
|
|
|
337 |
|
|
return -1;
|
338 |
|
|
}
|
339 |
|
|
|
340 |
6a06a912
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341 |
568b29d8
|
Leszek Koltunski
|
// rotate - static axis
|
342 |
6a06a912
|
Leszek Koltunski
|
|
343 |
0df17fad
|
Leszek Koltunski
|
synchronized long add(EffectNames eln, Data1D angle, Static3D axis, Data3D center)
|
344 |
6a06a912
|
Leszek Koltunski
|
{
|
345 |
1e438fc7
|
Leszek Koltunski
|
if( mMax[INDEX]>mNumEffects )
|
346 |
6a06a912
|
Leszek Koltunski
|
{
|
347 |
bdb341bc
|
Leszek Koltunski
|
if( angle instanceof Dynamic1D)
|
348 |
|
|
{
|
349 |
|
|
mInter[0][mNumEffects] = (Dynamic1D)angle;
|
350 |
|
|
}
|
351 |
568b29d8
|
Leszek Koltunski
|
else if( angle instanceof Static1D)
|
352 |
|
|
{
|
353 |
d425545a
|
Leszek Koltunski
|
mInter[0][mNumEffects] = null;
|
354 |
0df17fad
|
Leszek Koltunski
|
mUniforms[NUM_UNIFORMS*mNumEffects] = ((Static1D)angle).getX();
|
355 |
568b29d8
|
Leszek Koltunski
|
}
|
356 |
|
|
else return -1;
|
357 |
|
|
|
358 |
0df17fad
|
Leszek Koltunski
|
mUniforms[NUM_UNIFORMS*mNumEffects+1] = axis.getX();
|
359 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+2] = axis.getY();
|
360 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+3] = axis.getZ();
|
361 |
|
|
|
362 |
bdb341bc
|
Leszek Koltunski
|
if( center instanceof Dynamic3D)
|
363 |
|
|
{
|
364 |
|
|
mInter[1][mNumEffects] = (Dynamic3D)center;
|
365 |
|
|
}
|
366 |
0df17fad
|
Leszek Koltunski
|
else if( center instanceof Static3D )
|
367 |
|
|
{
|
368 |
|
|
mInter[1][mNumEffects] = null;
|
369 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
|
370 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
|
371 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
|
372 |
|
|
}
|
373 |
|
|
else return -1;
|
374 |
568b29d8
|
Leszek Koltunski
|
|
375 |
6a06a912
|
Leszek Koltunski
|
return addBase(eln);
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
return -1;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
382 |
568b29d8
|
Leszek Koltunski
|
// quaternion or rotate - dynamic axis
|
383 |
|
|
|
384 |
0df17fad
|
Leszek Koltunski
|
synchronized long add(EffectNames eln, Data4D data, Data3D center)
|
385 |
6a06a912
|
Leszek Koltunski
|
{
|
386 |
1e438fc7
|
Leszek Koltunski
|
if( mMax[INDEX]>mNumEffects )
|
387 |
6a06a912
|
Leszek Koltunski
|
{
|
388 |
bdb341bc
|
Leszek Koltunski
|
if( data instanceof Dynamic4D )
|
389 |
|
|
{
|
390 |
|
|
mInter[0][mNumEffects] = (Dynamic4D)data;
|
391 |
|
|
}
|
392 |
|
|
else if( data instanceof DynamicQuat)
|
393 |
|
|
{
|
394 |
|
|
mInter[0][mNumEffects] = (DynamicQuat)data;
|
395 |
|
|
}
|
396 |
568b29d8
|
Leszek Koltunski
|
else if( data instanceof Static4D )
|
397 |
|
|
{
|
398 |
d425545a
|
Leszek Koltunski
|
mInter[0][mNumEffects] = null;
|
399 |
0df17fad
|
Leszek Koltunski
|
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static4D)data).getX();
|
400 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static4D)data).getY();
|
401 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static4D)data).getZ();
|
402 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)data).getW();
|
403 |
|
|
}
|
404 |
|
|
else return -1;
|
405 |
|
|
|
406 |
bdb341bc
|
Leszek Koltunski
|
if( center instanceof Dynamic3D)
|
407 |
|
|
{
|
408 |
|
|
mInter[1][mNumEffects] = (Dynamic3D)center;
|
409 |
|
|
}
|
410 |
0df17fad
|
Leszek Koltunski
|
else if( center instanceof Static3D )
|
411 |
|
|
{
|
412 |
|
|
mInter[1][mNumEffects] = null;
|
413 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
|
414 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
|
415 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
|
416 |
568b29d8
|
Leszek Koltunski
|
}
|
417 |
|
|
else return -1;
|
418 |
|
|
|
419 |
6a06a912
|
Leszek Koltunski
|
return addBase(eln);
|
420 |
|
|
}
|
421 |
568b29d8
|
Leszek Koltunski
|
|
422 |
6a06a912
|
Leszek Koltunski
|
return -1;
|
423 |
|
|
}
|
424 |
|
|
|
425 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
426 |
568b29d8
|
Leszek Koltunski
|
// shear
|
427 |
|
|
|
428 |
0df17fad
|
Leszek Koltunski
|
synchronized long add(EffectNames eln, Data3D shear, Data3D center)
|
429 |
6a06a912
|
Leszek Koltunski
|
{
|
430 |
1e438fc7
|
Leszek Koltunski
|
if( mMax[INDEX]>mNumEffects )
|
431 |
6a06a912
|
Leszek Koltunski
|
{
|
432 |
bdb341bc
|
Leszek Koltunski
|
if( shear instanceof Dynamic3D)
|
433 |
|
|
{
|
434 |
|
|
mInter[0][mNumEffects] = (Dynamic3D)shear;
|
435 |
|
|
}
|
436 |
0df17fad
|
Leszek Koltunski
|
else if( shear instanceof Static3D )
|
437 |
568b29d8
|
Leszek Koltunski
|
{
|
438 |
0df17fad
|
Leszek Koltunski
|
mInter[0][mNumEffects] = null;
|
439 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)shear).getX();
|
440 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)shear).getY();
|
441 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)shear).getZ();
|
442 |
568b29d8
|
Leszek Koltunski
|
}
|
443 |
|
|
else return -1;
|
444 |
|
|
|
445 |
bdb341bc
|
Leszek Koltunski
|
if( center instanceof Dynamic3D)
|
446 |
|
|
{
|
447 |
|
|
mInter[1][mNumEffects] = (Dynamic3D)center;
|
448 |
|
|
}
|
449 |
0df17fad
|
Leszek Koltunski
|
else if( center instanceof Static3D )
|
450 |
568b29d8
|
Leszek Koltunski
|
{
|
451 |
0df17fad
|
Leszek Koltunski
|
mInter[1][mNumEffects] = null;
|
452 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
|
453 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
|
454 |
|
|
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
|
455 |
568b29d8
|
Leszek Koltunski
|
}
|
456 |
|
|
else return -1;
|
457 |
|
|
|
458 |
6a06a912
|
Leszek Koltunski
|
return addBase(eln);
|
459 |
|
|
}
|
460 |
|
|
|
461 |
|
|
return -1;
|
462 |
|
|
}
|
463 |
|
|
}
|