Project

General

Profile

« Previous | Next » 

Revision fa9b6494

Added by Leszek Koltunski over 7 years ago

Convert the first few Apps to the new Effect API.

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
21 21

  
22 22
///////////////////////////////////////////////////////////////////////////////////////////////////
23 23

  
24
import org.distorted.library.effect.FragmentEffectChroma;
25
import org.distorted.library.effect.FragmentEffectContrast;
26
import org.distorted.library.effect.VertexEffectDistort;
27
import org.distorted.library.effect.VertexEffectPinch;
28
import org.distorted.library.effect.VertexEffectSink;
29
import org.distorted.library.effect.VertexEffectSwirl;
24 30
import org.distorted.library.main.DistortedEffects;
25 31
import org.distorted.library.type.Dynamic1D;
26 32
import org.distorted.library.type.Dynamic2D;
......
260 266
    setRace(mBlackness, mAsianness);
261 267

  
262 268
    // WHITENESS
263
    effects.sink(wLipsDyn, wLipsCenter, wLipsRegion);
269
    effects.apply( new VertexEffectSink(wLipsDyn, wLipsCenter, wLipsRegion) );
264 270

  
265 271
    // ASIANNESS
266
    effects.distort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion);
267
    effects.pinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion);
268
    effects.distort(aNostrilsDyn, aNostrilsCenter, aNostrilsRegion);
269
    effects.swirl(aLEyeDyn, aLEyeCenter, aEyesRegion);
270
    effects.swirl(aREyeDyn, aREyeCenter, aEyesRegion);
271
    effects.distort(aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion);
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) );
272 278

  
273
    effects.chroma(aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false);
274
    effects.chroma(aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true);
275
    effects.chroma(aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true);
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 ) );
276 282

  
277 283
    // BLACKNESS
278
    effects.pinch(bFaceDyn, bFaceCenter, bFaceRegion);
279
    effects.distort(bTipLowerDyn, bTipLowerCenter, bTipLowerRegion);
280
    effects.pinch(bWholeNoseDyn, bWholeNoseCenter, bWholeNoseRegion);
281
    effects.pinch(bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion);
282
    effects.pinch(bLipsDyn, bLipsCenter, bLipsRegion);
283

  
284
    effects.chroma(bChromaSkinDyn, bChromaSkin, bSkinColorRegion, false);
285
    effects.chroma(bChromaEyesDyn, bChromaEyes, bLEyeColorRegion, true);
286
    effects.chroma(bChromaEyesDyn, bChromaEyes, bREyeColorRegion, true);
287
    effects.chroma(bChromaPupilDyn, bChromaPupil, bLPupilColorRegion, true);
288
    effects.chroma(bChromaPupilDyn, bChromaPupil, bRPupilColorRegion, true);
289

  
290
    effects.contrast(bContrastDyn);
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) );
295

  
296
    effects.apply( new FragmentEffectContrast(bContrastDyn) );
291 297
    }
292 298

  
293 299
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.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.MatrixEffectMove;
29
import org.distorted.library.effect.MatrixEffectScale;
27 30
import org.distorted.library.main.Distorted;
28 31
import org.distorted.library.main.DistortedEffects;
29 32
import org.distorted.library.main.DistortedScreen;
30
import org.distorted.library.EffectNames;
31 33
import org.distorted.library.main.MeshFlat;
32 34
import org.distorted.library.main.DistortedTexture;
33
import org.distorted.library.EffectTypes;
34 35
import org.distorted.library.type.Static3D;
35 36

  
36 37
import java.io.IOException;
......
51 52
   private AroundTheWorldEffectsManager mManager;
52 53
   private int mObjWidth, mObjHeight;
53 54

  
55
   private Static3D mMove, mScale;
56

  
54 57
///////////////////////////////////////////////////////////////////////////////////////////////////
55 58

  
56 59
   AroundTheWorldRenderer(GLSurfaceView view)
......
58 61
      DistortedEffects.setMaxVertex(12);
59 62
      DistortedEffects.setMaxFragment(9);
