Project

General

Profile

« Previous | Next » 

Revision b4a73ea5

Added by Leszek Koltunski almost 8 years ago

Essentially revert the last commit :)

View differences:

src/main/java/org/distorted/examples/check/CheckRenderer.java
45 45
import android.graphics.BitmapFactory;
46 46
import android.opengl.GLES20;
47 47
import android.opengl.GLSurfaceView;
48
import android.util.Log;
48 49

  
49 50
///////////////////////////////////////////////////////////////////////////////////////////////////
50 51

  
51 52
class CheckRenderer implements GLSurfaceView.Renderer 
52 53
{
54
    private static final String TAG = "CheckRenderer";
55

  
53 56
    private GLSurfaceView mView;
54 57
    private DistortedBitmap mSuccess;
55 58
    private int bmpHeight, bmpWidth;
......
138 141
      dSwirl.add(new Static2D(        0, bmpHeight/2));
139 142
      dSwirl.add(new Static2D( bmpWidth, bmpHeight/2));
140 143

  
141
      mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
144
      long swirlEffectID = mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
145

  
146
      if( swirlEffectID<0 )
147
        {
148
        Log.e(TAG, "Failed to add Swirl effect!");
149
        }
142 150

  
143 151
      Dynamic3D dDeform = new Dynamic3D(2000,0.0f);
144 152
      dDeform.add(new Static3D( 0,         0,0));
145 153
      dDeform.add(new Static3D( 0,-bmpHeight,0));
146 154

  
147
      mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
155
      long deformEffectID = mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
156

  
157
      if( deformEffectID<0 )
158
        {
159
        Log.e(TAG, "Failed to add Deform effect!");
160
        }
148 161

  
149 162
      // Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1.
150 163
      Static3D color = new Static3D(1,0,0);
......
152 165
      inter.add(new Static1D(0));
153 166
      inter.add(new Static1D(1));
154 167

  
155
      mSuccess.chroma(inter, color);
168
      long chromaEffectID = mSuccess.chroma(inter, color);
169

  
170
      if( chromaEffectID<0 )
171
        {
172
        Log.e(TAG, "Failed to add Chroma effect!");
173
        }
156 174

  
157 175
      try
158 176
        {
src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
77 77

  
78 78
    ArrayList<Long> itemsID  = new ArrayList<>();
79 79

  
80
    String[] itemsName = new String[] { getText(R.string.distort     ).toString(),
81
                                        getText(R.string.sink        ).toString(),
82
                                        getText(R.string.transparency).toString(),
83
                                        getText(R.string.macroblock  ).toString(),
84
                                        getText(R.string.chroma      ).toString()};
80
    String[] itemsName = new String[] { getText(R.string.distort   ).toString(),
81
                                        getText(R.string.sink      ).toString(),
82
                                        getText(R.string.alpha     ).toString(),
83
                                        getText(R.string.macroblock).toString(),
84
                                        getText(R.string.chroma    ).toString()};
85 85

  
86 86
    String[] itemsType = new String[] {"VERTEX", "FRAGMENT"};
87 87

  
src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java
42 42
import org.distorted.library.DistortedObject;
43 43
import org.distorted.library.EffectNames;
44 44

  
45
import java.util.ArrayList;
46

  
47 45
///////////////////////////////////////////////////////////////////////////////////////////////////
48 46

  
49 47
public class Fragment3DActivity extends Activity
50
                                implements View.OnClickListener,
48
                                implements OnSeekBarChangeListener,
49
                                           View.OnClickListener,
51 50
                                           AdapterView.OnItemSelectedListener
52 51
  {
53 52
  private static final int COLOR_OFF = 0xffffe81f;
......
55 54

  
56 55
  private boolean firstScreen;
57 56

  
57
  // fields needed for the first 'pick-a-shape' screen
58
  //
58 59
  private int mNumCols = 3;
59 60
  private int mNumRows = 3;
60 61
  private NumberPicker mColsPicker, mRowsPicker;
......
64 65
  private int mObjectType;
65 66
  private int mBitmap;
66 67

  
67
  private ArrayList<Fragment3DEffect> mEffects = new ArrayList<>();
68
  private DistortedBitmap mCenter = null;
68
  // fields needed for the second 'apply fragment effects' screen
69
  //
70
  private SeekBar bar;
71
  private TextView textChroma, textAlpha, textBrightness, textSaturation, textCenter;
72
  private int chromaL, chromaR, chromaG, chromaB;
73
  private int alphaL;
74
  private int brightnessL;
75
  private int saturationL;
76
  private int centerX, centerY;
77

  
78
  private float fchromaL, fchromaR, fchromaG, fchromaB;
79
  private float falphaL;
80
  private float fbrightnessL;
81
  private float fsaturationL;
82
  private float fcenterX, fcenterY;
83
  private EffectNames[] effects = new EffectNames[4];
69 84

  
70 85
///////////////////////////////////////////////////////////////////////////////////////////////////
71 86
    
......
204 219
      firstScreen = false;
205 220
      mObject = new DistortedBitmap(100,100,mNumCols);
206 221
      setContentView(R.layout.fragment3dlayout);
222
      Default(null);
207 223
      }
208 224
    else
209 225
      {
......
232 248
      str += mShape[i] ? "1" : "0";
233 249

  
234 250
    mObject = new DistortedCubes(mNumCols, str, 10);
251

  
235 252
    setContentView(R.layout.fragment3dlayout);
253
    Default(null);
236 254
    }
237 255

  
238 256

  
......
263 281
///////////////////////////////////////////////////////////////////////////////////////////////////
264 282
// 'second screen' methods
265 283

  
266
  private void removeAllViews()
284
  public void Default(View view)
267 285
    {
268
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
286
    effects[0] = EffectNames.CHROMA;
287
    effects[1] = EffectNames.ALPHA;
288
    effects[2] = EffectNames.BRIGHTNESS;
289
    effects[3] = EffectNames.SATURATION;
290
    
291
    chromaL = 0;
292
    chromaR = 0;
293
    chromaG = 0;
294
    chromaB = 0;
295

  
296
    alphaL     = 0;
297
    brightnessL= 0;
298
    saturationL= 0;
299

  
300
    centerX = 50;
301
    centerY = 50;
302

  
303
    textCenter = (TextView)findViewById(R.id.fragment3dcenterText);
304
    computeCenter();
305
    setCenterText();
269 306

  
307
    setBar(R.id.fragment3dcenterX, centerX);
308
    setBar(R.id.fragment3dcenterY, centerY);
309

  
310
    addViews();
311
    }
312
    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314
    
315
  private void addViews()
316
    {
317
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
318
    
270 319
    layout.removeAllViews();
271
    mEffects.clear();
272
    mCenter = null;
320
      
321
    View chroma    = getLayoutInflater().inflate(R.layout.fragment3dchroma    , null);
322
    View alpha     = getLayoutInflater().inflate(R.layout.fragment3dalpha     , null);
323
    View brightness= getLayoutInflater().inflate(R.layout.fragment3dbrightness, null);
324
    View saturation= getLayoutInflater().inflate(R.layout.fragment3dsaturation, null);
325
     
326
    for( int i=effects.length-1 ; i>=0 ; i-- )
327
      {
328
      switch(effects[i])
329
        {
330
        case CHROMA     : layout.addView(chroma    , 0); break;
331
        case ALPHA      : layout.addView(alpha     , 0); break;
332
        case BRIGHTNESS : layout.addView(brightness, 0); break;
333
        case SATURATION : layout.addView(saturation, 0); break;
334
        }
335
      }
336
      
337
    textChroma    = (TextView)findViewById(R.id.fragment3dchromaText);
338
    textAlpha     = (TextView)findViewById(R.id.fragment3dalphaText);
339
    textBrightness= (TextView)findViewById(R.id.fragment3dbrightnessText);
340
    textSaturation= (TextView)findViewById(R.id.fragment3dsaturationText);
341
     
342
    setChromaText();
343
    setAlphaText();
344
    setBrightnessText();
345
    setSaturationText();
346
      
347
    setBar(R.id.fragment3dchromaBar1, chromaL);
348
    setBar(R.id.fragment3dchromaBar2, chromaR);
349
    setBar(R.id.fragment3dchromaBar3, chromaG);
350
    setBar(R.id.fragment3dchromaBar4, chromaB);
351

  
352
    setBar(R.id.fragment3dalphaBar1     , alphaL);
353
    setBar(R.id.fragment3dbrightnessBar1, brightnessL);
354
    setBar(R.id.fragment3dsaturationBar1, saturationL);
355

  
356
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
357
    view.getRenderer().setOrder(effects);
273 358
    }
274 359

  
275 360
///////////////////////////////////////////////////////////////////////////////////////////////////
276 361

  
277
  private void addView(EffectNames name)
362
  private void moveUp(EffectNames name)
278 363
    {
279
    Fragment3DEffect newInfo = new Fragment3DEffect(name);
280
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
281
    newInfo.addView(layout);
282
    mEffects.add(newInfo);
364
    int len = effects.length-1;
365
    int index = -1;
366

  
367
    for(int i=0; i<=len; i++)
368
      {
369
      if( effects[i]==name )
370
        {
371
        index=i;
372
        break;
373
        }
374
      }
375

  
376
    if( index==0 )
377
      {
378
      for(int i=0; i<len; i++)
379
        effects[i] = effects[i+1];
380

  
381
      effects[len] = name;
382
      }
383
    else if( index>0 )
384
      {
385
      effects[index]   = effects[index-1];
386
      effects[index-1] = name;
387
      }
388

  
389
    addViews();
390
    }
391

  
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

  
394
  public void ButtonChroma(View v)
395
    {
396
    moveUp(EffectNames.CHROMA);
397
    }
398

  
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

  
401
  public void ButtonAlpha(View v)
402
    {
403
    moveUp(EffectNames.ALPHA);
404
    }
405

  
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407

  
408
  public void ButtonBrightness(View v)
409
    {
410
    moveUp(EffectNames.BRIGHTNESS);
411
    }
412

  
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

  
415
  public void ButtonSaturation(View v)
416
    {
417
    moveUp(EffectNames.SATURATION);
418
    }
419

  
420
///////////////////////////////////////////////////////////////////////////////////////////////////
421

  
422
  private void setBar(int id, int value)
423
    {
424
    bar = (SeekBar)findViewById(id);
425
    bar.setOnSeekBarChangeListener(this);
426
    bar.setProgress(value);
427
    }
428

  
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430

  
431
  private void computeChroma()
432
    {
433
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
434
    Fragment3DRenderer renderer = view.getRenderer();
435

  
436
    fchromaL = chromaL/100.0f;
437
    fchromaR = chromaR*255/100.0f;
438
    fchromaG = chromaG*255/100.0f;
439
    fchromaB = chromaB*255/100.0f;
440

  
441
    renderer.setChroma( fchromaL, fchromaR, fchromaG, fchromaB );
283 442
    }
284 443

  
285 444
///////////////////////////////////////////////////////////////////////////////////////////////////
286 445

  
287
  public void Remove(View v)
446
  private void setChromaText()
288 447
    {
289
    removeAllViews();
448
    fchromaL = ((int)(100*fchromaL))/100.0f;
449
    fchromaR = (float)((int)fchromaR);
450
    fchromaG = (float)((int)fchromaG);
451
    fchromaB = (float)((int)fchromaB);
452

  
453
    textChroma.setText("chroma("+fchromaL+"( "+fchromaR+" , "+fchromaG+" , "+fchromaB+" )");
290 454
    }
291 455

  
292 456
///////////////////////////////////////////////////////////////////////////////////////////////////
293 457

  
294
  public void newChroma(View v)
458
  private void computeAlpha()
295 459
    {
296
    addView(EffectNames.CHROMA);
460
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
461

  
462
    falphaL = alphaL/100.0f;
463

  
464
    view.getRenderer().setAlpha(falphaL);
297 465
    }
298 466

  
299 467
///////////////////////////////////////////////////////////////////////////////////////////////////
300 468

  
301
  public void newAlpha(View v)
469
  private void setAlphaText()
302 470
    {
303
    addView(EffectNames.ALPHA);
471
    falphaL = ((int)(100*falphaL))/100.0f;
472

  
473
    textAlpha.setText("alpha("+falphaL+")");
304 474
    }
305 475

  
306 476
///////////////////////////////////////////////////////////////////////////////////////////////////
307 477

  
308
  public void newBrightness(View v)
478
  private void computeBrightness()
309 479
    {
310
    addView(EffectNames.BRIGHTNESS);
480
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
481

  
482
    fbrightnessL = brightnessL/100.0f;
483

  
484
    view.getRenderer().setBrightness( fbrightnessL );
311 485
    }
312 486

  
313 487
///////////////////////////////////////////////////////////////////////////////////////////////////
314 488

  
315
  public void newSaturation(View v)
489
  private void setBrightnessText()
316 490
    {
317
    addView(EffectNames.SATURATION);
491
    fbrightnessL = ((int)(100*fbrightnessL))/100.0f;
492

  
493
    textBrightness.setText("brightness("+fbrightnessL+")");
318 494
    }
319 495

  
320 496
///////////////////////////////////////////////////////////////////////////////////////////////////
321 497

  
322
  public DistortedBitmap getCenter()
498
  private void computeSaturation()
499
    {
500
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
501

  
502
    fsaturationL = saturationL/100.0f;
503

  
504
    view.getRenderer().setSaturation( fsaturationL );
505
    }
506
    
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508

  
509
  private void setSaturationText()
323 510
    {
324
    return mCenter;
511
    fsaturationL = ((int)(100*fsaturationL))/100.0f;
512

  
513
    textSaturation.setText("saturation("+fsaturationL+")");
325 514
    }
326 515

  
327 516
///////////////////////////////////////////////////////////////////////////////////////////////////
328 517

  
329
  public void setCenter(DistortedBitmap center  )
518
  private void computeCenter()
330 519
    {
331
    mCenter = center;
520
    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
521

  
522
    fcenterX = centerX;
523
    fcenterY = centerY;
524

  
525
    view.getRenderer().setCenter( fcenterX, fcenterY );
526
    }
527

  
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

  
530
  private void setCenterText()
531
    {
532
    fcenterX = ((int)(100*fcenterX))/100.0f;
533
    fcenterY = ((int)(100*fcenterY))/100.0f;
534

  
535
    textCenter.setText("center("+fcenterX+","+fcenterY+")");
536
    }
537

  
538
///////////////////////////////////////////////////////////////////////////////////////////////////
539

  
540
  public float getCenterX()
541
    {
542
    return fcenterX;
543
    }
544

  
545
///////////////////////////////////////////////////////////////////////////////////////////////////
546

  
547
  public float getCenterY()
548
    {
549
    return fcenterY;
332 550
    }
333 551

  
334 552
///////////////////////////////////////////////////////////////////////////////////////////////////
......
374 592
    Distorted.onDestroy();
375 593
    super.onDestroy();
376 594
    }
595
    
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597
    
598
  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
599
    {
600
    switch (bar.getId())
601
      {
602
      case R.id.fragment3dcenterX       : centerX    = progress; computeCenter()    ; setCenterText()    ; break;
603
      case R.id.fragment3dcenterY       : centerY    = progress; computeCenter()    ; setCenterText()    ; break;
604
      case R.id.fragment3dchromaBar1    : chromaL    = progress; computeChroma()    ; setChromaText()    ; break;
605
      case R.id.fragment3dchromaBar2    : chromaR    = progress; computeChroma()    ; setChromaText()    ; break;
606
      case R.id.fragment3dchromaBar3    : chromaG    = progress; computeChroma()    ; setChromaText()    ; break;
607
      case R.id.fragment3dchromaBar4    : chromaB    = progress; computeChroma()    ; setChromaText()    ; break;
608
      case R.id.fragment3dalphaBar1     : alphaL     = progress; computeAlpha()     ; setAlphaText()     ; break;
609
      case R.id.fragment3dbrightnessBar1: brightnessL= progress; computeBrightness(); setBrightnessText(); break;
610
      case R.id.fragment3dsaturationBar1: saturationL= progress; computeSaturation(); setSaturationText(); break;
611
      }
612
    }
613

  
614
///////////////////////////////////////////////////////////////////////////////////////////////////
615

  
616
  public void onStartTrackingTouch(SeekBar bar) { }
617
    
618
///////////////////////////////////////////////////////////////////////////////////////////////////
619

  
620
  public void onStopTrackingTouch(SeekBar bar)  { }
377 621
  }
