Project

General

Profile

« Previous | Next » 

Revision f6d884d5

Added by Leszek Koltunski almost 8 years ago

Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)

View differences:

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

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

  
24
import org.distorted.library.DistortedObject;
25
import org.distorted.library.type.Dynamic;
24
import org.distorted.library.DistortedEffectQueues;
26 25
import org.distorted.library.type.Dynamic1D;
27 26
import org.distorted.library.type.Dynamic2D;
28 27
import org.distorted.library.type.Dynamic3D;
29
import org.distorted.library.type.Dynamic5D;
30 28
import org.distorted.library.type.Static1D;
31 29
import org.distorted.library.type.Static2D;
32 30
import org.distorted.library.type.Static3D;
33 31
import org.distorted.library.type.Static4D;
34
import org.distorted.library.type.Static5D;
35 32

  
36 33
class AroundTheWorldEffectsManager
37 34
  {
......
258 255

  
259 256
///////////////////////////////////////////////////////////////////////////////////////////////////
260 257

  
261
  synchronized void apply(DistortedObject obj)
258
  synchronized void apply(DistortedEffectQueues queues)
262 259
    {
263 260
    setRace(mBlackness, mAsianness);
264 261

  
265 262
    // WHITENESS
266
    obj.sink(wLipsDyn, wLipsCenter, wLipsRegion);
263
    queues.sink(wLipsDyn, wLipsCenter, wLipsRegion);
267 264

  
268 265
    // ASIANNESS
269
    obj.distort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion);
270
    obj.pinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion);
271
    obj.distort(aNostrilsDyn, aNostrilsCenter, aNostrilsRegion);
272
    obj.swirl(aLEyeDyn, aLEyeCenter, aEyesRegion);
273
    obj.swirl(aREyeDyn, aREyeCenter, aEyesRegion);
274
    obj.distort(aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion);
266
    queues.distort(aLipsNoseDyn, aLipsNoseCenter, aLipsNoseRegion);
267
    queues.pinch(aNoseBroaderDyn, aNoseBroaderCenter, aNoseBroaderRegion);
268
    queues.distort(aNostrilsDyn, aNostrilsCenter, aNostrilsRegion);
269
    queues.swirl(aLEyeDyn, aLEyeCenter, aEyesRegion);
270
    queues.swirl(aREyeDyn, aREyeCenter, aEyesRegion);
271
    queues.distort(aEyebrowsDyn, aEyebrowsCenter, aEyebrowsRegion);
275 272

  
276
    obj.chroma(aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false);
277
    obj.chroma(aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true);
278
    obj.chroma(aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true);
273
    queues.chroma(aChromaSkinDyn, aChromaSkin, aSkinColorRegion, false);
274
    queues.chroma(aChromaEyesDyn, aChromaEyes, aLEyeColorRegion, true);
275
    queues.chroma(aChromaEyesDyn, aChromaEyes, aREyeColorRegion, true);
279 276

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

  
287
    obj.chroma(bChromaSkinDyn, bChromaSkin, bSkinColorRegion, false);
288
    obj.chroma(bChromaEyesDyn, bChromaEyes, bLEyeColorRegion, true);
289
    obj.chroma(bChromaEyesDyn, bChromaEyes, bREyeColorRegion, true);
290
    obj.chroma(bChromaPupilDyn, bChromaPupil, bLPupilColorRegion, true);
291
    obj.chroma(bChromaPupilDyn, bChromaPupil, bRPupilColorRegion, true);
292

  
293
    obj.contrast(bContrastDyn);
278
    queues.pinch(bFaceDyn, bFaceCenter, bFaceRegion);
279
    queues.distort(bTipLowerDyn, bTipLowerCenter, bTipLowerRegion);
280
    queues.pinch(bWholeNoseDyn, bWholeNoseCenter, bWholeNoseRegion);
281
    queues.pinch(bNoseBroaderDyn, bNoseBroaderCenter, bNoseBroaderRegion);
282
    queues.pinch(bLipsDyn, bLipsCenter, bLipsRegion);
283

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

  
290
    queues.contrast(bContrastDyn);
294 291
    }
295 292

  
296 293
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29 29
import org.distorted.library.GridFlat;
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.Static3D;
33 34

  
......
42 43
class AroundTheWorldRenderer 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 GridFlat mGrid;
47 49
   private AroundTheWorldEffectsManager mEffects;
48 50
   private int mObjWidth, mObjHeight;
......
51 53

  
52 54
   AroundTheWorldRenderer(GLSurfaceView view)
53 55
      {
54
      mView = view;
55
      mEffects = new AroundTheWorldEffectsManager();
56

  
57 56
      Distorted.setMaxVertex(12);
58 57
      Distorted.setMaxFragment(9);
58

  
59
      mView = view;
60
      mEffects = new AroundTheWorldEffectsManager();
61
      mQueues = new DistortedEffectQueues();
62
      mEffects.apply(mQueues);
59 63
      }
60 64

  
61 65
///////////////////////////////////////////////////////////////////////////////////////////////////
......
70 74
   public void onDrawFrame(GL10 glUnused) 
71 75
      {
72 76
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
73
      mObject.draw(System.currentTimeMillis(), mGrid);
77
      mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
74 78
      }
75 79

  
76 80
///////////////////////////////////////////////////////////////////////////////////////////////////
77 81
    