60 63

  
64
      mMove = new Static3D(0,0,0);
65
      mScale= new Static3D(1,1,1);
66

  
61 67
      mView = view;
62 68
      mManager = new AroundTheWorldEffectsManager();
63 69
      mEffects = new DistortedEffects();
70
      mEffects.apply(new MatrixEffectMove(mMove));
71
      mEffects.apply(new MatrixEffectScale(mScale));
72

  
64 73
      mManager.apply(mEffects);
65 74
      mScreen = new DistortedScreen(mView);
66 75
      mScreen.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
......
84 93
    
85 94
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
86 95
      {
87
      mEffects.abortEffects(EffectTypes.MATRIX);
88

  
89 96
      if( (float)mObjHeight/mObjWidth > (float)height/width )
90 97
        {
91 98
        int w = (height*mObjWidth)/mObjHeight;
92 99
        float factor = (float)height/mObjHeight;
93
        mEffects.move( new Static3D((width-w)/2,0,0) );
94
        mEffects.scale(factor);
100
        mMove.set((width-w)/2,0,0);
101
        mScale.set(factor,factor,factor);
95 102
        }
96 103
      else
97 104
        {
98 105
        int h = (width*mObjHeight)/mObjWidth;
99 106
        float factor = (float)width/mObjWidth;
100
        mEffects.move( new Static3D(0,(height-h)/2,0) );
101
        mEffects.scale(factor);
107
        mMove.set(0,(height-h)/2,0);
108
        mScale.set(factor,factor,factor);
102 109
        }
103 110

  
104 111
      mScreen.resize(width,height);
......
135 142
      mScreen.detachAll();
136 143
      mScreen.attach(mTexture, mEffects, mMesh);
137 144

  
138
      DistortedEffects.enableEffect(EffectNames.DISTORT);
139
      DistortedEffects.enableEffect(EffectNames.SINK);
140
      DistortedEffects.enableEffect(EffectNames.PINCH);
141
      DistortedEffects.enableEffect(EffectNames.SWIRL);
142
      DistortedEffects.enableEffect(EffectNames.CHROMA);
143
      DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
144
      DistortedEffects.enableEffect(EffectNames.CONTRAST);
145
      DistortedEffects.enableEffect(EffectName.DISTORT);
146
      DistortedEffects.enableEffect(EffectName.SINK);
147
      DistortedEffects.enableEffect(EffectName.PINCH);
148
      DistortedEffects.enableEffect(EffectName.SWIRL);
149
      DistortedEffects.enableEffect(EffectName.CHROMA);
150
      DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA);
151
      DistortedEffects.enableEffect(EffectName.CONTRAST);
145 152

  
146 153
      try
147 154
        {
src/main/java/org/distorted/examples/bean/BeanRenderer.java
27 27

  
28 28
import org.distorted.examples.R;
29 29

  
30
import org.distorted.library.effect.EffectName;
31
import org.distorted.library.effect.MatrixEffectMove;
32
import org.distorted.library.effect.MatrixEffectScale;
33
import org.distorted.library.effect.VertexEffectDistort;
30 34
import org.distorted.library.main.DistortedEffects;
31 35
import org.distorted.library.main.DistortedScreen;
32
import org.distorted.library.EffectNames;
33
import org.distorted.library.EffectTypes;
34 36
import org.distorted.library.main.Distorted;
35 37
import org.distorted.library.main.DistortedTexture;
36 38
import org.distorted.library.main.MeshFlat;
......
51 53
   private DistortedScreen mScreen;
52 54
   private DistortedTexture mTexture;
53 55
   private MeshFlat mMesh;
54
   private int bmpHeight, bmpWidth;
55
    
56
   private int mObjHeight, mObjWidth;
57
   private Static3D mMove, mScale;
58

  
56 59
///////////////////////////////////////////////////////////////////////////////////////////////////
57 60

  
58 61
   BeanRenderer(GLSurfaceView v)
......
85 88
      dRight.add(p1);
86 89
      dRight.add(p1);
87 90

  
91
      mMove = new Static3D(0,0,0);
92
      mScale= new Static3D(1,1,1);
93

  
88 94
      mEffects = new DistortedEffects();
89
      mEffects.distort(dLeft , pLeft , rLeft );
90
      mEffects.distort(dRight, pRight, rRight);
95
      mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft) );
