Revision 66d31749
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
|---|---|---|
| 30 | 30 |
import org.distorted.library.effect.PostprocessEffectBlur; |
| 31 | 31 |
import org.distorted.library.main.Distorted; |
| 32 | 32 |
import org.distorted.library.main.DistortedEffects; |
| 33 |
import org.distorted.library.main.DistortedEffectsPostprocess; |
|
| 34 | 33 |
import org.distorted.library.main.DistortedNode; |
| 35 | 34 |
import org.distorted.library.main.DistortedScreen; |
| 36 | 35 |
import org.distorted.library.main.DistortedTexture; |
| ... | ... | |
| 52 | 51 |
private GLSurfaceView mView; |
| 53 | 52 |
private DistortedTexture mTexture; |
| 54 | 53 |
private DistortedEffects mEffects; |
| 55 |
private DistortedEffectsPostprocess mPostEffects; |
|
| 56 | 54 |
private DistortedScreen mScreen; |
| 57 | 55 |
private MeshFlat mMesh; |
| 58 | 56 |
private Static1D mRadiusSta; |
| ... | ... | |
| 63 | 61 |
|
| 64 | 62 |
BlurRenderer(GLSurfaceView v) |
| 65 | 63 |
{
|
| 66 |
mView = v; |
|
| 67 |
mMesh = new MeshFlat(1,1); |
|
| 68 |
mEffects = new DistortedEffects(); |
|
| 69 |
mPostEffects = new DistortedEffectsPostprocess(); |
|
| 70 |
mScreen = new DistortedScreen(mView); |
|
| 64 |
mView = v; |
|
| 65 |
mMesh = new MeshFlat(1,1); |
|
| 66 |
mScreen = new DistortedScreen(mView); |
|
| 71 | 67 |
|
| 72 | 68 |
mRadiusSta = new Static1D(5); |
| 73 | 69 |
Dynamic1D radiusDyn = new Dynamic1D(); |
| ... | ... | |
| 76 | 72 |
mMove = new Static3D(0,0,0); |
| 77 | 73 |
mScale= new Static3D(1,1,1); |
| 78 | 74 |
|
| 79 |
mPostEffects.apply( new PostprocessEffectBlur(radiusDyn) ); |
|
| 75 |
mEffects = new DistortedEffects(); |
|
| 76 |
mEffects.apply( new PostprocessEffectBlur(radiusDyn) ); |
|
| 80 | 77 |
mEffects.apply(new MatrixEffectMove(mMove)); |
| 81 | 78 |
mEffects.apply(new MatrixEffectScale(mScale)); |
| 82 | 79 |
} |
| ... | ... | |
| 146 | 143 |
mTexture.setTexture(bitmap); |
| 147 | 144 |
|
| 148 | 145 |
mScreen.detachAll(); |
| 149 |
DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh); |
|
| 150 |
node.setPostprocessEffects(mPostEffects); |
|
| 151 |
mScreen.attach(node); |
|
| 146 |
mScreen.attach(new DistortedNode(mTexture,mEffects,mMesh)); |
|
| 152 | 147 |
|
| 153 | 148 |
DistortedEffects.enableEffect(EffectName.BLUR); |
| 154 | 149 |
|
| src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
|---|---|---|
| 31 | 31 |
import org.distorted.library.effect.PostprocessEffectBlur; |
| 32 | 32 |
import org.distorted.library.main.Distorted; |
| 33 | 33 |
import org.distorted.library.main.DistortedEffects; |
| 34 |
import org.distorted.library.main.DistortedEffectsPostprocess; |
|
| 35 | 34 |
import org.distorted.library.main.DistortedNode; |
| 36 | 35 |
import org.distorted.library.main.DistortedScreen; |
| 37 | 36 |
import org.distorted.library.main.DistortedTexture; |
| ... | ... | |
| 69 | 68 |
private GLSurfaceView mView; |
| 70 | 69 |
private DistortedTexture mTex1, mTex2; |
| 71 | 70 |
private DistortedNode[] mNode; |
| 72 |
private DistortedEffectsPostprocess mPostEffects; |
|
| 73 | 71 |
private Static3D[] mMoveVector; |
| 74 | 72 |
private Static1D mBlurVector; |
| 75 | 73 |
private DistortedScreen mScreen; |
| 74 |
private PostprocessEffectBlur mBlur; |
|
| 76 | 75 |
private int mDistance; |
| 77 | 76 |
private boolean[] mBlurStatus; |
| 78 | 77 |
private Static3D mMove, mScale, mCenter; |
| ... | ... | |
| 90 | 89 |
mBlurStatus = new boolean[NUM_OBJECTS]; |
| 91 | 90 |
mMoveVector = new Static3D[NUM_OBJECTS]; |
| 92 | 91 |
mNode = new DistortedNode[NUM_OBJECTS]; |
| 93 |
mPostEffects= new DistortedEffectsPostprocess(); |
|
| 94 | 92 |
|
| 95 | 93 |
DistortedEffects[] effects= new DistortedEffects[NUM_OBJECTS]; |
| 96 | 94 |
|
| ... | ... | |
| 102 | 100 |
} |
| 103 | 101 |
|
| 104 | 102 |
mBlurVector = new Static1D(10); |
| 105 |
mPostEffects.apply( new PostprocessEffectBlur(mBlurVector) ); |
|
| 106 | 103 |
|
| 107 | 104 |
MeshCubes mesh = new MeshCubes(1,1,1); |
| 108 | 105 |
|
| ... | ... | |
| 121 | 118 |
mScreen.attach(mNode[i]); |
| 122 | 119 |
} |
| 123 | 120 |
|
| 121 |
mBlur = new PostprocessEffectBlur(mBlurVector); |
|
| 124 | 122 |
mBlurStatus[0] = true; |
| 125 |
mNode[0].setPostprocessEffects(mPostEffects);
|
|
| 123 |
effects[0].apply(mBlur);
|
|
| 126 | 124 |
|
| 127 | 125 |
mMove = new Static3D(0,0,0); |
| 128 | 126 |
mScale = new Static3D(1,1,1); |
| ... | ... | |
| 147 | 145 |
|
| 148 | 146 |
void setQuality(EffectQuality quality) |
| 149 | 147 |
{
|
| 150 |
mPostEffects.setQuality(quality); |
|
| 148 |
DistortedEffects effects; |
|
| 149 |
|
|
| 150 |
for(int i=0; i<NUM_OBJECTS; i++) |
|
| 151 |
{
|
|
| 152 |
effects = mNode[i].getEffects(); |
|
| 153 |
effects.setQuality(quality); |
|
| 154 |
} |
|
| 151 | 155 |
} |
| 152 | 156 |
|
| 153 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 238 | 242 |
|
| 239 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 240 | 244 |
|
| 241 |
boolean[] getChecked() |
|
| 245 |
boolean[] getChecked()
|
|
| 242 | 246 |
{
|
| 243 | 247 |
return mBlurStatus; |
| 244 | 248 |
} |
| 245 | 249 |
|
| 246 | 250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 247 | 251 |
|
| 248 |
void setChecked(int number, boolean checked) |
|
| 249 |
{
|
|
| 250 |
if( number>=0 && number<=7 ) |
|
| 251 |
{
|
|
| 252 |
if( checked && !mBlurStatus[number] ) |
|
| 253 |
{
|
|
| 254 |
mBlurStatus[number] = true; |
|
| 255 |
mNode[number].setPostprocessEffects(mPostEffects);
|
|
| 256 |
} |
|
| 257 |
if( !checked && mBlurStatus[number] ) |
|
| 258 |
{
|
|
| 259 |
mBlurStatus[number] = false; |
|
| 260 |
mNode[number].setPostprocessEffects(null);
|
|
| 261 |
} |
|
| 262 |
} |
|
| 263 |
else |
|
| 264 |
{
|
|
| 265 |
android.util.Log.e("renderer", "Error, number: "+number+" checked: "+checked );
|
|
| 266 |
} |
|
| 267 |
|
|
| 268 |
//android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked);
|
|
| 269 |
} |
|
| 252 |
void setChecked(int number, boolean checked)
|
|
| 253 |
{
|
|
| 254 |
if( number>=0 && number<=7 )
|
|
| 255 |
{
|
|
| 256 |
if( checked && !mBlurStatus[number] )
|
|
| 257 |
{
|
|
| 258 |
mBlurStatus[number] = true;
|
|
| 259 |
mNode[number].getEffects().apply(mBlur);
|
|
| 260 |
}
|
|
| 261 |
if( !checked && mBlurStatus[number] )
|
|
| 262 |
{
|
|
| 263 |
mBlurStatus[number] = false;
|
|
| 264 |
mNode[number].getEffects().abortEffect(mBlur);
|
|
| 265 |
}
|
|
| 266 |
}
|
|
| 267 |
else
|
|
| 268 |
{
|
|
| 269 |
android.util.Log.e("renderer", "Error, number: "+number+" checked: "+checked );
|
|
| 270 |
}
|
|
| 271 |
|
|
| 272 |
//android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked);
|
|
| 273 |
}
|
|
| 270 | 274 |
} |
Also available in: Unified diff
Remove DistortedEffectsPostprocess and unify it with DistortedEffects.
Job not finished - doesn't compile now!