Revision c40df162
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/triblur/TriblurRenderer.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 | 27 |
import org.distorted.library.effect.EffectQuality; |
28 |
import org.distorted.library.effect.EffectType; |
|
28 | 29 |
import org.distorted.library.effect.FragmentEffectChroma; |
29 | 30 |
import org.distorted.library.effect.MatrixEffectMove; |
30 | 31 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
31 | 32 |
import org.distorted.library.effect.MatrixEffectScale; |
32 | 33 |
import org.distorted.library.effect.PostprocessEffectBlur; |
34 |
import org.distorted.library.effect.PostprocessEffectGlow; |
|
33 | 35 |
import org.distorted.library.main.Distorted; |
34 | 36 |
import org.distorted.library.main.DistortedEffects; |
35 | 37 |
import org.distorted.library.main.DistortedNode; |
... | ... | |
65 | 67 |
private GLSurfaceView mView; |
66 | 68 |
private DistortedTexture mTex; |
67 | 69 |
private DistortedNode[] mNode; |
68 |
private Static1D[] mBlurVector;
|
|
70 |
private Static1D[] mEffectVector;
|
|
69 | 71 |
private DistortedScreen mScreen; |
70 | 72 |
private PostprocessEffectBlur[] mBlur; |
71 |
private boolean[] mBlurStatus; |
|
73 |
private PostprocessEffectGlow[] mGlow; |
|
74 |
private int[] mEffectStatus; |
|
72 | 75 |
private Static3D mMove1, mMove2, mScale1, mScale2, mCenter; |
73 | 76 |
|
74 | 77 |
Static4D mQuat1, mQuat2; |
... | ... | |
90 | 93 |
mScreen = new DistortedScreen(); |
91 | 94 |
mScreen.showFPS(); |
92 | 95 |
|
93 |
mBlurStatus = new boolean[NUM_OBJECTS];
|
|
94 |
mBlurVector = new Static1D[NUM_OBJECTS];
|
|
96 |
mEffectStatus = new int[NUM_OBJECTS];
|
|
97 |
mEffectVector = new Static1D[NUM_OBJECTS];
|
|
95 | 98 |
mNode = new DistortedNode[NUM_OBJECTS]; |
96 | 99 |
mBlur = new PostprocessEffectBlur[NUM_OBJECTS]; |
100 |
mGlow = new PostprocessEffectGlow[NUM_OBJECTS]; |
|
97 | 101 |
|
98 | 102 |
FragmentEffectChroma[] chroma= new FragmentEffectChroma[NUM_OBJECTS]; |
99 | 103 |
Static3D[] chromaVector = new Static3D[NUM_OBJECTS]; |
... | ... | |
118 | 122 |
{ |
119 | 123 |
moveVector[i] = new Static3D(OBJECTS[NUM*i ], OBJECTS[NUM*i+1], OBJECTS[NUM*i+2]); |
120 | 124 |
chromaVector[i] = new Static3D(OBJECTS[NUM*i+3], OBJECTS[NUM*i+4], OBJECTS[NUM*i+5]); |
121 |
mBlurVector[i] = new Static1D(10); |
|
122 |
mBlur[i] = new PostprocessEffectBlur(mBlurVector[i]); |
|
125 |
mEffectVector[i] = new Static1D(10); |
|
126 |
mBlur[i] = new PostprocessEffectBlur(mEffectVector[i]); |
|
127 |
mGlow[i] = new PostprocessEffectGlow(mEffectVector[i], new Static4D(1.0f,1.0f,1.0f,0.5f) ); |
|
123 | 128 |
chroma[i] = new FragmentEffectChroma( new Static1D(0.3f), chromaVector[i]); |
124 | 129 |
effects[i] = new DistortedEffects(); |
125 | 130 |
|
... | ... | |
131 | 136 |
effects[i].apply(quatEffect2); |
132 | 137 |
effects[i].apply(new MatrixEffectMove(moveVector[i])); |
133 | 138 |
|
134 |
mBlurStatus[i] = true;
|
|
139 |
mEffectStatus[i] = 1;
|
|
135 | 140 |
mNode[i] = new DistortedNode(mTex, effects[i], mesh ); |
136 | 141 |
mScreen.attach(mNode[i]); |
137 | 142 |
} |
... | ... | |
227 | 232 |
{ |
228 | 233 |
if( object>=0 && object<NUM_OBJECTS ) |
229 | 234 |
{ |
230 |
mBlurVector[object].set(range / 2);
|
|
235 |
mEffectVector[object].set(range / 2);
|
|
231 | 236 |
} |
232 | 237 |
} |
233 | 238 |
|
234 | 239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
235 | 240 |
|
236 |
boolean[] getChecked()
|
|
241 |
int[] getEffects()
|
|
237 | 242 |
{ |
238 |
return mBlurStatus;
|
|
243 |
return mEffectStatus;
|
|
239 | 244 |
} |
240 | 245 |
|
241 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
242 | 247 |
|
243 |
void setChecked(int object, boolean checked)
|
|
248 |
void setEffects(int object, int effect)
|
|
244 | 249 |
{ |
245 | 250 |
if( object>=0 && object<NUM_OBJECTS ) |
246 | 251 |
{ |
247 |
if( checked && !mBlurStatus[object] )
|
|
252 |
if( mEffectStatus[object] != effect )
|
|
248 | 253 |
{ |
249 |
mBlurStatus[object] = true; |
|
250 |
mNode[object].getEffects().apply(mBlur[object]); |
|
251 |
} |
|
252 |
if( !checked && mBlurStatus[object] ) |
|
253 |
{ |
|
254 |
mBlurStatus[object] = false; |
|
255 |
mNode[object].getEffects().abortEffect(mBlur[object]); |
|
254 |
mEffectStatus[object] = effect; |
|
255 |
mNode[object].getEffects().abortByType(EffectType.POSTPROCESS); |
|
256 |
|
|
257 |
if( effect==1 ) mNode[object].getEffects().apply(mBlur[object]); |
|
258 |
if( effect==2 ) mNode[object].getEffects().apply(mGlow[object]); |
|
256 | 259 |
} |
257 | 260 |
} |
258 | 261 |
else |
259 | 262 |
{ |
260 |
android.util.Log.e("renderer", "Error, number: "+object+" checked: "+checked );
|
|
263 |
android.util.Log.e("renderer", "Error, number: "+object+" effect: "+effect );
|
|
261 | 264 |
} |
262 | 265 |
|
263 | 266 |
//android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked); |
Also available in: Unified diff
Improve the Triblur app to be able to switch objects into 1 of 3 states: no postprocessing, blur, glow.