Revision 06366d12
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 24 | 24 |
import android.widget.TextView; |
| 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; |
|
| 35 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 36 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
| 37 |
import org.distorted.library.effect.MatrixEffectRotate; |
|
| 38 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 39 |
import org.distorted.library.effect.MatrixEffectShear; |
|
| 40 |
import org.distorted.library.effect.VertexEffectDeform; |
|
| 41 |
import org.distorted.library.effect.VertexEffectDistort; |
|
| 42 |
import org.distorted.library.effect.VertexEffectPinch; |
|
| 43 |
import org.distorted.library.effect.VertexEffectSink; |
|
| 44 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
| 45 |
import org.distorted.library.effect.VertexEffectWave; |
|
| 29 | 46 |
import org.distorted.library.main.DistortedEffects; |
| 30 | 47 |
import org.distorted.library.type.Dynamic1D; |
| 31 | 48 |
import org.distorted.library.type.Dynamic2D; |
| ... | ... | |
| 79 | 96 |
|
| 80 | 97 |
void apply(DistortedEffects effects) |
| 81 | 98 |
{
|
| 99 |
Effect effect=null; |
|
| 100 |
|
|
| 82 | 101 |
switch(mName) |
| 83 | 102 |
{
|
| 84 |
case ROTATE : mId = effects.rotate (mDyn4, mCenterDyn); break; |
|
| 85 |
case QUATERNION : mId = effects.quaternion(mDyn4, mCenterDyn); break; |
|
| 86 |
case MOVE : mId = effects.move (mDyn3) ; break; |
|
| 87 |
case SCALE : mId = effects.scale (mDyn3) ; break; |
|
| 88 |
case SHEAR : mId = effects.shear (mDyn3, mCenterDyn); break; |
|
| 89 |
|
|
| 90 |
case DISTORT : mId = effects.distort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 91 |
case DEFORM : mId = effects.deform (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 92 |
case SINK : mId = effects.sink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 93 |
case PINCH : mId = effects.pinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
| 94 |
case SWIRL : mId = effects.swirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 95 |
case WAVE : mId = effects.wave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
| 96 |
|
|
| 97 |
case ALPHA : mId = effects.alpha (mDyn1, mRegionDyn, false); break; |
|
| 98 |
case SMOOTH_ALPHA : mId = effects.alpha (mDyn1, mRegionDyn, true ); break; |
|
| 99 |
case CHROMA : mId = effects.chroma (mDyn1, mDyn3, mRegionDyn, false); break; |
|
| 100 |
case SMOOTH_CHROMA : mId = effects.chroma (mDyn1, mDyn3, mRegionDyn, true ); break; |
|
| 101 |
case BRIGHTNESS : mId = effects.brightness(mDyn1, mRegionDyn, false); break; |
|
| 102 |
case SMOOTH_BRIGHTNESS: mId = effects.brightness(mDyn1, mRegionDyn, true ); break; |
|
| 103 |
case SATURATION : mId = effects.saturation(mDyn1, mRegionDyn, false); break; |
|
| 104 |
case SMOOTH_SATURATION: mId = effects.saturation(mDyn1, mRegionDyn, true ); break; |
|
| 105 |
case CONTRAST : mId = effects.contrast (mDyn1, mRegionDyn, false); break; |
|
| 106 |
case SMOOTH_CONTRAST : mId = effects.contrast (mDyn1, mRegionDyn, true ); break; |
|
| 107 |
|
|
| 108 |
default: mId = -1; |
|
| 103 |
case ROTATE : effect = new MatrixEffectRotate(mDyn4, mCenterDyn); break; |
|
| 104 |
case QUATERNION : effect = new MatrixEffectQuaternion(mDyn4, mCenterDyn); break; |
|
| 105 |
case MOVE : effect = new MatrixEffectMove(mDyn3) ; break; |
|
| 106 |
case SCALE : effect = new MatrixEffectScale(mDyn3) ; break; |
|
| 107 |
case SHEAR : effect = new MatrixEffectShear(mDyn3, mCenterDyn); break; |
|
| 108 |
|
|
| 109 |
case DISTORT : effect = new VertexEffectDistort(mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 110 |
case DEFORM : effect = new VertexEffectDeform(mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 111 |
case SINK : effect = new VertexEffectSink(mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 112 |
case PINCH : effect = new VertexEffectPinch(mDyn2, mCenterDyn, mRegionDyn); break; |
|
| 113 |
case SWIRL : effect = new VertexEffectSwirl(mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 114 |
case WAVE : effect = new VertexEffectWave(mDyn5, mCenterDyn, mRegionDyn); break; |
|
| 115 |
|
|
| 116 |
case ALPHA : effect = new FragmentEffectAlpha(mDyn1, mRegionDyn, false); break; |
|
| 117 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, true ); break; |
|
| 118 |
case CHROMA : effect = new FragmentEffectChroma(mDyn1, mDyn3, mRegionDyn, false); break; |
|
| 119 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, true ); break; |
|
| 120 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, false); break; |
|
| 121 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, true ); break; |
|
| 122 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, false); break; |
|
| 123 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, true ); break; |
|
| 124 |
case CONTRAST : effect = new FragmentEffectContrast(mDyn1, mRegionDyn, false); break; |
|
| 125 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, true ); break; |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
if( effect!=null ) |
|
| 129 |
{
|
|
| 130 |
effects.apply(effect); |
|
| 131 |
mId = effect.getID(); |
|
| 109 | 132 |
} |
| 110 | 133 |
} |
| 111 | 134 |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 24 | 24 |
import android.opengl.GLSurfaceView; |
| 25 | 25 |
|
| 26 | 26 |
import org.distorted.examples.R; |
| 27 |
import org.distorted.library.effect.EffectName; |
|
| 28 |
import org.distorted.library.effect.EffectType; |
|
| 29 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 30 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
| 31 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 27 | 32 |
import org.distorted.library.main.Distorted; |
| 28 | 33 |
import org.distorted.library.main.DistortedEffects; |
| 29 | 34 |
import org.distorted.library.main.DistortedNode; |
| 30 | 35 |
import org.distorted.library.main.DistortedScreen; |
| 31 | 36 |
import org.distorted.library.main.DistortedTexture; |
| 32 |
import org.distorted.library.EffectNames; |
|
| 33 | 37 |
import org.distorted.library.main.MeshFlat; |
| 34 | 38 |
import org.distorted.library.main.MeshObject; |
| 35 |
import org.distorted.library.EffectTypes; |
|
| 36 |
import org.distorted.library.type.Dynamic3D; |
|
| 37 |
import org.distorted.library.type.DynamicQuat; |
|
| 38 | 39 |
import org.distorted.library.type.Static3D; |
| 39 | 40 |
import org.distorted.library.type.Static4D; |
| 40 | 41 |
|
| ... | ... | |
| 53 | 54 |
|
| 54 | 55 |
private GLSurfaceView mView; |
| 55 | 56 |
private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
| 56 |
private DistortedEffects mObjectEffects, mBackgroundEffects, mCenterEffects, mRegionEffects; |
|
| 57 | 57 |
private DistortedScreen mScreen; |
| 58 | 58 |
private DistortedNode mCenterNode, mRegionNode; |
| 59 |
private int mObjWidth, mObjHeight, mObjDepth; |
|
| 60 |
private DynamicQuat mQuatInt1, mQuatInt2; |
|
| 61 |
|
|
| 62 |
private Dynamic3D mCenterInter, mRegionInter; |
|
| 63 |
private Static3D mCenterPoint, mRegionPoint; |
|
| 64 |
private Dynamic3D mRegionScaleInter; |
|
| 65 |
private Static3D mRegionScalePoint; |
|
| 59 |
private int mObjWidth, mObjHeight; |
|
| 60 |
private Static3D mCenterPoint, mRegionPoint, mRegionScalePoint; |
|
| 61 |
private Static3D mRotateCen, mMoveObject, mMoveCenter, mScaleCenter, mMoveRegion, mMoveBackground, mScaleBackground; |
|
| 66 | 62 |
|
| 67 | 63 |
private float mFactorObj, mFactorReg; |
| 68 | 64 |
|
| ... | ... | |
| 79 | 75 |
|
| 80 | 76 |
Effects3DActivity act = (Effects3DActivity)v.getContext(); |
| 81 | 77 |
|
| 78 |
mRotateCen = new Static3D(0,0,0); |
|
| 79 |
mMoveObject = new Static3D(0,0,0); |
|
| 80 |
mMoveCenter = new Static3D(0,0,0); |
|
| 81 |
mScaleCenter = new Static3D(1,1,1); |
|
| 82 |
mMoveRegion = new Static3D(0,0,0); |
|
| 83 |
mMoveBackground = new Static3D(0,0,0); |
|
| 84 |
mScaleBackground= new Static3D(1,1,1); |
|
| 85 |
|
|
| 82 | 86 |
mObjectTexture = act.getTexture(); |
| 83 |
mObjectEffects = act.getEffects(); |
|
| 84 | 87 |
mBackgroundTexture = new DistortedTexture(100,100); |
| 85 | 88 |
mCenterTexture = new DistortedTexture(100,100); |
| 86 | 89 |
mRegionTexture = new DistortedTexture(100,100); |
| 87 |
mBackgroundEffects = new DistortedEffects(); |
|
| 88 |
mCenterEffects = new DistortedEffects(); |
|
| 89 |
mRegionEffects = new DistortedEffects(); |
|
| 90 |
|
|
| 91 |
DistortedEffects objectEffects = act.getEffects(); |
|
| 92 |
DistortedEffects backgroundEffects = new DistortedEffects(); |
|
| 93 |
DistortedEffects centerEffects = new DistortedEffects(); |
|
| 94 |
DistortedEffects regionEffects = new DistortedEffects(); |
|
| 90 | 95 |
|
| 91 | 96 |
MeshObject meshO = act.getMesh(); |
| 92 | 97 |
MeshFlat quad = new MeshFlat(1,1); |
| 93 | 98 |
|
| 94 | 99 |
mObjWidth = mObjectTexture.getWidth(); |
| 95 | 100 |
mObjHeight= mObjectTexture.getHeight(); |
| 96 |
mObjDepth = mObjectTexture.getDepth(meshO);
|
|
| 101 |
int objDepth = mObjectTexture.getDepth(meshO);
|
|
| 97 | 102 |
|
| 98 | 103 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 99 | 104 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| 100 | 105 |
|
| 101 |
mQuatInt1 = new DynamicQuat(0,0.5f); |
|
| 102 |
mQuatInt2 = new DynamicQuat(0,0.5f); |
|
| 103 |
|
|
| 104 |
mQuatInt1.add(mQuat1); |
|
| 105 |
mQuatInt2.add(mQuat2); |
|
| 106 |
|
|
| 107 |
mCenterInter= new Dynamic3D(); |
|
| 108 | 106 |
mCenterPoint= new Static3D(0,0,0); |
| 109 |
mCenterInter.add(mCenterPoint); |
|
| 110 |
|
|
| 111 |
mRegionInter= new Dynamic3D(); |
|
| 112 | 107 |
mRegionPoint= new Static3D(0,0,0); |
| 113 |
mRegionInter.add(mRegionPoint); |
|
| 114 |
|
|
| 115 |
mRegionScaleInter = new Dynamic3D(); |
|
| 116 | 108 |
mRegionScalePoint = new Static3D(0,0,0); |
| 117 |
mRegionScaleInter.add(mRegionScalePoint); |
|
| 118 | 109 |
|
| 119 |
mCenterNode = new DistortedNode(mCenterTexture, mCenterEffects, quad);
|
|
| 120 |
mRegionNode = new DistortedNode(mRegionTexture, mRegionEffects, quad);
|
|
| 110 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, quad);
|
|
| 111 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, quad);
|
|
| 121 | 112 |
|
| 122 | 113 |
mScreen = new DistortedScreen(mView); |
| 123 | 114 |
mScreen.setProjection(FOV, NEAR); |
| 124 |
mScreen.attach(mBackgroundTexture, mBackgroundEffects, quad ); |
|
| 125 |
mScreen.attach(mObjectTexture , mObjectEffects , meshO); |
|
| 115 |
mScreen.attach(mBackgroundTexture, backgroundEffects, quad ); |
|
| 116 |
mScreen.attach(mObjectTexture , objectEffects , meshO); |
|
| 117 |
|
|
| 118 |
int regionSize = mRegionTexture.getWidth(); |
|
| 119 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)objDepth/2 ); |
|
| 120 |
mRotateCen = new Static3D(0 ,0, 0); |
|
| 121 |
|
|
| 122 |
MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1, rotateObj); |
|
| 123 |
MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2, rotateObj); |
|
| 124 |
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, mRotateCen); |
|
| 125 |
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, mRotateCen); |
|
| 126 |
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint); |
|
| 127 |
|
|
| 128 |
objectEffects.apply( new MatrixEffectMove(mMoveObject)); |
|
| 129 |
objectEffects.apply( new MatrixEffectScale(mFactorObj) ); |
|
| 130 |
objectEffects.apply(quat1obj); |
|
| 131 |
objectEffects.apply(quat2obj); |
|
| 132 |
|
|
| 133 |
centerEffects.apply(quat1cen); |
|
| 134 |
centerEffects.apply(quat2cen); |
|
| 135 |
centerEffects.apply( new MatrixEffectMove(mMoveCenter) ); |
|
| 136 |
centerEffects.apply( centerMove ); |
|
| 137 |
centerEffects.apply( new MatrixEffectScale(mScaleCenter) ); |
|
| 138 |
|
|
| 139 |
regionEffects.apply(quat1cen); |
|
| 140 |
regionEffects.apply(quat2cen); |
|
| 141 |
regionEffects.apply( new MatrixEffectMove(mMoveRegion) ); |
|
| 142 |
regionEffects.apply( centerMove ); |
|
| 143 |
regionEffects.apply( new MatrixEffectMove(mRegionPoint) ); |
|
| 144 |
regionEffects.apply( new MatrixEffectScale(mRegionScalePoint) ); |
|
| 145 |
regionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize/2 , -regionSize/2 , 0)) ); |
|
| 146 |
|
|
| 147 |
// quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() ) |
|
| 148 |
backgroundEffects.apply(new MatrixEffectMove(mMoveBackground) ); |
|
| 149 |
backgroundEffects.apply(new MatrixEffectScale(mScaleBackground) ); |
|
| 126 | 150 |
} |
| 127 | 151 |
|
| 128 | 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 175 | 199 |
{
|
| 176 | 200 |
mScreenMin = width<height ? width:height; |
| 177 | 201 |
|
| 178 |
mObjectEffects.abortEffects(EffectTypes.MATRIX); |
|
| 179 |
mBackgroundEffects.abortEffects(EffectTypes.MATRIX); |
|
| 180 |
mCenterEffects.abortEffects(EffectTypes.MATRIX); |
|
| 181 |
mRegionEffects.abortEffects(EffectTypes.MATRIX); |
|
| 182 |
|
|
| 183 | 202 |
float factorCen; |
| 184 | 203 |
int centerSize = mCenterTexture.getWidth(); |
| 185 | 204 |
int regionSize = mRegionTexture.getWidth(); |
| ... | ... | |
| 198 | 217 |
Effects3DActivity act = (Effects3DActivity)mView.getContext(); |
| 199 | 218 |
mCenterPoint.set(mFactorObj*act.getCenterX(),mFactorObj*act.getCenterY(),0); |
| 200 | 219 |
mRegionPoint.set(mFactorObj*act.getRegionX(),mFactorObj*act.getRegionY(),0); |
| 201 |
|
|
| 202 | 220 |
mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize; |
| 203 | 221 |
mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg); |
| 222 |
mMoveObject.set( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0 ); |
|
| 223 |
mRotateCen.set(width/2,height/2, 0); |
|
| 204 | 224 |
|
| 205 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 ); |
|
| 206 |
|
|
| 207 |
mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) ); |
|
| 208 |
mObjectEffects.scale(mFactorObj); |
|
| 209 |
mObjectEffects.quaternion(mQuatInt1, rotateObj); |
|
| 210 |
mObjectEffects.quaternion(mQuatInt2, rotateObj); |
|
| 211 |
|
|
| 212 |
Static3D rotateCen = new Static3D(width/2,height/2, 0); |
|
| 213 |
|
|
| 214 |
mCenterEffects.quaternion(mQuatInt1, rotateCen); |
|
| 215 |
mCenterEffects.quaternion(mQuatInt2, rotateCen); |
|
| 216 |
|
|
| 217 |
mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 , |
|
| 218 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15) ); |
|
| 219 |
mCenterEffects.move(mCenterInter); |
|
| 220 |
mCenterEffects.scale(factorCen); |
|
| 221 |
|
|
| 222 |
mRegionEffects.quaternion(mQuatInt1, rotateCen); |
|
| 223 |
mRegionEffects.quaternion(mQuatInt2, rotateCen); |
|
| 224 |
|
|
| 225 |
mRegionEffects.move( new Static3D( (width -mFactorObj*mObjWidth )/2 , |
|
| 226 |
(height-mFactorObj*mObjHeight)/2 , 12) ); |
|
| 227 |
mRegionEffects.move(mCenterInter); |
|
| 228 |
mRegionEffects.move(mRegionInter); |
|
| 229 |
mRegionEffects.scale(mRegionScaleInter); |
|
| 230 |
mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) ); |
|
| 225 |
mMoveCenter.set( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 , |
|
| 226 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15 ); |
|
| 227 |
mScaleCenter.set(factorCen,factorCen,factorCen); |
|
| 228 |
mMoveRegion.set( (width -mFactorObj*mObjWidth )/2 ,(height-mFactorObj*mObjHeight)/2 , 12 ); |
|
| 231 | 229 |
|
| 232 | 230 |
int backgroundSize = mBackgroundTexture.getWidth(); |
| 233 | 231 |
float factorBackX = ((float)width)/backgroundSize; |
| 234 | 232 |
float factorBackY = ((float)height)/backgroundSize; |
| 235 | 233 |
|
| 236 | 234 |
// quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() ) |
| 237 |
mBackgroundEffects.move(new Static3D( -width/2, -height/2, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360))) );
|
|
| 238 |
mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
|
|
| 235 |
mMoveBackground.set( -width/2, -height/2, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) );
|
|
| 236 |
mScaleBackground.set( 2*factorBackX, 2*factorBackY, 1.0f );
|
|
| 239 | 237 |
|
| 240 | 238 |
mScreen.resize(width, height); |
| 241 | 239 |
} |
| ... | ... | |
| 274 | 272 |
mCenterTexture.setTexture(bitmapC); |
| 275 | 273 |
mRegionTexture.setTexture(bitmapR); |
| 276 | 274 |
|
| 277 |
EffectTypes type;
|
|
| 275 |
EffectType type; |
|
| 278 | 276 |
|
| 279 |
for( EffectNames name : EffectNames.values() )
|
|
| 277 |
for( EffectName name : EffectName.values() )
|
|
| 280 | 278 |
{
|
| 281 | 279 |
type = name.getType(); |
| 282 | 280 |
|
| 283 |
if( type== EffectTypes.VERTEX || type==EffectTypes.FRAGMENT )
|
|
| 281 |
if( type== EffectType.VERTEX || type==EffectType.FRAGMENT )
|
|
| 284 | 282 |
{
|
| 285 | 283 |
DistortedEffects.enableEffect(name); |
| 286 | 284 |
} |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.java | ||
|---|---|---|
| 24 | 24 |
import android.widget.TextView; |
| 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; |
|
| 35 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 36 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
| 37 |
import org.distorted.library.effect.MatrixEffectRotate; |
|
| 38 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 39 |
import org.distorted.library.effect.MatrixEffectShear; |
|
| 40 |
import org.distorted.library.effect.VertexEffectDeform; |
|
| 41 |
import org.distorted.library.effect.VertexEffectDistort; |
|
| 42 |
import org.distorted.library.effect.VertexEffectPinch; |
|
| 43 |
import org.distorted.library.effect.VertexEffectSink; |
|
| 44 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
| 45 |
import org.distorted.library.effect.VertexEffectWave; |
|
| 29 | 46 |
import org.distorted.library.main.DistortedEffects; |
| 30 | 47 |
import org.distorted.library.type.Dynamic1D; |
| 31 | 48 |
import org.distorted.library.type.Dynamic2D; |
| ... | ... | |
| 79 | 96 |
|
| 80 | 97 |
void apply(DistortedEffects effects) |
| 81 | 98 |
{
|
| 99 |
Effect effect=null; |
|
| 100 |
|
|
| 82 | 101 |
switch(mName) |
| 83 | 102 |
{
|
| 84 |
case ROTATE : mId = effects.rotate (mDyn4, mCenterDyn); break; |
|
| 85 |
case QUATERNION : mId = effects.quaternion(mDyn4, mCenterDyn); break; |
|
| 86 |
case MOVE : mId = effects.move (mDyn3) ; break; |
|
| 87 |
case SCALE : mId = effects.scale (mDyn3) ; break; |
|
| 88 |
case SHEAR : mId = effects.shear (mDyn3, mCenterDyn); break; |
|
| 89 |
|
|
| 90 |
case DISTORT : mId = effects.distort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 91 |
case DEFORM : mId = effects.deform (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 92 |
case SINK : mId = effects.sink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 93 |
case PINCH : mId = effects.pinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
| 94 |
case SWIRL : mId = effects.swirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 95 |
case WAVE : mId = effects.wave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
| 96 |
|
|
| 97 |
case ALPHA : mId = effects.alpha (mDyn1, mRegionDyn, false); break; |
|
| 98 |
case SMOOTH_ALPHA : mId = effects.alpha (mDyn1, mRegionDyn, true ); break; |
|
| 99 |
case CHROMA : mId = effects.chroma (mDyn1, mDyn3, mRegionDyn, false); break; |
|
| 100 |
case SMOOTH_CHROMA : mId = effects.chroma (mDyn1, mDyn3, mRegionDyn, true ); break; |
|
| 101 |
case BRIGHTNESS : mId = effects.brightness(mDyn1, mRegionDyn, false); break; |
|
| 102 |
case SMOOTH_BRIGHTNESS: mId = effects.brightness(mDyn1, mRegionDyn, true ); break; |
|
| 103 |
case SATURATION : mId = effects.saturation(mDyn1, mRegionDyn, false); break; |
|
| 104 |
case SMOOTH_SATURATION: mId = effects.saturation(mDyn1, mRegionDyn, true ); break; |
|
| 105 |
case CONTRAST : mId = effects.contrast (mDyn1, mRegionDyn, false); break; |
|
| 106 |
case SMOOTH_CONTRAST : mId = effects.contrast (mDyn1, mRegionDyn, true ); break; |
|
| 107 |
|
|
| 108 |
default: mId = -1; |
|
| 103 |
case ROTATE : effect = new MatrixEffectRotate (mDyn4, mCenterDyn); break; |
|
| 104 |
case QUATERNION : effect = new MatrixEffectQuaternion (mDyn4, mCenterDyn); break; |
|
| 105 |
case MOVE : effect = new MatrixEffectMove (mDyn3) ; break; |
|
| 106 |
case SCALE : effect = new MatrixEffectScale (mDyn3) ; break; |
|
| 107 |
case SHEAR : effect = new MatrixEffectShear (mDyn3, mCenterDyn); break; |
|
| 108 |
|
|
| 109 |
case DISTORT : effect = new VertexEffectDistort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 110 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 111 |
case SINK : effect = new VertexEffectSink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 112 |
case PINCH : effect = new VertexEffectPinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
| 113 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 114 |
case WAVE : effect = new VertexEffectWave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
| 115 |
|
|
| 116 |
case ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, false); break; |
|
| 117 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, true ); break; |
|
| 118 |
case CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, false); break; |
|
| 119 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, true ); break; |
|
| 120 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, false); break; |
|
| 121 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, true ); break; |
|
| 122 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, false); break; |
|
| 123 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, true ); break; |
|
| 124 |
case CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, false); break; |
|
| 125 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, true ); break; |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
if( effect!=null ) |
|
| 129 |
{
|
|
| 130 |
effects.apply(effect); |
|
| 131 |
mId = effect.getID(); |
|
| 109 | 132 |
} |
| 110 | 133 |
} |
| 111 | 134 |
|
Also available in: Unified diff
Progress with the last 2 APPs.