96
      mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight));
97
      mEffects.apply(new MatrixEffectMove(mMove));
98
      mEffects.apply(new MatrixEffectScale(mScale));
91 99

  
92 100
      mScreen = new DistortedScreen(mView);
93 101
      }
94 102

  
95 103
///////////////////////////////////////////////////////////////////////////////////////////////////
96 104
   
97
    public void onDrawFrame(GL10 glUnused) 
105
   public void onDrawFrame(GL10 glUnused)
98 106
      {
99 107
      mScreen.render( System.currentTimeMillis() );
100 108
      }
101 109

  
102 110
///////////////////////////////////////////////////////////////////////////////////////////////////
103 111
    
104
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
105
      { 
106
      mEffects.abortEffects(EffectTypes.MATRIX);
107
         
108
      if( (float)bmpHeight/bmpWidth > (float)height/width )
112
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
113
     {
114
     if( (float)mObjHeight/mObjWidth > (float)height/width )
109 115
        {
110
        int w = (height*bmpWidth)/bmpHeight;
111
        float factor = (float)height/bmpHeight;
112

  
113
        mEffects.move( new Static3D((width-w)/2,0,0) );
114
        mEffects.scale(factor);
116
        int w = (height*mObjWidth)/mObjHeight;
117
        float factor = (float)height/mObjHeight;
118
        mMove.set((width-w)/2,0,0);
119
        mScale.set(factor,factor,factor);
115 120
        }
116 121
      else
117 122
        {
118
        int h = (width*bmpHeight)/bmpWidth;
119
        float factor = (float)width/bmpWidth;
120

  
121
        mEffects.move( new Static3D(0,(height-h)/2,0) );
122
        mEffects.scale(factor);
123
        int h = (width*mObjHeight)/mObjWidth;
124
        float factor = (float)width/mObjWidth;
125
        mMove.set(0,(height-h)/2,0);
126
        mScale.set(factor,factor,factor);
123 127
        }
124
      
125
      mScreen.resize(width, height);
126
      }
128

  
129
      mScreen.resize(width,height);
130
     }
127 131

  
128 132
///////////////////////////////////////////////////////////////////////////////////////////////////
129 133
    
130
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
131
      {
132
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.bean);
133
      Bitmap bitmap;
134
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
135
     {
136
     InputStream is = mView.getContext().getResources().openRawResource(R.raw.bean);
137
     Bitmap bitmap;
134 138
        
135
      try 
136
        {
137
        bitmap = BitmapFactory.decodeStream(is);
138
        } 
139
      finally 
140
        {
141
        try 
142
          {
143
          is.close();
144
          } 
145
        catch(IOException e) { }
146
        }  
139
     try
140
       {
141
       bitmap = BitmapFactory.decodeStream(is);
142
       }
143
     finally
144
       {
145
       try
146
         {
147
         is.close();
148
         }
149
       catch(IOException e) { }
150
       }
147 151
      
148
      bmpHeight = bitmap.getHeight();
149
      bmpWidth  = bitmap.getWidth();
152
     mObjHeight = bitmap.getHeight();
153
     mObjWidth  = bitmap.getWidth();
150 154
      
151
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
152
      mTexture.setTexture(bitmap);
153
      if( mMesh==null ) mMesh = new MeshFlat(25,25*bmpHeight/bmpWidth);
154
      mScreen.detachAll();
155
      mScreen.attach(mTexture,mEffects,mMesh);
156

  
157
      DistortedEffects.enableEffect(EffectNames.DISTORT);
158

  
159
      try
160
        {
161
        Distorted.onCreate(mView.getContext());
162
        }
163
      catch(Exception ex)
164
        {
165
        android.util.Log.e("Bean", ex.getMessage() );
166
        }
167
      }
