Revision 1585ba24
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java | ||
---|---|---|
78 | 78 |
|
79 | 79 |
// Fragment effects: |
80 | 80 |
// a) change color of the skin to more brown and less red (CHROMA) |
81 |
private Static4D aSkinColorRegion; |
|
81 |
private Static3D aSkinColorCenter; |
|
82 |
private Static3D aSkinColorRegion; |
|
82 | 83 |
private Static3D aChromaSkin; |
83 | 84 |
private Static1D aChromaSkinFactor; |
84 | 85 |
private Dynamic1D aChromaSkinDyn; |
85 | 86 |
// b) darken both eyes (2 x SMOOTH_CHROMA) |
86 |
private Static4D aLEyeColorRegion, aREyeColorRegion; |
|
87 |
private Static3D aLEyeColorCenter, aREyeColorCenter; |
|
88 |
private Static3D aLEyeColorRegion, aREyeColorRegion; |
|
87 | 89 |
private Static3D aChromaEyes; |
88 | 90 |
private Static1D aChromaEyesFactor; |
89 | 91 |
private Dynamic1D aChromaEyesDyn; |
... | ... | |
117 | 119 |
private Dynamic2D bLipsDyn; |
118 | 120 |
// Fragment effects |
119 | 121 |
// a) make the whole face darker (CHROMA) |
120 |
private Static4D bSkinColorRegion; |
|
122 |
private Static3D bSkinColorCenter; |
|
123 |
private Static3D bSkinColorRegion; |
|
121 | 124 |
private Static3D bChromaSkin; |
122 | 125 |
private Static1D bChromaSkinFactor; |
123 | 126 |
private Dynamic1D bChromaSkinDyn; |
124 | 127 |
// b) move both eyes back to whiteness (2 x SMOOTH CHROMA) |
125 |
private Static4D bLEyeColorRegion, bREyeColorRegion; |
|
128 |
private Static3D bLEyeColorCenter, bREyeColorCenter; |
|
129 |
private Static3D bLEyeColorRegion, bREyeColorRegion; |
|
126 | 130 |
private Static3D bChromaEyes; |
127 | 131 |
private Static1D bChromaEyesFactor; |
128 | 132 |
private Dynamic1D bChromaEyesDyn; |
129 | 133 |
// c) darken both pupils (2 x SMOOTH_CHROMA) |
130 |
private Static4D bLPupilColorRegion, bRPupilColorRegion; |
|
134 |
private Static3D bLPupilColorCenter, bRPupilColorCenter; |
|
135 |
private Static3D bLPupilColorRegion, bRPupilColorRegion; |
|
131 | 136 |
private Static3D bChromaPupil; |
132 | 137 |
private Static1D bChromaPupilFactor; |
133 | 138 |
private Dynamic1D bChromaPupilDyn; |
... | ... | |
188 | 193 |
aEyebrowsDyn.add(aEyebrowsFactor); |
189 | 194 |
|
190 | 195 |
// Fragment Effects |
191 |
aSkinColorRegion = new Static4D(300,300,600,600); |
|
192 |
aLEyeColorRegion = new Static4D(172,230,29,25); |
|
193 |
aREyeColorRegion = new Static4D(423,230,29,25); |
|
196 |
aSkinColorCenter = new Static3D(300,300,0); |
|
197 |
aSkinColorRegion = new Static3D(600,600,600); |
|
198 |
aLEyeColorCenter = new Static3D(172,230,0); |
|
199 |
aLEyeColorRegion = new Static3D(29,25,25); |
|
200 |
aREyeColorCenter = new Static3D(423,230,0); |
|
201 |
aREyeColorRegion = new Static3D(29,25,25); |
|
194 | 202 |
|
195 | 203 |
aChromaSkin = new Static3D(0.5f, 0.5f, 0.5f); |
196 | 204 |
aChromaEyes = new Static3D(0.5f, 0.14f, 0.14f); |
... | ... | |
235 | 243 |
bLipsDyn.add(bLipsFactor); |
236 | 244 |
|
237 | 245 |
// Fragment Effects |
238 |
bSkinColorRegion = new Static4D(300,300,600,600); |
|
239 |
bLEyeColorRegion = new Static4D(158,241,55,24); |
|
240 |
bREyeColorRegion = new Static4D(436,241,55,24); |
|
241 |
bLPupilColorRegion = new Static4D(166,230,28,23); |
|
242 |
bRPupilColorRegion = new Static4D(431,230,28,23); |
|
246 |
bSkinColorCenter = new Static3D(300,300,0); |
|
247 |
bSkinColorRegion = new Static3D(600,600,600); |
|
248 |
bLEyeColorCenter = new Static3D(158,241,0); |
|
249 |
bLEyeColorRegion = new Static3D(55,24,50); |
|
250 |
bREyeColorCenter = new Static3D(436,241,0); |
|
251 |
bREyeColorRegion = new Static3D(55,24,50); |
|
252 |
bLPupilColorCenter = new Static3D(166,230,0); |
|
253 |
bLPupilColorRegion = new Static3D(28,23,25); |
|
254 |
bRPupilColorCenter = new Static3D(431,230,0); |
|
255 |
bRPupilColorRegion = new Static3D(28,23,25); |
|
243 | 256 |
|
244 | 257 |
bChromaSkin = new Static3D(0.4f, 0.25f, 0.25f); |
245 | 258 |
bChromaEyes = new Static3D(1.0f, 1.0f, 1.0f); |
... | ... | |
269 | 282 |
effects.apply( new VertexEffectSink(wLipsDyn, wLipsCenter, wLipsRegion) ); |
270 | 283 |
|
271 | 284 |
// ASIANNESS |
272 |
effects.apply( new VertexEffectDistort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion) );
|
|
273 |
effects.apply( new VertexEffectPinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion) ); |
|
274 |
effects.apply( new VertexEffectDistort( aNostrilsDyn, aNostrilsCenter, aNostrilsRegion) );
|
|
275 |
effects.apply( new VertexEffectSwirl( aLEyeDyn, aLEyeCenter, aEyesRegion) );
|
|
276 |
effects.apply( new VertexEffectSwirl( aREyeDyn, aREyeCenter, aEyesRegion) );
|
|
277 |
effects.apply( new VertexEffectDistort( aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion) );
|
|
285 |
effects.apply( new VertexEffectDistort(aLipsNoseDyn , aLipsNoseCenter , aLipsNoseRegion ) );
|
|
286 |
effects.apply( new VertexEffectPinch (aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion) );
|
|
287 |
effects.apply( new VertexEffectDistort( aNostrilsDyn , aNostrilsCenter , aNostrilsRegion ) );
|
|
288 |
effects.apply( new VertexEffectSwirl ( aLEyeDyn , aLEyeCenter , aEyesRegion ) );
|
|
289 |
effects.apply( new VertexEffectSwirl ( aREyeDyn , aREyeCenter , aEyesRegion ) );
|
|
290 |
effects.apply( new VertexEffectDistort( aEyebrowsDyn , aEyebrowsCenter , aEyebrowsRegion ) );
|
|
278 | 291 |
|
279 |
effects.apply( new FragmentEffectChroma( aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false) ); |
|
280 |
effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true ) ); |
|
281 |
effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true ) ); |
|
292 |
effects.apply( new FragmentEffectChroma( aChromaSkinDyn, aChromaSkin, aSkinColorCenter, aSkinColorRegion, false) );
|
|
293 |
effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aLEyeColorCenter, aLEyeColorRegion, true ) );
|
|
294 |
effects.apply( new FragmentEffectChroma( aChromaEyesDyn, aChromaEyes, aREyeColorCenter, aREyeColorRegion, true ) );
|
|
282 | 295 |
|
283 | 296 |
// BLACKNESS |
284 |
effects.apply( new VertexEffectPinch( bFaceDyn, bFaceCenter, bFaceRegion ) );
|
|
285 |
effects.apply( new VertexEffectDistort( bTipLowerDyn, bTipLowerCenter, bTipLowerRegion ) );
|
|
286 |
effects.apply( new VertexEffectPinch( bWholeNoseDyn, bWholeNoseCenter, bWholeNoseRegion ) );
|
|
287 |
effects.apply( new VertexEffectPinch( bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion ) ); |
|
288 |
effects.apply( new VertexEffectPinch( bLipsDyn, bLipsCenter, bLipsRegion ) );
|
|
289 |
|
|
290 |
effects.apply( new FragmentEffectChroma( bChromaSkinDyn, bChromaSkin, bSkinColorRegion, false ) );
|
|
291 |
effects.apply( new FragmentEffectChroma( bChromaEyesDyn, bChromaEyes, bLEyeColorRegion, true ) );
|
|
292 |
effects.apply( new FragmentEffectChroma( bChromaEyesDyn, bChromaEyes, bREyeColorRegion, true ) );
|
|
293 |
effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bLPupilColorRegion, true) );
|
|
294 |
effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bRPupilColorRegion, true) );
|
|
297 |
effects.apply( new VertexEffectPinch ( bFaceDyn , bFaceCenter , bFaceRegion ) );
|
|
298 |
effects.apply( new VertexEffectDistort( bTipLowerDyn , bTipLowerCenter , bTipLowerRegion ) );
|
|
299 |
effects.apply( new VertexEffectPinch ( bWholeNoseDyn , bWholeNoseCenter , bWholeNoseRegion ) );
|
|
300 |
effects.apply( new VertexEffectPinch ( bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion ) );
|
|
301 |
effects.apply( new VertexEffectPinch ( bLipsDyn , bLipsCenter , bLipsRegion ) );
|
|
302 |
|
|
303 |
effects.apply( new FragmentEffectChroma( bChromaSkinDyn , bChromaSkin , bSkinColorCenter , bSkinColorRegion , false ) );
|
|
304 |
effects.apply( new FragmentEffectChroma( bChromaEyesDyn , bChromaEyes , bLEyeColorCenter , bLEyeColorRegion , true ) );
|
|
305 |
effects.apply( new FragmentEffectChroma( bChromaEyesDyn , bChromaEyes , bREyeColorCenter , bREyeColorRegion , true ) );
|
|
306 |
effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bLPupilColorCenter, bLPupilColorRegion, true ) );
|
|
307 |
effects.apply( new FragmentEffectChroma( bChromaPupilDyn, bChromaPupil, bRPupilColorCenter, bRPupilColorRegion, true ) );
|
|
295 | 308 |
|
296 | 309 |
effects.apply( new FragmentEffectContrast(bContrastDyn) ); |
297 | 310 |
} |
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
75 | 75 |
moveDyn.add(mMove); |
76 | 76 |
moveDyn.add(new Static3D(0,0,0)); |
77 | 77 |
|
78 |
Static4D chromaRegion= new Static4D( 530, 200,100,100); |
|
79 |
Static4D alphaRegion = new Static4D( 230, 200,100,100); |
|
78 |
Static3D chromaCenter= new Static3D( 530, 200, 0 ); |
|
79 |
Static3D chromaRegion= new Static3D( 100, 100, 100 ); |
|
80 |
Static3D alphaCenter = new Static3D( 230, 200, 0 ); |
|
81 |
Static3D alphaRegion = new Static3D( 100, 100, 100 ); |
|
80 | 82 |
|
81 | 83 |
Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f); |
82 | 84 |
chromaDyn.add(new Static1D(1)); |
... | ... | |
92 | 94 |
diRotate.add(new Static1D(360)); |
93 | 95 |
|
94 | 96 |
mEffects = new DistortedEffects(); |
95 |
mEffects.apply( new FragmentEffectChroma( chromaDyn, new Static3D(1,0,0), chromaRegion ,true) ); |
|
96 |
mEffects.apply( new FragmentEffectAlpha(alphaDyn, alphaRegion, false) ); |
|
97 |
mEffects.apply( new FragmentEffectChroma( chromaDyn, new Static3D(1,0,0), chromaCenter, chromaRegion ,true) );
|
|
98 |
mEffects.apply( new FragmentEffectAlpha(alphaDyn, alphaCenter, alphaRegion, false) );
|
|
97 | 99 |
mEffects.apply( new MatrixEffectMove(moveDyn)); |
98 | 100 |
mEffects.apply( new MatrixEffectScale(diScale)); |
99 | 101 |
mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) ); |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
157 | 157 |
|
158 | 158 |
void setRegionRadius(int r) |
159 | 159 |
{ |
160 |
mRadius = ( r==100 ? 100.0f : r/100.0f);
|
|
160 |
mRadius = ( r==100 ? 100.0f : r/200.0f);
|
|
161 | 161 |
mRegion.set4(mRadius*scrWidth); |
162 | 162 |
} |
163 | 163 |
|
src/main/java/org/distorted/examples/earth/EarthActivity.java | ||
---|---|---|
168 | 168 |
|
169 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
170 | 170 |
|
171 |
void addNewPoint(float x, float y, EffectName effect)
|
|
171 |
void addNewPoint(float longitude, float latitude, EffectName effect)
|
|
172 | 172 |
{ |
173 | 173 |
EarthSurfaceView view = this.findViewById(R.id.earthSurfaceView); |
174 | 174 |
EarthRenderer renderer = view.getRenderer(); |
175 | 175 |
|
176 |
renderer.addNewPoint(x,y,effect);
|
|
176 |
renderer.addNewPoint(longitude,latitude,effect);
|
|
177 | 177 |
} |
178 | 178 |
|
179 | 179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
24 | 24 |
import android.opengl.GLSurfaceView; |
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 |
import org.distorted.library.effect.Effect; |
|
27 | 28 |
import org.distorted.library.effect.EffectName; |
28 | 29 |
import org.distorted.library.effect.EffectType; |
30 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
31 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
32 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
33 |
import org.distorted.library.effect.FragmentEffectContrast; |
|
34 |
import org.distorted.library.effect.FragmentEffectSaturation; |
|
29 | 35 |
import org.distorted.library.effect.MatrixEffectMove; |
30 | 36 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
31 | 37 |
import org.distorted.library.effect.MatrixEffectScale; |
38 |
import org.distorted.library.effect.VertexEffectDeform; |
|
39 |
import org.distorted.library.effect.VertexEffectDistort; |
|
40 |
import org.distorted.library.effect.VertexEffectPinch; |
|
41 |
import org.distorted.library.effect.VertexEffectSink; |
|
42 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
43 |
import org.distorted.library.effect.VertexEffectWave; |
|
32 | 44 |
import org.distorted.library.main.Distorted; |
33 | 45 |
import org.distorted.library.main.DistortedEffects; |
34 | 46 |
import org.distorted.library.main.DistortedScreen; |
... | ... | |
36 | 48 |
import org.distorted.library.mesh.MeshBase; |
37 | 49 |
import org.distorted.library.mesh.MeshSphere; |
38 | 50 |
import org.distorted.library.type.DynamicQuat; |
51 |
import org.distorted.library.type.Static1D; |
|
39 | 52 |
import org.distorted.library.type.Static3D; |
40 | 53 |
import org.distorted.library.type.Static4D; |
41 | 54 |
|
... | ... | |
49 | 62 |
|
50 | 63 |
class EarthRenderer implements GLSurfaceView.Renderer |
51 | 64 |
{ |
52 |
private static final int SIZE = 100;
|
|
65 |
private static final int SIZE = 500;
|
|
53 | 66 |
private static final int LEVEL= 32; |
54 | 67 |
private static final float FOV = 30.0f; |
55 | 68 |
private static final float NEAR = 0.1f; |
... | ... | |
65 | 78 |
Static4D mQuat1, mQuat2; |
66 | 79 |
int mScreenMin; |
67 | 80 |
|
81 |
private Static3D mColor; |
|
82 |
private Static1D mStrength; |
|
83 |
|
|
68 | 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
69 | 85 |
|
70 | 86 |
EarthRenderer(GLSurfaceView v) |
71 | 87 |
{ |
72 | 88 |
mView = v; |
73 | 89 |
|
90 |
mStrength = new Static1D(0.5f); |
|
91 |
mColor= new Static3D(255,0,0); |
|
74 | 92 |
mMove = new Static3D(0,0,0); |
75 | 93 |
mScale= new Static3D(1,1,1); |
76 | 94 |
mCenter=new Static3D(0,0,0); |
... | ... | |
132 | 150 |
|
133 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
134 | 152 |
|
135 |
void addNewPoint(float x, float y, EffectName effect)
|
|
153 |
void addNewPoint(float longitude, float latitude, EffectName name)
|
|
136 | 154 |
{ |
155 |
Effect effect =null; |
|
156 |
|
|
157 |
double sinLON = Math.sin(longitude); |
|
158 |
double cosLON = Math.cos(longitude); |
|
159 |
double sinLAT = Math.sin(latitude); |
|
160 |
double cosLAT = Math.cos(latitude); |
|
161 |
|
|
162 |
float x = 0.7071f*(float)(sinLON*cosLAT); |
|
163 |
float y = 0.7071f*(float)(cosLON*cosLAT); |
|
164 |
float z = 0.7071f*(float) sinLAT ; |
|
137 | 165 |
|
166 |
float radius = SIZE/10; |
|
167 |
Static4D region = new Static4D(x*mObjWidth,y*mObjHeight,radius,radius); |
|
168 |
|
|
169 |
switch(name) |
|
170 |
{ |
|
171 |
/* |
|
172 |
case DISTORT : effect = new VertexEffectDistort(mDyn3, center, mRegionV); break; |
|
173 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, center, mRegionV); break; |
|
174 |
case SINK : effect = new VertexEffectSink (mDyn1, center, mRegionV); break; |
|
175 |
case PINCH : effect = new VertexEffectPinch (mDyn2, center, mRegionV); break; |
|
176 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, center, mRegionV); break; |
|
177 |
case WAVE : effect = new VertexEffectWave (mDyn5, center, mRegionV); break; |
|
178 |
|
|
179 |
case ALPHA : effect = new FragmentEffectAlpha (mStrength, region, false); break; |
|
180 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mStrength, region, true ); break; |
|
181 |
case CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,region, false); break; |
|
182 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mStrength, mColor,region, true ); break; |
|
183 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mStrength, region, false); break; |
|
184 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mStrength, region, true ); break; |
|
185 |
case SATURATION : effect = new FragmentEffectSaturation(mStrength, region, false); break; |
|
186 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mStrength, region, true ); break; |
|
187 |
case CONTRAST : effect = new FragmentEffectContrast (mStrength, region, false); break; |
|
188 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mStrength, region, true ); break; |
|
189 |
*/ |
|
190 |
} |
|
191 |
|
|
192 |
if( effect!=null ) |
|
193 |
{ |
|
194 |
android.util.Log.e("renderer", "adding fragment effect"); |
|
195 |
mEffects.apply(effect); |
|
196 |
} |
|
138 | 197 |
} |
139 | 198 |
|
140 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/earth/EarthSurfaceViewPicker.java | ||
---|---|---|
195 | 195 |
mPointsY.add( (int)(MULTIPLIER*yf) ); |
196 | 196 |
mPointsE.add(mCurrentEffect.ordinal()); |
197 | 197 |
|
198 |
mAct.get().addNewPoint(xf,yf,mCurrentEffect); |
|
198 |
float longitude = (float)((xf-0.5f)*2.0f*Math.PI); |
|
199 |
float latitude = (float)((yf-0.5f)*Math.PI); |
|
200 |
|
|
201 |
mAct.get().addNewPoint(longitude,latitude,mCurrentEffect); |
|
199 | 202 |
} |
200 | 203 |
|
201 | 204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
48 | 48 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener |
49 | 49 |
{ |
50 | 50 |
private static final int NUMLINES = 10; |
51 |
final int BWID = 300; |
|
52 |
final int BHEI = 400; |
|
51 |
private static final int MESH_QUALITY = 100; |
|
52 |
static final int BWID = 600; |
|
53 |
static final int BHEI = 600; |
|
53 | 54 |
|
54 | 55 |
private EffectQueueSurfaceView mView; |
55 | 56 |
private Paint mPaint; |
... | ... | |
77 | 78 |
mScale = new Static3D(1,1,1); |
78 | 79 |
MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale); |
79 | 80 |
|
80 |
mMesh = new MeshFlat(80,80*texHeight/texWidth);
|
|
81 |
mMesh = new MeshFlat(MESH_QUALITY,MESH_QUALITY*texHeight/texWidth);
|
|
81 | 82 |
mTexture = new DistortedTexture(texWidth,texHeight); |
82 | 83 |
mEffects = new DistortedEffects(); |
83 | 84 |
mEffects.apply(scaleEffect); |
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
public class EffectQueueSurfaceView extends GLSurfaceView |
43 | 43 |
{ |
44 |
private static final int RADIUS = 60;
|
|
44 |
private static final int RADIUS = EffectQueueRenderer.BWID/6;
|
|
45 | 45 |
|
46 | 46 |
private EffectQueueRenderer mRenderer; |
47 | 47 |
private int mCurrentEffect; |
... | ... | |
51 | 51 |
private Dynamic1D mInterA, mInterB, mInterC, mInterS; |
52 | 52 |
private Dynamic3D mInterD; |
53 | 53 |
|
54 |
private final static Static3D mRED = new Static3D(1,0,0); |
|
54 |
private final static Static3D mRED = new Static3D(1,0,0); |
|
55 |
private final static Static3D mREGION = new Static3D(RADIUS,RADIUS,RADIUS); |
|
55 | 56 |
|
56 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 58 |
|
... | ... | |
146 | 147 |
success = mRenderer.getEffects().apply(sink); |
147 | 148 |
act.effectAdded(success,sink); |
148 | 149 |
break; |
149 |
case 2: FragmentEffectAlpha alpha = new FragmentEffectAlpha(mInterA, new Static4D(x,y,RADIUS,RADIUS), true);
|
|
150 |
case 2: FragmentEffectAlpha alpha = new FragmentEffectAlpha(mInterA, new Static3D(x,y,0), mREGION, true);
|
|
150 | 151 |
success = mRenderer.getEffects().apply(alpha); |
151 | 152 |
act.effectAdded(success,alpha); |
152 | 153 |
break; |
153 |
case 3: FragmentEffectSaturation saturation = new FragmentEffectSaturation(mInterB, new Static4D(x,y,RADIUS,RADIUS), false);
|
|
154 |
case 3: FragmentEffectSaturation saturation = new FragmentEffectSaturation(mInterB, new Static3D(x,y,0), mREGION, false);
|
|
154 | 155 |
success = mRenderer.getEffects().apply(saturation); |
155 | 156 |
act.effectAdded(success,saturation); |
156 | 157 |
break; |
157 |
case 4: FragmentEffectChroma chroma = new FragmentEffectChroma(mInterC, mRED, new Static4D(x,y,RADIUS,RADIUS), true);
|
|
158 |
case 4: FragmentEffectChroma chroma = new FragmentEffectChroma(mInterC, mRED, new Static3D(x,y,0), mREGION, true);
|
|
158 | 159 |
success = mRenderer.getEffects().apply(chroma); |
159 | 160 |
act.effectAdded(success,chroma); |
160 | 161 |
break; |
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
---|---|---|
76 | 76 |
private int[] mSeekID; |
77 | 77 |
private int[] mSeekRegionID; |
78 | 78 |
private int[] mSeekCenterID; |
79 |
private int mDimension; |
|
79 |
private int mDimension, mRegionDimension;
|
|
80 | 80 |
private TextView mText,mTextRegion,mTextCenter; |
81 | 81 |
|
82 | 82 |
private Dynamic1D mDyn1; |
... | ... | |
89 | 89 |
private Static3D mSta3; |
90 | 90 |
private Static4D mSta4; |
91 | 91 |
private Static5D mSta5; |
92 |
private Dynamic4D mRegionDyn; |
|
93 |
private Static4D mRegionSta; |
|
92 |
private Dynamic4D mRegion4Dyn; |
|
93 |
private Static4D mRegion4Sta; |
|
94 |
private Dynamic3D mRegion3Dyn; |
|
95 |
private Static3D mRegion3Sta; |
|
94 | 96 |
private Dynamic3D mCenterDyn; |
95 | 97 |
private Static3D mCenterSta; |
96 | 98 |
|
... | ... | |
147 | 149 |
case SCALE : effect = new MatrixEffectScale (mDyn3) ; break; |
148 | 150 |
case SHEAR : effect = new MatrixEffectShear (mDyn3, mCenterDyn); break; |
149 | 151 |
|
150 |
case DISTORT : effect = new VertexEffectDistort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
151 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, mCenterDyn, mRegionDyn); break; |
|
152 |
case SINK : effect = new VertexEffectSink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
153 |
case PINCH : effect = new VertexEffectPinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
154 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
155 |
case WAVE : effect = new VertexEffectWave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
156 |
|
|
157 |
case ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, false); break;
|
|
158 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, true ); break;
|
|
159 |
case CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, false); break;
|
|
160 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, true ); break;
|
|
161 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, false); break;
|
|
162 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, true ); break;
|
|
163 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, false); break;
|
|
164 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, true ); break;
|
|
165 |
case CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, false); break;
|
|
166 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, true ); break;
|
|
152 |
case DISTORT : effect = new VertexEffectDistort (mDyn3, mCenterDyn, mRegion4Dyn); break;
|
|
153 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, mCenterDyn, mRegion4Dyn); break;
|
|
154 |
case SINK : effect = new VertexEffectSink (mDyn1, mCenterDyn, mRegion4Dyn); break;
|
|
155 |
case PINCH : effect = new VertexEffectPinch (mDyn2, mCenterDyn, mRegion4Dyn); break;
|
|
156 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, mCenterDyn, mRegion4Dyn); break;
|
|
157 |
case WAVE : effect = new VertexEffectWave (mDyn5, mCenterDyn, mRegion4Dyn); break;
|
|
158 |
|
|
159 |
case ALPHA : effect = new FragmentEffectAlpha (mDyn1, mCenterDyn, mRegion3Dyn, false); break;
|
|
160 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mCenterDyn, mRegion3Dyn, true ); break;
|
|
161 |
case CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mCenterDyn, mRegion3Dyn, false); break;
|
|
162 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mCenterDyn, mRegion3Dyn, true ); break;
|
|
163 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mCenterDyn, mRegion3Dyn, false); break;
|
|
164 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mCenterDyn, mRegion3Dyn, true ); break;
|
|
165 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mCenterDyn, mRegion3Dyn, false); break;
|
|
166 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mCenterDyn, mRegion3Dyn, true ); break;
|
|
167 |
case CONTRAST : effect = new FragmentEffectContrast (mDyn1, mCenterDyn, mRegion3Dyn, false); break;
|
|
168 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mCenterDyn, mRegion3Dyn, true ); break;
|
|
167 | 169 |
|
168 | 170 |
case BLUR : effect = new PostprocessEffectBlur (mDyn1 ); break; |
169 | 171 |
case GLOW : effect = new PostprocessEffectGlow (mDyn1, mDyn4); break; |
... | ... | |
401 | 403 |
float z = (mInterRegion[2]-deduct)*factorX; // ?? |
402 | 404 |
float r = mInterRegion[3] *(factorX+factorY)/2; |
403 | 405 |
|
404 |
mRegionSta.set(x,y,z,r); |
|
406 |
mRegion4Sta.set(x,y,z,r); |
|
407 |
mRegion3Sta.set(x,y,z); |
|
405 | 408 |
} |
406 | 409 |
|
407 | 410 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
418 | 421 |
|
419 | 422 |
private void setRegionText() |
420 | 423 |
{ |
421 |
int f0 = (int)mRegionSta.get1(); |
|
422 |
int f1 = (int)mRegionSta.get2(); |
|
423 |
int f2 = (int)mRegionSta.get3(); |
|
424 |
int f3 = (int)mRegionSta.get4(); |
|
424 |
if( mRegionDimension==4 ) |
|
425 |
{ |
|
426 |
int f0 = (int) mRegion4Sta.get1(); |
|
427 |
int f1 = (int) mRegion4Sta.get2(); |
|
428 |
int f2 = (int) mRegion4Sta.get3(); |
|
429 |
int f3 = (int) mRegion4Sta.get4(); |
|
430 |
|
|
431 |
mTextRegion.setText("region (" + f0 + "," + f1 + "," + f2 + "," + f3 + ")"); |
|
432 |
} |
|
425 | 433 |
|
426 |
mTextRegion.setText("region ("+f0+","+f1+","+f2+","+f3+")"); |
|
434 |
if( mRegionDimension==3 ) |
|
435 |
{ |
|
436 |
int f0 = (int) mRegion3Sta.get1(); |
|
437 |
int f1 = (int) mRegion3Sta.get2(); |
|
438 |
int f2 = (int) mRegion3Sta.get3(); |
|
439 |
|
|
440 |
mTextRegion.setText("region (" + f0 + "," + f1 + "," + f2 + ")"); |
|
441 |
} |
|
427 | 442 |
} |
428 | 443 |
|
429 | 444 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
455 | 470 |
mSta4 = null; |
456 | 471 |
mSta5 = null; |
457 | 472 |
|
458 |
mDimension = mName.getDimension(); |
|
473 |
mDimension = mName.getEffectDimension(); |
|
474 |
mRegionDimension = mName.getRegionDimension(); |
|
459 | 475 |
|
460 | 476 |
switch(mDimension) |
461 | 477 |
{ |
... | ... | |
511 | 527 |
|
512 | 528 |
mInterRegion = new int[4]; |
513 | 529 |
mSeekRegionID= new int[4]; |
514 |
mRegionDyn = new Dynamic4D(); |
|
515 |
mRegionSta = new Static4D(0,0,0,0); |
|
516 |
mRegionDyn.add(mRegionSta); |
|
530 |
mRegion4Dyn = new Dynamic4D(); |
|
531 |
mRegion4Sta = new Static4D(0,0,0,0); |
|
532 |
mRegion4Dyn.add(mRegion4Sta); |
|
533 |
mRegion3Dyn = new Dynamic3D(); |
|
534 |
mRegion3Sta = new Static3D(0,0,0); |
|
535 |
mRegion3Dyn.add(mRegion3Sta); |
|
517 | 536 |
|
518 | 537 |
mInterCenter = new int[3]; |
519 | 538 |
mSeekCenterID= new int[3]; |
... | ... | |
610 | 629 |
{ |
611 | 630 |
Effects3DActivity2 act = mAct.get(); |
612 | 631 |
|
613 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion, null); |
|
614 |
mRegion.setBackgroundColor( num%2==1 ? BACKGROUND_EVEN: BACKGROUND_ODD ); |
|
632 |
if( mRegionDimension== 4 ) |
|
633 |
{ |
|
634 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion4, null); |
|
635 |
mRegion.setBackgroundColor(num % 2 == 1 ? BACKGROUND_EVEN : BACKGROUND_ODD); |
|
615 | 636 |
|
616 |
SeekBar[] seek = new SeekBar[4]; |
|
637 |
SeekBar[] seek = new SeekBar[4];
|
|
617 | 638 |
|
618 |
seek[0] = mRegion.findViewById(R.id.effectRegionBarX );
|
|
619 |
seek[1] = mRegion.findViewById(R.id.effectRegionBarY );
|
|
620 |
seek[2] = mRegion.findViewById(R.id.effectRegionBarRX);
|
|
621 |
seek[3] = mRegion.findViewById(R.id.effectRegionBarRY);
|
|
639 |
seek[0] = mRegion.findViewById(R.id.effectRegion4BarX);
|
|
640 |
seek[1] = mRegion.findViewById(R.id.effectRegion4BarY);
|
|
641 |
seek[2] = mRegion.findViewById(R.id.effectRegion4BarZ);
|
|
642 |
seek[3] = mRegion.findViewById(R.id.effectRegion4BarR);
|
|
622 | 643 |
|
623 |
mSeekRegionID[0] = seek[0].getId(); |
|
624 |
mSeekRegionID[1] = seek[1].getId(); |
|
625 |
mSeekRegionID[2] = seek[2].getId(); |
|
626 |
mSeekRegionID[3] = seek[3].getId(); |
|
644 |
mSeekRegionID[0] = seek[0].getId();
|
|
645 |
mSeekRegionID[1] = seek[1].getId();
|
|
646 |
mSeekRegionID[2] = seek[2].getId();
|
|
647 |
mSeekRegionID[3] = seek[3].getId();
|
|
627 | 648 |
|
628 |
mTextRegion = mRegion.findViewById(R.id.effectRegionText);
|
|
649 |
mTextRegion = mRegion.findViewById(R.id.effectRegion4Text);
|
|
629 | 650 |
|
630 |
setDefaultRegionInter(); |
|
651 |
setDefaultRegionInter();
|
|
631 | 652 |
|
632 |
for(int i=0; i<4; i++) |
|
633 |
{ |
|
634 |
seek[i].setOnSeekBarChangeListener(this); |
|
635 |
seek[i].setProgress( mInterRegion[i] ); |
|
653 |
for (int i = 0; i < 4; i++) |
|
654 |
{ |
|
655 |
seek[i].setOnSeekBarChangeListener(this); |
|
656 |
seek[i].setProgress(mInterRegion[i]); |
|
657 |
} |
|
658 |
|
|
659 |
act.setRegion(mRegion4Sta.get1(), mRegion4Sta.get2(), mRegion4Sta.get3(), mRegion4Sta.get4()); |
|
636 | 660 |
} |
661 |
else |
|
662 |
{ |
|
663 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion3, null); |
|
664 |
mRegion.setBackgroundColor(num % 2 == 1 ? BACKGROUND_EVEN : BACKGROUND_ODD); |
|
665 |
|
|
666 |
SeekBar[] seek = new SeekBar[3]; |
|
667 |
|
|
668 |
seek[0] = mRegion.findViewById(R.id.effectRegion3BarRX); |
|
669 |
seek[1] = mRegion.findViewById(R.id.effectRegion3BarRY); |
|
670 |
seek[2] = mRegion.findViewById(R.id.effectRegion3BarRZ); |
|
671 |
|
|
672 |
mSeekRegionID[0] = seek[0].getId(); |
|
673 |
mSeekRegionID[1] = seek[1].getId(); |
|
674 |
mSeekRegionID[2] = seek[2].getId(); |
|
675 |
|
|
676 |
mTextRegion = mRegion.findViewById(R.id.effectRegion3Text); |
|
637 | 677 |
|
638 |
act.setRegion(mRegionSta.get1(),mRegionSta.get2(),mRegionSta.get3(), mRegionSta.get4() ); |
|
678 |
setDefaultRegionInter(); |
|
679 |
|
|
680 |
for (int i = 0; i < 3; i++) |
|
681 |
{ |
|
682 |
seek[i].setOnSeekBarChangeListener(this); |
|
683 |
seek[i].setProgress(mInterRegion[i]); |
|
684 |
} |
|
685 |
|
|
686 |
act.setRegion(mRegion3Sta.get1(), mRegion3Sta.get2(), mRegion3Sta.get3(), 1.0f ); |
|
687 |
} |
|
639 | 688 |
|
640 | 689 |
return mRegion; |
641 | 690 |
} |
... | ... | |
709 | 758 |
setText(); |
710 | 759 |
} |
711 | 760 |
|
712 |
if( bar.getId() == mSeekRegionID[0] ) |
|
761 |
if( mRegionDimension>=1 && bar.getId() == mSeekRegionID[0] )
|
|
713 | 762 |
{ |
714 | 763 |
mInterRegion[0] = progress; |
715 | 764 |
fillRegionStatics(); |
716 | 765 |
setRegionText(); |
717 | 766 |
} |
718 |
if( bar.getId() == mSeekRegionID[1] ) |
|
767 |
if( mRegionDimension>=2 && bar.getId() == mSeekRegionID[1] )
|
|
719 | 768 |
{ |
720 | 769 |
mInterRegion[1] = progress; |
721 | 770 |
fillRegionStatics(); |
722 | 771 |
setRegionText(); |
723 | 772 |
} |
724 |
if( bar.getId() == mSeekRegionID[2] ) |
|
773 |
if( mRegionDimension>=3 && bar.getId() == mSeekRegionID[2] )
|
|
725 | 774 |
{ |
726 | 775 |
mInterRegion[2] = progress; |
727 | 776 |
fillRegionStatics(); |
728 | 777 |
setRegionText(); |
729 | 778 |
} |
730 |
if( bar.getId() == mSeekRegionID[3] ) |
|
779 |
if( mRegionDimension>=4 && bar.getId() == mSeekRegionID[3] )
|
|
731 | 780 |
{ |
732 | 781 |
mInterRegion[3] = progress; |
733 | 782 |
fillRegionStatics(); |
... | ... | |
765 | 814 |
view.getRenderer().showRegionAndCenter( showR,showC ); |
766 | 815 |
|
767 | 816 |
act.setCenter(mCenterSta.get1(),mCenterSta.get2(),mCenterSta.get3()); |
768 |
act.setRegion(mRegionSta.get1(),mRegionSta.get2(),mRegionSta.get3(), mRegionSta.get4());
|
|
817 |
act.setRegion(mRegion4Sta.get1(),mRegion4Sta.get2(),mRegion4Sta.get3(), mRegion4Sta.get4());
|
|
769 | 818 |
} |
770 | 819 |
} |
771 | 820 |
|
src/main/java/org/distorted/examples/effects3d/Effects3DTab.java | ||
---|---|---|
169 | 169 |
View view = eff.createView(mChildren); |
170 | 170 |
layout.addView(view); |
171 | 171 |
|
172 |
if( mEffectNames[mEffectAdd].supportsCenter() )
|
|
172 |
if( mEffectNames[mEffectAdd].getCenterDimension() > 0 )
|
|
173 | 173 |
{ |
174 | 174 |
View center = eff.createCenter(mChildren); |
175 | 175 |
layout.addView(center); |
176 | 176 |
} |
177 | 177 |
|
178 |
if( mEffectNames[mEffectAdd].supportsRegion() )
|
|
178 |
if( mEffectNames[mEffectAdd].getRegionDimension() > 0 )
|
|
179 | 179 |
{ |
180 | 180 |
View region = eff.createRegion(mChildren); |
181 | 181 |
layout.addView(region); |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
37 | 37 |
import org.distorted.library.effect.VertexEffectSwirl; |
38 | 38 |
import org.distorted.library.main.DistortedEffects; |
39 | 39 |
import org.distorted.library.type.Dynamic3D; |
40 |
import org.distorted.library.type.Dynamic4D; |
|
41 | 40 |
import org.distorted.library.type.Static1D; |
42 | 41 |
import org.distorted.library.type.Static3D; |
43 | 42 |
import org.distorted.library.type.Static4D; |
... | ... | |
58 | 57 |
|
59 | 58 |
private static final Object lock = new Object(); |
60 | 59 |
|
61 |
private Dynamic3D mCenterVertex;
|
|
60 |
private Dynamic3D mCenter; |
|
62 | 61 |
private Static4D mRegionVertex; |
63 |
private Dynamic4D mRegionFragment;
|
|
62 |
private Static3D mRegionFragment;
|
|
64 | 63 |
|
65 | 64 |
private Paint mPaint; |
66 | 65 |
private int moving; |
67 | 66 |
private long mTime = 0; |
68 | 67 |
|
69 | 68 |
private int mCurrEffect; |
70 |
private int mSize1, mSize2, mSizeR;
|
|
69 |
private int mSize1, mSize2; |
|
71 | 70 |
private Static3D mDistort; |
72 | 71 |
|
73 | 72 |
private MovingEffectsRenderer mRenderer; |
... | ... | |
89 | 88 |
mPaint.setStyle(Style.FILL); |
90 | 89 |
moving = -1; |
91 | 90 |
|
92 |
mCenterVertex = new Dynamic3D(LOOP_TIME,0.0f);
|
|
93 |
mRegionFragment = new Dynamic4D(LOOP_TIME,0.0f);
|
|
91 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f);
|
|
92 |
mRegionFragment = new Static3D(0,0,0);
|
|
94 | 93 |
mRegionVertex = new Static4D(0,0,0,0); |
95 | 94 |
mDistort = new Static3D(0,0,0); |
96 | 95 |
|
... | ... | |
105 | 104 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
106 | 105 |
setRenderer(mRenderer); |
107 | 106 |
|
108 |
mEffectDistort = new VertexEffectDistort( mDistort , mCenterVertex, mRegionVertex);
|
|
109 |
mEffectSink = new VertexEffectSink(new Static1D(10), mCenterVertex, mRegionVertex);
|
|
110 |
mEffectSwirl = new VertexEffectSwirl( new Static1D(30), mCenterVertex, mRegionVertex);
|
|
111 |
mEffectAlpha = new FragmentEffectAlpha(new Static1D(0.5f), mRegionFragment, true);
|
|
112 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mRegionFragment, true); |
|
107 |
mEffectDistort = new VertexEffectDistort ( mDistort , mCenter, mRegionVertex);
|
|
108 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, mRegionVertex);
|
|
109 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, mRegionVertex);
|
|
110 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, mRegionFragment, true);
|
|
111 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, mRegionFragment, true);
|
|
113 | 112 |
} |
114 | 113 |
} |
115 | 114 |
|
... | ... | |
121 | 120 |
|
122 | 121 |
mSize1 = max/200; |
123 | 122 |
mSize2 = max/80; |
124 |
mSizeR = max/6;
|
|
123 |
int rad= max/6;
|
|
125 | 124 |
|
126 |
mRegionVertex.set(0,0,0,mSizeR); |
|
125 |
mRegionVertex.set(0,0,0,rad); |
|
126 |
mRegionFragment.set(rad,rad,rad); |
|
127 | 127 |
mDistort.set3(max/10); |
128 | 128 |
} |
129 | 129 |
|
... | ... | |
223 | 223 |
DistortedEffects q = mRenderer.getEffects(); |
224 | 224 |
q.abortByType(EffectType.VERTEX); |
225 | 225 |
q.abortByType(EffectType.FRAGMENT); |
226 |
mCenterVertex.removeAll(); |
|
227 |
mRegionFragment.removeAll(); |
|
226 |
mCenter.removeAll(); |
|
228 | 227 |
mCurrEffect = EFFECT_POINTS; |
229 | 228 |
mRenderer.setRefresh(); |
230 | 229 |
} |
... | ... | |
236 | 235 |
{ |
237 | 236 |
synchronized(lock) |
238 | 237 |
{ |
239 |
int len = mCenterVertex.getNumPoints();
|
|
238 |
int len = mCenter.getNumPoints(); |
|
240 | 239 |
|
241 | 240 |
float[] drawCoord = new float[3]; |
242 | 241 |
Static3D cu; |
... | ... | |
248 | 247 |
for(int i=0; i<NUM_POINTS; i++) |
249 | 248 |
{ |
250 | 249 |
mPaint.setColor( 0xffffffff ); |
251 |
mCenterVertex.get( drawCoord, 0, (long)(i*step) );
|
|
250 |
mCenter.get( drawCoord, 0, (long)(i*step) ); |
|
252 | 251 |
c.drawCircle(drawCoord[0], drawCoord[1], mSize1, mPaint ); |
253 | 252 |
} |
254 | 253 |
} |
... | ... | |
257 | 256 |
|
258 | 257 |
for(int curr=0; curr<len; curr++) |
259 | 258 |
{ |
260 |
cu = mCenterVertex.getPoint(curr);
|
|
259 |
cu = mCenter.getPoint(curr); |
|
261 | 260 |
c.drawCircle(cu.get1(), cu.get2(), mSize2, mPaint); |
262 | 261 |
} |
263 | 262 |
|
... | ... | |
280 | 279 |
|
281 | 280 |
float gx, gy; |
282 | 281 |
Static3D dv; |
283 |
int len = mCenterVertex.getNumPoints();
|
|
282 |
int len = mCenter.getNumPoints(); |
|
284 | 283 |
|
285 | 284 |
for(int g=0; g<len; g++) |
286 | 285 |
{ |
287 |
dv = mCenterVertex.getPoint(g);
|
|
286 |
dv = mCenter.getPoint(g); |
|
288 | 287 |
gx = dv.get1(); |
289 | 288 |
gy = dv.get2(); |
290 | 289 |
|
... | ... | |
300 | 299 |
{ |
301 | 300 |
synchronized(lock) |
302 | 301 |
{ |
303 |
mCenterVertex.add(new Static3D(xDown,yDown,0)); |
|
304 |
mRegionFragment.add(new Static4D(xDown,yDown,mSizeR,mSizeR)); |
|
302 |
mCenter.add(new Static3D(xDown,yDown,0)); |
|
305 | 303 |
} |
306 | 304 |
} |
307 | 305 |
mRenderer.setRefresh(); |
... | ... | |
311 | 309 |
xDown = (int)event.getX(); |
312 | 310 |
yDown = (int)event.getY(); |
313 | 311 |
|
314 |
mCenterVertex.setPoint(moving, xDown, yDown, 0); |
|
315 |
mRegionFragment.setPoint(moving, xDown, yDown, mSizeR, mSizeR); |
|
312 |
mCenter.setPoint(moving, xDown, yDown, 0); |
|
316 | 313 |
} |
317 | 314 |
mRenderer.setRefresh(); |
318 | 315 |
break; |
src/main/java/org/distorted/examples/objecttree/ObjectTreeRenderer.java | ||
---|---|---|
180 | 180 |
mGridTexture.setTexture(bitmap2); |
181 | 181 |
DistortedEffects gridEffects = new DistortedEffects(); |
182 | 182 |
|
183 |
final int GRID = 10;
|
|
183 |
final int GRID = 20;
|
|
184 | 184 |
|
185 | 185 |
if( mMeshFlat==null ) mMeshFlat = new MeshFlat(1,1); |
186 | 186 |
if( mMeshCubes==null) mMeshCubes= new MeshCubes(GRID,GRID,1); |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
418 | 418 |
mCrawlBackgroundEffects.apply( new MatrixEffectRotate(new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(screenW/2,backH,0)) ); |
419 | 419 |
|
420 | 420 |
final int transpDist = 5; |
421 |
Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH); |
|
422 |
mCrawlBackgroundEffects.apply( new FragmentEffectAlpha(new Static1D(1-transpDist*0.6f), region, true) ); |
|
421 |
Static3D center = new Static3D( screenW/2 , (1-transpDist)*backH , 0 ); |
|
422 |
Static3D region = new Static3D( transpDist*backH , transpDist*backH , transpDist*backH ); |
|
423 |
mCrawlBackgroundEffects.apply( new FragmentEffectAlpha(new Static1D(1-transpDist*0.6f), center, region, true) ); |
|
423 | 424 |
|
424 | 425 |
Dynamic3D di = new Dynamic3D(70000,0.5f); |
425 | 426 |
di.add(new Static3D(screenW/2,+backH , 0)); |
src/main/res/layout/effectregion.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/effectRegionLayout" |
|
4 |
android:layout_width="match_parent" |
|
5 |
android:layout_height="wrap_content" |
|
6 |
android:orientation="vertical"> |
|
7 |
|
|
8 |
<TextView |
|
9 |
android:id="@+id/effectRegionText" |
|
10 |
android:layout_width="wrap_content" |
|
11 |
android:layout_height="wrap_content" |
|
12 |
android:layout_marginEnd="5dp" |
|
13 |
android:layout_marginStart="5dp" |
|
14 |
android:layout_marginTop="3dp" |
|
15 |
/> |
|
16 |
|
|
17 |
<LinearLayout |
|
18 |
android:orientation="horizontal" |
|
19 |
android:layout_width="match_parent" |
|
20 |
android:layout_height="match_parent"> |
|
21 |
|
|
22 |
<SeekBar |
|
23 |
android:id="@+id/effectRegionBarX" |
|
24 |
android:layout_width="wrap_content" |
|
25 |
android:layout_height="wrap_content" |
|
26 |
android:layout_marginEnd="5dp" |
|
27 |
android:layout_marginLeft="5dp" |
|
28 |
android:layout_marginRight="5dp" |
|
29 |
android:layout_weight="0.5"/> |
|
30 |
|
|
31 |
<SeekBar |
|
32 |
android:id="@+id/effectRegionBarY" |
|
33 |
android:layout_width="wrap_content" |
|
34 |
android:layout_height="wrap_content" |
|
35 |
android:layout_marginEnd="5dp" |
|
36 |
android:layout_marginLeft="5dp" |
|
37 |
android:layout_marginRight="5dp" |
|
38 |
android:layout_weight="0.5"/> |
|
39 |
|
|
40 |
</LinearLayout> |
|
41 |
|
|
42 |
<LinearLayout |
|
43 |
android:orientation="horizontal" |
|
44 |
android:layout_width="match_parent" |
|
45 |
android:layout_height="match_parent"> |
|
46 |
|
|
47 |
<SeekBar |
|
48 |
android:id="@+id/effectRegionBarRX" |
|
49 |
android:layout_width="wrap_content" |
|
50 |
android:layout_height="wrap_content" |
|
51 |
android:layout_marginEnd="5dp" |
|
52 |
android:layout_marginLeft="5dp" |
|
53 |
android:layout_marginRight="5dp" |
|
54 |
android:layout_weight="0.5"/> |
|
55 |
|
|
56 |
<SeekBar |
|
57 |
android:id="@+id/effectRegionBarRY" |
|
58 |
android:layout_width="wrap_content" |
|
59 |
android:layout_height="wrap_content" |
|
60 |
android:layout_marginEnd="5dp" |
|
61 |
android:layout_marginLeft="5dp" |
|
62 |
android:layout_marginRight="5dp" |
|
63 |
android:layout_weight="0.5"/> |
|
64 |
|
|
65 |
</LinearLayout> |
|
66 |
</LinearLayout> |
src/main/res/layout/effectregion3.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/effectRegion3Layout" |
|
4 |
android:layout_width="match_parent" |
|
5 |
android:layout_height="wrap_content" |
|
6 |
android:orientation="vertical"> |
|
7 |
|
|
8 |
<TextView |
|
9 |
android:id="@+id/effectRegion3Text" |
|
10 |
android:layout_width="wrap_content" |
|
11 |
android:layout_height="wrap_content" |
|
12 |
android:layout_marginEnd="5dp" |
|
13 |
android:layout_marginStart="5dp" |
|
14 |
android:layout_marginTop="3dp" |
|
15 |
/> |
|
16 |
|
|
17 |
<LinearLayout |
|
18 |
android:orientation="horizontal" |
|
19 |
android:layout_width="match_parent" |
|
20 |
android:layout_height="match_parent"> |
|
21 |
|
|
22 |
<SeekBar |
|
23 |
android:id="@+id/effectRegion3BarRX" |
|
24 |
android:layout_width="wrap_content" |
|
25 |
android:layout_height="wrap_content" |
|
26 |
android:layout_marginEnd="5dp" |
|
27 |
android:layout_marginLeft="5dp" |
|
28 |
android:layout_marginRight="5dp" |
|
29 |
android:layout_weight="1.0"/> |
|
30 |
|
|
31 |
<SeekBar |
|
32 |
android:id="@+id/effectRegion3BarRY" |
|
33 |
android:layout_width="wrap_content" |
|
34 |
android:layout_height="wrap_content" |
|
35 |
android:layout_marginEnd="5dp" |
|
36 |
android:layout_marginLeft="5dp" |
|
37 |
android:layout_marginRight="5dp" |
|
38 |
android:layout_weight="1.0"/> |
|
39 |
|
|
40 |
<SeekBar |
|
41 |
android:id="@+id/effectRegion3BarRZ" |
|
42 |
android:layout_width="wrap_content" |
|
43 |
android:layout_height="wrap_content" |
|
44 |
android:layout_marginEnd="5dp" |
|
45 |
android:layout_marginLeft="5dp" |
|
46 |
android:layout_marginRight="5dp" |
|
47 |
android:layout_weight="1.0"/> |
|
48 |
</LinearLayout> |
|
49 |
|
|
50 |
</LinearLayout> |
src/main/res/layout/effectregion4.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
android:id="@+id/effectRegionLayout" |
|
4 |
android:layout_width="match_parent" |
|
5 |
android:layout_height="wrap_content" |
|
6 |
android:orientation="vertical"> |
|
7 |
|
|
8 |
<TextView |
|
9 |
android:id="@+id/effectRegion4Text" |
|
10 |
android:layout_width="wrap_content" |
|
11 |
android:layout_height="wrap_content" |
|
12 |
android:layout_marginEnd="5dp" |
|
13 |
android:layout_marginStart="5dp" |
|
14 |
android:layout_marginTop="3dp" |
|
15 |
/> |
|
16 |
|
|
17 |
<LinearLayout |
|
18 |
android:orientation="horizontal" |
|
19 |
android:layout_width="match_parent" |
|
20 |
android:layout_height="match_parent"> |
|
21 |
|
|
22 |
<SeekBar |
|
23 |
android:id="@+id/effectRegion4BarX" |
|
24 |
android:layout_width="wrap_content" |
|
25 |
android:layout_height="wrap_content" |
|
26 |
android:layout_marginEnd="5dp" |
|
27 |
android:layout_marginLeft="5dp" |
|
28 |
android:layout_marginRight="5dp" |
|
29 |
android:layout_weight="0.5"/> |
|
30 |
|
|
31 |
<SeekBar |
|
32 |
android:id="@+id/effectRegion4BarY" |
|
33 |
android:layout_width="wrap_content" |
|
34 |
android:layout_height="wrap_content" |
|
35 |
android:layout_marginEnd="5dp" |
|
36 |
android:layout_marginLeft="5dp" |
|
37 |
android:layout_marginRight="5dp" |
|
38 |
android:layout_weight="0.5"/> |
|
39 |
|
|
40 |
</LinearLayout> |
|
41 |
|
|
42 |
<LinearLayout |
|
43 |
android:orientation="horizontal" |
|
44 |
android:layout_width="match_parent" |
|
45 |
android:layout_height="match_parent"> |
|
46 |
|
|
47 |
<SeekBar |
|
48 |
android:id="@+id/effectRegion4BarZ" |
|
49 |
android:layout_width="wrap_content" |
|
50 |
android:layout_height="wrap_content" |
|
51 |
android:layout_marginEnd="5dp" |
|
52 |
android:layout_marginLeft="5dp" |
|
53 |
android:layout_marginRight="5dp" |
|
54 |
android:layout_weight="0.5"/> |
|
55 |
|
|
56 |
<SeekBar |
|
57 |
android:id="@+id/effectRegion4BarR" |
|
58 |
android:layout_width="wrap_content" |
|
59 |
android:layout_height="wrap_content" |
|
60 |
android:layout_marginEnd="5dp" |
|
61 |
android:layout_marginLeft="5dp" |
|
62 |
android:layout_marginRight="5dp" |
|
63 |
android:layout_weight="0.5"/> |
|
64 |
|
|
65 |
</LinearLayout> |
|
66 |
</LinearLayout> |
Also available in: Unified diff
Make the Fragment effects truly 3D: change their 4D 'region' into a 3D 'center' (a point in 3D) and 3D 'region' (which is now a set of 3 radii defining an ellipsoid around the center)
Also corresponding changes to the applications.