78 82
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
79 83
      {
80
      mObject.abortEffects(EffectTypes.MATRIX);
84
      mQueues.abortEffects(EffectTypes.MATRIX);
81 85

  
82 86
      if( (float)mObjHeight/mObjWidth > (float)height/width )
83 87
        {
84 88
        int w = (height*mObjWidth)/mObjHeight;
85 89
        float factor = (float)height/mObjHeight;
86
        mObject.move( new Static3D((width-w)/2,0,0) );
87
        mObject.scale(factor);
90
        mQueues.move( new Static3D((width-w)/2,0,0) );
91
        mQueues.scale(factor);
88 92
        }
89 93
      else
90 94
        {
91 95
        int h = (width*mObjHeight)/mObjWidth;
92 96
        float factor = (float)width/mObjWidth;
93
        mObject.move( new Static3D(0,(height-h)/2,0) );
94
        mObject.scale(factor);
97
        mQueues.move( new Static3D(0,(height-h)/2,0) );
98
        mQueues.scale(factor);
95 99
        }
96 100

  
97 101
      Distorted.onSurfaceChanged(width, height);
......
122 126
      mObjWidth = bitmap.getWidth();
123 127
      mObjHeight= bitmap.getHeight();
124 128

  
125
      mObject = new DistortedObject(mObjWidth,mObjHeight,0);
126
      mObject.setTexture(bitmap);
127
      mEffects.apply(mObject);
129
      mTexture = new DistortedTexture(mObjWidth,mObjHeight,0);
130
      mTexture.setTexture(bitmap);
128 131

  
129 132
      mGrid = new GridFlat(30,30*mObjHeight/mObjWidth);
130 133

  
src/main/java/org/distorted/examples/bean/BeanRenderer.java
29 29

  
30 30
import org.distorted.library.EffectTypes;
31 31
import org.distorted.library.Distorted;
32
import org.distorted.library.DistortedObject;
32
import org.distorted.library.DistortedTexture;
33
import org.distorted.library.DistortedEffectQueues;
33 34
import org.distorted.library.GridFlat;
34 35
import org.distorted.library.type.Dynamic3D;
35 36
import org.distorted.library.type.Static3D;
......
45 46
class BeanRenderer implements GLSurfaceView.Renderer 
46 47
{
47 48
   private GLSurfaceView mView;
48
   private DistortedObject mBean;
49
   private DistortedTexture mTexture;
50
   private DistortedEffectQueues mQueues;
49 51
   private GridFlat mGrid;
50
   private Static3D pLeft, pRight;
51
   private Dynamic3D dLeft, dRight;
52
   private Static4D rLeft, rRight;
53 52
   private int bmpHeight, bmpWidth;
54 53
    
55 54
///////////////////////////////////////////////////////////////////////////////////////////////////
......
58 57
      {
59 58
      mView = v;
60 59
     
61
      pLeft = new Static3D( 98, 183, 0);
62
      pRight= new Static3D(233, 140, 0);
60
      Static3D pLeft = new Static3D( 98, 183, 0);
61
      Static3D pRight= new Static3D(233, 140, 0);
63 62
      
64
      rLeft = new Static4D( -3,-33,47,47);
65
      rRight= new Static4D(-14,-33,47,47);
63
      Static4D rLeft = new Static4D( -3,-33,47,47);
64
      Static4D rRight= new Static4D(-14,-33,47,47);
66 65
     
67
      dLeft = new Dynamic3D(2000,0.0f);
68
      dRight= new Dynamic3D(2000,0.0f);
66
      Dynamic3D dLeft = new Dynamic3D(2000,0.0f);
67
      Dynamic3D dRight= new Dynamic3D(2000,0.0f);
69 68

  
70 69
      Static3D p1 = new Static3D(  0,  0, 0);
71 70
      Static3D p2 = new Static3D(-15,-30, 0);
......
83 82
      dRight.add(p1);
84 83
      dRight.add(p1);
85 84
      dRight.add(p1);
85

  
86
      mQueues = new DistortedEffectQueues();
87
      mQueues.distort(dLeft , pLeft , rLeft );
88
      mQueues.distort(dRight, pRight, rRight);
86 89
      }
87 90

  
88 91
///////////////////////////////////////////////////////////////////////////////////////////////////
......
90 93
    public void onDrawFrame(GL10 glUnused) 
91 94
      {
92 95
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
93
      mBean.draw(System.currentTimeMillis(), mGrid);
96
      mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
94 97
      }
95 98

  
96 99
///////////////////////////////////////////////////////////////////////////////////////////////////
97 100
    
98 101
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
99 102
      { 
100
      mBean.abortEffects(EffectTypes.MATRIX);
103
      mQueues.abortEffects(EffectTypes.MATRIX);
101 104
         
102 105
      if( (float)bmpHeight/bmpWidth > (float)height/width )
103 106
        {
104 107
        int w = (height*bmpWidth)/bmpHeight;
105 108
        float factor = (float)height/bmpHeight;
106 109

  
107
        mBean.move( new Static3D((width-w)/2,0,0) );
108
        mBean.scale(factor);
110
        mQueues.move( new Static3D((width-w)/2,0,0) );
111
        mQueues.scale(factor);
109 112
        }
110 113
      else
111 114
        {
112 115
        int h = (width*bmpHeight)/bmpWidth;
113 116
        float factor = (float)width/bmpWidth;
114 117

  
115
        mBean.move( new Static3D(0,(height-h)/2,0) );
116
        mBean.scale(factor);
118
        mQueues.move( new Static3D(0,(height-h)/2,0) );
119
        mQueues.scale(factor);
117 120
        }
118 121
      
119 122
      Distorted.onSurfaceChanged(width, height); 
......
144 147
      bmpHeight = bitmap.getHeight();
145 148
      bmpWidth  = bitmap.getWidth();
146 149
      
147
      mBean = new DistortedObject(bmpWidth, bmpHeight, 1);
148
      mBean.setTexture(bitmap);
149
      mBean.distort(dLeft , pLeft , rLeft );
150
      mBean.distort(dRight, pRight, rRight);
151

  
150
      mTexture = new DistortedTexture(bmpWidth, bmpHeight, 0);
151
      mTexture.setTexture(bitmap);
152 152
      mGrid = new GridFlat(25,25*bmpHeight/bmpWidth);
153 153

  
154 154
      try
src/main/java/org/distorted/examples/check/CheckRenderer.java
28 28
import org.distorted.examples.R;
29 29

  
30 30
import org.distorted.library.Distorted;
31
import org.distorted.library.DistortedObject;
31
import org.distorted.library.DistortedTexture;
32
import org.distorted.library.DistortedEffectQueues;
32 33
import org.distorted.library.GridFlat;
33 34
import org.distorted.library.EffectTypes;
34 35
import org.distorted.library.type.Dynamic3D;
......
54 55
    private static String compilationTitle;
55 56

  
56 57
    private GLSurfaceView mView;
57
    private DistortedObject mSuccess;
58
    private DistortedTexture mTexture;
59
    private DistortedEffectQueues mQueues;
58 60
    private GridFlat mGrid;
59 61
    private int bmpHeight, bmpWidth;
60 62

  
......
63 65
    CheckRenderer(GLSurfaceView view)
64 66
      { 
65 67
      mView = view;
68
      mQueues = new DistortedEffectQueues();
66 69

  
67 70
      CheckActivity act = (CheckActivity)mView.getContext();
68 71

  
......
75 78
    public void onDrawFrame(GL10 glUnused) 
76 79
      {
77 80
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
78
      mSuccess.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
      mSuccess.abortEffects(EffectTypes.MATRIX);
88
      mQueues.abortEffects(EffectTypes.MATRIX);
86 89
      
87 90
      if( (float)bmpHeight/bmpWidth > (float)height/width )
88 91
        {
89 92
        int w = (height*bmpWidth)/bmpHeight;
90 93
        float factor = (float)height/bmpHeight;
91 94

  
92
        mSuccess.move( new Static3D((width-w)/2,0,0) );
93
        mSuccess.scale(factor);
95
        mQueues.move( new Static3D((width-w)/2,0,0) );
96
        mQueues.scale(factor);
94 97
        }
95 98
      else
96 99
        {
97 100
        int h = (width*bmpHeight)/bmpWidth;
98 101
        float factor = (float)width/bmpWidth;
99 102

  
100
        mSuccess.move( new Static3D(0,(height-h)/2,0) );
101
        mSuccess.scale(factor);
103
        mQueues.move( new Static3D(0,(height-h)/2,0) );
104
        mQueues.scale(factor);
102 105
        }
103 106
      
104 107
      Distorted.onSurfaceChanged(width, height);
......
129 132
      bmpHeight = bitmap.getHeight();
130 133
      bmpWidth  = bitmap.getWidth();
131 134

  
132
      mSuccess = new DistortedObject(bmpWidth,bmpHeight,1);
133
      mSuccess.setTexture(bitmap);
135
      mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
136
      mTexture.setTexture(bitmap);
134 137
      mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
135 138

  
136 139
      // Try adding 2 Vertex Effects to the Bitmap.
......
143 146
      dSwirl.add(new Static3D(        0, bmpHeight/2, 0));
144 147
      dSwirl.add(new Static3D( bmpWidth, bmpHeight/2, 0));
145 148

  
146
      long swirlEffectID = mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
149
      long swirlEffectID = mQueues.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
147 150

  
148 151
      if( swirlEffectID<0 )
149 152
        {
......
154 157
      dDeform.add(new Static3D( 0,         0,0));
155 158
      dDeform.add(new Static3D( 0,-bmpHeight,0));
156 159

  
157
      long deformEffectID = mSuccess.deform(dDeform, new Static3D(bmpWidth/2,0,0) );
160
      long deformEffectID = mQueues.deform(dDeform, new Static3D(bmpWidth/2,0,0) );
158 161

  
159 162
      if( deformEffectID<0 )
160 163
        {
......
167 170
      inter.add(new Static1D(0));
168 171
      inter.add(new Static1D(1));
169 172

  
170
      long chromaEffectID = mSuccess.chroma(inter, color);
173
      long chromaEffectID = mQueues.chroma(inter, color);
171 174

  
172 175
      if( chromaEffectID<0 )
173 176
        {
src/main/java/org/distorted/examples/cubes/CubesActivity.java
21 21

  
22 22
import org.distorted.library.Distorted;
23 23
import org.distorted.examples.R;
24
import org.distorted.library.DistortedObject;
24
import org.distorted.library.DistortedTexture;
25 25
import org.distorted.library.GridObject;
26 26
import org.distorted.library.GridCubes;
27 27

  
......
48 48
    private NumberPicker mColsPicker, mRowsPicker;
49 49
    private LinearLayout mLay;
50 50
    private boolean[] mShape;
51
    private DistortedObject mObject;
51
    private DistortedTexture mTexture;
52 52
    private GridObject mGrid;
53 53

  
54 54
///////////////////////////////////////////////////////////////////////////////////////////////////
......
200 200
        str += mShape[i] ? "1" : "0";
201 201

  
202 202
      mGrid = new GridCubes(mNumCols, str, false);
203
      mObject = new DistortedObject(mNumCols,mNumRows,1);
203
      mTexture = new DistortedTexture(mNumCols,mNumRows,1);
204 204

  
205 205
      setContentView(R.layout.cubeslayout);
206 206
      }
207 207

  
208 208
///////////////////////////////////////////////////////////////////////////////////////////////////
209 209

  
210
    public DistortedObject getObject()
210
    public DistortedTexture getTexture()
211 211
      {
212
      return mObject;
212
      return mTexture;
213 213
      }
214 214

  
215 215
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/cubes/CubesRenderer.java
27 27

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

  
30
import org.distorted.library.DistortedObject;
30
import org.distorted.library.DistortedTexture;
31
import org.distorted.library.DistortedEffectQueues;
31 32
import org.distorted.library.GridObject;
32 33
import org.distorted.library.EffectTypes;
33 34
import org.distorted.library.type.DynamicQuat;
......
45 46
class CubesRenderer implements GLSurfaceView.Renderer 
46 47
{
47 48
    private GLSurfaceView mView;
48
    private DistortedObject mObject;
49
    private DistortedTexture mTexture;
50
    private DistortedEffectQueues mQueues;
49 51
    private GridObject mGrid;
52
    private DynamicQuat mQuatInt1, mQuatInt2;
50 53
    private int mObjWidth, mObjHeight;
51 54

  
52
    private DynamicQuat mQuatInt1, mQuatInt2;
53
    
54 55
    Static4D mQuat1, mQuat2;
55 56
    int mScreenMin;
56 57
    
......
62 63

  
63 64
      CubesActivity act = (CubesActivity)v.getContext();
64 65

  
65
      mObject = act.getObject();
66
      mGrid   = act.getGrid();
66
      mQueues  = new DistortedEffectQueues();
67
      mTexture = act.getTexture();
68
      mGrid    = act.getGrid();
67 69

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

  
71 73
      mQuat1 = new Static4D(0,0,0,1);  // unity
72 74
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
83 85
    public void onDrawFrame(GL10 glUnused) 
84 86
      {
85 87
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
86
      mObject.draw(System.currentTimeMillis(),mGrid);
88
      mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
87 89
      }
88 90

  
89 91
///////////////////////////////////////////////////////////////////////////////////////////////////
......
92 94
      {
93 95
      mScreenMin = width<height ? width:height;
94 96
    	
95
      mObject.abortEffects(EffectTypes.MATRIX);
97
      mQueues.abortEffects(EffectTypes.MATRIX);
96 98
      float factor;
97 99

  
98 100
      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
......
104 106
        factor = (0.8f*width)/mObjWidth;
105 107
        }
106 108

  
107
      mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
108
      mObject.scale(factor);
109
      mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
110
      mQueues.scale(factor);
109 111
      Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
110 112

  
111
      mObject.quaternion(mQuatInt1, center);
112
      mObject.quaternion(mQuatInt2, center);
113
      mQueues.quaternion(mQuatInt1, center);
114
      mQueues.quaternion(mQuatInt2, center);
113 115
       
114 116
      Distorted.onSurfaceChanged(width, height); 
115 117
      }
......
136 138
        catch(IOException e) { }
137 139
        }  
138 140
      
139
      mObject.setTexture(bitmap);
141
      mTexture.setTexture(bitmap);
140 142
      
141 143
      try
142 144
        {
src/main/java/org/distorted/examples/deform/DeformRenderer.java
23 23
import javax.microedition.khronos.opengles.GL10;
24 24

  
25 25
import org.distorted.library.Distorted;
26
import org.distorted.library.DistortedObject;
26
import org.distorted.library.DistortedTexture;
27
import org.distorted.library.DistortedEffectQueues;
27 28
import org.distorted.library.GridObject;
28 29
import org.distorted.library.GridFlat;
29 30

  
......
43 44
///////////////////////////////////////////////////////////////////////////////////////////////////
44 45

  
45 46
class DeformRenderer implements GLSurfaceView.Renderer 
46
{
47
   {
47 48
   private static final int NUM_VECTORS =  8;
48 49
   private static final int NUM_LINES   = 10;
49 50
   private static final int NUM_FRAMES  = 10;
50 51

  
51 52
   private GLSurfaceView mView;
52
   private DistortedObject fps, stretch;
53
   private DistortedTexture fpsTexture, stretchTexture;
54
   private DistortedEffectQueues fpsQueues, stretchQueues;
53 55
   private GridObject fpsGrid, stretchGrid;
54 56
   private Static3D touchPoint;
55 57

  
......
83 85
   DeformRenderer(GLSurfaceView view)
84 86
      { 
85 87
      mView = view;
86
      
88

  
89
      mPaint = new Paint();
90
      mPaint.setAntiAlias(true);
91
      mPaint.setTextAlign(Paint.Align.CENTER);
92

  
93
      fpsQueues     = new DistortedEffectQueues();
94
      stretchQueues = new DistortedEffectQueues();
95

  
87 96
      mRegion = new Static4D(0,0,0,0);
88 97

  
89 98
      durations = new long[NUM_FRAMES+1];
90 99
      currDuration = 0;
91 100

  
92
      for(int i=0; i<NUM_FRAMES+1; i++)
93
        {
94
        durations[i]=0;
95
        }
101
      for(int i=0; i<NUM_FRAMES+1; i++) durations[i]=0;
96 102

  
97 103
      // DISTORT
98 104
      mReleasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
......
159 165

  
160 166
///////////////////////////////////////////////////////////////////////////////////////////////////
161 167

  
162
    public void onPause()
168
   public void onPause()
163 169
      {
164 170
      bitmapCreated = false;  
165 171
      }
166 172
      
167 173
///////////////////////////////////////////////////////////////////////////////////////////////////
168 174
   
169
    public void onDrawFrame(GL10 glUnused) 
170
      {
171
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
175
   public void onDrawFrame(GL10 glUnused)
176
     {
177
     GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
172 178
    
173
      long time = System.currentTimeMillis();
179
     long time = System.currentTimeMillis();
174 180
      
175
      stretch.draw(time,stretchGrid);
181
     stretchQueues.draw(time,stretchTexture,stretchGrid);
176 182
      
177
      mPaint.setColor(0xffffffff);
178
      fpsCanvas.drawRect(0, 0, fpsW, fpsH, mPaint);
179
      mPaint.setColor(0xff000000);
180
      fpsCanvas.drawText(fpsString, fpsW/2, 5*fpsH/6, mPaint);
183
     mPaint.setColor(0xffffffff);
184
     fpsCanvas.drawRect(0, 0, fpsW, fpsH, mPaint);
185
     mPaint.setColor(0xff000000);
186
     fpsCanvas.drawText(fpsString, fpsW/2, 5*fpsH/6, mPaint);
181 187
      
182
      fps.setTexture(fpsBitmap);
183
      fps.draw(time,fpsGrid);
188
     fpsTexture.setTexture(fpsBitmap);
189
     fpsQueues.draw(time,fpsTexture,fpsGrid);
184 190
      
185
      computeFPS(time);
186
      }
191
     computeFPS(time);
192
     }
187 193

  
188 194
///////////////////////////////////////////////////////////////////////////////////////////////////
189 195
    
190
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
191
      { 
192
      scrHeight = height;
193
      scrWidth  = width;
196
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
197
     {
198
     scrHeight = height;
199
     scrWidth  = width;
194 200

  
195
      setRegionRadius(50);
201
     setRegionRadius(50);
196 202

  
197
      Distorted.onSurfaceChanged(width, height);
203
     Distorted.onSurfaceChanged(width, height);
198 204
      
199
      if( !bitmapCreated )
200
        {
201
        createBitmap(scrWidth/2,scrHeight/2);
202
        stretch.move( new Static3D(scrWidth/4,scrHeight/4,0) );
203
        fps.move( new Static3D(5,5,0) );
204
        bitmapCreated=true;
205
        }
206
      else
207
        {
208
        stretch.abortEffects(EffectTypes.VERTEX);
209
        stretch.abortEffects(EffectTypes.FRAGMENT);
210
        stretch.abortEffects(EffectNames.SHEAR);
211
        }
212
      }
205
     if( !bitmapCreated )
206
       {
207
       createBitmap(scrWidth/2,scrHeight/2);
208
       stretchQueues.move( new Static3D(scrWidth/4,scrHeight/4,0) );
209
       fpsQueues.move( new Static3D(5,5,0) );
210
       bitmapCreated=true;
211
       }
212
     else
213
       {
214
       stretchQueues.abortEffects(EffectTypes.VERTEX);
215
       stretchQueues.abortEffects(EffectTypes.FRAGMENT);
216
       stretchQueues.abortEffects(EffectNames.SHEAR);
217
       }
218
     }
213 219

  
214 220
///////////////////////////////////////////////////////////////////////////////////////////////////
215 221
    
216
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
217
      {
218
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
219

  
220
      try
221
        {
222
        Distorted.onSurfaceCreated(mView.getContext());
223
        }
224
      catch(Exception ex)
225
        {
226
        android.util.Log.e("DeformRenderer", ex.toString() );
227
        }
228
      }
222
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
223
     {
224
     GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
225

  
226
     try
227
       {
228
       Distorted.onSurfaceCreated(mView.getContext());
229
       }
230
     catch(Exception ex)
231
       {
232
       android.util.Log.e("DeformRenderer", ex.toString() );
233
       }
234
     }
229 235
    
230 236
///////////////////////////////////////////////////////////////////////////////////////////////////
231 237

  
232
    private void createBitmap(int w, int h)
233
      {  
234
      Canvas stretchCanvas;   
238
   private void createBitmap(int w, int h)
239
     {
240
     Canvas stretchCanvas;
235 241
      
236
      mPaint = new Paint();
237
      stretch = new DistortedObject(w,h,1);
238
      stretchGrid = new GridFlat(50,50*h/w);
239
      Bitmap stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888);
240
      stretchCanvas = new Canvas(stretchBitmap);
242
     stretchTexture = new DistortedTexture(w,h,0);
243
     stretchGrid    = new GridFlat(50,50*h/w);
244
     Bitmap stretchBitmap = Bitmap.createBitmap(w,h, Bitmap.Config.ARGB_8888);
245
     stretchCanvas = new Canvas(stretchBitmap);
241 246
      
242
      fpsW = scrWidth/5;
243
      fpsH = fpsW/2;
244
        
245
      mPaint.setAntiAlias(true);
246
      mPaint.setTextAlign(Paint.Align.CENTER);
247
      mPaint.setTextSize(2*fpsH/3);
248
      mPaint.setColor(0xff008800);
249
      mPaint.setStyle(Style.FILL);
250
      stretchCanvas.drawRect(0, 0, w, h, mPaint);
251
      mPaint.setColor(0xffffffff);
247
     fpsW = scrWidth/5;
248
     fpsH = fpsW/2;
249

  
250
     mPaint.setTextSize(2*fpsH/3);
251
     mPaint.setColor(0xff008800);
252
     mPaint.setStyle(Style.FILL);
253
     stretchCanvas.drawRect(0, 0, w, h, mPaint);
254
     mPaint.setColor(0xffffffff);
252 255
      
253
      for(int i=0; i<=NUM_LINES ; i++ )
254
        {
255
        stretchCanvas.drawRect(w*i/NUM_LINES - 1,                 0,  w*i/NUM_LINES + 1,  h                , mPaint);
256
        stretchCanvas.drawRect(                0, h *i/NUM_LINES -1,  w                ,  h*i/NUM_LINES + 1, mPaint);
257
        }
256
     for(int i=0; i<=NUM_LINES ; i++ )
257
       {
258
       stretchCanvas.drawRect(w*i/NUM_LINES - 1,                 0,  w*i/NUM_LINES + 1,  h                , mPaint);
259
       stretchCanvas.drawRect(                0, h *i/NUM_LINES -1,  w                ,  h*i/NUM_LINES + 1, mPaint);
260
       }
258 261
        
259
      touchPoint= new Static3D(0,0,0);
262
     touchPoint= new Static3D(0,0,0);
260 263
        
261
      fps = new DistortedObject( fpsW, fpsH, 1);
262
      fpsGrid = new GridFlat(1,1);
264
     fpsTexture = new DistortedTexture( fpsW, fpsH, 0);
265
     fpsGrid = new GridFlat(1,1);
263 266

  
264
      fpsBitmap = Bitmap.createBitmap(fpsW,fpsH, Bitmap.Config.ARGB_8888);
265
      fpsCanvas = new Canvas(fpsBitmap);
267
     fpsBitmap = Bitmap.createBitmap(fpsW,fpsH, Bitmap.Config.ARGB_8888);
268
     fpsCanvas = new Canvas(fpsBitmap);
266 269
        
267
      stretch.setTexture(stretchBitmap);
268
      fps.setTexture(fpsBitmap);
269
      }
270
     stretchTexture.setTexture(stretchBitmap);
271
     fpsTexture.setTexture(fpsBitmap);
272
     }
270 273

  
271 274
///////////////////////////////////////////////////////////////////////////////////////////////////
272 275

  
273
    void down(int x, int y)
274
      {
275
      int xt = x-scrWidth/4;
276
      int yt = y-scrHeight/4;
276
   void down(int x, int y)
277
     {
278
     int xt = x-scrWidth/4;
279
     int yt = y-scrHeight/4;
277 280
      
278
      if( xt<0 ) xt=0;
279
      if( xt>scrWidth/2 ) xt=scrWidth/2;
280
      if( yt<0 ) yt=0;
281
      if( yt>scrHeight/2 ) yt=scrHeight/2;
281
     if( xt<0 ) xt=0;
282
     if( xt>scrWidth/2 ) xt=scrWidth/2;
283
     if( yt<0 ) yt=0;
284
     if( yt>scrHeight/2 ) yt=scrHeight/2;
282 285
      
283
      touchPoint.set(xt,yt,0);
284

  
285
      switch(mMode)
286
        {
287
        case DISTORT: vDistort[0].set(0,0,0);
288
                      mLastEffect = stretch.distort( mMovingDistortDynamic, touchPoint, mRegion);
289
                      break;
290
        case DEFORM : vDeform[0].set(0,0,0);
291
                      mLastEffect = stretch.deform( mMovingDeformDynamic, touchPoint, mRegion);
292
                      break;
293
        case SHEAR  : vShear[0].set(0,0,0);
294
                      mLastEffect = stretch.shear(mMovingShearDynamic, touchPoint);
295
                      break;
296
        }                   
297
      }
286
     touchPoint.set(xt,yt,0);
287

  
288
     switch(mMode)
289
       {
290
       case DISTORT: vDistort[0].set(0,0,0);
291
                     mLastEffect = stretchQueues.distort( mMovingDistortDynamic, touchPoint, mRegion);
292
                     break;
293
       case DEFORM : vDeform[0].set(0,0,0);
294
                     mLastEffect = stretchQueues.deform( mMovingDeformDynamic, touchPoint, mRegion);
295
                     break;
296
       case SHEAR  : vShear[0].set(0,0,0);
297
                     mLastEffect = stretchQueues.shear(mMovingShearDynamic, touchPoint);
298
                     break;
299
       }
300
     }
298 301
    
299 302
///////////////////////////////////////////////////////////////////////////////////////////////////
300 303

  
301
    void move(int x, int y)
302
      {
303
      switch(mMode)
304
        {
305
        case DISTORT: vDistort[0].set(x,y);
306
                      break;
307
        case DEFORM:  vDeform[0].set(x,y);
308
                      break;
309
        case SHEAR:   vShear[0].set( (float)x/(scrWidth/2), (float)y/(scrHeight/2));
310
                      break;
311
        }
312
      }
304
   void move(int x, int y)
305
     {
306
     switch(mMode)
307
       {
308
       case DISTORT: vDistort[0].set(x,y);
309
                     break;
310
       case DEFORM:  vDeform[0].set(x,y);
311
                     break;
312
       case SHEAR:   vShear[0].set( (float)x/(scrWidth/2), (float)y/(scrHeight/2));
313
                     break;
314
       }
315
     }
313 316
    
314 317
///////////////////////////////////////////////////////////////////////////////////////////////////
315 318

  
316
    void up()
317
      {
318
      stretch.abortEffect(mLastEffect);
319

  
320
      float damp = -0.65f;
321

  
322
      switch(mMode)
323
        {
324
        case DISTORT: for(int i=1; i<NUM_VECTORS-1; i++)
325
                        {
326
                        vDistort[i].set( vDistort[i-1].getX()*damp, vDistort[i-1].getY()*damp );
327
                        }
328
                      vDistort[NUM_VECTORS-1].set(0,0);
329
                      stretch.distort( mReleasedDistortDynamic, touchPoint, mRegion);
330
                      break;
331
        case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++)
332
                        {
333
                        vDeform[i].set( vDeform[i-1].getX()*damp, vDeform[i-1].getY()*damp );
334
                        }
335
                      vDeform[NUM_VECTORS-1].set(0,0);
336
                      stretch.deform( mReleasedDeformDynamic, touchPoint, mRegion);
337
                      break;
338
        case SHEAR  : for(int i=1; i<NUM_VECTORS-1; i++)
339
                        {
340
                        vShear[i].set( vShear[i-1].getX()*damp, vShear[i-1].getY()*damp );
341
                        }
342
                      vShear[NUM_VECTORS-1].set(0,0);
343
                      stretch.shear(mReleasedShearDynamic, touchPoint);
344
                      break;
345
        }      
346
      }
319
   void up()
320
     {
321
     stretchQueues.abortEffect(mLastEffect);
322

  
323
     float damp = -0.65f;
324

  
325
     switch(mMode)
326
       {
327
       case DISTORT: for(int i=1; i<NUM_VECTORS-1; i++)
328
                       {
329
                       vDistort[i].set( vDistort[i-1].getX()*damp, vDistort[i-1].getY()*damp );
330
                       }
331
                     vDistort[NUM_VECTORS-1].set(0,0);
332
                     stretchQueues.distort( mReleasedDistortDynamic, touchPoint, mRegion);
333
                     break;
334
       case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++)
335
                       {
336
                       vDeform[i].set( vDeform[i-1].getX()*damp, vDeform[i-1].getY()*damp );
337
                       }
338
                     vDeform[NUM_VECTORS-1].set(0,0);
339
                     stretchQueues.deform( mReleasedDeformDynamic, touchPoint, mRegion);
340
                     break;
341
       case SHEAR  : for(int i=1; i<NUM_VECTORS-1; i++)
342
                       {
343
                       vShear[i].set( vShear[i-1].getX()*damp, vShear[i-1].getY()*damp );
344
                       }
345
                     vShear[NUM_VECTORS-1].set(0,0);
346
                     stretchQueues.shear(mReleasedShearDynamic, touchPoint);
347
                     break;
348
       }
349
     }
347 350

  
348 351
///////////////////////////////////////////////////////////////////////////////////////////////////
349 352

  
350
    private void computeFPS(long currentTime)
351
      {
352
      if( lastTime!=0 )
353
        {
354
        currDuration++;
355
        if( currDuration>=NUM_FRAMES ) currDuration = 0;
356
        durations[NUM_FRAMES] += ((currentTime-lastTime)-durations[currDuration]);
357
        durations[currDuration] = currentTime-lastTime;
358

  
359
        fpsString = "" + ((int)(10000.0f*NUM_FRAMES/durations[NUM_FRAMES]))/10.0f;
360
        }
353
   private void computeFPS(long currentTime)
354
     {
355
     if( lastTime!=0 )
356
       {
357
       currDuration++;
358
       if( currDuration>=NUM_FRAMES ) currDuration = 0;
359
       durations[NUM_FRAMES] += ((currentTime-lastTime)-durations[currDuration]);
360
       durations[currDuration] = currentTime-lastTime;
361

  
362
       fpsString = "" + ((int)(10000.0f*NUM_FRAMES/durations[NUM_FRAMES]))/10.0f;
363
       }
361 364
      
362
      lastTime = currentTime;   
363
      }
364
}
365
     lastTime = currentTime;
366
     }
367
   }
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java
28 28
import org.distorted.examples.R;
29 29

  
30 30
import org.distorted.library.Distorted;
31
import org.distorted.library.DistortedObject;
31
import org.distorted.library.DistortedTexture;
32
import org.distorted.library.DistortedEffectQueues;
32 33
import org.distorted.library.GridFlat;
33 34
import org.distorted.library.EffectTypes;
34 35
import org.distorted.library.type.Dynamic3D;
......
48 49
   private static final int NUM = 3;
49 50
   
50 51
   private GLSurfaceView mView;
51
   private DistortedObject[] mObj;
52
   private DistortedTexture[] mTexture;
53
   private DistortedEffectQueues[] mQueues;
52 54
   private GridFlat mGrid;
53
   private Static3D mPoint;
54
   private Dynamic3D dDistort;
55 55
   private int bmpHeight, bmpWidth;
56 56
    
57 57
///////////////////////////////////////////////////////////////////////////////////////////////////
......
60 60
      {     
61 61
      mView = v;
62 62
     
63
      // create shared effects - enlarge the nose and keep moving the whole bitmap left and right.
64
      dDistort = new Dynamic3D(3000,0.0f);
63
      Dynamic3D dDistort = new Dynamic3D(3000,0.0f);
65 64
      dDistort.add(new Static3D( 25,0,0));
66 65
      dDistort.add(new Static3D(-25,0,0));
67
      mPoint = new Static3D(305, 380, 0);
66
      Static3D mPoint = new Static3D(305, 380, 0);
67

  
68
      mQueues = new DistortedEffectQueues[NUM];
69
      mQueues[0] = new DistortedEffectQueues();
70
      for(int i=1; i<NUM; i++)
71
        mQueues[i] = new DistortedEffectQueues(mQueues[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
72

  
73
      // Add the effects only to the first queue - all VERTEX and FRAGMENT effects are shared!
74
      // (Matrix effect cannot be shared as we have to display each Texture in a different location)
75
      mQueues[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80));  // enlarge the nose
76
      mQueues[0].distort(dDistort,mPoint);                                 // keep moving the whole bitmap left and right.
68 77
      }
69 78

  
70 79
///////////////////////////////////////////////////////////////////////////////////////////////////
......
98 107
      
99 108
      long time = System.currentTimeMillis();
100 109
      
101
      for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
110
      for(int i=NUM-1; i>=0; i--) mQueues[i].draw(time, mTexture[i], mGrid);
102 111
      }
103 112

  
104 113
///////////////////////////////////////////////////////////////////////////////////////////////////
......
107 116
      {  
108 117
      for(int i=NUM-1; i>=0; i--) 
109 118
        {   
110
        mObj[i].abortEffects(EffectTypes.MATRIX);
119
        mQueues[i].abortEffects(EffectTypes.MATRIX);
111 120
        }
112 121
      
113 122
      if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
......
117 126

  
118 127
        for(int i=NUM-1; i>=0; i--) 
119 128
          {
120
          mObj[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
121
          mObj[i].scale(factor);
129
          mQueues[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
130
          mQueues[i].scale(factor);
122 131
          }
123 132
        }
124 133
      else
......
129 138

  
130 139
        for(int i=NUM-1; i>=0; i--) 
131 140
          {
132
          mObj[i].move( new Static3D(i*w,(height-h)/2,0) );
133
          mObj[i].scale(factor);
141
          mQueues[i].move( new Static3D(i*w,(height-h)/2,0) );
142
          mQueues[i].scale(factor);
134 143
          }
135 144
        }
136 145
         
......
150 159
      bmpHeight = bitmap0.getHeight();
151 160
      bmpWidth  = bitmap0.getWidth();
152 161
      
153
      // create NUM DistortedBitmaps with shared effects
154
      mObj = new DistortedObject[NUM];
155
      mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1);
156
      for(int i=1; i<NUM; i++) 
157
        mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
162
      mTexture = new DistortedTexture[NUM];
163
      for(int i=0; i<NUM; i++)
164
        mTexture[i] = new DistortedTexture(bmpWidth, bmpHeight,0);
158 165
      
159
      mObj[0].setTexture(bitmap0);
160
      mObj[1].setTexture(bitmap1);
161
      mObj[2].setTexture(bitmap2);
162
         
163
      mObj[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80));
164
      mObj[0].distort(dDistort,mPoint);
166
      mTexture[0].setTexture(bitmap0);
167
      mTexture[1].setTexture(bitmap1);
168
      mTexture[2].setTexture(bitmap2);
165 169

  
166 170
      mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
167 171

  
src/main/java/org/distorted/examples/effectqueue/EffectQueueActivity.java
84 84

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

  
87

  
88 87
    mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsID);
89 88
    mAdapterID.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
90 89
    mID.setAdapter(mAdapterID);
......
170 169
    Long currID = (Long)mID.getItemAtPosition(mPosID);
171 170

  
172 171
    EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
173
    v.getRenderer().mBackground.abortEffect(currID);
172
    v.getRenderer().getQueues().abortEffect(currID);
174 173
    }
175 174

  
176 175
///////////////////////////////////////////////////////////////////////////////////////////////////
......
190 189
      }
191 190

  
192 191
    EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
193
    v.getRenderer().mBackground.abortEffects(name);
192
    v.getRenderer().getQueues().abortEffects(name);
194 193
    }