src/main/java/org/distorted/examples/fragment3d/Fragment3DEffect.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.examples.fragment3d;
21

  
22
import android.widget.LinearLayout;
23
import android.widget.SeekBar;
24
import android.widget.TextView;
25

  
26
import org.distorted.library.DistortedBitmap;
27
import org.distorted.library.EffectNames;
28

  
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

  
31
public class Fragment3DEffect implements SeekBar.OnSeekBarChangeListener
32

  
33
  {
34
  private static Fragment3DActivity activity;
35

  
36
  private EffectNames name;
37
  private float inter1, inter2, inter3, inter4;
38
  private float regX, regY, regRX, regRY;
39

  
40
  private TextView textEffect, textCenter;
41
  private SeekBar[] mSpinRegion;
42
  private SeekBar[] mSpinInter;
43

  
44
  private DistortedBitmap mRegion;
45

  
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

  
48
  public static void setActivity(Fragment3DActivity act)
49
    {
50
    activity = act;
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  public Fragment3DEffect(EffectNames name)
56
    {
57
    this.name = name;
58
    mSpinInter = new SeekBar[name.getDimension()];
59
    mSpinRegion= new SeekBar[4];
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public void addView(LinearLayout layout)
65
    {
66

  
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  private void setBar(int id, int value)
72
    {
73
    SeekBar bar = (SeekBar)activity.findViewById(id);
74
    bar.setOnSeekBarChangeListener(this);
75
    bar.setProgress(value);
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
81
    {
82
    switch (bar.getId())
83
      {
84
      // TODO
85
      }
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  public void onStartTrackingTouch(SeekBar bar) { }
91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
  public void onStopTrackingTouch(SeekBar bar)  { }
95
  }
src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
61 61

  
62 62
    private DynamicQuat mQuatInt1, mQuatInt2;
63 63

  
64
    private EffectNames[] order;
65

  
66
    private Dynamic2D mCenterInter;
67
    private Dynamic3D mChromaInter, mMoveInter;
68
    private Dynamic1D mChromaLevelInter, mAlphaInter, mBrightnessInter, mSaturationInter;
69

  
70
    private Static2D mCenterPoint;
71
    private Static3D mChromaPoint, mMovePoint;
72
    private Static1D mChromaLevel, mAlphaPoint, mBrightnessPoint, mSaturationPoint;
73

  
64 74
    Static4D mQuat1, mQuat2;
65 75
    int mScreenMin;
66 76

  
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

  
79
    public void setChroma(float level, float r, float g, float b)
80
      {
81
      mChromaLevel.set(level);
82
      mChromaPoint.set(r, g, b);
83
      }
84
    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

  
87
    public void setAlpha(float level)
88
      {
89
      mAlphaPoint.set(level);
90
      }
91
     
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
    public void setBrightness(float level)
95
      {
96
      mBrightnessPoint.set(level);
97
      }
98
    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

  
101
    public void setSaturation(float level)
102
      {
103
      mSaturationPoint.set(level);
104
      }
105

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

  
108
    public void setCenter(float x, float y)
109
      {
110
      x = (0.012f*x-0.1f)*mObjWidth;
111
      y = (0.012f*y-0.1f)*mObjHeight;
112

  
113
      mCenterPoint.set(x,y);
114
      mMovePoint.set(mFactorObj*x,mFactorObj*y,0);
115
      }
116

  
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

  
119
    public void setOrder(EffectNames[] effects)
120
      {
121
      order = effects;
122
      setFragmentEffects();
123
      }
124
      
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

  
127
    private void setFragmentEffects()
128
      {
129
      mObject.abortEffects(EffectTypes.FRAGMENT);
130

  
131
      for( int i=0; i<=order.length-1 ; i++ )
132
        {
133
        switch(order[i])
134
          {
135
          case CHROMA    : mObject.chroma    ( mChromaLevelInter , mChromaInter) ; break;
136
          case ALPHA     : mObject.alpha     ( mAlphaInter                     ) ; break;
137
          case BRIGHTNESS: mObject.brightness( mBrightnessInter                ) ; break;
138
          case SATURATION: mObject.saturation( mSaturationInter                ) ; break;
139
          }
140
        }
141
      }
142
    
67 143
///////////////////////////////////////////////////////////////////////////////////////////////////
68 144

  
69 145
    public Fragment3DRenderer(GLSurfaceView v)
......
71 147
      mView = v;
72 148

  
73 149
      mObject = ((Fragment3DActivity)v.getContext()).getObject();
150
      mCenter = new DistortedBitmap(SIZE, SIZE, 1);
74 151

  
75 152
      mObjWidth = mObject.getWidth();
76 153
      mObjHeight= mObject.getHeight();
77 154

  
155
      mCenterPoint    = new Static2D(0,0);
156
      mMovePoint      = new Static3D(0,0,0);
157
      mChromaPoint    = new Static3D(0,0,0);
158
      mChromaLevel    = new Static1D(0);
159
      mAlphaPoint     = new Static1D(1);
160
      mBrightnessPoint= new Static1D(1);
161
      mSaturationPoint= new Static1D(0.5f);
162

  
163
      mCenterInter     = new Dynamic2D();
164
      mMoveInter       = new Dynamic3D();
165
      mChromaInter     = new Dynamic3D();
166
      mChromaLevelInter= new Dynamic1D();
167
      mAlphaInter      = new Dynamic1D();
168
      mBrightnessInter = new Dynamic1D();
169
      mSaturationInter = new Dynamic1D();
170

  
171
      mCenterInter.add(mCenterPoint);
172
      mMoveInter.add(mMovePoint);
173
      mChromaInter.add(mChromaPoint);
174
      mChromaLevelInter.add(mChromaLevel);
175
      mAlphaInter.add(mAlphaPoint);
176
      mBrightnessInter.add(mBrightnessPoint);
177
      mSaturationInter.add(mSaturationPoint);
178

  
78 179
      mQuat1 = new Static4D(0,0,0,1);  // unity
79 180
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
80 181

  
......
95 196
      long time = System.currentTimeMillis();
96 197

  
97 198
      mObject.draw(time);
98

  
99
      mCenter = mView.
100

  
101 199
      mCenter.draw(time);
102 200
      }
103 201

  
......
123 221
        mFactorCen = (0.15f*width)/centerSize;
124 222
        }
125 223

  
126

  
127
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
128

  
129
      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
130
      mObject.scale(mFactorObj);
131
      mObject.quaternion(mQuatInt1, rotateObj);
132
      mObject.quaternion(mQuatInt2, rotateObj);
133

  
134 224
      Fragment3DActivity act = (Fragment3DActivity)mView.getContext();
135 225
      float cX = act.getCenterX();
136 226
      float cY = act.getCenterY();
......
140 230

  
141 231
      mMovePoint.set(cX*mFactorObj,cY*mFactorObj,0);
142 232

  
233
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
234

  
235
      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
236
      mObject.scale(mFactorObj);
237
      mObject.quaternion(mQuatInt1, rotateObj);
238
      mObject.quaternion(mQuatInt2, rotateObj);
239

  
143 240
      Static3D rotateCen = new Static3D(width/2,height/2, 0);
144 241

  
145 242
      mCenter.quaternion(mQuatInt1, rotateCen);
src/main/res/layout/fragment3dalpha.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
              android:id="@+id/fragment3dRowAlpha"
4
              android:layout_width="match_parent"
5
              android:layout_height="wrap_content"
6
              android:orientation="horizontal">
2 7

  
3
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
                          android:id="@+id/fragment3dRowAlpha"
5
                          android:layout_width="match_parent"
6
                          android:layout_height="wrap_content"
7
                          android:orientation="horizontal">
8
    <LinearLayout
9
        android:layout_width="0dp"
10
        android:layout_height="wrap_content"
11
        android:layout_weight="0.8"
12
        android:orientation="vertical" >
8 13

  
9
                <LinearLayout
10
                    android:layout_width="0dp"
11
                    android:layout_height="wrap_content"
12
                    android:layout_weight="0.8"
13
                    android:orientation="vertical" >
14
        <TextView
15
            android:id="@+id/fragment3dalphaText"
16
            android:layout_width="wrap_content"
17
            android:layout_height="wrap_content"
18
            android:layout_marginEnd="5dp"
19
            android:layout_marginStart="5dp"
20
            android:layout_marginTop="3dp"
21
            />
14 22

  
15
                    <TextView
16
                        android:id="@+id/fragment3dalphaText"
17
                        android:layout_width="wrap_content"
18
                        android:layout_height="wrap_content"
19
                        android:layout_marginEnd="5dp"
20
                        android:layout_marginStart="5dp"
21
                        android:layout_marginTop="3dp"
22
                        />
23
        <SeekBar
24
            android:id="@+id/fragment3dalphaBar1"
25
            android:layout_width="fill_parent"
26
            android:layout_height="wrap_content"
27
            android:layout_marginEnd="5dp"
28
            android:layout_marginLeft="5dp"
29
            android:layout_marginRight="5dp" />
30
    </LinearLayout>
23 31

  
24
                    <SeekBar
25
                        android:id="@+id/fragment3dalphaBar1"
26
                        android:layout_width="fill_parent"
27
                        android:layout_height="wrap_content"
28
                        android:layout_marginEnd="5dp"
29
                        android:layout_marginLeft="5dp"
30
                        android:layout_marginRight="5dp" />
31

  
32
                </LinearLayout>
33

  
34
                <Button
35
                    android:id="@+id/fragment3dUpAlpha"
36
                    android:layout_width="60dp"
37
                    android:layout_height="fill_parent"
38
                    android:onClick="ButtonAlpha"
39
                    android:text="@string/Up" />
40

  
41
            </LinearLayout>
32
    <Button
33
        android:id="@+id/fragment3dUpAlpha"
34
        android:layout_width="60dp"
35
        android:layout_height="fill_parent"
36
        android:onClick="ButtonAlpha"
37
        android:text="@string/Up" />
38
</LinearLayout>
src/main/res/layout/fragment3dbrightness.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2

  
3
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
                          android:id="@+id/fragment3dRowBrightness"
5
                          android:orientation="horizontal"
6
                          android:layout_width="match_parent"
7
                          android:layout_height="wrap_content" >
3
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
              android:id="@+id/fragment3dRowBrightness"
5
              android:orientation="horizontal"
6
              android:layout_width="match_parent"
7
              android:layout_height="wrap_content" >
8 8

  
9
                <LinearLayout
10
                    android:layout_width="0dp"
11
                    android:layout_height="match_parent"
12
                    android:layout_weight="0.70"
13
                    android:orientation="vertical" >
9
    <LinearLayout
10
        android:layout_width="0dp"
11
        android:layout_height="match_parent"
12
        android:layout_weight="0.70"
13
        android:orientation="vertical" >
14 14

  
15
                    <TextView
16
                        android:id="@+id/fragment3dbrightnessText"
17
                        android:layout_width="wrap_content"
18
                        android:layout_height="wrap_content"
19
                        android:layout_marginEnd="5dp"
20
                        android:layout_marginStart="5dp"
21
                        android:layout_marginTop="3dp"
22
                        />
15
        <TextView
16
            android:id="@+id/fragment3dbrightnessText"
17
            android:layout_width="wrap_content"
18
            android:layout_height="wrap_content"
19
            android:layout_marginEnd="5dp"
20
            android:layout_marginStart="5dp"
21
            android:layout_marginTop="3dp" />
23 22

  
24
                    <SeekBar
25
                        android:id="@+id/fragment3dbrightnessBar1"
26
                        android:layout_width="fill_parent"
27
                        android:layout_height="wrap_content"
28
                        android:layout_gravity="end"
29
                        android:layout_marginEnd="5dp"
30
                        android:layout_marginLeft="5dp"
31
                        android:layout_marginRight="5dp" />
23
        <SeekBar
24
            android:id="@+id/fragment3dbrightnessBar1"
25
            android:layout_width="fill_parent"
26
            android:layout_height="wrap_content"
27
            android:layout_gravity="end"
28
            android:layout_marginEnd="5dp"
29
            android:layout_marginLeft="5dp"
30
            android:layout_marginRight="5dp" />
32 31

  
33
                </LinearLayout>
32
    </LinearLayout>
34 33

  
35
                <Button
36
                    android:id="@+id/fragment3dUpBrightness"
37
                    android:layout_width="60dp"
38
                    android:layout_height="fill_parent"
39
                    android:onClick="ButtonBrightness"
40
                    android:text="@string/Up" />
34
    <Button
35
        android:id="@+id/fragment3dUpBrightness"
36
        android:layout_width="60dp"
37
        android:layout_height="fill_parent"
38
        android:onClick="ButtonBrightness"
39
        android:text="@string/Up" />
41 40

  
42
            </LinearLayout>
43
           
41
</LinearLayout>
src/main/res/layout/fragment3dchroma.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
                          android:id="@+id/fragment3dRowChroma"
4
                          android:orientation="horizontal"
5
                          android:layout_width="match_parent"
6
                          android:layout_height="wrap_content" >
7 2

  
8
                <LinearLayout
9
                    android:layout_width="0dp"
10
                    android:layout_height="match_parent"
11
                    android:layout_weight="0.70"
12
                    android:orientation="vertical" >
3
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
              android:id="@+id/fragment3dRowChroma"
5
              android:orientation="horizontal"
6
              android:layout_width="match_parent"
7
              android:layout_height="wrap_content" >
8
    <LinearLayout
9
        android:layout_width="0dp"
10
        android:layout_height="match_parent"
11
        android:layout_weight="0.70"
12
        android:orientation="vertical" >
13 13

  
14
                    <TextView
15
                        android:id="@+id/fragment3dchromaText"
16
                        android:layout_width="wrap_content"
17
                        android:layout_height="wrap_content"
18
                        android:layout_marginEnd="5dp"
19
                        android:layout_marginStart="5dp"
20
                        android:layout_marginTop="3dp"
21
                        />
14
        <TextView
15
            android:id="@+id/fragment3dchromaText"
16
            android:layout_width="wrap_content"
17
            android:layout_height="wrap_content"
18
            android:layout_marginEnd="5dp"
19
            android:layout_marginStart="5dp"
20
            android:layout_marginTop="3dp" />
22 21

  
23
                    <SeekBar
24
                        android:id="@+id/fragment3dchromaBar1"
25
                        android:layout_width="fill_parent"
26
                        android:layout_height="wrap_content"
27
                        android:layout_gravity="end"
28
                        android:layout_marginEnd="5dp"
29
                        android:layout_marginLeft="5dp"
30
                        android:layout_marginRight="5dp" />
22
        <SeekBar
23
            android:id="@+id/fragment3dchromaBar1"
24
            android:layout_width="fill_parent"
25
            android:layout_height="wrap_content"
26
            android:layout_gravity="end"
27
            android:layout_marginEnd="5dp"
28
            android:layout_marginLeft="5dp"
29
            android:layout_marginRight="5dp" />
31 30

  
32
                    <LinearLayout
33
                        android:orientation="horizontal"
34
                        android:layout_width="match_parent"
35
                        android:layout_height="match_parent">
31
        <LinearLayout
32
            android:orientation="horizontal"
33
            android:layout_width="match_parent"
34
            android:layout_height="match_parent">
36 35

  
37
                        <SeekBar
38
                            android:id="@+id/fragment3dchromaBar2"
39
                            android:layout_width="fill_parent"
40
                            android:layout_height="wrap_content"
41
                            android:layout_marginLeft="5dp"
42
                            android:layout_marginRight="5dp"
43
                            android:layout_weight="0.33"/>
36
            <SeekBar
37
                android:id="@+id/fragment3dchromaBar2"
38
                android:layout_width="fill_parent"
39
                android:layout_height="wrap_content"
40
                android:layout_marginLeft="5dp"
41
                android:layout_marginRight="5dp"
42
                android:layout_weight="0.33"/>
44 43

  
45
                        <SeekBar
46
                            android:id="@+id/fragment3dchromaBar3"
47
                            android:layout_width="fill_parent"
48
                            android:layout_height="wrap_content"
49
                            android:layout_marginEnd="5dp"
50
                            android:layout_marginLeft="5dp"
51
                            android:layout_marginRight="5dp"
52
                            android:layout_weight="0.33"/>
44
            <SeekBar
45
                android:id="@+id/fragment3dchromaBar3"
46
                android:layout_width="fill_parent"
47
                android:layout_height="wrap_content"
48
                android:layout_marginEnd="5dp"
49
                android:layout_marginLeft="5dp"
50
                android:layout_marginRight="5dp"
51
                android:layout_weight="0.33"/>
53 52

  
54
                        <SeekBar
55
                            android:id="@+id/fragment3dchromaBar4"
56
                            android:layout_width="fill_parent"
57
                            android:layout_height="wrap_content"
58
                            android:layout_marginRight="5dp"
59
                            android:layout_marginLeft="5dp"
60
                            android:layout_weight="0.33"/>
61
                    </LinearLayout>
53
            <SeekBar
54
                android:id="@+id/fragment3dchromaBar4"
55
                android:layout_width="fill_parent"
56
                android:layout_height="wrap_content"
57
                android:layout_marginRight="5dp"
58
                android:layout_marginLeft="5dp"
59
                android:layout_weight="0.33"/>
62 60

  
63
                </LinearLayout>
61
        </LinearLayout>
64 62

  
65
                <Button
66
                    android:id="@+id/fragment3dUpChroma"
67
                    android:layout_width="60dp"
68
                    android:layout_height="fill_parent"
69
                    android:onClick="ButtonChroma"
70
                    android:text="@string/Up" />
63
    </LinearLayout>
71 64

  
72
            </LinearLayout>
65
    <Button
66
        android:id="@+id/fragment3dUpChroma"
67
        android:layout_width="60dp"
68
        android:layout_height="fill_parent"
69
        android:onClick="ButtonChroma"
70
        android:text="@string/Up" />
71

  
72
</LinearLayout>
src/main/res/layout/fragment3dlayout.xml
13 13
    <LinearLayout
14 14
        android:orientation="horizontal"
15 15
        android:layout_width="match_parent"
16
        android:layout_height="50dp">
16
        android:layout_height="wrap_content"
17
        android:layout_marginBottom="5dp"
18
        android:background="@android:color/holo_green_dark">
17 19

  
18
        <Button
19
            android:layout_width="wrap_content"
20
            android:layout_height="wrap_content"
21
            android:text="@string/chroma"
22
            android:id="@+id/newChroma"
23
            android:onClick="newChroma"/>
20
        <LinearLayout
21
            android:orientation="vertical"
22
            android:layout_width="0dp"
23
            android:layout_height="match_parent"
24
            android:layout_weight="0.8">
24 25

  
25
        <Button
26
            android:layout_width="wrap_content"
27
            android:layout_height="wrap_content"
28
            android:text="@string/alpha"
29
            android:id="@+id/newAlpha"
30
            android:onClick="newAlpha"/>
26
            <TextView
27
                android:id="@+id/fragment3dcenterText"
28
                android:layout_width="wrap_content"
29
                android:layout_height="wrap_content"
30
                android:layout_marginEnd="5dp"
31
                android:layout_marginStart="5dp"
32
                android:layout_marginTop="3dp"
33
                />
31 34

  
32
        <Button
33
            android:layout_width="wrap_content"
34
            android:layout_height="wrap_content"
35
            android:text="@string/brightness"
36
            android:id="@+id/newBrigthness"
37
            android:onClick="newBrightness"/>
35
            <LinearLayout
36
                android:orientation="horizontal"
37
                android:layout_width="match_parent"
38
                android:layout_height="match_parent"
39
                >
38 40

  
39
        <Button
40
            android:layout_width="wrap_content"
41
            android:layout_height="wrap_content"
42
            android:text="@string/saturation"
43
            android:id="@+id/newSaturation"
44
            android:onClick="newSaturation"/>
41
                <SeekBar
42
                    android:layout_width="fill_parent"
43
                    android:layout_height="wrap_content"
44
                    android:id="@+id/fragment3dcenterX"
45
                    android:layout_weight="0.5"
46
                    android:paddingLeft="5dp"
47
                    android:paddingRight="3dp"/>
48

  
49
                <SeekBar
50
                    android:layout_width="fill_parent"
51
                    android:layout_height="wrap_content"
52
                    android:id="@+id/fragment3dcenterY"
53
                    android:layout_weight="0.5"
54
                    android:paddingLeft="3dp"
55
                    android:paddingRight="5dp"/>
56
            </LinearLayout>
57

  
58
        </LinearLayout>
45 59

  
46 60
        <Button
47 61
            android:id="@+id/buttonDefault"
48
            android:layout_width="fill_parent"
62
            android:layout_width="60dp"
49 63
            android:layout_height="wrap_content"
50
            android:onClick="Remove"
51
            android:text="@string/removebut"
64
            android:onClick="Default"
65
            android:text="@string/reset"
52 66
            android:layout_gravity="right"
53 67
            android:layout_marginTop="3dp"/>
54 68
    </LinearLayout>
src/main/res/layout/fragment3dsaturation.xml
1 1
<?xml version="1.0" encoding="utf-8"?>
2
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
                          android:id="@+id/fragment3dRowSaturation"
4
                          android:orientation="horizontal"
5
                          android:layout_width="match_parent"
6
                          android:layout_height="wrap_content" >
7 2

  
8
                <LinearLayout
9
                    android:layout_width="0dp"
10
                    android:layout_height="match_parent"
11
                    android:layout_weight="0.70"
12
                    android:orientation="vertical" >
3
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
              android:id="@+id/fragment3dRowSaturation"
5
              android:orientation="horizontal"
6
              android:layout_width="match_parent"
7
              android:layout_height="wrap_content" >
13 8

  
14
                    <TextView
15
                        android:id="@+id/fragment3dsaturationText"
16
                        android:layout_width="wrap_content"
17
                        android:layout_height="wrap_content"
18
                        android:layout_marginEnd="5dp"
19
                        android:layout_marginStart="5dp"
20
                        android:layout_marginTop="3dp"
21
                        />
9
    <LinearLayout
10
        android:layout_width="0dp"
11
        android:layout_height="match_parent"
12
        android:layout_weight="0.70"
13
        android:orientation="vertical" >
22 14

  
23
                    <SeekBar
24
                        android:id="@+id/fragment3dsaturationBar1"
25
                        android:layout_width="fill_parent"
26
                        android:layout_height="wrap_content"
27
                        android:layout_gravity="end"
28
                        android:layout_marginEnd="5dp"
29
                        android:layout_marginLeft="5dp"
30
                        android:layout_marginRight="5dp" />
15
        <TextView
16
            android:id="@+id/fragment3dsaturationText"
17
            android:layout_width="wrap_content"
18
            android:layout_height="wrap_content"
19
            android:layout_marginEnd="5dp"
20
            android:layout_marginStart="5dp"
21
            android:layout_marginTop="3dp" />
31 22

  
32
                </LinearLayout>
23
        <SeekBar
24
            android:id="@+id/fragment3dsaturationBar1"
25
            android:layout_width="fill_parent"
26
            android:layout_height="wrap_content"
27
            android:layout_gravity="end"
28
            android:layout_marginEnd="5dp"
29
            android:layout_marginLeft="5dp"
30
            android:layout_marginRight="5dp" />
33 31

  
34
                <Button
35
                    android:id="@+id/fragment3dUpSaturation"
36
                    android:layout_width="60dp"
37
                    android:layout_height="fill_parent"
38
                    android:onClick="ButtonSaturation"
39
                    android:text="@string/Up" />
32
    </LinearLayout>
40 33

  
41
            </LinearLayout>
34
    <Button
35
        android:id="@+id/fragment3dUpSaturation"
36
        android:layout_width="60dp"
37
        android:layout_height="fill_parent"
38
        android:onClick="ButtonSaturation"
39
        android:text="@string/Up" />
40

  
41
</LinearLayout>
src/main/res/layout/movingeffectslayout.xml
64 64
            android:onClick="Transparency"
65 65
            android:paddingLeft="5dp"
66 66
            android:paddingRight="5dp"
67
            android:text="@string/transparency" />
67
            android:text="@string/alpha" />
68 68

  
69 69
        <Button
70 70
            android:id="@+id/movingeffectsMacro"

Also available in: Unified diff