155
     if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
156
     mTexture.setTexture(bitmap);
157
     if( mMesh==null ) mMesh = new MeshFlat(25,25*mObjHeight/mObjWidth);
158
     mScreen.detachAll();
159
     mScreen.attach(mTexture,mEffects,mMesh);
160

  
161
     DistortedEffects.enableEffect(EffectName.DISTORT);
162

  
163
     try
164
       {
165
       Distorted.onCreate(mView.getContext());
166
       }
167
     catch(Exception ex)
168
       {
169
       android.util.Log.e("Bean", ex.getMessage() );
170
       }
171
     }
168 172
}
src/main/java/org/distorted/examples/blur/BlurRenderer.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.MatrixEffectMove;
29
import org.distorted.library.effect.MatrixEffectScale;
30
import org.distorted.library.effect.PostprocessEffectBlur;
27 31
import org.distorted.library.main.Distorted;
28 32
import org.distorted.library.main.DistortedEffects;
29 33
import org.distorted.library.main.DistortedEffectsPostprocess;
30 34
import org.distorted.library.main.DistortedNode;
31 35
import org.distorted.library.main.DistortedScreen;
32 36
import org.distorted.library.main.DistortedTexture;
33
import org.distorted.library.EffectNames;
34
import org.distorted.library.EffectTypes;
35 37
import org.distorted.library.main.MeshFlat;
36 38
import org.distorted.library.type.Dynamic1D;
37 39
import org.distorted.library.type.Static1D;
......
54 56
    private DistortedScreen mScreen;
55 57
    private MeshFlat mMesh;
56 58
    private Static1D mRadiusSta;
57
    private int bmpHeight, bmpWidth;
59
    private int mObjHeight, mObjWidth;
60
    private Static3D mMove, mScale;
58 61

  
59 62
///////////////////////////////////////////////////////////////////////////////////////////////////
60 63

  
......
70 73
      Dynamic1D radiusDyn = new Dynamic1D();
71 74
      radiusDyn.add(mRadiusSta);
72 75

  
73
      mPostEffects.blur(radiusDyn);
76
      mMove = new Static3D(0,0,0);
77
      mScale= new Static3D(1,1,1);
78

  
79
      mPostEffects.apply( new PostprocessEffectBlur(radiusDyn) );
80
      mEffects.apply(new MatrixEffectMove(mMove));
81
      mEffects.apply(new MatrixEffectScale(mScale));
74 82
      }
75 83

  
76 84
///////////////////////////////////////////////////////////////////////////////////////////////////
......
91 99

  
92 100
///////////////////////////////////////////////////////////////////////////////////////////////////
93 101
    
94
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
95
      { 
96
      mEffects.abortEffects(EffectTypes.MATRIX);
97
      
98
      if( (float)bmpHeight/bmpWidth > (float)height/width )
99
        {
100
        int w = (height*bmpWidth)/bmpHeight;
101
        float factor = (float)height/bmpHeight;
102

  
103
        mEffects.move( new Static3D((width-w)/2,0,0) );
104
        mEffects.scale(factor);
105
        }
106
      else
107
        {
108
        int h = (width*bmpHeight)/bmpWidth;
109
        float factor = (float)width/bmpWidth;
110

  
111
        mEffects.move( new Static3D(0,(height-h)/2,0) );
112
        mEffects.scale(factor);
113
        }
114
      
115
      mScreen.resize(width, height);
116
      }
102
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
103
     {
104
     if( (float)mObjHeight/mObjWidth > (float)height/width )
105
       {
106
       int w = (height*mObjWidth)/mObjHeight;
107
       float factor = (float)height/mObjHeight;
108
       mMove.set((width-w)/2,0,0);
109
       mScale.set(factor,factor,factor);
110
       }
111
     else
112
       {
113
       int h = (width*mObjHeight)/mObjWidth;
114
       float factor = (float)width/mObjWidth;
115
       mMove.set(0,(height-h)/2,0);
116
       mScale.set(factor,factor,factor);
117
       }
118

  
119
     mScreen.resize(width,height);
120
     }