195 194

  
196 195
///////////////////////////////////////////////////////////////////////////////////////////////////
......
207 206
      }
208 207

  
209 208
    EffectQueueSurfaceView v = (EffectQueueSurfaceView) this.findViewById(R.id.effects2dSurfaceView);
210
    v.getRenderer().mBackground.abortEffects(type);
209
    v.getRenderer().getQueues().abortEffects(type);
211 210
    }
212 211

  
213 212
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.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.DistortedTexture;
34
import org.distorted.library.DistortedEffectQueues;
34 35
import org.distorted.library.Distorted;
35 36
import org.distorted.library.EffectNames;
36 37
import org.distorted.library.EffectTypes;
......
40 41

  
41 42
///////////////////////////////////////////////////////////////////////////////////////////////////
42 43

  
43
public class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener
44
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener
44 45
  {  
45 46
  private static final int NUMLINES =  10;
46 47
  static final int BWID = 300;
......
50 51
  private Paint mPaint;
51 52
  private int texWidth, texHeight;
52 53

  
53
  DistortedObject mBackground;
54
  GridFlat mGrid;
54
  private DistortedTexture mTexture;
55
  private GridFlat mGrid;
56
  private DistortedEffectQueues mQueues;
55 57

  
56 58
///////////////////////////////////////////////////////////////////////////////////////////////////
57 59

  
......
67 69
    texWidth = BWID;
68 70
    texHeight= BHEI;
69 71

  
70
    mGrid      = new GridFlat(80,80*texHeight/texWidth);
71
    mBackground= new DistortedObject(texWidth,texHeight,1);
72
    mGrid    = new GridFlat(80,80*texHeight/texWidth);
73
    mTexture = new DistortedTexture(texWidth,texHeight,0);
74
    mQueues  = new DistortedEffectQueues();
72 75

  
73
    mBackground.addEventListener(this);
76
    mQueues.addEventListener(this);
74 77
    }
