Revision 52e8e76a
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/deform/DeformActivity.java | ||
---|---|---|
147 | 147 |
|
148 | 148 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
149 | 149 |
{ |
150 |
switch (bar.getId())
|
|
150 |
if (bar.getId() == R.id.deformSeekRadius)
|
|
151 | 151 |
{ |
152 |
case R.id.deformSeekRadius: DeformSurfaceView view = findViewById(R.id.deformSurfaceView); |
|
153 |
view.getRenderer().setRegionRadius(progress); |
|
154 |
textR.setText(getString(R.string.radius_placeholder,(progress<100 ? (""+progress): "Infinity") )); |
|
155 |
break; |
|
152 |
DeformSurfaceView view = findViewById(R.id.deformSurfaceView); |
|
153 |
view.getRenderer().setRegionRadius(progress); |
|
154 |
textR.setText(getString(R.string.radius_placeholder,(progress<100 ? (""+progress): "Infinity") )); |
|
156 | 155 |
} |
157 | 156 |
} |
158 | 157 |
|
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
76 | 76 |
private VertexEffectDistort mMovingDistort, mReleasedDistort; |
77 | 77 |
private VertexEffectDeform mMovingDeform, mReleasedDeform; |
78 | 78 |
|
79 |
private Dynamic3D mReleasedDistortDynamic, mReleasedDeformDynamic, mReleasedShearDynamic; |
|
80 |
|
|
79 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
80 | 82 |
|
81 | 83 |
DeformRenderer(GLSurfaceView view) |
... | ... | |
91 | 93 |
mEffects.apply( new MatrixEffectScale(mScale) ); |
92 | 94 |
|
93 | 95 |
// DISTORT |
94 |
Dynamic3D releasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
95 |
releasedDistortDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
96 |
mReleasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
97 |
mReleasedDistortDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
96 | 98 |
Dynamic3D movingDistortDynamic = new Dynamic3D(0,0.5f); |
97 | 99 |
movingDistortDynamic.setMode(Dynamic3D.MODE_PATH); |
98 | 100 |
|
... | ... | |
101 | 103 |
for(int i=0; i<NUM_VECTORS; i++) |
102 | 104 |
{ |
103 | 105 |
vDistort[i] = new Static3D(0,0,0); |
104 |
releasedDistortDynamic.add(vDistort[i]);
|
|
106 |
mReleasedDistortDynamic.add(vDistort[i]);
|
|
105 | 107 |
} |
106 | 108 |
|
107 | 109 |
movingDistortDynamic.add(vDistort[0]); |
108 | 110 |
|
109 | 111 |
// Deform |
110 |
Dynamic3D releasedDeformDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
111 |
releasedDeformDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
112 |
mReleasedDeformDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
113 |
mReleasedDeformDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
112 | 114 |
Dynamic3D movingDeformDynamic = new Dynamic3D(0,0.5f); |
113 | 115 |
movingDeformDynamic.setMode(Dynamic3D.MODE_PATH); |
114 | 116 |
|
... | ... | |
117 | 119 |
for(int i=0; i<NUM_VECTORS; i++) |
118 | 120 |
{ |
119 | 121 |
vDeform[i] = new Static3D(0,0,0); |
120 |
releasedDeformDynamic.add(vDeform[i]);
|
|
122 |
mReleasedDeformDynamic.add(vDeform[i]);
|
|
121 | 123 |
} |
122 | 124 |
|
123 | 125 |
movingDeformDynamic.add(vDeform[0]); |
124 | 126 |
|
125 | 127 |
// Shear |
126 |
Dynamic3D releasedShearDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
127 |
releasedShearDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
128 |
mReleasedShearDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
129 |
mReleasedShearDynamic.setMode(Dynamic3D.MODE_PATH);
|
|
128 | 130 |
Dynamic3D movingShearDynamic = new Dynamic3D(0,0.5f); |
129 | 131 |
movingShearDynamic.setMode(Dynamic3D.MODE_PATH); |
130 | 132 |
|
... | ... | |
133 | 135 |
for(int i=0; i<NUM_VECTORS; i++) |
134 | 136 |
{ |
135 | 137 |
vShear[i] = new Static3D(0,0,0); |
136 |
releasedShearDynamic.add(vShear[i]);
|
|
138 |
mReleasedShearDynamic.add(vShear[i]);
|
|
137 | 139 |
} |
138 | 140 |
|
139 | 141 |
movingShearDynamic.add(vShear[0]); |
... | ... | |
143 | 145 |
|
144 | 146 |
Static1D deformRadius = new Static1D(0.5f); |
145 | 147 |
|
146 |
mMovingDistort = new VertexEffectDistort( movingDistortDynamic , mTouchPoint, mRegion); |
|
147 |
mMovingDeform = new VertexEffectDeform ( movingDeformDynamic , deformRadius, mTouchPoint, mRegion); |
|
148 |
mMovingShear = new MatrixEffectShear ( movingShearDynamic , mTouchPoint ); |
|
149 |
mReleasedDistort = new VertexEffectDistort( releasedDistortDynamic, mTouchPoint, mRegion);
|
|
150 |
mReleasedDeform = new VertexEffectDeform ( releasedDeformDynamic , deformRadius, mTouchPoint, mRegion);
|
|
151 |
mReleasedShear = new MatrixEffectShear ( releasedShearDynamic , mTouchPoint );
|
|
148 |
mMovingDistort = new VertexEffectDistort( movingDistortDynamic , mTouchPoint, mRegion);
|
|
149 |
mMovingDeform = new VertexEffectDeform ( movingDeformDynamic , deformRadius, mTouchPoint, mRegion);
|
|
150 |
mMovingShear = new MatrixEffectShear ( movingShearDynamic , mTouchPoint );
|
|
151 |
mReleasedDistort = new VertexEffectDistort( mReleasedDistortDynamic, mTouchPoint, mRegion);
|
|
152 |
mReleasedDeform = new VertexEffectDeform ( mReleasedDeformDynamic , deformRadius, mTouchPoint, mRegion);
|
|
153 |
mReleasedShear = new MatrixEffectShear ( mReleasedShearDynamic , mTouchPoint );
|
|
152 | 154 |
} |
153 | 155 |
|
154 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
301 | 303 |
} |
302 | 304 |
vDistort[NUM_VECTORS-1].set(0,0,0); |
303 | 305 |
mEffects.apply(mReleasedDistort); |
306 |
mReleasedDistortDynamic.resetToBeginning(); |
|
304 | 307 |
mReleasedDistort.notifyWhenFinished(this); |
305 | 308 |
break; |
306 | 309 |
case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++) |
... | ... | |
309 | 312 |
} |
310 | 313 |
vDeform[NUM_VECTORS-1].set(0,0,0); |
311 | 314 |
mEffects.apply(mReleasedDeform); |
315 |
mReleasedDeformDynamic.resetToBeginning(); |
|
312 | 316 |
mReleasedDeform.notifyWhenFinished(this); |
313 | 317 |
break; |
314 | 318 |
case SHEAR : for(int i=1; i<NUM_VECTORS-1; i++) |
... | ... | |
317 | 321 |
} |
318 | 322 |
vShear[NUM_VECTORS-1].set(0,0,0); |
319 | 323 |
mEffects.apply(mReleasedShear); |
324 |
mReleasedShearDynamic.resetToBeginning(); |
|
320 | 325 |
mReleasedShear.notifyWhenFinished(this); |
321 | 326 |
break; |
322 | 327 |
} |
src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java | ||
---|---|---|
66 | 66 |
private PostprocessEffectGlow[] mGlow = new PostprocessEffectGlow[NUM_LEAVES]; |
67 | 67 |
private int mGlowing; |
68 | 68 |
private Static3D mScale; |
69 |
private Dynamic2D mHaloAndRadiusDyn; |
|
70 |
private Dynamic4D[] mColorDyn; |
|
69 | 71 |
|
70 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 73 |
|
... | ... | |
108 | 110 |
root.attach(node); |
109 | 111 |
} |
110 | 112 |
|
111 |
Dynamic2D haloAndRadiusDyn = new Dynamic2D(FLASH_TIME,1.0f); |
|
112 |
haloAndRadiusDyn.add(new Static2D( 0, 0)); |
|
113 |
haloAndRadiusDyn.add(new Static2D(70,50)); |
|
113 |
mHaloAndRadiusDyn = new Dynamic2D(FLASH_TIME,1.0f); |
|
114 |
mHaloAndRadiusDyn.add(new Static2D( 0, 0)); |
|
115 |
mHaloAndRadiusDyn.add(new Static2D(70,50)); |
|
116 |
|
|
117 |
mColorDyn = new Dynamic4D[NUM_LEAVES]; |
|
114 | 118 |
|
115 | 119 |
for(int leaf=0; leaf<NUM_LEAVES; leaf++) |
116 | 120 |
{ |
117 |
Dynamic4D color= new Dynamic4D(FLASH_TIME,1.0f);
|
|
118 |
Static4D P1 = new Static4D(colors[3*leaf],colors[3*leaf+1], colors[3*leaf+2], 0.0f); |
|
119 |
Static4D P2 = new Static4D(colors[3*leaf],colors[3*leaf+1], colors[3*leaf+2], 1.0f); |
|
120 |
color.add(P1);
|
|
121 |
color.add(P2);
|
|
121 |
mColorDyn[leaf] = new Dynamic4D(FLASH_TIME,1.0f);
|
|
122 |
Static4D P1 = new Static4D(colors[3*leaf],colors[3*leaf+1], colors[3*leaf+2], 0.0f);
|
|
123 |
Static4D P2 = new Static4D(colors[3*leaf],colors[3*leaf+1], colors[3*leaf+2], 1.0f);
|
|
124 |
mColorDyn[leaf].add(P1);
|
|
125 |
mColorDyn[leaf].add(P2);
|
|
122 | 126 |
|
123 |
mGlow[leaf] = new PostprocessEffectGlow(haloAndRadiusDyn,color);
|
|
127 |
mGlow[leaf] = new PostprocessEffectGlow(mHaloAndRadiusDyn,mColorDyn[leaf]);
|
|
124 | 128 |
} |
125 | 129 |
|
126 | 130 |
makeGlow(0); |
... | ... | |
135 | 139 |
{ |
136 | 140 |
mGlowing = leaf; |
137 | 141 |
mLeafEffects[leaf].apply(mGlow[leaf]); |
142 |
mHaloAndRadiusDyn.resetToBeginning(); |
|
143 |
mColorDyn[leaf].resetToBeginning(); |
|
138 | 144 |
mGlow[leaf].notifyWhenFinished(this); |
139 | 145 |
} |
140 | 146 |
|
Also available in: Unified diff
Before somehow the Dynamics sometimes tolerated not being reset to beginning before next use. New version doesn't - correct that in two apps.