117 121

  
118 122
///////////////////////////////////////////////////////////////////////////////////////////////////
119 123
    
120
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
121
      {
122
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
123
      Bitmap bitmap;
124
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
125
     {
126
     InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
127
     Bitmap bitmap;
124 128
        
125
      try 
126
        {
127
        bitmap = BitmapFactory.decodeStream(is);
128
        } 
129
      finally 
130
        {
131
        try 
132
          {
133
          is.close();
134
          } 
135
        catch(IOException e) { }
136
        }  
129
     try
130
       {
131
       bitmap = BitmapFactory.decodeStream(is);
132
       }
133
     finally
134
       {
135
       try
136
         {
137
         is.close();
138
         }
139
       catch(IOException e) { }
140
       }
137 141
      
138
      bmpHeight = bitmap.getHeight();
139
      bmpWidth  = bitmap.getWidth();
140

  
141
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
142
      mTexture.setTexture(bitmap);
143

  
144
      mScreen.detachAll();
145
      DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh);
146
      node.setPostprocessEffects(mPostEffects);
147
      mScreen.attach(node);
148

  
149
      DistortedEffects.enableEffect(EffectNames.BLUR);
150

  
151
      try
152
        {
153
        Distorted.onCreate(mView.getContext());
154
        }
155
      catch(Exception ex)
156
        {
157
        android.util.Log.e("Blur", ex.getMessage() );
158
        }
159
      }
142
     mObjHeight = bitmap.getHeight();
143
     mObjWidth  = bitmap.getWidth();
144

  
145
     if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
146
     mTexture.setTexture(bitmap);
147

  
148
     mScreen.detachAll();
149
     DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh);
150
     node.setPostprocessEffects(mPostEffects);
151
     mScreen.attach(node);
152

  
153
     DistortedEffects.enableEffect(EffectName.BLUR);
154

  
155
     try
156
       {
157
       Distorted.onCreate(mView.getContext());
158
       }
159
     catch(Exception ex)
160
       {
161
       android.util.Log.e("Blur", ex.getMessage() );
162
       }
163
     }
160 164
}
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
26 26
import javax.microedition.khronos.opengles.GL10;
27 27

  
28 28
import org.distorted.examples.R;
29
import org.distorted.library.effect.EffectName;
30
import org.distorted.library.effect.FragmentEffectAlpha;
31
import org.distorted.library.effect.FragmentEffectChroma;
32
import org.distorted.library.effect.MatrixEffectMove;
33
import org.distorted.library.effect.MatrixEffectRotate;
34
import org.distorted.library.effect.MatrixEffectScale;
29 35
import org.distorted.library.main.Distorted;
30 36
import org.distorted.library.main.DistortedEffects;
31 37
import org.distorted.library.main.DistortedScreen;
32 38
import org.distorted.library.main.DistortedTexture;
33
import org.distorted.library.EffectNames;
34 39
import org.distorted.library.main.MeshFlat;
35
import org.distorted.library.EffectTypes;
36 40
import org.distorted.library.type.Dynamic1D;
37 41
import org.distorted.library.type.Dynamic3D;
38 42
import org.distorted.library.type.Static1D;
......
47 51

  
48 52
class CatAndDogRenderer implements GLSurfaceView.Renderer
49 53
{
54
    private static final int DURATION = 10000;  // 10 seconds
55

  
50 56
    private GLSurfaceView mView;
51 57
    private DistortedEffects mEffects;
52 58
    private MeshFlat mMesh;
53 59
    private DistortedTexture mTexture;
54 60
    private DistortedScreen mScreen;
55
    private int bmpHeight, bmpWidth;
61
    private int mObjHeight, mObjWidth;
62
    private Static3D mMove, mRotate;
56 63

  
57 64
///////////////////////////////////////////////////////////////////////////////////////////////////
58 65

  
......
63 70
      mMesh = new MeshFlat(1,1);  // no vertex effects, grid can be a (1x1) quad.
64 71
      mEffects = new DistortedEffects();
65 72

  
73
      Dynamic3D move   = new Dynamic3D(DURATION,0.0f);
74
      mRotate = new Static3D(0,0,0);
75
      mMove   = new Static3D(0,0,0);
76
      Static3D move2  = new Static3D(0,0,0);
77

  
78
      move.add(mMove);
79
      move.add(move2);
80

  
66 81
      Static4D chromaRegion= new Static4D( 530, 200,100,100);
67 82
      Static4D alphaRegion = new Static4D( 230, 200,100,100);
68 83

  
69 84
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
70 85
      chromaDyn.add(new Static1D(1));
71 86
      chromaDyn.add(new Static1D(0));
72

  
73
      mEffects.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
74

  
75 87
      Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f);