75 78

  
76 79
///////////////////////////////////////////////////////////////////////////////////////////////////
77
   
80

  
81
  DistortedEffectQueues getQueues()
82
    {
83
    return mQueues;
84
    }
85

  
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

  
78 88
  public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
79 89
    {
80 90
    Bitmap bitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888);
......
89 99
      canvas.drawRect(texWidth*i/NUMLINES - 1,                       0,  texWidth*i/NUMLINES + 1,  texHeight               , mPaint);
90 100
      canvas.drawRect(                      0, texHeight*i/NUMLINES -1,  texWidth               ,  texHeight*i/NUMLINES + 1, mPaint);
91 101
      }
92
    mBackground.setTexture(bitmap);
102
    mTexture.setTexture(bitmap);
93 103

  
94 104
    try
95 105
      {
......
105 115

  
106 116
  public void onSurfaceChanged(GL10 glUnused, int width, int height)
107 117
    {
108
    mBackground.abortEffects(EffectTypes.MATRIX);
109
    mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
118
    mQueues.abortEffects(EffectTypes.MATRIX);
119
    mQueues.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
110 120
    Distorted.onSurfaceChanged(width,height);
111 121
    mView.setScreenSize(width,height);
112 122
    }
......
116 126
  public void onDrawFrame(GL10 glUnused)
117 127
    {   
118 128
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
119
    mBackground.draw(System.currentTimeMillis(), mGrid);
129
    mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
120 130
    }
121 131

  
122 132
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java
140 140

  
141 141
                                    switch(mCurrentEffect)
142 142
                                      {
143
                                      case 0: id = mRenderer.mBackground.distort(mInterD, mPoint, mRegionV);
143
                                      case 0: id = mRenderer.getQueues().distort(mInterD, mPoint, mRegionV);
144 144
                                              act.effectAdded(id, EffectNames.DISTORT, EffectTypes.VERTEX);
145 145
                                              break;
146
                                      case 1: id = mRenderer.mBackground.sink(mInterS, mPoint, mRegionV);
146
                                      case 1: id = mRenderer.getQueues().sink(mInterS, mPoint, mRegionV);
147 147
                                              act.effectAdded(id, EffectNames.SINK, EffectTypes.VERTEX);
148 148
                                              break;
149
                                      case 2: id = mRenderer.mBackground.alpha(mInterA, mRegionF, true);
149
                                      case 2: id = mRenderer.getQueues().alpha(mInterA, mRegionF, true);
150 150
                                              act.effectAdded(id, EffectNames.ALPHA, EffectTypes.FRAGMENT);
151 151
                                              break;
152
                                      case 3: id = mRenderer.mBackground.saturation(mInterB, mRegionF, false);
152
                                      case 3: id = mRenderer.getQueues().saturation(mInterB, mRegionF, false);
153 153
                                              act.effectAdded(id, EffectNames.SATURATION, EffectTypes.FRAGMENT);
154 154
                                              break;
155
                                      case 4: id = mRenderer.mBackground.chroma(mInterC, mRED, mRegionF, true);
155
                                      case 4: id = mRenderer.getQueues().chroma(mInterC, mRED, mRegionF, true);
156 156
                                              act.effectAdded(id, EffectNames.CHROMA, EffectTypes.FRAGMENT);
157 157
                                              break;
158 158
                                      }
src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java
41 41
import org.distorted.library.GridFlat;
42 42
import org.distorted.library.GridCubes;
43 43
import org.distorted.library.GridObject;
44
import org.distorted.library.DistortedObject;
44
import org.distorted.library.DistortedTexture;
45
import org.distorted.library.DistortedEffectQueues;
45 46
import org.distorted.library.EffectNames;
46 47
import org.distorted.library.EffectTypes;
47 48

  
......
66 67
  private int mNumRows = 10;
67 68
  private NumberPicker mColsPicker, mRowsPicker;
68 69
  private boolean[] mShape;
69
  private DistortedObject mObject;
70
  private DistortedTexture mTexture;
71
  private DistortedEffectQueues mQueues;
70 72
  private GridObject mGrid;
71 73
  private int mObjectType;
72 74
  private int mBitmapID;
......
217 219

  
218 220
///////////////////////////////////////////////////////////////////////////////////////////////////
219 221

  
220
  public DistortedObject getObject()
222
  public DistortedTexture getTexture()
221 223
    {
222
    return mObject;
224
    return mTexture;
225
    }
226

  
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228

  
229
  public DistortedEffectQueues getQueues()
230
    {
231
    return mQueues;
223 232
    }
224 233

  
225 234
///////////////////////////////////////////////////////////////////////////////////////////////////
......
401 410
      int w = mBitmap.getWidth();
402 411
      int h = mBitmap.getHeight();
403 412

  
404
      mObject = new DistortedObject(w,h,1);
413
      mQueues = new DistortedEffectQueues();
414
      mTexture= new DistortedTexture(w,h,0);
405 415
      mGrid   = new GridFlat(mNumCols,mNumCols*h/w);
406 416
      setEffectView();
407 417
      }
......
431 441
    for(int i=0; i<mNumRows*mNumCols; i++)
432 442
      str += mShape[i] ? "1" : "0";
433 443

  
434
    mObject = new DistortedObject(mNumCols,mNumRows,1);
444
    mQueues = new DistortedEffectQueues();
445
    mTexture= new DistortedTexture(mNumCols,mNumRows,1);
435 446
    mGrid   = new GridCubes(mNumCols, str, false);
436 447

  
437 448
    setEffectView();
......
471 482

  
472 483
  public int getWidth()
473 484
    {
474
    return mObject==null ? 0: mObject.getWidth();
485
    return mTexture==null ? 0: mTexture.getWidth();
475 486
    }
476 487

  
477 488
///////////////////////////////////////////////////////////////////////////////////////////////////
478 489

  
479 490
  public int getHeight()
480 491
    {
481
    return mObject==null ? 0: mObject.getHeight();
492
    return mTexture==null ? 0: mTexture.getHeight();
482 493
    }
483 494

  
484 495
///////////////////////////////////////////////////////////////////////////////////////////////////
485 496

  
486 497
  public int getDepth()
487 498
    {
488
    return mObject==null ? 0: mObject.getDepth();
499
    return mTexture==null ? 0: mTexture.getDepth();
489 500
    }
