Project

General

Profile

« Previous | Next » 

Revision 7bf107f7

Added by Leszek Koltunski about 5 years ago

Some more progress with porting apps to new VERTEX API.

View differences:

src/main/java/org/distorted/examples/check/CheckRenderer.java
30 30
import org.distorted.library.Distorted;
31 31
import org.distorted.library.DistortedBitmap;
32 32
import org.distorted.library.EffectTypes;
33
import org.distorted.library.type.Dynamic3D;
33 34
import org.distorted.library.type.Static1D;
34 35
import org.distorted.library.type.Static2D;
35 36
import org.distorted.library.type.Static3D;
......
132 133
      //
133 134
      // Even if adding some of the Effects fails, the App will still start - you just won't see
134 135
      // the effects that failed to add.
135
      Static2D pDown   = new Static2D(bmpWidth/2,   0);
136
      Static3D vDown   = new Static3D( 0,-bmpHeight,0);
137
      Static4D mRegion = new Static4D( 0, 0, 40 ,40 );
138

  
139
      Dynamic2D mPoint = new Dynamic2D();
140
      mPoint.setCount(0.0f);
141
      mPoint.setDuration(2000);
142
      mPoint.add(new Static2D(        0, bmpHeight/2));
143
      mPoint.add(new Static2D( bmpWidth, bmpHeight/2));
144

  
145
      mSuccess.swirl( 30, mRegion, mPoint );
146
      mSuccess.deform(vDown, pDown, 2000, 0.0f);
136

  
137
      Dynamic2D dSwirl = new Dynamic2D();
138
      dSwirl.setCount(0.0f);
139
      dSwirl.setDuration(2000);
140
      dSwirl.add(new Static2D(        0, bmpHeight/2));
141
      dSwirl.add(new Static2D( bmpWidth, bmpHeight/2));
142

  
143
      mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
144

  
145
      Dynamic3D dDeform = new Dynamic3D();
146
      dDeform.setCount(0.0f);
147
      dDeform.setDuration(2000);
148
      dDeform.add(new Static3D( 0,         0,0));
149
      dDeform.add(new Static3D( 0,-bmpHeight,0));
150

  
151
      mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
147 152

  
148 153
      // Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1.
149 154
      Static3D color = new Static3D(1,0,0);
src/main/java/org/distorted/examples/deform/DeformRenderer.java
248 248
      
249 249
      switch(mMode)