76 88
      alphaDyn.add(new Static1D(1));
77 89
      alphaDyn.add(new Static1D(0));
90
      Dynamic3D diScale = new Dynamic3D(DURATION,0.0f);
91
      diScale.add(new Static3D(1,1,1));
92
      diScale.add(new Static3D(0.33f,0.33f,1));
93
      Dynamic1D diRotate = new Dynamic1D(DURATION,0.0f);
94
      diRotate.add(new Static1D(  0));
95
      diRotate.add(new Static1D(360));
78 96

  
79
      mEffects.alpha( alphaDyn, alphaRegion, false );
97
      mEffects.apply( new FragmentEffectChroma( chromaDyn, new Static3D(1,0,0), chromaRegion ,true) );
98
      mEffects.apply( new FragmentEffectAlpha(alphaDyn, alphaRegion, false) );
99
      mEffects.apply( new MatrixEffectMove(mMove));
100
      mEffects.apply( new MatrixEffectScale(diScale));
101
      mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) );
80 102

  
81 103
      mScreen = new DistortedScreen(mView);
82 104
      }
83 105

  
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

  
108
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
109
      {
110
      mMove.set(width-mObjWidth,height-mObjHeight,0);
111
      mRotate.set(mObjWidth/2,mObjHeight/2,0);
112
      mScreen.resize(width, height);
113
      }
84 114
///////////////////////////////////////////////////////////////////////////////////////////////////
85 115
   
86 116
    public void onDrawFrame(GL10 glUnused) 
......
108 138
        catch(IOException e) { }
109 139
        }  
110 140
      
111
      bmpHeight = bitmap.getHeight();
112
      bmpWidth  = bitmap.getWidth();
141
      mObjHeight = bitmap.getHeight();
142
      mObjWidth  = bitmap.getWidth();
113 143

  
114
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
144
      if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
115 145
      mTexture.setTexture(bitmap);
116 146

  
117 147
      mScreen.detachAll();
118 148
      mScreen.attach(mTexture,mEffects,mMesh);
119 149

  
120
      DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
121
      DistortedEffects.enableEffect(EffectNames.ALPHA);
150
      DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA);
151
      DistortedEffects.enableEffect(EffectName.ALPHA);
122 152

  
123 153
      try
124 154
        {
......
129 159
        android.util.Log.e("Renderer", ex.getMessage() );
130 160
        }
131 161
      }
132
    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134
    
135
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
136
      {
137
      int duration = 10000;   // 10 seconds
138
      
139
      Dynamic3D diMove = new Dynamic3D(duration,0.0f);
140
      diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0));
141
      diMove.add(new Static3D(0,0,0));
142
      
143
      Dynamic3D diScale = new Dynamic3D(duration,0.0f);
144
      diScale.add(new Static3D(1,1,1));
145
      diScale.add(new Static3D(0.33f,0.33f,1));
146
      
147
      Dynamic1D diRotate = new Dynamic1D(duration,0.0f);
148
      diRotate.add(new Static1D(  0));
149
      diRotate.add(new Static1D(360));
150
      
151
      mEffects.abortEffects(EffectTypes.MATRIX);
152

  
153
      mEffects.move(diMove);
154
      mEffects.scale(diScale);
155
      mEffects.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
156

  
157
      mScreen.resize(width, height);
158
      }
159 162
}

Also available in: Unified diff