490 501

  
491 502
///////////////////////////////////////////////////////////////////////////////////////////////////
......
564 575
      layout.addView(region);
565 576
      }
566 577

  
567
    eff.apply(mObject);
578
    eff.apply(mQueues);
568 579
    }
569 580

  
570 581
///////////////////////////////////////////////////////////////////////////////////////////////////
......
574 585
    mEffects.clear();
575 586
    LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout);
576 587
    layout.removeAllViews();
577
    mObject.abortEffects(EffectTypes.VERTEX);
578
    mObject.abortEffects(EffectTypes.FRAGMENT);
588
    mQueues.abortEffects(EffectTypes.VERTEX);
589
    mQueues.abortEffects(EffectTypes.FRAGMENT);
579 590

  
580 591
    resetData();
581 592

  
......
606 617
        view = effect.getRegion();
607 618
        if( view!=null ) layout.removeView(view);
608 619

  
609
        long id = effect.getId();
610
        mObject.abortEffect(id);
620
        mQueues.abortEffect(effect.getId());
611 621
        mEffects.remove(effect);
612 622

  
613 623
        resetData();
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
26 26

  
27 27
import org.distorted.examples.R;
28 28
import org.distorted.library.Distorted;
29
import org.distorted.library.DistortedTexture;
29 30
import org.distorted.library.GridFlat;
30
import org.distorted.library.DistortedObject;
31
import org.distorted.library.DistortedEffectQueues;
31 32
import org.distorted.library.GridObject;
32 33
import org.distorted.library.EffectTypes;
33 34
import org.distorted.library.type.Dynamic3D;
......
46 47
class Effects3DRenderer implements GLSurfaceView.Renderer
47 48
{
48 49
    private GLSurfaceView mView;
49
    private DistortedObject mObject;
50
    private DistortedObject mBackground;
51
    private DistortedObject mCenter;
52
    private DistortedObject mRegion;
50
    private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture;
51
    private DistortedEffectQueues mObjectQueues, mBackgroundQueues, mCenterQueues, mRegionQueues;
53 52
    private GridFlat mQuad;
54
    private GridObject mGrid;
53
    private GridObject mObjectGrid;
55 54
    private int mObjWidth, mObjHeight, mObjDepth;
56 55
    private DynamicQuat mQuatInt1, mQuatInt2;
57 56

  
......
73 72

  
74 73
      Effects3DActivity act = (Effects3DActivity)v.getContext();
75 74

  
76
      mObject     = act.getObject();
77
      mGrid       = act.getGrid();
78
      mBackground = new DistortedObject(100, 100, 1);
79
      mCenter     = new DistortedObject(100, 100, 1);
80
      mRegion     = new DistortedObject(100, 100, 1);
81
      mQuad       = new GridFlat(1,1);
82

  
83
      mObjWidth = mObject.getWidth();
84
      mObjHeight= mObject.getHeight();
85
      mObjDepth = mObject.getDepth();
75
      mObjectTexture     = act.getTexture();
76
      mObjectGrid        = act.getGrid();
77
      mObjectQueues      = act.getQueues();
78
      mBackgroundTexture = new DistortedTexture(100, 100, 0);
79
      mCenterTexture     = new DistortedTexture(100, 100, 0);
80
      mRegionTexture     = new DistortedTexture(100, 100, 0);
81
      mQuad              = new GridFlat(1,1);
82
      mBackgroundQueues  = new DistortedEffectQueues();
83
      mCenterQueues      = new DistortedEffectQueues();
84
      mRegionQueues      = new DistortedEffectQueues();
85

  
86
      mObjWidth = mObjectTexture.getWidth();
87
      mObjHeight= mObjectTexture.getHeight();
88
      mObjDepth = mObjectTexture.getDepth();
86 89

  
87 90
      mQuat1 = new Static4D(0,0,0,1);  // unity
88 91
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
117 120

  
118 121
    void setRegion(float x, float y, float r)
119 122
      {
120
      mFactorReg = 2*mFactorObj*r/mRegion.getWidth();
123
      mFactorReg = 2*mFactorObj*r/mRegionTexture.getWidth();
121 124
      mRegionPoint.set(mFactorObj*x,mFactorObj*y,0);
122 125
      mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
123 126
      }
......
130 133

  
131 134
      long time = System.currentTimeMillis();
132 135

  
133
      mBackground.draw(time,mQuad);
134
      mObject.draw(time,mGrid);
136
      mBackgroundQueues.draw(time,mBackgroundTexture,mQuad);
137
      mObjectQueues.draw(time,mObjectTexture,mObjectGrid);
135 138

  
136 139
      if( Effects3DActivity.supportsCenter() )
137 140
        {
138
        mCenter.draw(time, mQuad);
139
        if( Effects3DActivity.supportsRegion() ) mRegion.draw(time, mQuad);
141
        mCenterQueues.draw(time, mCenterTexture,mQuad);
142
        if( Effects3DActivity.supportsRegion() ) mRegionQueues.draw(time, mRegionTexture,mQuad);
140 143
        }
141 144
      }
142 145

  
......
146 149
      {
147 150
      mScreenMin = width<height ? width:height;
148 151

  
149
      mObject.abortEffects(EffectTypes.MATRIX);
150
      mBackground.abortEffects(EffectTypes.MATRIX);
151
      mCenter.abortEffects(EffectTypes.MATRIX);
152
      mRegion.abortEffects(EffectTypes.MATRIX);
152
      mObjectQueues.abortEffects(EffectTypes.MATRIX);
153
      mBackgroundQueues.abortEffects(EffectTypes.MATRIX);
154
      mCenterQueues.abortEffects(EffectTypes.MATRIX);
155
      mRegionQueues.abortEffects(EffectTypes.MATRIX);
153 156

  
154 157
      float factorCen;
155
      int centerSize = mCenter.getWidth();
156
      int regionSize = mRegion.getWidth();
158
      int centerSize = mCenterTexture.getWidth();
159
      int regionSize = mRegionTexture.getWidth();
157 160

  
158 161
      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
159 162
        {
......
175 178

  
176 179
      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
177 180

  
178
      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
179
      mObject.scale(mFactorObj);
180
      mObject.quaternion(mQuatInt1, rotateObj);
181
      mObject.quaternion(mQuatInt2, rotateObj);
181
      mObjectQueues.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
182
      mObjectQueues.scale(mFactorObj);
183
      mObjectQueues.quaternion(mQuatInt1, rotateObj);
184
      mObjectQueues.quaternion(mQuatInt2, rotateObj);
182 185

  
183 186
      Static3D rotateCen = new Static3D(width/2,height/2, 0);
184 187

  
185
      mCenter.quaternion(mQuatInt1, rotateCen);
186
      mCenter.quaternion(mQuatInt2, rotateCen);
188
      mCenterQueues.quaternion(mQuatInt1, rotateCen);
189
      mCenterQueues.quaternion(mQuatInt2, rotateCen);
187 190

  
188
      mCenter.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
191
      mCenterQueues.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
189 192
                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
190
      mCenter.move(mCenterInter);
191
      mCenter.scale(factorCen);
193
      mCenterQueues.move(mCenterInter);
194
      mCenterQueues.scale(factorCen);
192 195

  
193
      mRegion.quaternion(mQuatInt1, rotateCen);
194
      mRegion.quaternion(mQuatInt2, rotateCen);
196
      mRegionQueues.quaternion(mQuatInt1, rotateCen);
197
      mRegionQueues.quaternion(mQuatInt2, rotateCen);
195 198

  
196
      mRegion.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
199
      mRegionQueues.move( new Static3D( (width -mFactorObj*mObjWidth )/2 ,
197 200
                                  (height-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+12) );
198
      mRegion.move(mCenterInter);
199
      mRegion.move(mRegionInter);
200
      mRegion.scale(mRegionScaleInter);
201
      mRegion.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
201
      mRegionQueues.move(mCenterInter);
202
      mRegionQueues.move(mRegionInter);
203
      mRegionQueues.scale(mRegionScaleInter);
204
      mRegionQueues.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
202 205

  
203
      int backgroundSize = mBackground.getWidth();
206
      int backgroundSize = mBackgroundTexture.getWidth();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff