Project

General

Profile

« Previous | Next » 

Revision a4d59c0b

Added by Leszek Koltunski almost 6 years ago

Massive: make the coordinate system agree with that of OpenGL (i.e. invert the Y axis).

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldActivity.java
37 37
      super.onCreate(savedState);
38 38
      setContentView(R.layout.aroundtheworldlayout);
39 39

  
40
      AroundTheWorldSurfaceView       view = (AroundTheWorldSurfaceView)       this.findViewById(R.id.aroundTheWorldSurfaceView);
41
      AroundTheWorldSurfaceViewPicker pick = (AroundTheWorldSurfaceViewPicker) this.findViewById(R.id.aroundTheWorldSurfaceViewPicker);
40
      AroundTheWorldSurfaceView       view = findViewById(R.id.aroundTheWorldSurfaceView);
41
      AroundTheWorldSurfaceViewPicker pick = findViewById(R.id.aroundTheWorldSurfaceViewPicker);
42 42
      AroundTheWorldEffectsManager    mana = view.getManager();
43 43
      AroundTheWorldRendererPicker    renp = pick.getRenderer();
44 44

  
......
56 56
    @Override
57 57
    protected void onPause() 
58 58
      {
59
      AroundTheWorldSurfaceView view = (AroundTheWorldSurfaceView) this.findViewById(R.id.aroundTheWorldSurfaceView);
59
      AroundTheWorldSurfaceView view = findViewById(R.id.aroundTheWorldSurfaceView);
60 60
      view.onPause();
61 61
      Distorted.onPause();
62 62
      super.onPause();
......
69 69
      {
70 70
      super.onResume();
71 71

  
72
      AroundTheWorldSurfaceView view = (AroundTheWorldSurfaceView) this.findViewById(R.id.aroundTheWorldSurfaceView);
72
      AroundTheWorldSurfaceView view = findViewById(R.id.aroundTheWorldSurfaceView);
73 73
      view.onResume();
74 74
      }
75 75
 
......
89 89
      {
90 90
      super.onSaveInstanceState(savedInstanceState);
91 91

  
92
      AroundTheWorldSurfaceViewPicker pick = (AroundTheWorldSurfaceViewPicker) this.findViewById(R.id.aroundTheWorldSurfaceViewPicker);
92
      AroundTheWorldSurfaceViewPicker pick = findViewById(R.id.aroundTheWorldSurfaceViewPicker);
93 93

  
94 94
      savedInstanceState.putFloat("x", pick.getx() );
95 95
      savedInstanceState.putFloat("y", pick.gety() );
......
102 102
      {
103 103
      super.onRestoreInstanceState(savedInstanceState);
104 104

  
105
      AroundTheWorldSurfaceViewPicker pick = (AroundTheWorldSurfaceViewPicker) this.findViewById(R.id.aroundTheWorldSurfaceViewPicker);
105
      AroundTheWorldSurfaceViewPicker pick = findViewById(R.id.aroundTheWorldSurfaceViewPicker);
106 106

  
107 107
      float x = savedInstanceState.getFloat("x");
108 108
      float y = savedInstanceState.getFloat("y");
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldEffectsManager.java
151 151
    // WHITENESS
152 152
    // Vertex Effects
153 153
    wLipsRegion = new Static4D(0,0,0,100);
154
    wLipsCenter = new Static3D(300,500,0);
154
    wLipsCenter = new Static3D(300,100,0);
155 155
    wLipsFactor = new Static1D(0.7f);
156 156
    wLipsDyn    = new Dynamic1D();
157 157
    wLipsDyn.add(wLipsFactor);
......
159 159
    // ASIANNESS
160 160
    // Vertex Effects
161 161
    aLipsNoseRegion    = new Static4D(0,0,0,267);
162
    aLipsNoseCenter    = new Static3D(300,560,0);
162
    aLipsNoseCenter    = new Static3D(300, 40,0);
163 163
    aLipsNoseDyn       = new Dynamic3D();
164 164
    aLipsNoseFactor    = new Static3D(0,0,0);
165 165
    aLipsNoseDyn.add(aLipsNoseFactor);
166 166

  
167 167
    aNoseBroaderRegion = new Static4D(0,0,0,130);
168
    aNoseBroaderCenter = new Static3D(300,307,0);
168
    aNoseBroaderCenter = new Static3D(300,293,0);
169 169
    aNoseBroaderDyn    = new Dynamic2D();
170 170
    aNoseBroaderFactor = new Static2D(0,90);
171 171
    aNoseBroaderDyn.add(aNoseBroaderFactor);
172 172

  
173 173
    aNostrilsRegion    = new Static4D(0,0,0,60);
174
    aNostrilsCenter    = new Static3D(300,336,0);
174
    aNostrilsCenter    = new Static3D(300,264,0);
175 175
    aNostrilsDyn       = new Dynamic3D();
176 176
    aNostrilsFactor    = new Static3D(0,0,0);
177 177
    aNostrilsDyn.add(aNostrilsFactor);
178 178

  
179 179
    aEyesRegion        = new Static4D(0,0,0,83);
180
    aLEyeCenter        = new Static3D(176,230,0);
181
    aREyeCenter        = new Static3D(420,230,0);
180
    aLEyeCenter        = new Static3D(176,370,0);
181
    aREyeCenter        = new Static3D(420,370,0);
182 182
    aLEyeDyn           = new Dynamic1D();
183 183
    aREyeDyn           = new Dynamic1D();
184 184
    aLEyeFactor        = new Static1D(0);
......
187 187
    aREyeDyn.add(aREyeFactor);
188 188

  
189 189
    aEyebrowsRegion    = new Static4D(0,0,0,142);
190
    aEyebrowsCenter    = new Static3D(300,100,0);
190
    aEyebrowsCenter    = new Static3D(300,500,0);
191 191
    aEyebrowsDyn       = new Dynamic3D();
192 192
    aEyebrowsFactor    = new Static3D(0,0,0);
193 193
    aEyebrowsDyn.add(aEyebrowsFactor);
......
195 195
    // Fragment Effects
196 196
    aSkinColorCenter   = new Static3D(300,300,0);
197 197
    aSkinColorRegion   = new Static3D(600,600,600);
198
    aLEyeColorCenter   = new Static3D(172,230,0);
198
    aLEyeColorCenter   = new Static3D(172,370,0);
199 199
    aLEyeColorRegion   = new Static3D(29,25,25);
200
    aREyeColorCenter   = new Static3D(423,230,0);
200
    aREyeColorCenter   = new Static3D(423,370,0);
201 201
    aREyeColorRegion   = new Static3D(29,25,25);
202 202

  
203 203
    aChromaSkin        = new Static3D(0.5f, 0.5f, 0.5f);
......
219 219
    bFaceDyn.add(bFaceFactor);
220 220

  
221 221
    bTipLowerRegion    = new Static4D(0,0,0,41);
222
    bTipLowerCenter    = new Static3D(300,393,0);
222
    bTipLowerCenter    = new Static3D(300,207,0);
223 223
    bTipLowerFactor    = new Static3D(0,0,0);
224 224
    bTipLowerDyn       = new Dynamic3D();
225 225
    bTipLowerDyn.add(bTipLowerFactor);
226 226

  
227 227
    bWholeNoseRegion   = new Static4D(0,0,0,130);
228
    bWholeNoseCenter   = new Static3D(300,357,0);
228
    bWholeNoseCenter   = new Static3D(300,243,0);
229 229
    bWholeNoseFactor   = new Static2D(1.0f,90.0f);
230 230
    bWholeNoseDyn      = new Dynamic2D();
231 231
    bWholeNoseDyn.add(bWholeNoseFactor);
232 232

  
233 233
    bNoseBroaderRegion = new Static4D(0,0,0,95);
234
    bNoseBroaderCenter = new Static3D(300,408,0);
234
    bNoseBroaderCenter = new Static3D(300,192,0);
235 235
    bNoseBroaderFactor = new Static2D(1.0f,90.0f);
236 236
    bNoseBroaderDyn    = new Dynamic2D();
237 237
    bNoseBroaderDyn.add(bNoseBroaderFactor);
238 238

  
239
    bLipsRegion        = new Static4D(0,96,0,118);
240
    bLipsCenter        = new Static3D(300,458,0);
239
    bLipsRegion        = new Static4D(0,-96,0,118);
240
    bLipsCenter        = new Static3D(300,142,0);
241 241
    bLipsFactor        = new Static2D(1.0f,0.0f);
242 242
    bLipsDyn           = new Dynamic2D();
243 243
    bLipsDyn.add(bLipsFactor);
......
245 245
    // Fragment Effects
246 246
    bSkinColorCenter     = new Static3D(300,300,0);
247 247
    bSkinColorRegion     = new Static3D(600,600,600);
248
    bLEyeColorCenter     = new Static3D(158,241,0);
248
    bLEyeColorCenter     = new Static3D(158,359,0);
249 249
    bLEyeColorRegion     = new Static3D(55,24,50);
250
    bREyeColorCenter     = new Static3D(436,241,0);
250
    bREyeColorCenter     = new Static3D(436,359,0);
251 251
    bREyeColorRegion     = new Static3D(55,24,50);
252
    bLPupilColorCenter   = new Static3D(166,230,0);
252
    bLPupilColorCenter   = new Static3D(166,370,0);
253 253
    bLPupilColorRegion   = new Static3D(28,23,25);
254
    bRPupilColorCenter   = new Static3D(431,230,0);
254
    bRPupilColorCenter   = new Static3D(431,370,0);
255 255
    bRPupilColorRegion   = new Static3D(28,23,25);
256 256

  
257 257
    bChromaSkin        = new Static3D(0.4f, 0.25f, 0.25f);
......
323 323
    wLipsFactor.set(1.0f-0.3f*mWhiteness);
324 324

  
325 325
    // ASIANNESS
326
    aLipsNoseFactor.set2(-23.0f*mAsianness);
326
    aLipsNoseFactor.set2(23.0f*mAsianness);
327 327
    aNoseBroaderFactor.set1(1.0f+0.85f*mAsianness);
328
    aNostrilsFactor.set2(-12.0f*mAsianness);
328
    aNostrilsFactor.set2(12.0f*mAsianness);
329 329
    aLEyeFactor.set(+10.0f*mAsianness);
330 330
    aREyeFactor.set(-10.0f*mAsianness);
331
    aEyebrowsFactor.set2(-40.0f*mAsianness);
331
    aEyebrowsFactor.set2(40.0f*mAsianness);
332 332

  
333 333
    aChromaSkinFactor.set(0.2f*mAsianness);
334 334
    aChromaEyesFactor.set(0.7f*mAsianness);
335 335

  
336 336
    // BLACKNESS
337 337
    bFaceFactor.set1(1.0f + 0.1f*mBlackness);
338
    bTipLowerFactor.set2(23.0f*mBlackness);
338
    bTipLowerFactor.set2(-23.0f*mBlackness);
339 339
    bWholeNoseFactor.set1(1.0f+0.5f*mBlackness);
340 340
    bNoseBroaderFactor.set1(1.0f+0.38f*mBlackness);
341 341
    bLipsFactor.set1(1.0f+1.0f*mBlackness);
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceViewPicker.java
97 97

  
98 98
///////////////////////////////////////////////////////////////////////////////////////////////////
99 99

  
100

  
101
    @Override public boolean onTouchEvent(MotionEvent event)
100
    @Override
101
    public boolean onTouchEvent(MotionEvent event)
102 102
      {
103 103
      int x = (int)event.getX();
104 104
      int y = (int)event.getY();
src/main/java/org/distorted/examples/bean/BeanRenderer.java
61 61
      {
62 62
      mView = v;
63 63
     
64
      Static3D pointLeft  = new Static3D( 98, 183, 0);
65
      Static3D pointRight = new Static3D(233, 140, 0);
66
      Static4D regionLeft = new Static4D( -3,-33, 0,47);
67
      Static4D regionRight= new Static4D(-14,-33, 0,47);
64
      Static3D pointLeft  = new Static3D( 98, 297, 0);
65
      Static3D pointRight = new Static3D(233, 340, 0);
66
      Static4D regionLeft = new Static4D( -3, 33, 0, 47);
67
      Static4D regionRight= new Static4D(-14, 33, 0, 47);
68 68
      Dynamic3D dynLeft   = new Dynamic3D(2000,0.0f);
69 69
      Dynamic3D dynRight  = new Dynamic3D(2000,0.0f);
70 70

  
71
      Static3D p1 = new Static3D(  0,  0, 0);
72
      Static3D p2 = new Static3D(-15,-30, 0);
71
      Static3D vect1 = new Static3D(  0,  0, 0);
72
      Static3D vect2 = new Static3D(-15, 30, 0);
73 73

  
74
      dynLeft.add(p1);
75
      dynLeft.add(p1);
76
      dynLeft.add(p1);
77
      dynLeft.add(p1);
78
      dynLeft.add(p2);
79
      dynLeft.add(p2);
74
      dynLeft.add(vect1);
75
      dynLeft.add(vect1);
76
      dynLeft.add(vect1);
77
      dynLeft.add(vect1);
78
      dynLeft.add(vect2);
79
      dynLeft.add(vect2);
80 80
      
81
      dynRight.add(p1);
82
      dynRight.add(p2);
83
      dynRight.add(p2);
84
      dynRight.add(p1);
85
      dynRight.add(p1);
86
      dynRight.add(p1);
81
      dynRight.add(vect1);
82
      dynRight.add(vect2);
83
      dynRight.add(vect2);
84
      dynRight.add(vect1);
85
      dynRight.add(vect1);
86
      dynRight.add(vect1);
87 87

  
88 88
      mMove = new Static3D(0,0,0);
89 89
      mScale= new Static3D(1,1,1);
......
91 91
      mEffects = new DistortedEffects();
92 92
      mEffects.apply( new VertexEffectDistort(dynLeft , pointLeft , regionLeft) );
93 93
      mEffects.apply( new VertexEffectDistort(dynRight, pointRight, regionRight));
94
      mEffects.apply( new MatrixEffectMove(mMove) );
94
      mEffects.apply( new MatrixEffectMove (mMove ) );
95 95
      mEffects.apply( new MatrixEffectScale(mScale) );
96 96

  
97 97
      mScreen = new DistortedScreen();
......
152 152
     if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
153 153
     mTexture.setTexture(bitmap);
154 154
     if( mMesh==null ) mMesh = new MeshFlat(25,25*mObjHeight/mObjWidth);
155

  
155 156
     mScreen.detachAll();
156 157
     mScreen.attach(mTexture,mEffects,mMesh);
157 158

  
src/main/java/org/distorted/examples/blur/BlurActivity.java
42 42
      {
43 43
      super.onCreate(icicle);
44 44
      setContentView(R.layout.blurlayout);
45
      textBlur = (TextView)findViewById(R.id.blurText);
46
      SeekBar bar = (SeekBar)findViewById(R.id.blurSeek);
45
      textBlur = findViewById(R.id.blurText);
46
      SeekBar bar = findViewById(R.id.blurSeek);
47 47
      bar.setOnSeekBarChangeListener(this);
48 48
      bar.setProgress(50);
49 49
      }
......
53 53
    @Override
54 54
    protected void onPause() 
55 55
      {
56
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.blurSurfaceView);
56
      GLSurfaceView view = findViewById(R.id.blurSurfaceView);
57 57
      view.onPause();
58 58
      Distorted.onPause();
59 59
      super.onPause();
......
65 65
    protected void onResume() 
66 66
      {
67 67
      super.onResume();
68
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.blurSurfaceView);
68
      GLSurfaceView view = findViewById(R.id.blurSurfaceView);
69 69
      view.onResume();
70 70
      }
71 71
 
......
82 82
    
83 83
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
84 84
      {
85
      BlurSurfaceView view = (BlurSurfaceView) this.findViewById(R.id.blurSurfaceView);
85
      BlurSurfaceView view = findViewById(R.id.blurSurfaceView);
86 86

  
87 87
      switch (bar.getId()) 
88 88
        {
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
40 40
import org.distorted.library.type.Dynamic3D;
41 41
import org.distorted.library.type.Static1D;
42 42
import org.distorted.library.type.Static3D;
43
import org.distorted.library.type.Static4D;
44 43

  
45 44
import android.graphics.Bitmap;
46 45
import android.graphics.BitmapFactory;
......
75 74
      moveDyn.add(mMove);
76 75
      moveDyn.add(new Static3D(0,0,0));
77 76

  
78
      Static3D chromaCenter= new Static3D( 530, 200, 0   );
77
      Static3D chromaCenter= new Static3D( 530, 300, 0   );
79 78
      Static3D chromaRegion= new Static3D( 100, 100, 100 );
80
      Static3D alphaCenter = new Static3D( 230, 200, 0   );
79
      Static3D alphaCenter = new Static3D( 230, 300, 0   );
81 80
      Static3D alphaRegion = new Static3D( 100, 100, 100 );
82 81

  
83 82
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
......
156 155
        }
157 156
      catch(Exception ex)
158 157
        {
159
        android.util.Log.e("Renderer", ex.getMessage() );
158
        android.util.Log.e("CatAndDog", ex.getMessage() );
160 159
        }
161 160
      }
162 161
}
src/main/java/org/distorted/examples/check/CheckActivity.java
44 44
      super.onCreate(icicle);
45 45
      setContentView(R.layout.check1layout);
46 46
       
47
      mVPicker = (NumberPicker)findViewById(R.id.check1NumberPickerVertex);
48
      mFPicker = (NumberPicker)findViewById(R.id.check1NumberPickerFragment);
47
      mVPicker = findViewById(R.id.check1NumberPickerVertex);
48
      mFPicker = findViewById(R.id.check1NumberPickerFragment);
49 49
      
50 50
      mVPicker.setMaxValue(1000);
51 51
      mVPicker.setMinValue(   0);
......
76 76
    @Override
77 77
    protected void onPause() 
78 78
      {
79
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.checkSurfaceView);
79
      GLSurfaceView mView = findViewById(R.id.checkSurfaceView);
80 80
      if( mView!=null ) mView.onPause();
81 81

  
82 82
      Distorted.onPause();
......
90 90
      {
91 91
      super.onResume();
92 92
      
93
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.checkSurfaceView);
93
      GLSurfaceView mView = findViewById(R.id.checkSurfaceView);
94 94
      if( mView!=null ) mView.onResume();    
95 95
      }
96 96
 
src/main/java/org/distorted/examples/check/CheckRenderer.java
143 143
///////////////////////////////////////////////////////////////////////////////////////////////////
144 144
    
145 145
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
146
      { 
147
      if( (float)mObjHeight/mObjWidth > (float)height/width )
148
        {
149
        int w = (height*mObjWidth)/mObjHeight;
150
        float factor = (float)height/mObjHeight;
151
        mMove.set((width-w)/2,0,0);
152
        mScale.set(factor,factor,factor);
153
        }
154
      else
155
        {
156
        int h = (width*mObjHeight)/mObjWidth;
157
        float factor = (float)width/mObjWidth;
158
        mMove.set(0,(height-h)/2,0);
159
        mScale.set(factor,factor,factor);
160
        }
146
      {
147
      final float SCALE = 0.9f;
148

  
149
      float xW = (float)width /mObjWidth;
150
      float xH = (float)height/mObjHeight;
151

  
152
      float factor = xW>xH ? SCALE*xH : SCALE*xW;
153

  
154
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
155
      mScale.set(factor,factor,factor);
161 156

  
162 157
      mScreen.resize(width,height);
163 158
      }
......
196 191
      mSwirl1.set (          0, mObjHeight/2, 0);
197 192
      mSwirl2.set (mObjWidth  , mObjHeight/2, 0);
198 193
      mDeform1.set(          0,         0   , 0);
199
      mDeform2.set(          0,-mObjHeight  , 0);
194
      mDeform2.set(          0, mObjHeight  , 0);
200 195
      mCenter.set (mObjWidth/2,         0   , 0);
201 196

  
202 197
      try
src/main/java/org/distorted/examples/deform/DeformActivity.java
47 47
      super.onCreate(savedState);
48 48
      setContentView(R.layout.deformlayout);
49 49

  
50
      textR = (TextView)findViewById(R.id.deformTextRadius);
50
      textR = findViewById(R.id.deformTextRadius);
51 51

  
52
      SeekBar barR = (SeekBar)findViewById(R.id.deformSeekRadius);
52
      SeekBar barR = findViewById(R.id.deformSeekRadius);
53 53
      barR.setOnSeekBarChangeListener(this);
54 54

  
55 55
      if( savedState==null )
56 56
        {
57 57
        barR.setProgress(50);
58
        RadioButton effect = (RadioButton)findViewById(R.id.deformDistortButton);
58
        RadioButton effect = findViewById(R.id.deformDistortButton);
59 59
        effect.setChecked(true);
60 60
        Distort(null);
61 61
        }
......
66 66
    @Override
67 67
    protected void onPause() 
68 68
      {
69
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
69
      DeformSurfaceView view = findViewById(R.id.deformSurfaceView);
70 70

  
71 71
      Distorted.onPause();
72 72
      view.onPause();
......
80 80
      {
81 81
      super.onResume();
82 82
      
83
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
83
      GLSurfaceView view = findViewById(R.id.deformSurfaceView);
84 84
      view.onResume();
85 85
      }
86 86
 
......
97 97
    
98 98
    public void Distort(View v)
99 99
      {
100
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
100
      DeformSurfaceView view = findViewById(R.id.deformSurfaceView);
101 101
      view.getRenderer().setMode(EffectName.DISTORT);
102 102
      mCurrEffect = EffectName.DISTORT;
103 103
      }     
......
106 106

  
107 107
    public void Deform(View v)
108 108
      {
109
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
109
      DeformSurfaceView view = findViewById(R.id.deformSurfaceView);
110 110
      view.getRenderer().setMode(EffectName.DEFORM);
111 111
      mCurrEffect = EffectName.DEFORM;
112 112
      }       
......
115 115

  
116 116
    public void Shear(View v)
117 117
      {
118
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
118
      DeformSurfaceView view = findViewById(R.id.deformSurfaceView);
119 119
      view.getRenderer().setMode(EffectName.SHEAR);
120 120
      mCurrEffect = EffectName.SHEAR;
121 121
      }       
......
149 149
      {
150 150
      switch (bar.getId()) 
151 151
        {
152
        case R.id.deformSeekRadius: DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
152
        case R.id.deformSeekRadius: DeformSurfaceView view = findViewById(R.id.deformSurfaceView);
153 153
                                    view.getRenderer().setRegionRadius(progress);
154 154
                                    textR.setText(getString(R.string.radius_placeholder,(progress<100 ? (""+progress): "Infinity") ));
155 155
                                    break;
src/main/java/org/distorted/examples/deform/DeformRenderer.java
81 81
      mView = view;
82 82

  
83 83
      stretchEffects = new DistortedEffects();
84
      mRegion = new Static4D(0,0,0,0);
85
      mMove   = new Static3D(0,0,0);
86
      mTouchPoint= new Static3D(0,0,0);
84
      mRegion     = new Static4D(0,0,0,0);
85
      mMove       = new Static3D(0,0,0);
86
      mTouchPoint = new Static3D(0,0,0);
87 87

  
88 88
      // DISTORT
89 89
      Dynamic3D releasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
......
136 136
      mScreen = new DistortedScreen();
137 137
      mScreen.showFPS();
138 138

  
139
      mMovingDistort   = new VertexEffectDistort(movingDistortDynamic, mTouchPoint, mRegion);
140
      mMovingDeform    = new VertexEffectDeform(movingDeformDynamic, mTouchPoint, mRegion);
141
      mMovingShear     = new MatrixEffectShear(movingShearDynamic, mTouchPoint);
142
      mReleasedDistort = new VertexEffectDistort(releasedDistortDynamic, mTouchPoint, mRegion);
143
      mReleasedDeform  = new VertexEffectDeform(releasedDeformDynamic, mTouchPoint, mRegion);
144
      mReleasedShear   = new MatrixEffectShear(releasedShearDynamic, mTouchPoint);
139
      mMovingDistort   = new VertexEffectDistort( movingDistortDynamic  , mTouchPoint, mRegion);
140
      mMovingDeform    = new VertexEffectDeform ( movingDeformDynamic   , mTouchPoint, mRegion);
141
      mMovingShear     = new MatrixEffectShear  ( movingShearDynamic    , mTouchPoint         );
142
      mReleasedDistort = new VertexEffectDistort( releasedDistortDynamic, mTouchPoint, mRegion);
143
      mReleasedDeform  = new VertexEffectDeform ( releasedDeformDynamic , mTouchPoint, mRegion);
144
      mReleasedShear   = new MatrixEffectShear  ( releasedShearDynamic  , mTouchPoint         );
145 145

  
146 146
      stretchEffects.apply(new MatrixEffectMove(mMove));
147 147
      }
......
195 195

  
196 196
     for(int i=0; i<=NUM_LINES ; i++ )
197 197
       {
198
       stretchCanvas.drawRect(w*i/NUM_LINES - 1,                 0,  w*i/NUM_LINES + 1,  h                , paint);
199
       stretchCanvas.drawRect(                0, h *i/NUM_LINES -1,  w                ,  h*i/NUM_LINES + 1, paint);
198
       stretchCanvas.drawRect(w*i/NUM_LINES-1,               0, w*i/NUM_LINES+1, h              , paint);
199
       stretchCanvas.drawRect(              0, h*i/NUM_LINES-1, w              , h*i/NUM_LINES+1, paint);
200 200
       }
201 201

  
202 202
     if( stretchTexture==null ) stretchTexture = new DistortedTexture(w,h);
......
231 231

  
232 232
   void down(int x, int y)
233 233
     {
234
     int xt = x-scrWidth/4;
234
     int xt = x-scrWidth /4;
235 235
     int yt = y-scrHeight/4;
236 236
      
237 237
     if( xt<0 ) xt=0;
238
     if( xt>scrWidth/2 ) xt=scrWidth/2;
238
     if( xt>scrWidth /2 ) xt=scrWidth/2;
239 239
     if( yt<0 ) yt=0;
240 240
     if( yt>scrHeight/2 ) yt=scrHeight/2;
241 241
      
242
     mTouchPoint.set(xt,yt,0);
242
     mTouchPoint.set(xt, scrHeight/2-yt,0);   // OpenGL coord system and 2D coords have inverted Y axis
243 243

  
244 244
     switch(mMode)
245 245
       {
......
264 264
     {
265 265
     switch(mMode)
266 266
       {
267
       case DISTORT: vDistort[0].set(x,y,0);
267
       case DISTORT: vDistort[0].set(x,-y,0);
268 268
                     break;
269
       case DEFORM:  vDeform[0].set(x,y,0);
269
       case DEFORM:  vDeform[0].set(x,-y,0);
270 270
                     break;
271
       case SHEAR:   vShear[0].set( (float)x/(scrWidth/2), (float)y/(scrHeight/2), 0);
271
       case SHEAR:   vShear[0].set( (float)x/(scrWidth/2), (float)(-y)/(scrHeight/2), 0);
272 272
                     break;
273 273
       }
274 274
     }
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java
69 69
      Dynamic3D dDistort = new Dynamic3D(3000,0.0f);
70 70
      dDistort.add(new Static3D( 25,0,0));
71 71
      dDistort.add(new Static3D(-25,0,0));
72
      Static3D mPoint = new Static3D(305, 380, 0);
72
      Static3D mPoint = new Static3D(305, 220, 0);
73 73

  
74 74
      mEffects = new DistortedEffects[NUM];
75 75
      mEffects[0] = new DistortedEffects();
......
78 78

  
79 79
      // Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared!
80 80
      // (Matrix effect cannot be shared as we have to display each Texture in a different location)
81
      VertexEffectSink sink = new VertexEffectSink(new Static1D(8), mPoint, new Static4D(0,0,80,80));
81
      VertexEffectSink sink = new VertexEffectSink(new Static1D(8), mPoint, new Static4D(0,0,0,80));
82 82
      VertexEffectDistort distort = new VertexEffectDistort(dDistort,mPoint);
83 83
      mEffects[0].apply(sink);    // enlarge the nose
84 84
      mEffects[0].apply(distort); // keep moving the whole bitmap left and right.
......
106 106
   private Bitmap readBitmap(int id)
107 107
     {
108 108
     InputStream is = mView.getContext().getResources().openRawResource(id);
109
     Bitmap bitmap=null;
109
     Bitmap bitmap;
110 110
           
111 111
     try 
112 112
       {
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
69 69
      mView = v;
70 70
      
71 71
      // mEffects[0] effects
72
      Static3D pLeft = new Static3D(214, 206, 0);
73
      Static3D pRight= new Static3D(390, 212, 0);
72
      Static3D pLeft = new Static3D(214, 394, 0);
73
      Static3D pRight= new Static3D(390, 388, 0);
74 74
      Static4D RegionEye = new Static4D(0,0,0,60);
75 75
      
76 76
      // mEffects[1] effects
77 77
      Dynamic3D dyn = new Dynamic3D(1000,0.0f);
78 78
      dyn.add(new Static3D( 50,0,0));
79 79
      dyn.add(new Static3D(-50,0,0));
80
      Static3D pNose1 = new Static3D(305, 340, 0);
80
      Static3D pNose1 = new Static3D(305, 260, 0);
81 81
      
82 82
      // we don't need to prepare anything for mEffects[2] effects
83 83

  
src/main/java/org/distorted/examples/earth/EarthRenderer.java
187 187

  
188 188
      float factor = xW>xH ? mLevel*xH : mLevel*xW;
189 189

  
190
      mMove.set( (mScrWidth-factor*mObjWidth)/2 , (mScrHeight-factor*mObjHeight)/2 , 0);
190
      mMove.set( (mScrWidth-factor*mObjWidth)/2 , (mScrHeight-factor*mObjHeight)/2 , -factor*mObjDepth );
191 191
      mScaleFactor.set(factor,factor,factor);
192 192
      }
193 193

  
......
205 205
      double cosLAT = Math.cos(latitude);
206 206

  
207 207
      float x = (float)(sinLON*cosLAT)/2.0f;
208
      float y = (float)        sinLAT /2.0f;
208
      float y = (float)       -sinLAT /2.0f;
209 209
      float z = (float)(cosLON*cosLAT)/2.0f;
210 210

  
211 211
      Static3D center = new Static3D( (0.5f+x)*mObjWidth, (0.5f+y)*mObjHeight, (0.5f+z)*mObjDepth);
src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java
65 65
    mPosName = 0;
66 66
    mPosType = 0;
67 67

  
68
    mAdd  = (Spinner)findViewById(R.id.effects2d_spinnerAdd );
69
    mID   = (Spinner)findViewById(R.id.effects2d_spinnerID  );
70
    mName = (Spinner)findViewById(R.id.effects2d_spinnerName);
71
    mType = (Spinner)findViewById(R.id.effects2d_spinnerType);
68
    mAdd  = findViewById(R.id.effects2d_spinnerAdd );
69
    mID   = findViewById(R.id.effects2d_spinnerID  );
70
    mName = findViewById(R.id.effects2d_spinnerName);
71
    mType = findViewById(R.id.effects2d_spinnerType);
72 72

  
73 73
    mAdd.setOnItemSelectedListener(this);
74 74
    mID.setOnItemSelectedListener(this);
......
101 101
    adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
102 102
    mType.setAdapter(adapterType);
103 103

  
104
    mLayoutList = (TableLayout)findViewById(R.id.effects2dTableList);
104
    mLayoutList = findViewById(R.id.effects2dTableList);
105 105
    }
106 106

  
107 107
///////////////////////////////////////////////////////////////////////////////////////////////////
......
111 111
    {
112 112
    super.onResume();
113 113
      
114
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
114
    GLSurfaceView mView = findViewById(R.id.effects2dSurfaceView);
115 115
    mView.onResume();
116 116
    }
117 117

  
......
120 120
  @Override
121 121
  protected void onPause() 
122 122
    {
123
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
123
    GLSurfaceView mView = findViewById(R.id.effects2dSurfaceView);
124 124
    mView.onPause();
125 125

  
126 126
    Distorted.onPause();
......
150 150
    {
151 151
    switch(parent.getId())
152 152
      {
153
      case R.id.effects2d_spinnerAdd : EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
153
      case R.id.effects2d_spinnerAdd : EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
154 154
                                       v.setEffect(pos); break;
155 155
      case R.id.effects2d_spinnerID  : mPosID   = pos; break;
156 156
      case R.id.effects2d_spinnerName: mPosName = pos; break;
......
171 171
    try
172 172
      {
173 173
      Long currEffect = (Long)mID.getItemAtPosition(mPosID);
174
      EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
174
      EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
175 175
      v.getRenderer().getEffects().abortById(currEffect);
176 176
      }
177 177
    catch(IndexOutOfBoundsException ex)
......
196 196
      default: name = EffectName.CONTRAST     ;
197 197
      }
198 198

  
199
    EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
199
    EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
200 200
    v.getRenderer().getEffects().abortByName(name);
201 201
    }
202 202

  
......
213 213
      default: type = EffectType.MATRIX;
214 214
      }
215 215

  
216
    EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
216
    EffectQueueSurfaceView v = findViewById(R.id.effects2dSurfaceView);
217 217
    v.getRenderer().getEffects().abortByType(type);
218 218
    }
219 219

  
......
230 230
      tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
231 231

  
232 232
      TextView b1 = new TextView(this);
233
      b1.setText("ID: "+effect.getID());
233
      b1.setText(getString(R.string.effect_id_placeholder,effect.getID()));
234 234
      b1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
235 235
      tr.addView(b1);
236 236

  
......
245 245
      tr.addView(b3);
246 246

  
247 247
      TextView b4 = new TextView(this);
248
      b4.setText("LIVE");
248
      b4.setText(R.string.effect_live);
249 249
      b4.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
250 250
      tr.addView(b4);
251 251

  
......
297 297
        if( row!=null )
298 298
          {
299 299
          TextView v = (TextView)row.getVirtualChildAt(3);
300
          v.setText("FINISHED");
300
          v.setText(R.string.effect_finished);
301 301
          }
302 302
        }
303 303
      });
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java
107 107

  
108 108
    for(int i=0; i<=NUMLINES ; i++ )
109 109
      {
110
      canvas.drawRect(texWidth*i/NUMLINES - 1,                       0,  texWidth*i/NUMLINES + 1,  texHeight               , mPaint);
111
      canvas.drawRect(                      0, texHeight*i/NUMLINES -1,  texWidth               ,  texHeight*i/NUMLINES + 1, mPaint);
110
      canvas.drawRect(texWidth*i/NUMLINES-1,                      0, texWidth*i/NUMLINES+1, texHeight             , mPaint);
111
      canvas.drawRect(                    0, texHeight*i/NUMLINES-1, texWidth             , texHeight*i/NUMLINES+1, mPaint);
112 112
      }
113 113
    mTexture.setTexture(bitmap);
114 114

  
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java
26 26
import android.view.MotionEvent;
27 27
import android.util.AttributeSet;
28 28

  
29
import org.distorted.library.effect.Effect;
29 30
import org.distorted.library.effect.FragmentEffectAlpha;
30 31
import org.distorted.library.effect.FragmentEffectChroma;
31 32
import org.distorted.library.effect.FragmentEffectSaturation;
......
47 48
  private int mCurrentEffect;
48 49
  private int mScrW, mScrH;
49 50
    
50
  private Static4D mRegionV;
51 51
  private Dynamic1D mInterA, mInterB, mInterC, mInterS;
52 52
  private Dynamic3D mInterD;
53 53

  
54
  private final static Static3D mRED    = new Static3D(1,0,0);
55
  private final static Static3D mREGION = new Static3D(RADIUS,RADIUS,RADIUS);
54
  private final static Static3D RED      = new Static3D(1,0,0);
55
  private final static Static3D REGION_F = new Static3D(RADIUS,RADIUS,RADIUS);
56
  private final static Static4D REGION_V = new Static4D(0,0,0,RADIUS);
56 57

  
57 58
///////////////////////////////////////////////////////////////////////////////////////////////////
58 59
    
......
97 98
      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
98 99
      setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
99 100
      setRenderer(mRenderer);
100
      mRegionV= new Static4D(0,0,0,RADIUS);
101
      setEffect(0);  
101
      setEffect(0);
102 102
      }
103 103
    }
104 104

  
......
126 126

  
127 127
///////////////////////////////////////////////////////////////////////////////////////////////////
128 128
    
129
  @Override public boolean onTouchEvent(MotionEvent event) 
129
  @Override
130
  public boolean onTouchEvent(MotionEvent event)
130 131
    {
131 132
    int x,y,action = event.getAction();
133
    Effect effect;
132 134
    boolean success;
133 135

  
134 136
    switch(action)
135 137
      {
136
      case MotionEvent.ACTION_DOWN: x = (int)event.getX()* mRenderer.BWID/mScrW;
137
                                    y = (int)event.getY()* mRenderer.BHEI/mScrH;
138
      case MotionEvent.ACTION_DOWN: x =                          (int)event.getX()* EffectQueueRenderer.BWID/mScrW;
139
                                    y = EffectQueueRenderer.BHEI-(int)event.getY()* EffectQueueRenderer.BHEI/mScrH;
138 140
                                    EffectQueueActivity act = (EffectQueueActivity)getContext();
141
                                    Static3D center = new Static3D(x,y,0);
139 142

  
140 143
                                    switch(mCurrentEffect)
141 144
                                      {
142
                                      case 0: VertexEffectDistort distort = new VertexEffectDistort(mInterD, new Static3D(x,y,0), mRegionV);
143
                                              success = mRenderer.getEffects().apply(distort);
144
                                              act.effectAdded(success,distort);
145
                                      case 0: effect = new VertexEffectDistort     (mInterD,      center, REGION_V);
146
                                              success= mRenderer.getEffects().apply(effect);
147
                                              act.effectAdded(success,effect);
145 148
                                              break;
146
                                      case 1: VertexEffectSink sink = new VertexEffectSink(mInterS, new Static3D(x,y,0), mRegionV);
147
                                              success = mRenderer.getEffects().apply(sink);
148
                                              act.effectAdded(success,sink);
149
                                      case 1: effect = new VertexEffectSink        (mInterS,      center, REGION_V);
150
                                              success= mRenderer.getEffects().apply(effect);
151
                                              act.effectAdded(success,effect);
149 152
                                              break;
150
                                      case 2: FragmentEffectAlpha alpha = new FragmentEffectAlpha(mInterA, new Static3D(x,y,0), mREGION, true);
151
                                              success = mRenderer.getEffects().apply(alpha);
152
                                              act.effectAdded(success,alpha);
153
                                      case 2: effect = new FragmentEffectAlpha     (mInterA,      center, REGION_F, true);
154
                                              success= mRenderer.getEffects().apply(effect);
155
                                              act.effectAdded(success,effect);
153 156
                                              break;
154
                                      case 3: FragmentEffectSaturation saturation = new FragmentEffectSaturation(mInterB, new Static3D(x,y,0), mREGION, false);
155
                                              success = mRenderer.getEffects().apply(saturation);
156
                                              act.effectAdded(success,saturation);
157
                                      case 3: effect = new FragmentEffectSaturation(mInterB,      center, REGION_F, false);
158
                                              success= mRenderer.getEffects().apply(effect);
159
                                              act.effectAdded(success,effect);
157 160
                                              break;
158
                                      case 4: FragmentEffectChroma chroma = new FragmentEffectChroma(mInterC, mRED, new Static3D(x,y,0), mREGION, true);
159
                                              success = mRenderer.getEffects().apply(chroma);
160
                                              act.effectAdded(success,chroma);
161
                                      case 4: effect = new FragmentEffectChroma    (mInterC, RED, center, REGION_F, true);
162
                                              success= mRenderer.getEffects().apply(effect);
163
                                              act.effectAdded(success,effect);
161 164
                                              break;
162 165
                                      }
163 166

  
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
253 253
      mRegionPoint.set(mFactorObj*act.getRegionX(),-mFactorObj*act.getRegionY(),0);
254 254
      mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize;
255 255
      mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
256
      mMoveObject.set( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0 );
256
      mMoveObject.set( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , -mFactorObj*mObjDepth );
257 257
      mRotateCen.set(width/2,height/2, 0);
258 258
      mScaleObject.set(mFactorObj,mFactorObj,mFactorObj);
259 259
      mMoveCenter.set( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
src/main/java/org/distorted/examples/flag/FlagActivity.java
48 48

  
49 49
      mNoise = new Static5D(0,0,0,0,0);
50 50

  
51
      textAmplitude = (TextView)findViewById(R.id.flagAmplitude);
52
      textLength    = (TextView)findViewById(R.id.flagLength);
53
      textAngleA    = (TextView)findViewById(R.id.flagAngleA);
54
      textAngleB    = (TextView)findViewById(R.id.flagAngleB);
51
      textAmplitude = findViewById(R.id.flagAmplitude);
52
      textLength    = findViewById(R.id.flagLength);
53
      textAngleA    = findViewById(R.id.flagAngleA);
54
      textAngleB    = findViewById(R.id.flagAngleB);
55 55

  
56
      SeekBar barAmplitude  = (SeekBar)findViewById(R.id.flagSeekAmplitude);
57
      SeekBar barLength     = (SeekBar)findViewById(R.id.flagSeekLength);
58
      SeekBar barAngleA     = (SeekBar)findViewById(R.id.flagSeekAngleA);
59
      SeekBar barAngleB     = (SeekBar)findViewById(R.id.flagSeekAngleB);
56
      SeekBar barAmplitude  = findViewById(R.id.flagSeekAmplitude);
57
      SeekBar barLength     = findViewById(R.id.flagSeekLength);
58
      SeekBar barAngleA     = findViewById(R.id.flagSeekAngleA);
59
      SeekBar barAngleB     = findViewById(R.id.flagSeekAngleB);
60 60

  
61 61
      barAmplitude.setOnSeekBarChangeListener(this);
62 62
      barLength.setOnSeekBarChangeListener(this);
......
68 68
      barAngleA.setProgress(25);
69 69
      barAngleB.setProgress(1);
70 70

  
71
      textNoiseAmplitude = (TextView)findViewById(R.id.flagNoiseAmplitude);
72
      textNoiseLength    = (TextView)findViewById(R.id.flagNoiseLength);
73
      textNoiseAngleA    = (TextView)findViewById(R.id.flagNoiseAngleA);
74
      textNoiseAngleB    = (TextView)findViewById(R.id.flagNoiseAngleB);
71
      textNoiseAmplitude = findViewById(R.id.flagNoiseAmplitude);
72
      textNoiseLength    = findViewById(R.id.flagNoiseLength);
73
      textNoiseAngleA    = findViewById(R.id.flagNoiseAngleA);
74
      textNoiseAngleB    = findViewById(R.id.flagNoiseAngleB);
75 75

  
76
      SeekBar barNoiseAmplitude  = (SeekBar)findViewById(R.id.flagSeekNoiseAmplitude);
77
      SeekBar barNoiseLength     = (SeekBar)findViewById(R.id.flagSeekNoiseLength);
78
      SeekBar barNoiseAngleA     = (SeekBar)findViewById(R.id.flagSeekNoiseAngleA);
79
      SeekBar barNoiseAngleB     = (SeekBar)findViewById(R.id.flagSeekNoiseAngleB);
76
      SeekBar barNoiseAmplitude = findViewById(R.id.flagSeekNoiseAmplitude);
77
      SeekBar barNoiseLength    = findViewById(R.id.flagSeekNoiseLength);
78
      SeekBar barNoiseAngleA    = findViewById(R.id.flagSeekNoiseAngleA);
79
      SeekBar barNoiseAngleB    = findViewById(R.id.flagSeekNoiseAngleB);
80 80

  
81 81
      barNoiseAmplitude.setOnSeekBarChangeListener(this);
82 82
      barNoiseLength.setOnSeekBarChangeListener(this);
......
99 99
    @Override
100 100
    protected void onPause() 
101 101
      {
102
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.flagSurfaceView);
102
      GLSurfaceView mView = findViewById(R.id.flagSurfaceView);
103 103
      mView.onPause();
104 104

  
105 105
      Distorted.onPause();
......
113 113
      {
114 114
      super.onResume();
115 115

  
116
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.flagSurfaceView);
116
      GLSurfaceView mView = findViewById(R.id.flagSurfaceView);
117 117
      mView.onResume();
118 118
      }
119 119
    
......
140 140

  
141 141
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
142 142
      {
143
      FlagSurfaceView mView = (FlagSurfaceView) this.findViewById(R.id.flagSurfaceView);
143
      FlagSurfaceView mView = findViewById(R.id.flagSurfaceView);
144 144
      FlagRenderer renderer = mView.getRenderer();
145 145

  
146 146
      switch (bar.getId())
src/main/java/org/distorted/examples/flag/FlagRenderer.java
50 50
class FlagRenderer implements GLSurfaceView.Renderer
51 51
{
52 52
    private GLSurfaceView mView;
53
    private DistortedEffects mEffects;
54 53
    private DistortedTexture mTexture;
55 54
    private DistortedScreen mScreen;
56 55
    private Dynamic5D mWaveDyn;
......
67 66
      {
68 67
      mView = v;
69 68

  
70
      mEffects = new DistortedEffects();
71 69
      mTexture = new DistortedTexture(500,300);
72 70

  
73 71
      mObjWidth = mTexture.getWidth();
......
87 85
      Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0);  // middle of the right edge
88 86
      Static4D waveRegion = new Static4D(0,0,0,mObjWidth);
89 87

  
90
      mEffects.apply( new VertexEffectWave(mWaveDyn, waveCenter, waveRegion) );
88
      DistortedEffects effects = new DistortedEffects();
89
      effects.apply( new VertexEffectWave(mWaveDyn, waveCenter, waveRegion) );
91 90

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

  
96
      mEffects.apply( new MatrixEffectMove(mMove));
97
      mEffects.apply( new MatrixEffectScale(mScale));
98
      mEffects.apply( new MatrixEffectQuaternion(mQuat1, mCenter) );
99
      mEffects.apply( new MatrixEffectQuaternion(mQuat2, mCenter) );
95
      effects.apply( new MatrixEffectMove(mMove));
96
      effects.apply( new MatrixEffectScale(mScale));
97
      effects.apply( new MatrixEffectQuaternion(mQuat1, mCenter) );
98
      effects.apply( new MatrixEffectQuaternion(mQuat2, mCenter) );
100 99

  
101 100
      mScreen = new DistortedScreen();
102
      mScreen.attach(mTexture,mEffects, new MeshCubes(50,30,1) );
101
      mScreen.attach(mTexture, effects, new MeshCubes(50,30,1) );
103 102
      }
104 103

  
105 104
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/girl/GirlActivity.java
44 44
      
45 45
      setContentView(R.layout.girllayout);
46 46
           
47
      textSwing = (TextView)findViewById(R.id.girlTextSwing);
48
      textSize  = (TextView)findViewById(R.id.girlTextSize);
49
      textHips  = (TextView)findViewById(R.id.girlTextHips);
47
      textSwing = findViewById(R.id.girlTextSwing);
48
      textSize  = findViewById(R.id.girlTextSize);
49
      textHips  = findViewById(R.id.girlTextHips);
50 50

  
51
      SeekBar barSwing = (SeekBar)findViewById(R.id.girlSeekSwing);
52
      SeekBar barSize  = (SeekBar)findViewById(R.id.girlSeekSize);
53
      SeekBar barHips  = (SeekBar)findViewById(R.id.girlSeekHips);
51
      SeekBar barSwing = findViewById(R.id.girlSeekSwing);
52
      SeekBar barSize  = findViewById(R.id.girlSeekSize);
53
      SeekBar barHips  = findViewById(R.id.girlSeekHips);
54 54
      
55 55
      barSwing.setOnSeekBarChangeListener(this); 
56 56
      barSize.setOnSeekBarChangeListener(this); 
......
70 70
    @Override
71 71
    protected void onPause() 
72 72
      {
73
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
73
      GLSurfaceView view = findViewById(R.id.girlSurfaceView);
74 74
      view.onPause();
75 75

  
76 76
      Distorted.onPause();
......
84 84
      {
85 85
      super.onResume();
86 86
      
87
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.girlSurfaceView);
87
      GLSurfaceView view = findViewById(R.id.girlSurfaceView);
88 88
      view.onResume();
89 89
      }
90 90
 
......
103 103
      {
104 104
      int v;
105 105
      float s;
106
      GirlSurfaceView view = (GirlSurfaceView) this.findViewById(R.id.girlSurfaceView);
106
      GirlSurfaceView view = findViewById(R.id.girlSurfaceView);
107 107

  
108 108
      switch (bar.getId()) 
109 109
        {
src/main/java/org/distorted/examples/girl/GirlRenderer.java
67 67
      {
68 68
      mView = v;
69 69

  
70
      Static3D pLeft = new Static3D(132, 264, 0);
71
      Static3D pRight= new Static3D(247, 264, 0);
70
      Static3D pLeft = new Static3D(132, 336, 0);
71
      Static3D pRight= new Static3D(247, 336, 0);
72 72
      
73 73
      // Size
74 74
      Static4D sinkRegion = new Static4D(0,0,0,60);
......
100 100
      diR.add(v1);
101 101
      
102 102
      // Lower Movement
103
      Static3D pHips = new Static3D(216,505,0);
103
      Static3D pHips      = new Static3D(216,95,0);
104 104
      Static4D HipsRegion = new Static4D(0,0,0,120);
105
      Dynamic1D diHips = new Dynamic1D(1500,0.0f);
105
      Dynamic1D diHips    = new Dynamic1D(1500,0.0f);
106 106
      
107 107
      dBegin = new Static1D(0);
108 108
      dMiddle= new Static1D(0);
......
117 117

  
118 118
      mEffects = new DistortedEffects();
119 119

  
120
      mEffects.apply( new VertexEffectSink(diSink, pLeft, sinkRegion) );
121
      mEffects.apply( new VertexEffectSink(diSink, pRight,sinkRegion) );
122
      mEffects.apply( new VertexEffectDistort(diL, pLeft , Region) );
123
      mEffects.apply( new VertexEffectDistort(diR, pRight, Region) );
124
      mEffects.apply( new VertexEffectSwirl(diHips, pHips, HipsRegion) );
120
      mEffects.apply( new VertexEffectSink   ( diSink, pLeft , sinkRegion) );
121
      mEffects.apply( new VertexEffectSink   ( diSink, pRight, sinkRegion) );
122
      mEffects.apply( new VertexEffectDistort( diL   , pLeft , Region    ) );
123
      mEffects.apply( new VertexEffectDistort( diR   , pRight, Region    ) );
124
      mEffects.apply( new VertexEffectSwirl  ( diHips, pHips , HipsRegion) );
125 125

  
126 126
      mMove = new Static3D(0,0,0);
127 127
      mScale= new Static3D(1,1,1);
......
150 150

  
151 151
   void setSwing(int swing)
152 152
     {
153
     v0.set( 0,-swing, 0);
153
     v0.set( 0, swing, 0);
154 154
     v1.set( swing, 0, 0);
155
     v2.set( 0, swing, 0);
155
     v2.set( 0,-swing, 0);
156 156
     v3.set(-swing, 0, 0);
157 157
     }
158 158
   
src/main/java/org/distorted/examples/inflate/InflateRenderer.java
110 110
    
111 111
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
112 112
      {
113
      final float SCALE = 0.75f;
114

  
113 115
      mScreenMin = width<height ? width:height;
114
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (0.75f*height)/mObjHeight :  (0.75f*width)/mObjWidth;
115
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
116
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
117
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , -factor*mObjDepth/2 );
116 118
      mScale.set(factor,factor,factor);
117 119
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
118 120
      mScreen.resize(width, height);
src/main/java/org/distorted/examples/listener/ListenerRenderer.java
66 66

  
67 67
   ListenerRenderer(GLSurfaceView v)
68 68
      {
69
      DistortedEffects.setMax(EffectType.VERTEX,NUM_BUBBLES);
69
      // one more than we have bubbles at any given time because it can sometimes happen that
70
      // the old bubble is not yet removed when we add a new one
71
      DistortedEffects.setMax(EffectType.VERTEX,NUM_BUBBLES+1);
72

  
70 73
      mView = v;
71 74
      mEffects = new DistortedEffects();
72 75
      mEffects.registerForMessages(this);
......
81 84

  
82 85
///////////////////////////////////////////////////////////////////////////////////////////////////
83 86

  
84
   private boolean randomizeNewBubble()
87
   private boolean addNewBubble()
85 88
      {
86 89
      int radius   = (int)(( 0.10f + 0.70f*mRnd.nextFloat())*bmpWidth);           // pop up a bubble of size (radius,height)
87 90
      int height   = (int)((-0.10f + 0.20f*mRnd.nextFloat())*bmpWidth);           // 
88 91
      int pointx   = mRnd.nextInt( (int)(0.8f*bmpWidth ))+ (int)(0.1f*bmpWidth ); // at a random place on the bitmap (but not near the edge)
89 92
      int pointy   = mRnd.nextInt( (int)(0.8f*bmpHeight))+ (int)(0.1f*bmpHeight); // 
90
      int duration = 1000 + mRnd.nextInt(3000);                                   // for anytime from 3 to 4 seconds 
93
      int duration = 1000 + mRnd.nextInt(3000);                                   // for anytime from 1 to 4 seconds
91 94

  
92 95
      Dynamic3D dDistort = new Dynamic3D(duration,1.0f);
93 96
      dDistort.add(new Static3D(0,0,     0));
......
103 106
     {
104 107
     switch(em)
105 108
        {
106
        case EFFECT_REMOVED: randomizeNewBubble();
107
        default            : break;
109
        case EFFECT_REMOVED: if( !addNewBubble() )
110
                               {
111
                               android.util.Log.e("Listener", "failed to add new bubble - this should never happen!");
112
                               }
113
                             break;
108 114
        }
109 115
     }
110 116
   
......
170 176
     mScreen.detachAll();
171 177
     mScreen.attach(mTexture,mEffects,mMesh);
172 178

  
173
     for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
179
     for(int i=0; i<NUM_BUBBLES; i++) addNewBubble();
174 180

  
175 181
     VertexEffectDistort.enable();
176 182

  
src/main/java/org/distorted/examples/mirror/MirrorActivity.java
42 42
      super.onCreate(icicle);
43 43
      setContentView(R.layout.mirrorlayout);
44 44
       
45
      SeekBar bar = (SeekBar)findViewById(R.id.mirrorSeek);
45
      SeekBar bar = findViewById(R.id.mirrorSeek);
46 46
      bar.setOnSeekBarChangeListener(this);
47 47
      bar.setProgress(INIT_POSITION);
48 48
      }
......
52 52
    @Override
53 53
    protected void onPause() 
54 54
      {
55
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.mirrorSurfaceView);
55
      GLSurfaceView view = findViewById(R.id.mirrorSurfaceView);
56 56
      view.onPause();
57 57

  
58 58
      Distorted.onPause();
......
65 65
    protected void onResume() 
66 66
      {
67 67
      super.onResume();
68
      MirrorSurfaceView view = (MirrorSurfaceView) this.findViewById(R.id.mirrorSurfaceView);
68
      MirrorSurfaceView view = findViewById(R.id.mirrorSurfaceView);
69 69
      view.onResume();
70 70
      view.getRenderer().onResume();
71 71
      }
......
85 85
      {
86 86
      switch (bar.getId()) 
87 87
        {
88
        case R.id.mirrorSeek: MirrorSurfaceView view = (MirrorSurfaceView) this.findViewById(R.id.mirrorSurfaceView);
88
        case R.id.mirrorSeek: MirrorSurfaceView view = findViewById(R.id.mirrorSurfaceView);
89 89
                              view.getRenderer().setPosition(progress);
90 90
                              break;
91 91
        }
src/main/java/org/distorted/examples/mirror/MirrorRenderer.java
50 50
   private static final float HEAD_SCALE       =0.30f;  // Head's height will be 30% of the height of the mirror
51 51
   private static final float MIRROR_BRIGHTNESS=0.70f;  // Each next mirror 30% darker
52 52
   private static final float MIRROR_MARGIN    =0.11f;  // The frame of the mirror takes up 11% of its width
53
   private static final float MIRROR_MOVE      =0.12f;  // Each next mirror is moved to the right by 12% of
53
   private static final float MIRROR_MOVE_H    =0.12f;  // Each next mirror is moved to the left by 12% of
54 54
                                                        // the length of the previous one
55
   private static final float MIRROR_MOVE_V    =0.22f;  // Move the mirror up
55 56

  
56 57
   private GLSurfaceView mView;
57 58
   private DistortedEffects mEffectsMirror, mEffectsHead, mEffectsNull;
......
141 142
        mOffScreen2 = new DistortedFramebuffer( (int)(MIRROR_SCALE*mScreenW), (int)(MIRROR_SCALE*mScreenH), 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL );
142 143

  
143 144
        mScaleMirror.set( (float)mScreenW/mMirrorW, (float)mScreenH/mMirrorH, 1.0f);
144
        mMoveOffscreen2.set( MIRROR_MOVE*mScreenW, MIRROR_MOVE*mScreenH*mMirrorW/mMirrorH, 0);
145
        mMoveOffscreen2.set( MIRROR_MOVE_H*mScreenW, MIRROR_MOVE_V*mScreenH*mMirrorW/mMirrorH, 0);
145 146

  
146 147
        float headScale = HEAD_SCALE *mScreenH/ mHeadH;
147 148
        mScaleHead.set(headScale,headScale,headScale);
148
        mHeadPosition.set2( mScreenH*(1.0f-MIRROR_MARGIN*mMirrorW/mMirrorH) - headScale* mHeadH);
149
        mHeadPosition.set2( mScreenH*MIRROR_MARGIN*mMirrorW/mMirrorH );
149 150
        setPosition(mX);
150 151

  
151 152
        mOffScreen1.attach( mTextureMirror, mEffectsMirror    , mQuad );
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
60 60
      {
61 61
      mView = v;
62 62

  
63
      Static3D pLeft = new Static3D( 90, 258, 0);
64
      Static3D pRight= new Static3D(176, 255, 0);
63
      // two points, centers of the Distort effect
64
      // the left and right tip of the mouth
65
      Static3D pLeft  = new Static3D( 90, 108, 0);
66
      Static3D pRight = new Static3D(176, 111, 0);
65 67

  
66
      Static4D rLeft = new Static4D(-10,-10, 0,25);
67
      Static4D rRight= new Static4D( 10, -5, 0,25);
68
      // two regions defining the areas affected by the Distort effect
69
      Static4D rLeft  = new Static4D(-10, 10, 0, 25);
70
      Static4D rRight = new Static4D( 10,  5, 0, 25);
71

  
72
      // two dynamics for interpolating through vectors of distortion. Interpolate
73
      // every 1000 miliseconds, indefinately ('0.0f').
68 74
      Dynamic3D dLeft = new Dynamic3D(1000,0.0f);
69 75
      Dynamic3D dRight= new Dynamic3D(1000,0.0f);
70
      dLeft.add ( new Static3D(  0,  0,0) );
71
      dLeft.add ( new Static3D(-20,-20,0) );
72
      dRight.add( new Static3D(  0,  0,0) );
73
      dRight.add( new Static3D( 20,-10,0) );
76

  
77
      // two vectors of distortion the left tip of the mouth gets distorted with -
78
      // interpolated from (0,0,0) - i.e. no distortion - to (-20,20,0), i.e.
79
      // slightly to the top left.
80
      dLeft.add ( new Static3D(  0,  0, 0) );
81
      dLeft.add ( new Static3D(-20, 20, 0) );
82

  
83
      // likewise two vectors the right tip is distorted with.
84
      dRight.add( new Static3D(  0,  0, 0) );
85
      dRight.add( new Static3D( 20, 10, 0) );
74 86

  
75 87
      mEffects = new DistortedEffects();
76 88
      mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) );
......
155 167
      mScreen.detachAll();
156 168
      mScreen.attach(mTexture,mEffects,mMesh);
157 169

  
170
      // All effects are by default disabled!
158 171
      VertexEffectDistort.enable();
159 172

  
160 173
      try
src/main/java/org/distorted/examples/movingeffects/MovingEffectsActivity.java
47 47
  
48 48
      setContentView(R.layout.movingeffectslayout);
49 49
      
50
      mAbort = (Button)findViewById(R.id.movingeffectsAbort);
51
      mChroma= (Button)findViewById(R.id.movingeffectsChroma);
52
      mTrans = (Button)findViewById(R.id.movingeffectsTrans);
53
      mSink  = (Button)findViewById(R.id.movingeffectsSink);
54
      mBubble= (Button)findViewById(R.id.movingeffectsBubble);
55
      mSwirl= (Button)findViewById(R.id.movingeffectsSwirl);
50
      mAbort = findViewById(R.id.movingeffectsAbort);
51
      mChroma= findViewById(R.id.movingeffectsChroma);
52
      mTrans = findViewById(R.id.movingeffectsTrans);
53
      mSink  = findViewById(R.id.movingeffectsSink);
54
      mBubble= findViewById(R.id.movingeffectsBubble);
55
      mSwirl = findViewById(R.id.movingeffectsSwirl);
56 56
      
57 57
      mAbort.setBackgroundColor(COLOR_PRESSED);
58 58
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
......
68 68
      }
69 69

  
70 70
///////////////////////////////////////////////////////////////////
71

  
71 72
    @Override
72 73
    protected void onResume() 
73 74
      {
74 75
      super.onResume();
75 76
      
76
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
77
      GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
77 78
      view.onResume();
78 79
      }
79 80

  
80 81
///////////////////////////////////////////////////////////////////
82

  
81 83
    @Override
82 84
    protected void onPause() 
83 85
      {
84 86
      Abort(null);   
85 87
      
86
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
88
      GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
87 89
      view.onPause();
88 90

  
89 91
      Distorted.onPause();
......
91 93
      }
92 94
    
93 95
///////////////////////////////////////////////////////////////////
96

  
94 97
    @Override
95 98
    public void onStop()
96 99
      {
......
117 120
    
118 121
    public void Bubble(View v)
119 122
      {
120
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
123
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
121 124
      view.Bubble();
122 125
      
123 126
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
......
132 135

  
133 136
    public void Sink(View v)
134 137
      {
135
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
138
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
136 139
      view.Sink();
137 140
      
138 141
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
......
147 150
    
148 151
    public void Transparency(View v)
149 152
      {
150
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
153
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
151 154
      view.Transparency();
152 155
      
153 156
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
......
162 165

  
163 166
    public void Chroma(View v)
164 167
      {
165
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
168
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
166 169
      view.Chroma();
167 170
      
168 171
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
......
177 180

  
178 181
    public void Swirl(View v)
179 182
      {
180
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
183
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
181 184
      view.Swirl();
182 185
      
183 186
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
......
192 195

  
193 196
    public void Abort(View v)
194 197
      {
195
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
198
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
196 199
      view.Abort();
197 200
      
198 201
      mAbort.setBackgroundColor(COLOR_PRESSED);
......
202 205
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
203 206
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
204 207
      }
205

  
206
///////////////////////////////////////////////////////////////////
207
// end of file
208 208
}
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
63 63

  
64 64
    private Paint mPaint;
65 65
    private int moving;
66
    private int mScrHeight;
66 67
    private long mTime = 0;
67 68
    
68 69
    private int mCurrEffect;
......
118 119
      {
119 120
      int max = width>height ? width:height;
120 121

  
122
      mScrHeight = height;
123

  
121 124
      mSize1 = max/200;
122 125
      mSize2 = max/80;
123 126
      int rad= max/6;
......
248 251
            {
249 252
            mPaint.setColor( 0xffffffff );
250 253
            mCenter.get( drawCoord, 0, (long)(i*step) );
251
            c.drawCircle(drawCoord[0], drawCoord[1], mSize1, mPaint );
254
            c.drawCircle(drawCoord[0], mScrHeight-drawCoord[1], mSize1, mPaint );
252 255
            }
253 256
          }
254 257
     
......
257 260
        for(int curr=0; curr<len; curr++)
258 261
          {       
259 262
          cu = mCenter.getPoint(curr);
260
          c.drawCircle(cu.get1(), cu.get2(), mSize2, mPaint);
263
          c.drawCircle(cu.get1(), mScrHeight-cu.get2(), mSize2, mPaint);
261 264
          }
262 265
        
263 266
        if( time-mTime > LOOP_TIME ) mTime = time;
......
266 269
       
267 270
///////////////////////////////////////////////////////////////////////////////////////////////////
268 271
    
269
    @Override public boolean onTouchEvent(MotionEvent event) 
272
    @Override
273
    public boolean onTouchEvent(MotionEvent event)
270 274
      {
271 275
      if( mCurrEffect!=EFFECT_POINTS ) return true;   
272 276

  
......
274 278

  
275 279
      switch(event.getAction())
276 280
        {
277
        case MotionEvent.ACTION_DOWN: xDown = (int)event.getX();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff