Project

General

Profile

« Previous | Next » 

Revision 40eef4b9

Added by Leszek Koltunski almost 8 years ago

Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.

Still does not compile, but pushing already.

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
122 122
      mObjWidth = bitmap.getWidth();
123 123
      mObjHeight= bitmap.getHeight();
124 124

  
125
      mObject = new DistortedObject(mObjWidth,mObjHeight,1);
125
      mObject = new DistortedObject(mObjWidth,mObjHeight,0);
126 126
      mObject.setTexture(bitmap);
127 127
      mEffects.apply(mObject);
128 128

  
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java
27 27

  
28 28
import org.distorted.examples.R;
29 29
import org.distorted.library.Distorted;
30
import org.distorted.library.DistortedObject;
30
import org.distorted.library.DistortedEffectQueues;
31
import org.distorted.library.DistortedTexture;
31 32
import org.distorted.library.GridFlat;
32 33
import org.distorted.library.EffectTypes;
33 34
import org.distorted.library.type.Dynamic1D;
......
46 47
class CatAndDogRenderer implements GLSurfaceView.Renderer
47 48
{
48 49
    private GLSurfaceView mView;
49
    private DistortedObject mObject;
50
    private DistortedEffectQueues mQueues;
51
    private DistortedTexture mTexture;
50 52
    private GridFlat mGrid;
51
    private Static4D chromaRegion, alphaRegion;
52 53
    private int bmpHeight, bmpWidth;
53 54

  
54 55
///////////////////////////////////////////////////////////////////////////////////////////////////
......
56 57
    public CatAndDogRenderer(GLSurfaceView v)
57 58
      {   
58 59
      mView = v;
59
      
60
      chromaRegion= new Static4D( 530, 200,100,100);
61
      alphaRegion = new Static4D( 230, 200,100,100);
60

  
61
      mGrid   = new GridFlat(1,1);  // no vertex effects, grid can be a (1x1) quad.
62
      mQueues = new DistortedEffectQueues();
63

  
64
      Static4D chromaRegion= new Static4D( 530, 200,100,100);
65
      Static4D alphaRegion = new Static4D( 230, 200,100,100);
66

  
67
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
68
      chromaDyn.add(new Static1D(1));
69
      chromaDyn.add(new Static1D(0));
70

  
71
      mQueues.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
72

  
73
      Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f);
74
      alphaDyn.add(new Static1D(1));
75
      alphaDyn.add(new Static1D(0));
76

  
77
      mQueues.alpha( alphaDyn, alphaRegion, false );
62 78
      }
63 79

  
64 80
///////////////////////////////////////////////////////////////////////////////////////////////////
......
66 82
    public void onDrawFrame(GL10 glUnused) 
67 83
      {
68 84
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
69
      mObject.draw(System.currentTimeMillis(), mGrid);
85
      mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
70 86
      }
71 87

  
72 88
///////////////////////////////////////////////////////////////////////////////////////////////////
......
94 110
      bmpHeight = bitmap.getHeight();
95 111
      bmpWidth  = bitmap.getWidth();
96 112

  
97
      mGrid = new GridFlat(1,1);  // no vertex effects, grid can be a (1x1) quad.
98

  
99
      mObject = new DistortedObject(bmpWidth,bmpHeight,1);
100
      mObject.setTexture(bitmap);
101

  
102
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
103
      chromaDyn.add(new Static1D(1));
104
      chromaDyn.add(new Static1D(0));
105

  
106
      mObject.chroma(chromaDyn, new Static3D(1,0,0), chromaRegion ,true);
107

  
108
      Dynamic1D alphaDyn = new Dynamic1D(3000,0.0f);
109
      alphaDyn.add(new Static1D(1));
110
      alphaDyn.add(new Static1D(0));
113
      mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
114
      mTexture.setTexture(bitmap);
111 115

  
112
      mObject.alpha( alphaDyn, alphaRegion, false );
113
      
114 116
      try
115 117
        {
116 118
        Distorted.onSurfaceCreated(mView.getContext());
......
139 141
      diRotate.add(new Static1D(  0));
140 142
      diRotate.add(new Static1D(360));
141 143
      
142
      mObject.abortEffects(EffectTypes.MATRIX);
144
      mQueues.abortEffects(EffectTypes.MATRIX);
143 145

  
144
      mObject.move(diMove);
145
      mObject.scale(diScale);
146
      mObject.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
146
      mQueues.move(diMove);
147
      mQueues.scale(diScale);
148
      mQueues.rotate( diRotate, new Static3D(0,0,1), new Static3D(bmpWidth/2,bmpHeight/2,0) );
147 149

  
148 150
      Distorted.onSurfaceChanged(width, height); 
149 151
      }
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
29 29

  
30 30
import org.distorted.library.Distorted;
31 31
import org.distorted.library.GridFlat;
32
import org.distorted.library.DistortedObject;
32
import org.distorted.library.DistortedTexture;
33
import org.distorted.library.DistortedEffectQueues;
33 34
import org.distorted.library.EffectTypes;
34 35
import org.distorted.library.type.Dynamic1D;
35 36
import org.distorted.library.type.Dynamic3D;
......
49 50
   private static final int NUM = 3;
50 51
   
51 52
   private GLSurfaceView mView;
52
   private DistortedObject[] mObj;
53
   private DistortedEffectQueues[] mQueue;
54
   private DistortedTexture mTexture;
53 55
   private GridFlat mGrid;
54
   private Static3D pLeft, pRight, pNose1;
55
   private Static4D RegionEye;
56
   private Dynamic3D mDI;
57 56
   private int bmpHeight, bmpWidth;
58 57
    
59 58
///////////////////////////////////////////////////////////////////////////////////////////////////
......
62 61
      {     
63 62
      mView = v;
64 63
      
65
      // mObj[0] effects
66
      pLeft = new Static3D(214, 206, 0);
67
      pRight= new Static3D(390, 212, 0);
68
      RegionEye = new Static4D(0,0,60,60);
64
      // mQueue[0] effects
65
      Static3D pLeft = new Static3D(214, 206, 0);
66
      Static3D pRight= new Static3D(390, 212, 0);
67
      Static4D RegionEye = new Static4D(0,0,60,60);
69 68
      
70
      // mObj[1] effects
71
      mDI = new Dynamic3D(1000,0.0f);
72
      mDI.add(new Static3D( 50,0,0));
73
      mDI.add(new Static3D(-50,0,0));
74
      pNose1 = new Static3D(305, 340, 0);
69
      // mQueue[1] effects
70
      Dynamic3D dyn = new Dynamic3D(1000,0.0f);
71
      dyn.add(new Static3D( 50,0,0));
72
      dyn.add(new Static3D(-50,0,0));
73
      Static3D pNose1 = new Static3D(305, 340, 0);
75 74
      
76
      // we don't need to prepare anything for bmp[2] effects
75
      // we don't need to prepare anything for mQueue[2] effects
76

  
77
      mQueue= new DistortedEffectQueues[NUM];
78

  
79
      for(int i=0; i<NUM; i++) mQueue[i] = new DistortedEffectQueues();
80

  
81
      Dynamic1D sink = new Dynamic1D(2000,0.0f);
82
      sink.add(new Static1D( 1));
83
      sink.add(new Static1D(10));
84

  
85
      mQueue[0].sink(sink, pLeft, RegionEye);
86
      mQueue[0].sink(sink, pRight,RegionEye);
87
      mQueue[1].distort(dyn, pNose1);
88

  
89
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
90
      chromaDyn.add(new Static1D(0));
91
      chromaDyn.add(new Static1D(1));
92

  
93
      mQueue[2].chroma(chromaDyn, new Static3D(0,1,0) );
77 94
      }
78 95

  
79 96
///////////////////////////////////////////////////////////////////////////////////////////////////
......
84 101
      
85 102
     long time = System.currentTimeMillis();
86 103
   
87
     for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
104
     for(int i=NUM-1; i>=0; i--) mQueue[i].draw(time, mTexture, mGrid);
88 105
     }
89 106

  
90 107
///////////////////////////////////////////////////////////////////////////////////////////////////
......
93 110
     {
94 111
     for(int i=NUM-1; i>=0; i--)
95 112
       {
96
       mObj[i].abortEffects(EffectTypes.MATRIX);
113
       mQueue[i].abortEffects(EffectTypes.MATRIX);
97 114
       }
98 115
      
99 116
     if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
......
103 120

  
104 121
       for(int i=NUM-1; i>=0; i--)
105 122
         {
106
         mObj[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
107
         mObj[i].scale(factor);
123
         mQueue[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
124
         mQueue[i].scale(factor);
108 125
         }
109 126
       }
110 127
     else
......
115 132

  
116 133
       for(int i=NUM-1; i>=0; i--)
117 134
         {
118
         mObj[i].move( new Static3D(i*w, (height-h)/2, 0) );
119
         mObj[i].scale(factor);
135
         mQueue[i].move( new Static3D(i*w, (height-h)/2, 0) );
136
         mQueue[i].scale(factor);
120 137
         }
121 138
       }
122 139
       
......
148 165
     bmpHeight = bitmap.getHeight();
149 166
     bmpWidth  = bitmap.getWidth();
150 167

  
151
     mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
168
     mGrid     = new GridFlat(30,30*bmpHeight/bmpWidth);
169
     mTexture  = new DistortedTexture(bmpWidth, bmpHeight, 1);
152 170

  
153
     mObj = new DistortedObject[NUM];
154
     mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1);
155
      
156
     for(int i=1; i<NUM; i++) mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_BITMAP);
157
      
158
     // setting the bitmap once is enough; others are cloned!
159
     mObj[0].setTexture(bitmap);
160

  
161
     Dynamic1D sink = new Dynamic1D(2000,0.0f);
162
     sink.add(new Static1D( 1));
163
     sink.add(new Static1D(10));
171
     mTexture.setTexture(bitmap);
164 172

  
165
     mObj[0].sink(sink, pLeft, RegionEye);
166
     mObj[0].sink(sink, pRight,RegionEye);
167
     mObj[1].distort(mDI, pNose1);
168

  
169
     Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
170
     chromaDyn.add(new Static1D(0));
171
     chromaDyn.add(new Static1D(1));
172

  
173
     mObj[2].chroma(chromaDyn, new Static3D(0,1,0) );
174
      
175 173
     try
176 174
       {
177 175
       Distorted.onSurfaceCreated(mView.getContext());
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java
30 30
import android.opengl.GLSurfaceView;
31 31

  
32 32
import org.distorted.library.GridFlat;
33
import org.distorted.library.DistortedObject;
33
import org.distorted.library.DistortedEffectQueues;
34
import org.distorted.library.DistortedTexture;
34 35
import org.distorted.library.Distorted;
35 36

  
36 37
///////////////////////////////////////////////////////////////////////////////////////////////////
......
38 39
class DynamicRenderer implements GLSurfaceView.Renderer
39 40
   {  
40 41
   private DynamicSurfaceView mView;
41
   private DistortedObject mBackground;
42
   private DistortedTexture mTexture;
43
   private DistortedEffectQueues mQueues;
42 44
   private GridFlat mGrid;
43 45
   private Canvas mCanvas;
44 46
   private Bitmap mBitmap;
......
57 59
     mPaint.setStyle(Style.FILL);
58 60
      
59 61
     mView = v;
62
     mGrid   = new GridFlat(1,1);
63
     mQueues = new DistortedEffectQueues();
60 64
     }
61 65

  
62 66
///////////////////////////////////////////////////////////////////////////////////////////////////
......
80 84
     texW = width;
81 85
     texH = height;
82 86

  
83
     mGrid       = new GridFlat(1,1);
84
     mBackground = new DistortedObject(texW,texH,1);
85
     mBitmap     = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888);
86
     mCanvas     = new Canvas(mBitmap);
87
     mTexture= new DistortedTexture(texW,texH,0);
88
     mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888);
89
     mCanvas = new Canvas(mBitmap);
87 90

  
88 91
     Distorted.onSurfaceChanged(texW,texH);
89 92
     mView.onSurfaceChanged(texW,texH);
......
99 102
      
100 103
     mCanvas.drawRect(0, 0, texW, texH, mPaint);
101 104
     mView.drawCurve(mCanvas,time);
102
     mBackground.setTexture(mBitmap);
103
     mBackground.draw(time,mGrid);
105
     mTexture.setTexture(mBitmap);
106
     mQueues.draw(time,mTexture,mGrid);
104 107
     }
105 108

  
106 109
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
24 24
import android.widget.TextView;
25 25

  
26 26
import org.distorted.examples.R;
27
import org.distorted.library.DistortedObject;
27
import org.distorted.library.DistortedEffectQueues;
28 28
import org.distorted.library.EffectNames;
29 29
import org.distorted.library.EffectTypes;
30 30
import org.distorted.library.type.Dynamic1D;
......
77 77
///////////////////////////////////////////////////////////////////////////////////////////////////
78 78
// requires knowledge about effect nature
79 79

  
80
  void apply(DistortedObject object)
80
  void apply(DistortedEffectQueues queues)
81 81
    {
82 82
    switch(mName)
83 83
      {
84
      case ROTATE           : mId = object.rotate    (mDyn4, mCenterDyn); break;
85
      case QUATERNION       : mId = object.quaternion(mDyn4, mCenterDyn); break;
86
      case MOVE             : mId = object.move      (mDyn3)            ; break;
87
      case SCALE            : mId = object.scale     (mDyn3)            ; break;
88
      case SHEAR            : mId = object.shear     (mDyn3, mCenterDyn); break;
89

  
90
      case DISTORT          : mId = object.distort   (mDyn3, mCenterDyn, mRegionDyn); break;
91
      case DEFORM           : mId = object.deform    (mDyn3, mCenterDyn, mRegionDyn); break;
92
      case SINK             : mId = object.sink      (mDyn1, mCenterDyn, mRegionDyn); break;
93
      case PINCH            : mId = object.pinch     (mDyn2, mCenterDyn, mRegionDyn); break;
94
      case SWIRL            : mId = object.swirl     (mDyn1, mCenterDyn, mRegionDyn); break;
95
      case WAVE             : mId = object.wave      (mDyn5, mCenterDyn, mRegionDyn); break;
96

  
97
      case ALPHA            : mId = object.alpha     (mDyn1,        mRegionDyn, false); break;
98
      case SMOOTH_ALPHA     : mId = object.alpha     (mDyn1,        mRegionDyn, true ); break;
99
      case CHROMA           : mId = object.chroma    (mDyn1, mDyn3, mRegionDyn, false); break;
100
      case SMOOTH_CHROMA    : mId = object.chroma    (mDyn1, mDyn3, mRegionDyn, true ); break;
101
      case BRIGHTNESS       : mId = object.brightness(mDyn1,        mRegionDyn, false); break;
102
      case SMOOTH_BRIGHTNESS: mId = object.brightness(mDyn1,        mRegionDyn, true ); break;
103
      case SATURATION       : mId = object.saturation(mDyn1,        mRegionDyn, false); break;
104
      case SMOOTH_SATURATION: mId = object.saturation(mDyn1,        mRegionDyn, true ); break;
105
      case CONTRAST         : mId = object.contrast  (mDyn1,        mRegionDyn, false); break;
106
      case SMOOTH_CONTRAST  : mId = object.contrast  (mDyn1,        mRegionDyn, true ); break;
84
      case ROTATE           : mId = queues.rotate    (mDyn4, mCenterDyn); break;
85
      case QUATERNION       : mId = queues.quaternion(mDyn4, mCenterDyn); break;
86
      case MOVE             : mId = queues.move      (mDyn3)            ; break;
87
      case SCALE            : mId = queues.scale     (mDyn3)            ; break;
88
      case SHEAR            : mId = queues.shear     (mDyn3, mCenterDyn); break;
89

  
90
      case DISTORT          : mId = queues.distort   (mDyn3, mCenterDyn, mRegionDyn); break;
91
      case DEFORM           : mId = queues.deform    (mDyn3, mCenterDyn, mRegionDyn); break;
92
      case SINK             : mId = queues.sink      (mDyn1, mCenterDyn, mRegionDyn); break;
93
      case PINCH            : mId = queues.pinch     (mDyn2, mCenterDyn, mRegionDyn); break;
94
      case SWIRL            : mId = queues.swirl     (mDyn1, mCenterDyn, mRegionDyn); break;
95
      case WAVE             : mId = queues.wave      (mDyn5, mCenterDyn, mRegionDyn); break;
96

  
97
      case ALPHA            : mId = queues.alpha     (mDyn1,        mRegionDyn, false); break;
98
      case SMOOTH_ALPHA     : mId = queues.alpha     (mDyn1,        mRegionDyn, true ); break;
99
      case CHROMA           : mId = queues.chroma    (mDyn1, mDyn3, mRegionDyn, false); break;
100
      case SMOOTH_CHROMA    : mId = queues.chroma    (mDyn1, mDyn3, mRegionDyn, true ); break;
101
      case BRIGHTNESS       : mId = queues.brightness(mDyn1,        mRegionDyn, false); break;
102
      case SMOOTH_BRIGHTNESS: mId = queues.brightness(mDyn1,        mRegionDyn, true ); break;
103
      case SATURATION       : mId = queues.saturation(mDyn1,        mRegionDyn, false); break;
104
      case SMOOTH_SATURATION: mId = queues.saturation(mDyn1,        mRegionDyn, true ); break;
105
      case CONTRAST         : mId = queues.contrast  (mDyn1,        mRegionDyn, false); break;
106
      case SMOOTH_CONTRAST  : mId = queues.contrast  (mDyn1,        mRegionDyn, true ); break;
107 107

  
108 108
      default: mId = -1;
109 109
      }
src/main/java/org/distorted/examples/flag/FlagRenderer.java
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29 29
import org.distorted.library.GridCubes;
30
import org.distorted.library.DistortedObject;
30
import org.distorted.library.DistortedEffectQueues;
31
import org.distorted.library.DistortedTexture;
31 32
import org.distorted.library.EffectTypes;
32 33
import org.distorted.library.type.Dynamic;
33 34
import org.distorted.library.type.Dynamic5D;
......
47 48
class FlagRenderer implements GLSurfaceView.Renderer
48 49
{
49 50
    private GLSurfaceView mView;
50
    private DistortedObject mObject;
51
    private DistortedEffectQueues mQueues;
52
    private DistortedTexture mTexture;
51 53
    private GridCubes mGrid;
52 54
    private int mObjWidth, mObjHeight;
53 55
    private DynamicQuat mQuatInt1, mQuatInt2;
......
63 65
      {
64 66
      mView = v;
65 67

  
66
      mGrid = new GridCubes(50,30,false);
67
      mObject = new DistortedObject(500,300,10);
68
      mQueues  = new DistortedEffectQueues();
69
      mGrid    = new GridCubes(50,30,false);
70
      mTexture = new DistortedTexture(500,300,10);
68 71

  
69
      mObjWidth = mObject.getWidth();
70
      mObjHeight= mObject.getHeight();
72
      mObjWidth = mTexture.getWidth();
73
      mObjHeight= mTexture.getHeight();
71 74

  
72 75
      mWaveDyn = new Dynamic5D(1000,0.0f);
73 76
      mWaveSta1= new Static5D(0,0,-180,0,0);  // all other values besides the
......
89 92
      Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0);  // middle of the right edge
90 93
      Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth);
91 94

  
92
      mObject.wave(mWaveDyn, waveCenter, waveRegion);
95
      mQueues.wave(mWaveDyn, waveCenter, waveRegion);
93 96
      }
94 97

  
95 98
///////////////////////////////////////////////////////////////////////////////////////////////////
......
136 139
    public void onDrawFrame(GL10 glUnused) 
137 140
      {
138 141
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
139
      mObject.draw(System.currentTimeMillis(), mGrid);
142
      mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
140 143
      }
141 144

  
142 145
///////////////////////////////////////////////////////////////////////////////////////////////////
......
145 148
      {
146 149
      mScreenMin = width<height ? width:height;
147 150
    	
148
      mObject.abortEffects(EffectTypes.MATRIX);
151
      mQueues.abortEffects(EffectTypes.MATRIX);
149 152
      float factor;
150 153

  
151 154
      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
......
157 160
        factor = (0.8f*width)/mObjWidth;
158 161
        }
159 162

  
160
      mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
161
      mObject.scale(factor);
163
      mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
164
      mQueues.scale(factor);
162 165
      Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
163 166

  
164
      mObject.quaternion(mQuatInt1, center);
165
      mObject.quaternion(mQuatInt2, center);
167
      mQueues.quaternion(mQuatInt1, center);
168
      mQueues.quaternion(mQuatInt2, center);
166 169
       
167 170
      Distorted.onSurfaceChanged(width, height); 
168 171
      }
......
189 192
        catch(IOException e) { }
190 193
        }  
191 194
      
192
      mObject.setTexture(bitmap);
195
      mTexture.setTexture(bitmap);
193 196
      
194 197
      try
195 198
        {
src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.java
220 220
    {
221 221
    switch(parent.getId())
222 222
      {
223
      case R.id.matrix3dspinner          : mEffectAdd = pos;
224
                                           break;
223
      case R.id.matrix3dspinner: mEffectAdd = pos;
224
                                 break;
225 225
      }
226 226
    }
227 227

  
src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.java
24 24
import android.widget.TextView;
25 25

  
26 26
import org.distorted.examples.R;
27
import org.distorted.library.DistortedObject;
27
import org.distorted.library.DistortedEffectQueues;
28 28
import org.distorted.library.EffectNames;
29 29
import org.distorted.library.EffectTypes;
30 30
import org.distorted.library.type.Dynamic1D;
......
77 77
///////////////////////////////////////////////////////////////////////////////////////////////////
78 78
// requires knowledge about effect nature
79 79

  
80
  void apply(DistortedObject object)
80
  void apply(DistortedEffectQueues queues)
81 81
    {
82 82
    switch(mName)
83 83
      {
84
      case ROTATE           : mId = object.rotate    (mDyn4, mCenterDyn); break;
85
      case QUATERNION       : mId = object.quaternion(mDyn4, mCenterDyn); break;
86
      case MOVE             : mId = object.move      (mDyn3)            ; break;
87
      case SCALE            : mId = object.scale     (mDyn3)            ; break;
88
      case SHEAR            : mId = object.shear     (mDyn3, mCenterDyn); break;
89

  
90
      case DISTORT          : mId = object.distort   (mDyn3, mCenterDyn, mRegionDyn); break;
91
      case DEFORM           : mId = object.deform    (mDyn3, mCenterDyn, mRegionDyn); break;
92
      case SINK             : mId = object.sink      (mDyn1, mCenterDyn, mRegionDyn); break;
93
      case PINCH            : mId = object.pinch     (mDyn2, mCenterDyn, mRegionDyn); break;
94
      case SWIRL            : mId = object.swirl     (mDyn1, mCenterDyn, mRegionDyn); break;
95
      case WAVE             : mId = object.wave      (mDyn5, mCenterDyn, mRegionDyn); break;
96

  
97
      case ALPHA            : mId = object.alpha     (mDyn1,        mRegionDyn, false); break;
98
      case SMOOTH_ALPHA     : mId = object.alpha     (mDyn1,        mRegionDyn, true ); break;
99
      case CHROMA           : mId = object.chroma    (mDyn1, mDyn3, mRegionDyn, false); break;
100
      case SMOOTH_CHROMA    : mId = object.chroma    (mDyn1, mDyn3, mRegionDyn, true ); break;
101
      case BRIGHTNESS       : mId = object.brightness(mDyn1,        mRegionDyn, false); break;
102
      case SMOOTH_BRIGHTNESS: mId = object.brightness(mDyn1,        mRegionDyn, true ); break;
103
      case SATURATION       : mId = object.saturation(mDyn1,        mRegionDyn, false); break;
104
      case SMOOTH_SATURATION: mId = object.saturation(mDyn1,        mRegionDyn, true ); break;
105
      case CONTRAST         : mId = object.contrast  (mDyn1,        mRegionDyn, false); break;
106
      case SMOOTH_CONTRAST  : mId = object.contrast  (mDyn1,        mRegionDyn, true ); break;
84
      case ROTATE           : mId = queues.rotate    (mDyn4, mCenterDyn); break;
85
      case QUATERNION       : mId = queues.quaternion(mDyn4, mCenterDyn); break;
86
      case MOVE             : mId = queues.move      (mDyn3)            ; break;
87
      case SCALE            : mId = queues.scale     (mDyn3)            ; break;
88
      case SHEAR            : mId = queues.shear     (mDyn3, mCenterDyn); break;
89

  
90
      case DISTORT          : mId = queues.distort   (mDyn3, mCenterDyn, mRegionDyn); break;
91
      case DEFORM           : mId = queues.deform    (mDyn3, mCenterDyn, mRegionDyn); break;
92
      case SINK             : mId = queues.sink      (mDyn1, mCenterDyn, mRegionDyn); break;
93
      case PINCH            : mId = queues.pinch     (mDyn2, mCenterDyn, mRegionDyn); break;
94
      case SWIRL            : mId = queues.swirl     (mDyn1, mCenterDyn, mRegionDyn); break;
95
      case WAVE             : mId = queues.wave      (mDyn5, mCenterDyn, mRegionDyn); break;
96

  
97
      case ALPHA            : mId = queues.alpha     (mDyn1,        mRegionDyn, false); break;
98
      case SMOOTH_ALPHA     : mId = queues.alpha     (mDyn1,        mRegionDyn, true ); break;
99
      case CHROMA           : mId = queues.chroma    (mDyn1, mDyn3, mRegionDyn, false); break;
100
      case SMOOTH_CHROMA    : mId = queues.chroma    (mDyn1, mDyn3, mRegionDyn, true ); break;
101
      case BRIGHTNESS       : mId = queues.brightness(mDyn1,        mRegionDyn, false); break;
102
      case SMOOTH_BRIGHTNESS: mId = queues.brightness(mDyn1,        mRegionDyn, true ); break;
103
      case SATURATION       : mId = queues.saturation(mDyn1,        mRegionDyn, false); break;
104
      case SMOOTH_SATURATION: mId = queues.saturation(mDyn1,        mRegionDyn, true ); break;
105
      case CONTRAST         : mId = queues.contrast  (mDyn1,        mRegionDyn, false); break;
106
      case SMOOTH_CONTRAST  : mId = queues.contrast  (mDyn1,        mRegionDyn, true ); break;
107 107

  
108 108
      default: mId = -1;
109 109
      }
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
34 34
import org.distorted.library.type.Static1D;
35 35
import org.distorted.library.Distorted;
36 36
import org.distorted.library.GridFlat;
37
import org.distorted.library.DistortedObject;
37
import org.distorted.library.DistortedEffectQueues;
38
import org.distorted.library.DistortedTexture;
38 39

  
39 40
import android.graphics.Bitmap;
40 41
import android.graphics.BitmapFactory;
......
51 52
   
52 53
   private GLSurfaceView mView;
53 54
   private DistortedObjectTree mScreen;
54
   private DistortedObject mLeaf;
55
   private DistortedTexture mLeaf;
56

  
57
   private int mScreenW, mScreenH;
55 58

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

  
......
59 62
      {     
60 63
      mView = v;
61 64

  
62
      mLeaf = new DistortedObject(LEAF_SIZE,LEAF_SIZE,1);
65
      mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE,1);
63 66
      GridFlat grid = new GridFlat(1,1);
67
      DistortedEffectQueues queue = new DistortedEffectQueues();
68

  
69
      mScreenW = 9*LEAF_SIZE;
70
      mScreenH = 9*LEAF_SIZE;
64 71

  
65
      mScreen = new DistortedObjectTree(new DistortedObject(9*LEAF_SIZE,9*LEAF_SIZE,1), grid);
72
      mScreen = new DistortedObjectTree(new DistortedTexture(mScreenW,mScreenH,0), queue, grid);
66 73
     
67 74
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
68 75
      rot.setMode(Dynamic1D.MODE_JUMP);
......
72 79
      DistortedObjectTree[] mCircleNode = new DistortedObjectTree[NUM_CIRCLES];
73 80
    
74 81
      int[] colors    = new int[] {0,0,1,  0,0,0,  1,0,0,  1,1,0,  0,1,0}; // blue, black, red, yellow, green  
75
      int[] positions = new int[] {0*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE,2*LEAF_SIZE,  6*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE/2,9*LEAF_SIZE/2,  9*LEAF_SIZE/2,9*LEAF_SIZE/2};
82
      int[] positions = new int[] {0,2*LEAF_SIZE,  3*LEAF_SIZE,2*LEAF_SIZE,  6*LEAF_SIZE,2*LEAF_SIZE,  3*LEAF_SIZE/2,9*LEAF_SIZE/2,  9*LEAF_SIZE/2,9*LEAF_SIZE/2};
76 83
      
77
      DistortedObject tmp;
78 84
      Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0);
79 85
      Static3D axis   = new Static3D(0,0,1);
80 86
      Static3D moveVector = new Static3D(0,LEAF_SIZE,0);
......
83 89
        {
84 90
        if( i==0 )
85 91
          {
86
          mCircleNode[i] = new DistortedObjectTree(new DistortedObject(3*LEAF_SIZE,3*LEAF_SIZE,1), grid);
92
          queue = new DistortedEffectQueues();
93
          mCircleNode[i] = new DistortedObjectTree(new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE,1), queue, grid);
87 94
        
88 95
          for(int j=0; j<NUM_LEAVES; j++)
89 96
            {
90
            tmp = new DistortedObject(mLeaf, Distorted.CLONE_BITMAP);
91
            mCircleNode[i].attach(tmp,grid);
92
            tmp.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center );
93
            tmp.move(moveVector);
97
            queue = new DistortedEffectQueues();
98
            mCircleNode[i].attach(mLeaf, queue, grid);
99
            queue.rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center );
100
            queue.move(moveVector);
94 101
            }
95 102
          }
96 103
        else
......
99 106
          }
100 107
      
101 108
        mScreen.attach(mCircleNode[i]);
102
        tmp = mCircleNode[i].getObject();
103
        tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
104
        tmp.rotate( rot, axis, center );
105
        tmp.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
109
        queue = mCircleNode[i].getQueues();
110
        queue.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
111
        queue.rotate( rot, axis, center );
112
        queue.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
106 113
        }
107 114
      }
108 115

  
......
118 125
    
119 126
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
120 127
      {
121
      DistortedObject bmp = mScreen.getObject();
122
      int bmpWidth  = bmp.getWidth();
123
      int bmpHeight = bmp.getHeight();
124
     
125
      bmp.abortEffects(EffectTypes.MATRIX);
128
      DistortedEffectQueues queues = mScreen.getQueues();
129

  
130
      queues.abortEffects(EffectTypes.MATRIX);
126 131
      
127
      if( (float)bmpHeight/bmpWidth > (float)height/width )
132
      if( (float)mScreenH/mScreenW > (float)height/width )
128 133
        {
129
        int w = (height*bmpWidth)/bmpHeight;
130
        float factor = (float)height/bmpHeight;
134
        int w = (height*mScreenW)/mScreenH;
135
        float factor = (float)height/mScreenH;
131 136

  
132
        bmp.move( new Static3D((width-w)/2 ,0, 0) );
133
        bmp.scale( factor );
137
        queues.move( new Static3D((width-w)/2 ,0, 0) );
138
        queues.scale( factor );
134 139
        }
135 140
      else
136 141
        {
137
        int h = (width*bmpHeight)/bmpWidth;
138
        float factor = (float)width/bmpWidth;
142
        int h = (width*mScreenH)/mScreenW;
143
        float factor = (float)width/mScreenW;
139 144

  
140
        bmp.move( new Static3D(0,(height-h)/2,0) );
141
        bmp.scale( factor );
145
        queues.move( new Static3D(0,(height-h)/2,0) );
146
        queues.scale( factor );
142 147
        }
143 148
      
144 149
      Distorted.onSurfaceChanged(width, height); 
src/main/java/org/distorted/examples/save/SaveRenderer.java
31 31
import org.distorted.examples.R;
32 32

  
33 33
import org.distorted.library.Distorted;
34
import org.distorted.library.DistortedObject;
34
import org.distorted.library.DistortedEffectQueues;
35
import org.distorted.library.DistortedTexture;
35 36
import org.distorted.library.GridFlat;
36 37
import org.distorted.library.DistortedFramebuffer;
37 38
import org.distorted.library.EffectTypes;
......
52 53
class SaveRenderer implements GLSurfaceView.Renderer
53 54
  {
54 55
  private GLSurfaceView mView;
55
  private DistortedObject mGirl;
56
  private DistortedTexture mGirl;
57
  private DistortedEffectQueues mQueues;
56 58
  private GridFlat mGrid;
57 59
  private DistortedFramebuffer mOffscreen;
58
  private Static3D pLeft, pRight;
59
  private Static4D sinkRegion;
60
  private Dynamic1D diSink;
61 60
  private Static1D s0;
62 61
  private Dynamic3D mScaleDyn;
63 62
  private Static3D mScaleFactor;
......
77 76
      
78 77
    boobsSink  = 1.0f;
79 78
      
80
    pLeft = new Static3D(132, 264, 0);
81
    pRight= new Static3D(247, 264, 0);
79
    Static3D pLeft = new Static3D(132, 264, 0);
80
    Static3D pRight= new Static3D(247, 264, 0);
82 81
      
83
    sinkRegion = new Static4D(0,0,60,60);
82
    Static4D sinkRegion = new Static4D(0,0,60,60);
84 83
      
85 84
    s0 = new Static1D(boobsSink);
86 85
      
87
    diSink = new Dynamic1D();
86
    Dynamic1D diSink = new Dynamic1D();
88 87
    diSink.add(s0);
89 88

  
90 89
    mScale = 1.0f;
91 90
    mScaleDyn = new Dynamic3D();
92 91
    mScaleFactor = new Static3D(mScale,mScale,1.0f);
93 92
    mScaleDyn.add(mScaleFactor);
93

  
94
    mQueues = new DistortedEffectQueues();
95
    mQueues.sink( diSink, pLeft , sinkRegion);
96
    mQueues.sink( diSink, pRight, sinkRegion);
94 97
    }
95 98

  
96 99
///////////////////////////////////////////////////////////////////////////////////////////////////
......
145 148
    {
146 149
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
147 150

  
151
    long time = System.currentTimeMillis();
152

  
148 153
    if( isSaving )  // render to an offscreen buffer and read pixels
149 154
      {
150
      mGirl.abortEffects(EffectTypes.MATRIX);
151
      mGirl.scale(mScaleFactor);
152
      mGirl.draw(System.currentTimeMillis(), mGrid, mOffscreen);
155
      mQueues.abortEffects(EffectTypes.MATRIX);
156
      mQueues.scale(mScaleFactor);
157
      mQueues.draw(time, mGirl, mGrid, mOffscreen);
153 158
      applyMatrixEffects(scrWidth,scrHeight);
154 159

  
155 160
      int fW =(int)(mScale*bmpWidth);
......
164 169
      isSaving = false;
165 170
      }
166 171

  
167
    mGirl.draw(System.currentTimeMillis(), mGrid);
172
    mQueues.draw(time, mGirl, mGrid);
168 173
    }
169 174

  
170 175
///////////////////////////////////////////////////////////////////////////////////////////////////
171 176

  
172 177
  private void applyMatrixEffects(int width, int height)
173 178
    {
174
    mGirl.abortEffects(EffectTypes.MATRIX);
179
    mQueues.abortEffects(EffectTypes.MATRIX);
175 180

  
176 181
    if( (float)bmpHeight/bmpWidth > (float)height/width )
177 182
      {
178 183
      int w = (height*bmpWidth)/bmpHeight;
179 184
      float factor = (float)height/bmpHeight;
180 185

  
181
      mGirl.move( new Static3D((width-w)/2,0,0) );
182
      mGirl.scale(factor);
186
      mQueues.move( new Static3D((width-w)/2,0,0) );
187
      mQueues.scale(factor);
183 188
      }
184 189
    else
185 190
      {
186 191
      int h = (width*bmpHeight)/bmpWidth;
187 192
      float factor = (float)width/bmpWidth;
188 193

  
189
      mGirl.move( new Static3D(0,(height-h)/2,0) );
190
      mGirl.scale(factor);
194
      mQueues.move( new Static3D(0,(height-h)/2,0) );
195
      mQueues.scale(factor);
191 196
      }
192 197

  
193
    mGirl.scale(mScaleDyn);
198
    mQueues.scale(mScaleDyn);
194 199
    }
195 200

  
196 201
///////////////////////////////////////////////////////////////////////////////////////////////////
......
229 234
    bmpWidth  = bitmap.getWidth();
230 235

  
231 236
    mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
232
    mGirl = new DistortedObject(bmpWidth,bmpHeight,1);
237
    mGirl = new DistortedTexture(bmpWidth,bmpHeight,0);
233 238
    mGirl.setTexture(bitmap);
234 239

  
235
    mGirl.sink( diSink, pLeft , sinkRegion);
236
    mGirl.sink( diSink, pRight, sinkRegion);
237

  
238 240
    mOffscreen = new DistortedFramebuffer(bmpWidth,bmpHeight);
239 241

  
240 242
    try
src/main/java/org/distorted/examples/wind/WindEffectsManager.java
21 21

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

  
24
import org.distorted.library.DistortedObject;
24
import org.distorted.library.DistortedEffectQueues;
25
import org.distorted.library.DistortedTexture;
25 26
import org.distorted.library.type.Dynamic;
26 27
import org.distorted.library.type.Dynamic3D;
27 28
import org.distorted.library.type.Dynamic5D;
......
47 48

  
48 49
///////////////////////////////////////////////////////////////////////////////////////////////////
49 50

  
50
  WindEffectsManager(DistortedObject obj)
51
  WindEffectsManager(DistortedTexture texture)
51 52
    {
52
    mHeight = obj.getHeight();
53
    mWidth  = obj.getWidth();
53
    mHeight = texture.getHeight();
54
    mWidth  = texture.getWidth();
54 55

  
55 56
    shearFactor = new Static3D(0,0,0);
56 57
    shearDynamic= new Dynamic3D();
......
89 90

  
90 91
///////////////////////////////////////////////////////////////////////////////////////////////////
91 92

  
92
  synchronized void apply(DistortedObject obj, int wind)
93
  synchronized void apply(DistortedEffectQueues queues, int wind)
93 94
    {
94 95
    Static3D midLeft = new Static3D(0,mHeight/2,0);
95 96
    Static3D midRight = new Static3D(mWidth,mHeight/2,0);
......
97 98

  
98 99
    setWind(wind);
99 100

  
100
    obj.shear(shearDynamic,midLeft);
101
    obj.scale(scaleDynamic);
102
    obj.deform(deformForce,midRight);
103
    obj.wave(windDynamic1, midRight, windRegion);
104
    obj.wave(windDynamic2, midRight, windRegion);
105
    obj.wave(windDynamic3, midRight, windRegion);
101
    queues.shear(shearDynamic,midLeft);
102
    queues.scale(scaleDynamic);
103
    queues.deform(deformForce,midRight);
104
    queues.wave(windDynamic1, midRight, windRegion);
105
    queues.wave(windDynamic2, midRight, windRegion);
106
    queues.wave(windDynamic3, midRight, windRegion);
106 107
    }
107 108

  
108 109
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/wind/WindRenderer.java
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29 29
import org.distorted.library.GridCubes;
30
import org.distorted.library.DistortedObject;
30
import org.distorted.library.DistortedEffectQueues;
31
import org.distorted.library.DistortedTexture;
31 32
import org.distorted.library.type.Static1D;
32 33
import org.distorted.library.type.Static3D;
33 34

  
......
42 43
class WindRenderer implements GLSurfaceView.Renderer
43 44
{
44 45
   private GLSurfaceView mView;
45
   private DistortedObject mObject;
46
   private DistortedEffectQueues mQueues;
47
   private DistortedTexture mTexture;
46 48
   private GridCubes mGrid;
47 49
   private WindEffectsManager mEffects;
48 50
   private int mObjWidth, mObjHeight;
......
55 57
      mView = view;
56 58

  
57 59
      mGrid    = new GridCubes(50,30,false);
58
      mObject  = new DistortedObject(50,30,1);
59
      mEffects = new WindEffectsManager(mObject);
60
      mQueues  = new DistortedEffectQueues();
61
      mTexture = new DistortedTexture(50,30,1);
62
      mEffects = new WindEffectsManager(mTexture);
60 63

  
61
      mObjWidth = mObject.getWidth();
62
      mObjHeight= mObject.getHeight();
64
      mObjWidth = mTexture.getWidth();
65
      mObjHeight= mTexture.getHeight();
63 66
      }
64 67

  
65 68
///////////////////////////////////////////////////////////////////////////////////////////////////
......
75 78
   public void onDrawFrame(GL10 glUnused) 
76 79
      {
77 80
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
78
      mObject.draw(System.currentTimeMillis(),mGrid);
81
      mQueues.draw(System.currentTimeMillis(),mTexture, mGrid);
79 82
      }
80 83

  
81 84
///////////////////////////////////////////////////////////////////////////////////////////////////
82 85
    
83 86
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
84 87
      {
85
      mObject.abortAllEffects();
88
      mQueues.abortAllEffects();
86 89

  
87 90
      float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth);
88 91

  
89
      mObject.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
90
      mObject.scale(factor);
92
      mQueues.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
93
      mQueues.scale(factor);
91 94

  
92 95
      Static1D angle = new Static1D(-45);
93 96
      Static3D axis  = new Static3D(0,0,1);
94 97
      Static3D center= new Static3D(0,mObjHeight/2,0);
95 98

  
96
      mObject.rotate(angle, axis, center);
99
      mQueues.rotate(angle, axis, center);
97 100

  
98
      mEffects.apply(mObject, mWind);
101
      mEffects.apply(mQueues,mWind);
99 102

  
100 103
      Distorted.onSurfaceChanged(width, height);
101 104
      }
......
122 125
        catch(IOException e) { }
123 126
        }
124 127

  
125
      mObject.setTexture(bitmap);
128
      mTexture.setTexture(bitmap);
126 129

  
127 130
      try
128 131
        {

Also available in: Unified diff