250 250
        {
251
        case MODE_DISTORT: stretch.distort(v[0], dr, touchPoint, 0, 0.5f);
251
        case MODE_DISTORT: stretch.distort( mMovingDynamic, touchPoint, dr);
252 252
                           break;
253
        case MODE_DEFORM : stretch.deform( v[0], touchPoint);
253
        case MODE_DEFORM : stretch.deform( mMovingDynamic, touchPoint);
254 254
                           break;
255 255
        case MODE_SHEAR  : shearID = stretch.shear(touchPoint, mMovingDynamic);
256 256
                           break;
......
291 291
      
292 292
      switch(mMode)
293 293
        {
294
        case MODE_DISTORT: stretch.distort( mReleasedDynamic, dr, touchPoint);
294
        case MODE_DISTORT: stretch.distort( mReleasedDynamic, touchPoint, dr);
295 295
                           break;
296 296
        case MODE_DEFORM : stretch.deform( mReleasedDynamic, touchPoint);
297 297
                           break;
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
161 161
      
162 162
      // setting the bitmap once is enough; others are cloned!
163 163
      bmp[0].setBitmap(bitmap);
164
         
165
      bmp[0].sink(10.0f, RegionEye, pLeft , 2000, 0.0f);
166
      bmp[0].sink(10.0f, RegionEye, pRight, 2000, 0.0f);
164

  
165
      Dynamic1D sink = new Dynamic1D();
166
      sink.setDuration(2000);
167
      sink.setCount(0);
168
      sink.add(new Static1D( 1));
169
      sink.add(new Static1D(10));
170

  
171
      bmp[0].sink(sink, pLeft, RegionEye);
172
      bmp[0].sink(sink, pRight,RegionEye);
167 173
      bmp[1].distort(mDI, pNose1);
168 174

  
169 175
      Dynamic1D macroblockDyn = new Dynamic1D();
src/main/java/org/distorted/examples/fbo/FBORenderer.java
134 134

  
135 135
      mText.move( new Static3D(lisaWidth/6,lisaHeight/3,0) );
136 136
      mText.scale( new Static3D(factor,factor,factor) );
137
      mText.sink(0.5f, new Static2D( textWidth/2, textHeight/2), 5000, 0.0f);
137

  
138
      Dynamic1D sinkDyn = new Dynamic1D();
139
      sinkDyn.setDuration(5000);
140
      sinkDyn.setCount(0);
141
      sinkDyn.add(new Static1D(1.0f));
142
      sinkDyn.add(new Static1D(0.5f));
143

  
144
      mText.sink(sinkDyn, new Static2D(textWidth/2,textHeight/2));
138 145

  
139 146
      Dynamic1D macroblockDyn = new Dynamic1D();
140 147
      macroblockDyn.setDuration(10000);
src/main/java/org/distorted/examples/fov/FOVRenderer.java
115 115
        
116 116
      int min = w<h ? w:h;
117 117
        
118
      Static3D dp3D = new Static3D(0,0,min/5);
119
      Static4D dr = new Static4D(0,0,min/5,min/5);
120
        
121
      Static2D point1 = new Static2D(  w/4,   h/4);
122
      Static2D point2 = new Static2D(3*w/4,   h/4);
123
      Static2D point3 = new Static2D(  w/4, 3*h/4);
124
      Static2D point4 = new Static2D(3*w/4, 3*h/4);
125
       
126
      fov.distort(dp3D, dr, point1, 0, 0.5f);
127
      fov.distort(dp3D, dr, point2, 0, 0.5f);
128
      fov.distort(dp3D, dr, point3, 0, 0.5f);
129
      fov.distort(dp3D, dr, point4, 0, 0.5f);
118
      Static3D vector = new Static3D(0,0,min/5);
119
      Static4D region = new Static4D(0,0,min/5,min/5);
120

  
121
      fov.distort(vector, new Static2D(  w/4,   h/4), region);
122
      fov.distort(vector, new Static2D(3*w/4,   h/4), region);
123
      fov.distort(vector, new Static2D(  w/4, 3*h/4), region);
124
      fov.distort(vector, new Static2D(3*w/4, 3*h/4), region);
130 125
      }
131 126

  
132 127
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/listener/ListenerRenderer.java
31 31
import org.distorted.library.Distorted;
32 32
import org.distorted.library.DistortedBitmap;
33 33
import org.distorted.library.EffectTypes;
34
import org.distorted.library.type.Dynamic3D;
34 35
import org.distorted.library.type.Static2D;
35 36
import org.distorted.library.type.Static3D;
36 37
import org.distorted.library.type.Static4D;
......
70 71
      int pointx   = mRnd.nextInt( (int)(0.8f*bmpWidth ))+ (int)(0.1f*bmpWidth ); // at a random place on the bitmap (but not near the edge)
71 72
      int pointy   = mRnd.nextInt( (int)(0.8f*bmpHeight))+ (int)(0.1f*bmpHeight); // 
72 73
      int duration = 1000 + mRnd.nextInt(3000);                                   // for anytime from 3 to 4 seconds 
73
        
74
      Static3D dp3d = new Static3D(0,0,height);
75
      Static2D dp2d = new Static2D(pointx,pointy);
76
      Static4D dr  = new Static4D(0,0,radius,radius);
77
     
78
      return water.distort(dp3d, dr, dp2d, duration, 1.0f);
74

  
75
      Dynamic3D dDistort = new Dynamic3D();
76
      dDistort.setCount(1);
77
      dDistort.setDuration(duration);
78
      dDistort.add(new Static3D(0,0,     0));
79
      dDistort.add(new Static3D(0,0,height));
80

  
81
      return water.distort(dDistort, new Static2D(pointx,pointy), new Static4D(0,0,radius,radius));
79 82
      }
80 83
   
81 84
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
29 29
import org.distorted.library.Distorted;
30 30
import org.distorted.library.DistortedBitmap;
31 31
import org.distorted.library.EffectTypes;
32
import org.distorted.library.type.Dynamic3D;
32 33
import org.distorted.library.type.Static2D;
33 34
import org.distorted.library.type.Static3D;
34 35
import org.distorted.library.type.Static4D;
......
46 47
    private DistortedBitmap monaLisa;
47 48
    private Static2D pLeft, pRight;
48 49
    private Static4D rLeft, rRight;
49
    private Static3D vLeft, vRight;
50
    private Dynamic3D dLeft, dRight;
51

  
50 52
    private int bmpHeight, bmpWidth;
51 53
    
52 54
///////////////////////////////////////////////////////////////////////////////////////////////////
......
60 62
      
61 63
      rLeft = new Static4D(-10,-10,25,25);
62 64
      rRight= new Static4D( 10, -5,25,25);
63
      
64
      vLeft = new Static3D(-20,-20,0);
65
      vRight= new Static3D( 20,-10,0);
65

  
66
      dLeft = new Dynamic3D();
67
      dRight= new Dynamic3D();
68

  
69
      dLeft.setDuration(1000);
70
      dRight.setDuration(1000);
71

  
72
      dLeft.setCount(0);
73
      dRight.setCount(0);
74

  
75
      dLeft.add( new Static3D(  0,  0,0) );
76
      dLeft.add( new Static3D(-20,-20,0) );
77

  
78
      dRight.add( new Static3D(  0,  0,0) );
79
      dRight.add( new Static3D( 20,-10,0) );
66 80
      }
67 81

  
68 82
///////////////////////////////////////////////////////////////////////////////////////////////////
......
125 139
      bmpWidth  = bitmap.getWidth();
126 140
      
127 141
      monaLisa = new DistortedBitmap(bitmap, 10);
128
      monaLisa.distort( vLeft, rLeft , pLeft, 1000, 0);
129
      monaLisa.distort(vRight, rRight, pRight,1000, 0);
130
      
142
      monaLisa.distort( dLeft, pLeft , rLeft );
143
      monaLisa.distort(dRight, pRight, rRight);
144

  
131 145
      try
132 146
        {
133 147
        Distorted.onSurfaceCreated(mView.getContext());
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
38 38
import org.distorted.library.type.Static3D;
39 39
import org.distorted.library.type.Static4D;
40 40

  
41
///////////////////////////////////////////////////////////////////
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42 42

  
43 43
public class MovingEffectsSurfaceView extends GLSurfaceView
44 44
    {
......
57 57
    private static int xDown,yDown;
58 58
    private static int mScrW, mScrH;
59 59

  
60
    private static Dynamic1D macroDyn, alphaDyn;
61 60
    private static Dynamic2D di2D;
62
    private static Dynamic3D di3D;
63 61
    private static Static4D dr;
64

  
65 62
    private static Dynamic4D mRegion;
66 63

  
67 64
    private static Paint mPaint;
......
71 68
    
72 69
    private static int mCurrEffect;
73 70
    
74
///////////////////////////////////////////////////////////////////
71
///////////////////////////////////////////////////////////////////////////////////////////////////
75 72
    
76 73
    public MovingEffectsSurfaceView(Context c, AttributeSet attrs) 
77 74
      {
78 75
      super(c, attrs);
79 76

  
80
      macroDyn = new Dynamic1D();
81
      macroDyn.setDuration(0);
82
      macroDyn.setCount(0.5f);
83
      macroDyn.add(new Static1D(1));
84
      macroDyn.add(new Static1D(3));
85

  
86
      alphaDyn = new Dynamic1D();
87
      alphaDyn.setDuration(0);
88
      alphaDyn.setCount(0.5f);
89
      alphaDyn.add(new Static1D(1.0f));
90
      alphaDyn.add(new Static1D(0.5f));
91

  
92 77
      mCurrEffect=EFFECT_POINTS;
93 78
      mPaint = new Paint();
94 79
      mPaint.setStyle(Style.FILL);
......
97 82
      di2D = new Dynamic2D();
98 83
      di2D.setCount(0.0f);
99 84
      di2D.setDuration(LOOP_TIME);
100
      
101
      di3D = new Dynamic3D();
102
      di3D.add(new Static3D(0,0, 0));
103
      di3D.add(new Static3D(0,0,30));
104
      
85

  
105 86
      dr = new Static4D(0,0,60,60);
106 87

  
107 88
      mRegion = new Dynamic4D();
......
125 106
        }
126 107
      }
127 108

  
128
///////////////////////////////////////////////////////////////////
109
///////////////////////////////////////////////////////////////////////////////////////////////////
129 110

  
130 111
    public static void setScreenSize(int width, int height)
131 112
      {
......
133 114
      mScrH = height;
134 115
      }
135 116

  
136
///////////////////////////////////////////////////////////////////
117
///////////////////////////////////////////////////////////////////////////////////////////////////
137 118

  
138 119
    public static int getCurrentEffect()
139 120
      {
140 121
      return mCurrEffect;
141 122
      }
142 123
    
143
///////////////////////////////////////////////////////////////////
124
///////////////////////////////////////////////////////////////////////////////////////////////////
144 125
    
145 126
    public static void Bubble()
146 127
      {
......
150 131
        {
151 132
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX);
152 133
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT);
153
        MovingEffectsRenderer.mBackground.distort(di3D, dr, di2D);
134
        MovingEffectsRenderer.mBackground.distort( new Static3D(0,0,30) , di2D, dr);
154 135
        mCurrEffect = EFFECT_BUBBLE;
155 136
        }
156 137
      }
157 138

  
158
///////////////////////////////////////////////////////////////////
139
///////////////////////////////////////////////////////////////////////////////////////////////////
159 140

  
160 141
    public static void Sink()
161 142
      {
......
165 146
        {
166 147
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX);
167 148
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT);
168
        MovingEffectsRenderer.mBackground.sink(10.0f, dr, di2D, 0, 0.5f);
149
        MovingEffectsRenderer.mBackground.sink(new Static1D(10), di2D, dr);
169 150
        mCurrEffect = EFFECT_SINK;
170 151
        }
171 152
      }
172 153

  
173
///////////////////////////////////////////////////////////////////
154
///////////////////////////////////////////////////////////////////////////////////////////////////
174 155

  
175 156
    public static void Macroblock()
176 157
      {
......
180 161
        {
181 162
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX);
182 163
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT);
183
        MovingEffectsRenderer.mBackground.macroblock(macroDyn, mRegion);
164
        MovingEffectsRenderer.mBackground.macroblock(new Static1D(3), mRegion);
184 165
        mCurrEffect = EFFECT_MACRO;
185 166
        }
186 167
      }
187 168

  
188
///////////////////////////////////////////////////////////////////
169
///////////////////////////////////////////////////////////////////////////////////////////////////
189 170

  
190 171
    public static void Transparency()
191 172
      {
......
195 176
        {
196 177
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX);
197 178
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT);
198
        MovingEffectsRenderer.mBackground.alpha(alphaDyn, mRegion, true);
179
        MovingEffectsRenderer.mBackground.alpha(new Static1D(0.5f), mRegion, true);
199 180
        mCurrEffect = EFFECT_TRANS;
200 181
        }
201 182
      }
202 183

  
203
///////////////////////////////////////////////////////////////////
184
///////////////////////////////////////////////////////////////////////////////////////////////////
204 185

  
205 186
    public static void Swirl()
206 187
      {
......
210 191
        {
211 192
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX);
212 193
        MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT);
213
        MovingEffectsRenderer.mBackground.swirl(30, dr, di2D);
194
        MovingEffectsRenderer.mBackground.swirl( new Static1D(30), di2D, dr);
214 195
        mCurrEffect = EFFECT_SWIRL;
215 196
        }
216 197
      }
217 198
    
218
///////////////////////////////////////////////////////////////////
199
///////////////////////////////////////////////////////////////////////////////////////////////////
219 200

  
220 201
    public static void Abort()
221 202
      {
......
229 210
        }
230 211
      }
231 212

  
232
///////////////////////////////////////////////////////////////////
213
///////////////////////////////////////////////////////////////////////////////////////////////////
233 214
 
234 215
    public static void drawCurve(Canvas c, long time)
235 216
      {
......
265 246
        }
266 247
      }
267 248
       
268
///////////////////////////////////////////////////////////////////
249
///////////////////////////////////////////////////////////////////////////////////////////////////
269 250
    
270 251
    @Override public boolean onTouchEvent(MotionEvent event) 
271 252
      {
......
314 295
        }
315 296
      return true;
316 297
      }
317
 
318
///////////////////////////////////////////////////////////////////
319
// end of file
320

  
321 298
  }
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java
34 34
import org.distorted.library.Distorted;
35 35
import org.distorted.library.DistortedBitmap;
36 36
import org.distorted.library.EffectTypes;
37
import org.distorted.library.type.Dynamic3D;
37 38
import org.distorted.library.type.Static2D;
38 39
import org.distorted.library.type.Static3D;
39 40
import org.distorted.library.type.Static4D;
......
65 66

  
66 67
  private Static2D pLeft, pRight;
67 68
  private Static4D rLeft, rRight;
68
  private Static3D vLeft, vRight;
69

  
70
  private Dynamic3D dLeft, dRight;
69 71

  
70 72
  SurfaceView mView;
71 73

  
......
82 84
    rLeft = new Static4D(-10,-10,25,25);
83 85
    rRight= new Static4D( 10, -5,25,25);
84 86

  
85
    vLeft = new Static3D(-20,-20,0);
86
    vRight= new Static3D( 20,-10,0);
87
    dLeft = new Dynamic3D();
88
    dRight= new Dynamic3D();
89

  
90
    dLeft.setDuration(1000);
91
    dRight.setDuration(1000);
92

  
93
    dLeft.setCount(0);
94
    dRight.setCount(0);
95

  
96
    dLeft.add( new Static3D(  0,  0,0) );
97
    dLeft.add( new Static3D(-20,-20,0) );
98

  
99
    dRight.add( new Static3D(  0,  0,0) );
100
    dRight.add( new Static3D( 20,-10,0) );
87 101
    }
88 102

  
89 103
///////////////////////////////////////////////////////////////////////////////////////////////////
......
181 195
      }
182 196

  
183 197
    monaLisa = new DistortedBitmap(bmp, 10);
184
    monaLisa.distort( vLeft, rLeft , pLeft, 1000, 0);
185
    monaLisa.distort(vRight, rRight, pRight,1000, 0);
198
    monaLisa.distort( dLeft, pLeft , rLeft );
199
    monaLisa.distort(dRight, pRight, rRight);
186 200

  
187 201
    bmpHeight = bmp.getHeight();
188 202
    bmpWidth  = bmp.getWidth();
src/main/java/org/distorted/examples/save/SaveRenderer.java
209 209
      
210 210
    mGirl = new DistortedBitmap(bitmap, 30);
211 211

  
212
    mGirl.sink( diSink, sinkRegion, pLeft );
213
    mGirl.sink( diSink, sinkRegion, pRight);
212
    mGirl.sink( diSink, pLeft , sinkRegion);
213
    mGirl.sink( diSink, pRight, sinkRegion);
214 214

  
215 215
    try
216 216
      {

Also available in: Unified diff