Revision 0df17fad
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/library/DistortedObject.java | ||
---|---|---|
171 | 171 |
|
172 | 172 |
void releasePriv() |
173 | 173 |
{ |
174 |
if( matrixCloned ==false) mM.abortAll(); |
|
175 |
if( vertexCloned ==false) mV.abortAll(); |
|
176 |
if( fragmentCloned==false) mF.abortAll(); |
|
174 |
if( matrixCloned ==false) mM.abortAll(false);
|
|
175 |
if( vertexCloned ==false) mV.abortAll(false);
|
|
176 |
if( fragmentCloned==false) mF.abortAll(false);
|
|
177 | 177 |
|
178 | 178 |
mBmp = null; |
179 | 179 |
mGrid = null; |
... | ... | |
374 | 374 |
*/ |
375 | 375 |
public int abortAllEffects() |
376 | 376 |
{ |
377 |
return mM.abortAll() + mV.abortAll() + mF.abortAll();
|
|
377 |
return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
|
|
378 | 378 |
} |
379 | 379 |
|
380 | 380 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
388 | 388 |
{ |
389 | 389 |
switch(type) |
390 | 390 |
{ |
391 |
case MATRIX : return mM.abortAll(); |
|
392 |
case VERTEX : return mV.abortAll(); |
|
393 |
case FRAGMENT: return mF.abortAll(); |
|
391 |
case MATRIX : return mM.abortAll(true);
|
|
392 |
case VERTEX : return mV.abortAll(true);
|
|
393 |
case FRAGMENT: return mF.abortAll(true);
|
|
394 | 394 |
default : return 0; |
395 | 395 |
} |
396 | 396 |
} |
... | ... | |
498 | 498 |
* Rotates the Object by 'angle' degrees around the center. |
499 | 499 |
* Static axis of rotation is given by the last parameter. |
500 | 500 |
* |
501 |
* @param center Coordinates of the Point we are rotating around. |
|
502 | 501 |
* @param angle Angle that we want to rotate the Object to. Unit: degrees |
503 | 502 |
* @param axis Axis of rotation |
503 |
* @param center Coordinates of the Point we are rotating around. |
|
504 | 504 |
* @return ID of the effect added, or -1 if we failed to add one. |
505 | 505 |
*/ |
506 |
public long rotate(Data3D center, Data1D angle, Static3D axis)
|
|
506 |
public long rotate(Data1D angle, Static3D axis, Data3D center )
|
|
507 | 507 |
{ |
508 |
return mM.add(EffectNames.ROTATE, center, angle, axis);
|
|
508 |
return mM.add(EffectNames.ROTATE, angle, axis, center);
|
|
509 | 509 |
} |
510 | 510 |
|
511 | 511 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
513 | 513 |
* Rotates the Object by 'angle' degrees around the center. |
514 | 514 |
* Here both angle and axis can dynamically change. |
515 | 515 |
* |
516 |
* @param center Coordinates of the Point we are rotating around. |
|
517 | 516 |
* @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ). |
517 |
* @param center Coordinates of the Point we are rotating around. |
|
518 | 518 |
* @return ID of the effect added, or -1 if we failed to add one. |
519 | 519 |
*/ |
520 |
public long rotate(Data3D center, Data4D angleaxis)
|
|
520 |
public long rotate(Data4D angleaxis, Data3D center)
|
|
521 | 521 |
{ |
522 |
return mM.add(EffectNames.ROTATE, center, angleaxis);
|
|
522 |
return mM.add(EffectNames.ROTATE, angleaxis, center);
|
|
523 | 523 |
} |
524 | 524 |
|
525 | 525 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
526 | 526 |
/** |
527 | 527 |
* Rotates the Object by quaternion. |
528 |
* |
|
529 |
* @param center Coordinates of the Point we are rotating around. |
|
528 |
* |
|
530 | 529 |
* @param quaternion The quaternion describing the rotation. |
530 |
* @param center Coordinates of the Point we are rotating around. |
|
531 | 531 |
* @return ID of the effect added, or -1 if we failed to add one. |
532 | 532 |
*/ |
533 |
public long quaternion(Data3D center, Data4D quaternion)
|
|
533 |
public long quaternion(Data4D quaternion, Data3D center )
|
|
534 | 534 |
{ |
535 |
return mM.add(EffectNames.QUATERNION,center,quaternion);
|
|
535 |
return mM.add(EffectNames.QUATERNION,quaternion,center);
|
|
536 | 536 |
} |
537 | 537 |
|
538 | 538 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
539 | 539 |
/** |
540 | 540 |
* Shears the Object. |
541 | 541 |
* |
542 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
|
543 | 542 |
* @param shear The 3-tuple of shear factors. |
543 |
* @param center Center of shearing, i.e. the point which stays unmoved. |
|
544 | 544 |
* @return ID of the effect added, or -1 if we failed to add one. |
545 | 545 |
*/ |
546 |
public long shear(Data3D center, Data3D shear)
|
|
546 |
public long shear(Data3D shear, Data3D center)
|
|
547 | 547 |
{ |
548 |
return mM.add(EffectNames.SHEAR, center, shear);
|
|
548 |
return mM.add(EffectNames.SHEAR, shear, center);
|
|
549 | 549 |
} |
550 | 550 |
|
551 | 551 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectMessageSender.java | ||
---|---|---|
116 | 116 |
|
117 | 117 |
static void newMessage(EffectListener l, EffectMessage m, long id, int name, long bmpID, String str) |
118 | 118 |
{ |
119 |
Message msg = mThis.new Message(l,m,id,name,bmpID,str); |
|
120 |
mList.add(msg); |
|
119 |
if( mThis!=null ) |
|
120 |
{ |
|
121 |
Message msg = mThis.new Message(l,m,id,name,bmpID,str); |
|
122 |
mList.add(msg); |
|
123 |
} |
|
121 | 124 |
} |
122 | 125 |
} |
123 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectNames.java | ||
---|---|---|
22 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 23 |
/** |
24 | 24 |
* Names of Effects one can apply to DistortedObjects. |
25 |
* <p> |
|
26 |
* Effect's 'unity' is a set of values which |
|
25 | 27 |
*/ |
26 | 28 |
public enum EffectNames |
27 | 29 |
{ |
28 | 30 |
// EFFECT NAME /////// EFFECT TYPE ////////////// UNITY ///////////////////////// |
29 |
|
|
31 |
|
|
32 |
///////////////////////////////////////////////////////////////////////////////// |
|
33 |
// MATRIX EFFECTS. |
|
34 |
// Always 7 Uniforms: 4 per-effect interpolated values + 3 dimensional center. |
|
35 |
/** |
|
36 |
* Rotate the whole Object around a center point (in angle-axis notation). |
|
37 |
* <p> |
|
38 |
* 7 Uniforms: (angle,axisX,axisY,axisZ,centerX,centerY,centerZ) |
|
39 |
* Unity: angle==0 |
|
40 |
*/ |
|
30 | 41 |
ROTATE ( EffectTypes.MATRIX , new float[] {0.0f} ), |
31 |
QUATERNION ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), // quaternion is a unity iff its axis (x,y,z) is (0,0,0) |
|
42 |
/** |
|
43 |
* Rotate the whole Object around a center point (in quaternion notation). |
|
44 |
* <p> |
|
45 |
* 7 Uniforms: (quatX,quatY,quatZ,quatW,centerX,centerY,centerZ) |
|
46 |
* Unity: (quatX,quatY,quatZ) = (0,0,0) |
|
47 |
*/ |
|
48 |
QUATERNION ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
|
49 |
/** |
|
50 |
* Move the whole Object by a vector. |
|
51 |
* <p> |
|
52 |
* 7 Uniforms: (vectorX,vectorY,vectorZ,UNUSED,UNUSED,UNUSED,UNUSED) |
|
53 |
* Unity: (vectorX,vectorY,vectorZ) = (0,0,0) |
|
54 |
*/ |
|
32 | 55 |
MOVE ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
56 |
/** |
|
57 |
* Scale the whole Object independently in all 3 dimensions. |
|
58 |
* <p> |
|
59 |
* 7 Uniforms: (scaleX,scaleY,scaleZ,UNUSED,UNUSED,UNUSED,UNUSED) |
|
60 |
* Unity: (scaleX,scaleY,scaleZ) = (1,1,1) |
|
61 |
*/ |
|
33 | 62 |
SCALE ( EffectTypes.MATRIX , new float[] {1.0f,1.0f,1.0f} ), |
63 |
/** |
|
64 |
* Shear the whole Object in 3 dimensions around a center point. |
|
65 |
* <p> |
|
66 |
* 7 Uniforms: (shearX,shearY,shearZ,UNUSED,centerX,centerY,centerZ) |
|
67 |
* Unity: (shearX,shearY,shearZ) = (0,0,0) |
|
68 |
*/ |
|
34 | 69 |
SHEAR ( EffectTypes.MATRIX , new float[] {0.0f,0.0f,0.0f} ), |
35 | 70 |
// add new Matrix effects here... |
36 |
|
|
71 |
|
|
72 |
///////////////////////////////////////////////////////////////////////////////// |
|
73 |
// VERTEX EFFECTS |
|
74 |
// Always 9 Uniforms: 3 per-effect interpolated values, 4-dimensional Region, |
|
75 |
// 2-dimensional center of the effect. |
|
76 |
/** |
|
77 |
* Apply a 3D vector of force to area around a point on the surface of the Object. |
|
78 |
* <p> |
|
79 |
* 9 Uniforms: (forceX,forceY,forceZ,regionX,regionY,regionRX,regionRY,centerX,centerY) |
|
80 |
* Unity: (forceX,forceY,forceZ) = (0,0,0) |
|
81 |
*/ |
|
37 | 82 |
DISTORT ( EffectTypes.VERTEX , new float[] {0.0f,0.0f,0.0f} ), // keep this the first VERT effect (reason: getType) |
83 |
/** |
|
84 |
* Deform the whole Object by applying a 2D vector of force to a center point. |
|
85 |
* <p> |
|
86 |
* 9 Uniforms: (forceX,forceY,UNUSED,UNUSED,UNUSED,UNUSED,UNUSED,centerX,centerY) |
|
87 |
* Unity: (forceX,forceY) = (0,0) |
|
88 |
*/ |
|
38 | 89 |
DEFORM ( EffectTypes.VERTEX , new float[] {0.0f,0.0f} ), |
90 |
/** |
|
91 |
* Pull (or push away) all points around a center point to (from) it. |
|
92 |
* <p> |
|
93 |
* 9 Uniforms: (sinkFactor,UNUSED,UNUSED,regionX,regionY,regionRX,regionRY,centerX,centerY) |
|
94 |
* Unity: sinkFactor = 1 |
|
95 |
*/ |
|
39 | 96 |
SINK ( EffectTypes.VERTEX , new float[] {1.0f} ), |
97 |
/** |
|
98 |
* Smoothly rotate a limited area around a center point. |
|
99 |
* <p> |
|
100 |
* 9 Uniforms: (swirlAngle,UNUSED,UNUSED,regionX,regionY,regionRX,regionRY,centerX,centerY) |
|
101 |
* Unity: swirlAngle = 0 |
|
102 |
*/ |
|
40 | 103 |
SWIRL ( EffectTypes.VERTEX , new float[] {0.0f} ), |
41 |
WAVE ( EffectTypes.VERTEX , new float[] {0.0f} ), |
|
42 | 104 |
// add new Vertex Effects here... |
43 |
|
|
105 |
|
|
106 |
///////////////////////////////////////////////////////////////////////////////// |
|
107 |
// FRAGMENT EFFECTS |
|
108 |
// Always 8 Uniforms: 4-per effect interpolated values, 4 dimensional Region. |
|
109 |
/** |
|
110 |
* Create square-shaped macroblocks. |
|
111 |
* <p> |
|
112 |
* 8 Uniforms: (macroblockSize,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
113 |
* Unity: macroblockSize = 1 |
|
114 |
*/ |
|
44 | 115 |
MACROBLOCK ( EffectTypes.FRAGMENT, new float[] {1.0f} ), // keep this the first FRAG effect (reason: getType) |
116 |
/** |
|
117 |
* Make a given Region (partially) transparent. |
|
118 |
* <p> |
|
119 |
* 8 Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
120 |
* Unity: transparencyLevel = 1 |
|
121 |
*/ |
|
45 | 122 |
ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
123 |
/** |
|
124 |
* Make a given Region (partially) transparent. |
|
125 |
* Effect smoothly fades towards the edges of the region. |
|
126 |
* <p> |
|
127 |
* 8 Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
128 |
* Unity: transparencyLevel = 1 |
|
129 |
*/ |
|
46 | 130 |
SMOOTH_ALPHA ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
131 |
/** |
|
132 |
* Blend current color in the texture with a given color. |
|
133 |
* <p> |
|
134 |
* 8 Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY) |
|
135 |
* Unity: blendLevel = 0 |
|
136 |
*/ |
|
47 | 137 |
CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} ), |
138 |
/** |
|
139 |
* Smoothly blend current color in the texture with a given color. |
|
140 |
* <p> |
|
141 |
* 8 Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY) |
|
142 |
* Unity: blendLevel = 0 |
|
143 |
*/ |
|
48 | 144 |
SMOOTH_CHROMA ( EffectTypes.FRAGMENT, new float[] {0.0f} ), |
145 |
/** |
|
146 |
* Change brightness level of a given Region. |
|
147 |
* <p> |
|
148 |
* 8 Uniforms: (brightnessLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
149 |
* Unity: brightnessLevel = 1 |
|
150 |
*/ |
|
49 | 151 |
BRIGHTNESS ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
152 |
/** |
|
153 |
* Smoothly change brightness level of a given Region. |
|
154 |
* <p> |
|
155 |
* 8 Uniforms: (brightnessLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
156 |
* Unity: brightnessLevel = 1 |
|
157 |
*/ |
|
50 | 158 |
SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
159 |
/** |
|
160 |
* Change saturation level of a given Region. |
|
161 |
* <p> |
|
162 |
* 8 Uniforms: (saturationLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
163 |
* Unity: saturationLevel = 1 |
|
164 |
*/ |
|
51 | 165 |
SATURATION ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
166 |
/** |
|
167 |
* Smoothly change saturation level of a given Region. |
|
168 |
* <p> |
|
169 |
* 8 Uniforms: (saturationLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
170 |
* Unity: saturationLevel = 1 |
|
171 |
*/ |
|
52 | 172 |
SMOOTH_SATURATION( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
173 |
/** |
|
174 |
* Change contrast level of a given Region. |
|
175 |
* <p> |
|
176 |
* 8 Uniforms: (contrastLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
177 |
* Unity: contrastLevel = 1 |
|
178 |
*/ |
|
53 | 179 |
CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
54 |
SMOOTH_CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} ), |
|
55 |
HUE ( EffectTypes.FRAGMENT, new float[] {0.0f} ), |
|
56 |
SMOOTH_HUE ( EffectTypes.FRAGMENT, new float[] {0.0f} ); |
|
180 |
/** |
|
181 |
* Smoothly change contrast level of a given Region. |
|
182 |
* <p> |
|
183 |
* 8 Uniforms: (contrastLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY) |
|
184 |
* Unity: contrastLevel = 1 |
|
185 |
*/ |
|
186 |
SMOOTH_CONTRAST ( EffectTypes.FRAGMENT, new float[] {1.0f} ); |
|
57 | 187 |
// add new Fragment effects here... |
58 | 188 |
|
59 | 189 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectQueue.java | ||
---|---|---|
195 | 195 |
} |
196 | 196 |
|
197 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
198 |
|
|
199 |
synchronized int abortAll() |
|
198 |
// we do want to notify Listeners if they called 'abortAll' themselves but don't want to notify |
|
199 |
// them if it is the library itself which is releasing resources. |
|
200 |
|
|
201 |
synchronized int abortAll(boolean notify) |
|
200 | 202 |
{ |
201 | 203 |
int ret = mNumEffects; |
202 | 204 |
long removedID; |
... | ... | |
208 | 210 |
mInter[1][i] = null; |
209 | 211 |
mInter[2][i] = null; |
210 | 212 |
|
211 |
removedID = mID[i]; |
|
212 |
removedType= mType[i]; |
|
213 |
|
|
214 |
for(int j=0; j<mNumListeners; j++) |
|
215 |
EffectMessageSender.newMessage( mListeners.elementAt(j), |
|
216 |
EffectMessage.EFFECT_REMOVED, |
|
217 |
(removedID<<EffectTypes.LENGTH)+EffectNames.getType(removedType).type, |
|
218 |
removedType, |
|
219 |
mBitmapID, |
|
220 |
null); |
|
213 |
if( notify ) |
|
214 |
{ |
|
215 |
removedID = mID[i]; |
|
216 |
removedType= mType[i]; |
|
217 |
|
|
218 |
for(int j=0; j<mNumListeners; j++) |
|
219 |
EffectMessageSender.newMessage( mListeners.elementAt(j), |
|
220 |
EffectMessage.EFFECT_REMOVED, |
|
221 |
(removedID<<EffectTypes.LENGTH)+EffectNames.getType(removedType).type, |
|
222 |
removedType, |
|
223 |
mBitmapID, |
|
224 |
null); |
|
225 |
} |
|
221 | 226 |
} |
222 | 227 |
|
223 | 228 |
mNumEffects= 0; |
src/main/java/org/distorted/library/EffectQueueMatrix.java | ||
---|---|---|
105 | 105 |
|
106 | 106 |
for(int i=0; i<mNumEffects; i++) |
107 | 107 |
{ |
108 |
if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i+3, mCurrentDuration[i], step) )
|
|
108 |
if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) ) |
|
109 | 109 |
{ |
110 | 110 |
for(int j=0; j<mNumListeners; j++) |
111 | 111 |
EffectMessageSender.newMessage( mListeners.elementAt(j), |
... | ... | |
115 | 115 |
mBitmapID, |
116 | 116 |
null); |
117 | 117 |
|
118 |
if( EffectNames.isUnity(mType[i], mUniforms, NUM_UNIFORMS*i+3) )
|
|
118 |
if( EffectNames.isUnity(mType[i], mUniforms, NUM_UNIFORMS*i) ) |
|
119 | 119 |
{ |
120 | 120 |
remove(i); |
121 | 121 |
i--; |
... | ... | |
125 | 125 |
|
126 | 126 |
if( mInter[1][i]!=null ) |
127 | 127 |
{ |
128 |
mInter[1][i].interpolateMain(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i]); |
|
128 |
mInter[1][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+4, mCurrentDuration[i]);
|
|
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
mCurrentDuration[i] += step; |
... | ... | |
161 | 161 |
{ |
162 | 162 |
if (mType[i] == EffectNames.ROTATE.ordinal() ) |
163 | 163 |
{ |
164 |
x = mUniforms[NUM_UNIFORMS*i ];
|
|
165 |
y = mUniforms[NUM_UNIFORMS*i+1];
|
|
166 |
z = mUniforms[NUM_UNIFORMS*i+2];
|
|
164 |
x = mUniforms[NUM_UNIFORMS*i+4];
|
|
165 |
y = mUniforms[NUM_UNIFORMS*i+5];
|
|
166 |
z = mUniforms[NUM_UNIFORMS*i+6];
|
|
167 | 167 |
|
168 | 168 |
Matrix.translateM(viewMatrix, 0, x,-y, z); |
169 |
Matrix.rotateM( viewMatrix, 0, mUniforms[NUM_UNIFORMS*i+3], mUniforms[NUM_UNIFORMS*i+4], mUniforms[NUM_UNIFORMS*i+5], mUniforms[NUM_UNIFORMS*i+6]);
|
|
169 |
Matrix.rotateM( viewMatrix, 0, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
|
|
170 | 170 |
Matrix.translateM(viewMatrix, 0,-x, y,-z); |
171 | 171 |
} |
172 | 172 |
else if(mType[i] == EffectNames.QUATERNION.ordinal() ) |
173 | 173 |
{ |
174 |
x = mUniforms[NUM_UNIFORMS*i ];
|
|
175 |
y = mUniforms[NUM_UNIFORMS*i+1];
|
|
176 |
z = mUniforms[NUM_UNIFORMS*i+2];
|
|
174 |
x = mUniforms[NUM_UNIFORMS*i+4];
|
|
175 |
y = mUniforms[NUM_UNIFORMS*i+5];
|
|
176 |
z = mUniforms[NUM_UNIFORMS*i+6];
|
|
177 | 177 |
|
178 | 178 |
Matrix.translateM(viewMatrix, 0, x,-y, z); |
179 |
multiplyByQuat(viewMatrix, mUniforms[NUM_UNIFORMS*i+3], mUniforms[NUM_UNIFORMS*i+4], mUniforms[NUM_UNIFORMS*i+5], mUniforms[NUM_UNIFORMS*i+6]);
|
|
179 |
multiplyByQuat(viewMatrix, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
|
|
180 | 180 |
Matrix.translateM(viewMatrix, 0,-x, y,-z); |
181 | 181 |
} |
182 | 182 |
else if(mType[i] == EffectNames.MOVE.ordinal() ) |
183 | 183 |
{ |
184 |
sx = mUniforms[NUM_UNIFORMS*i+3];
|
|
185 |
sy = mUniforms[NUM_UNIFORMS*i+4];
|
|
186 |
sz = mUniforms[NUM_UNIFORMS*i+5];
|
|
184 |
sx = mUniforms[NUM_UNIFORMS*i ];
|
|
185 |
sy = mUniforms[NUM_UNIFORMS*i+1];
|
|
186 |
sz = mUniforms[NUM_UNIFORMS*i+2];
|
|
187 | 187 |
|
188 | 188 |
Matrix.translateM(viewMatrix, 0, sx,-sy, sz); |
189 | 189 |
} |
190 | 190 |
else if(mType[i] == EffectNames.SCALE.ordinal() ) |
191 | 191 |
{ |
192 |
sx = mUniforms[NUM_UNIFORMS*i+3];
|
|
193 |
sy = mUniforms[NUM_UNIFORMS*i+4];
|
|
194 |
sz = mUniforms[NUM_UNIFORMS*i+5];
|
|
192 |
sx = mUniforms[NUM_UNIFORMS*i ];
|
|
193 |
sy = mUniforms[NUM_UNIFORMS*i+1];
|
|
194 |
sz = mUniforms[NUM_UNIFORMS*i+2];
|
|
195 | 195 |
|
196 | 196 |
Matrix.scaleM(viewMatrix, 0, sx, sy, sz); |
197 | 197 |
} |
198 | 198 |
else if(mType[i] == EffectNames.SHEAR.ordinal() ) |
199 | 199 |
{ |
200 |
x = mUniforms[NUM_UNIFORMS*i ];
|
|
201 |
y = mUniforms[NUM_UNIFORMS*i+1];
|
|
202 |
z = mUniforms[NUM_UNIFORMS*i+2];
|
|
203 |
|
|
204 |
sx = mUniforms[NUM_UNIFORMS*i+3];
|
|
205 |
sy = mUniforms[NUM_UNIFORMS*i+4];
|
|
206 |
sz = mUniforms[NUM_UNIFORMS*i+5];
|
|
207 |
|
|
200 |
sx = mUniforms[NUM_UNIFORMS*i ];
|
|
201 |
sy = mUniforms[NUM_UNIFORMS*i+1];
|
|
202 |
sz = mUniforms[NUM_UNIFORMS*i+2];
|
|
203 |
|
|
204 |
x = mUniforms[NUM_UNIFORMS*i+4];
|
|
205 |
y = mUniforms[NUM_UNIFORMS*i+5];
|
|
206 |
z = mUniforms[NUM_UNIFORMS*i+6];
|
|
207 |
|
|
208 | 208 |
Matrix.translateM(viewMatrix, 0, x,-y, z); |
209 | 209 |
|
210 | 210 |
viewMatrix[4] += sx*viewMatrix[0]; // Multiply viewMatrix by 1 x 0 0 , i.e. X-shear. TODO: change this so it is symmetric w respect to all the axis. |
... | ... | |
260 | 260 |
else if( vector instanceof Static3D ) |
261 | 261 |
{ |
262 | 262 |
mInter[0][mNumEffects] = null; |
263 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)vector).getX();
|
|
264 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)vector).getY();
|
|
265 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)vector).getZ();
|
|
263 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)vector).getX();
|
|
264 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)vector).getY();
|
|
265 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)vector).getZ();
|
|
266 | 266 |
} |
267 | 267 |
else return -1; |
268 | 268 |
|
... | ... | |
275 | 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
276 | 276 |
// rotate - static axis |
277 | 277 |
|
278 |
synchronized long add(EffectNames eln, Data3D center, Data1D angle, Static3D axis)
|
|
278 |
synchronized long add(EffectNames eln, Data1D angle, Static3D axis, Data3D center)
|
|
279 | 279 |
{ |
280 | 280 |
if( mMax[INDEX]>mNumEffects ) |
281 | 281 |
{ |
282 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center; |
|
283 |
else if( center instanceof Static3D ) |
|
284 |
{ |
|
285 |
mInter[1][mNumEffects] = null; |
|
286 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)center).getX(); |
|
287 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY(); |
|
288 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ(); |
|
289 |
} |
|
290 |
else return -1; |
|
291 |
|
|
292 | 282 |
if( angle instanceof Dynamic1D) mInter[0][mNumEffects] = (Dynamic1D)angle; |
293 | 283 |
else if( angle instanceof Static1D) |
294 | 284 |
{ |
295 | 285 |
mInter[0][mNumEffects] = null; |
296 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static1D)angle).getX();
|
|
286 |
mUniforms[NUM_UNIFORMS*mNumEffects] = ((Static1D)angle).getX(); |
|
297 | 287 |
} |
298 | 288 |
else return -1; |
299 | 289 |
|
300 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = axis.getX(); |
|
301 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = axis.getY(); |
|
302 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = axis.getZ(); |
|
290 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = axis.getX(); |
|
291 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = axis.getY(); |
|
292 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = axis.getZ(); |
|
293 |
|
|
294 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center; |
|
295 |
else if( center instanceof Static3D ) |
|
296 |
{ |
|
297 |
mInter[1][mNumEffects] = null; |
|
298 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX(); |
|
299 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY(); |
|
300 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ(); |
|
301 |
} |
|
302 |
else return -1; |
|
303 | 303 |
|
304 | 304 |
return addBase(eln); |
305 | 305 |
} |
... | ... | |
310 | 310 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
311 | 311 |
// quaternion or rotate - dynamic axis |
312 | 312 |
|
313 |
synchronized long add(EffectNames eln, Data3D center, Data4D data)
|
|
313 |
synchronized long add(EffectNames eln, Data4D data, Data3D center)
|
|
314 | 314 |
{ |
315 | 315 |
if( mMax[INDEX]>mNumEffects ) |
316 | 316 |
{ |
317 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center; |
|
318 |
else if( center instanceof Static3D ) |
|
319 |
{ |
|
320 |
mInter[1][mNumEffects] = null; |
|
321 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)center).getX(); |
|
322 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY(); |
|
323 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ(); |
|
324 |
} |
|
325 |
else return -1; |
|
326 |
|
|
327 | 317 |
if( data instanceof Dynamic4D ) mInter[0][mNumEffects] = (Dynamic4D)data; |
328 | 318 |
else if( data instanceof DynamicQuat) mInter[0][mNumEffects] = (DynamicQuat)data; |
329 | 319 |
else if( data instanceof Static4D ) |
330 | 320 |
{ |
331 | 321 |
mInter[0][mNumEffects] = null; |
332 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)data).getX(); |
|
333 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static4D)data).getY(); |
|
334 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static4D)data).getZ(); |
|
335 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static4D)data).getW(); |
|
322 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static4D)data).getX(); |
|
323 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static4D)data).getY(); |
|
324 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static4D)data).getZ(); |
|
325 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)data).getW(); |
|
326 |
} |
|
327 |
else return -1; |
|
328 |
|
|
329 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center; |
|
330 |
else if( center instanceof Static3D ) |
|
331 |
{ |
|
332 |
mInter[1][mNumEffects] = null; |
|
333 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX(); |
|
334 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY(); |
|
335 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ(); |
|
336 | 336 |
} |
337 | 337 |
else return -1; |
338 | 338 |
|
... | ... | |
345 | 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
346 | 346 |
// shear |
347 | 347 |
|
348 |
synchronized long add(EffectNames eln, Data3D center, Data3D shear)
|
|
348 |
synchronized long add(EffectNames eln, Data3D shear, Data3D center)
|
|
349 | 349 |
{ |
350 | 350 |
if( mMax[INDEX]>mNumEffects ) |
351 | 351 |
{ |
352 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
|
|
353 |
else if( center instanceof Static3D )
|
|
352 |
if( shear instanceof Dynamic3D) mInter[0][mNumEffects] = (Dynamic3D)shear;
|
|
353 |
else if( shear instanceof Static3D )
|
|
354 | 354 |
{ |
355 |
mInter[1][mNumEffects] = null;
|
|
356 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)center).getX();
|
|
357 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY();
|
|
358 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ();
|
|
355 |
mInter[0][mNumEffects] = null;
|
|
356 |
mUniforms[NUM_UNIFORMS*mNumEffects ] = ((Static3D)shear).getX();
|
|
357 |
mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)shear).getY();
|
|
358 |
mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)shear).getZ();
|
|
359 | 359 |
} |
360 | 360 |
else return -1; |
361 | 361 |
|
362 |
if( shear instanceof Dynamic3D) mInter[0][mNumEffects] = (Dynamic3D)shear;
|
|
363 |
else if( shear instanceof Static3D )
|
|
362 |
if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
|
|
363 |
else if( center instanceof Static3D )
|
|
364 | 364 |
{ |
365 |
mInter[0][mNumEffects] = null;
|
|
366 |
mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)shear).getX();
|
|
367 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)shear).getY();
|
|
368 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)shear).getZ();
|
|
365 |
mInter[1][mNumEffects] = null;
|
|
366 |
mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
|
|
367 |
mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
|
|
368 |
mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
|
|
369 | 369 |
} |
370 | 370 |
else return -1; |
371 | 371 |
|
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
289 | 289 |
P.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2)); // if d2=1 (i.e P=S) we should have P unchanged. How to do it? |
290 | 290 |
} |
291 | 291 |
|
292 |
////////////////////////////////////////////////////////////////////////////////////////////// |
|
293 |
// Wave |
|
294 |
// |
|
295 |
|
|
296 |
void wave(in int effect, inout vec4 P) |
|
297 |
{ |
|
298 |
|
|
299 |
} |
|
300 |
|
|
301 | 292 |
////////////////////////////////////////////////////////////////////////////////////////////// |
302 | 293 |
// Clamp v.z to (-u_Depth,u_Depth) with the following function: |
303 | 294 |
// define h to be, say, 0.7; let H=u_Depth |
... | ... | |
332 | 323 |
// case DEFORM : deform(3*i,v) ; break; |
333 | 324 |
// case SINK : sink(3*i,v) ; break; |
334 | 325 |
// case SWIRL : swirl(3*i,v) ; break; |
335 |
// case WAVE : wave(3*i,v) ; break; |
|
336 | 326 |
// } |
337 | 327 |
|
338 | 328 |
if( vType[i]==DISTORT) distort(3*i,v,n); |
339 | 329 |
else if( vType[i]==DEFORM ) deform(3*i,v); |
340 | 330 |
else if( vType[i]==SINK ) sink(3*i,v); |
341 | 331 |
else if( vType[i]==SWIRL ) swirl(3*i,v); |
342 |
else if( vType[i]==WAVE ) wave(3*i,v); |
|
343 | 332 |
} |
344 | 333 |
|
345 | 334 |
restrict(v.z); |
Also available in: Unified diff
- Javadoc for EffectNames
- make Matrix effects consistent with the rest (center of effect as last parameter!)
- bugfix for yesterday's bugfix (we only want to send 'EFFECT_REMOVED' messages if it was really the Application that called 'abortAll' and not when we are cleaning up everything)