Project

General

Profile

« Previous | Next » 

Revision 8eed34d3

Added by Leszek Koltunski about 4 years ago

Moving the Vertex and Fragment centers of effect to the center of the Mesh.

View differences:

src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
63 63

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

  
122
      mScrWidth  = width;
122 123
      mScrHeight = height;
123 124

  
124 125
      mSize1 = max/200;
......
251 252
            {
252 253
            mPaint.setColor( 0xffffffff );
253 254
            mCenter.get( drawCoord, 0, (long)(i*step) );
254
            c.drawCircle(drawCoord[0], mScrHeight-drawCoord[1], mSize1, mPaint );
255
            c.drawCircle(drawCoord[0] + mScrWidth*0.5f, mScrHeight*0.5f - drawCoord[1], mSize1, mPaint );
255 256
            }
256 257
          }
257 258
     
......
260 261
        for(int curr=0; curr<len; curr++)
261 262
          {       
262 263
          cu = mCenter.getPoint(curr);
263
          c.drawCircle(cu.get0(), mScrHeight-cu.get1(), mSize2, mPaint);
264
          c.drawCircle(cu.get0() + mScrWidth*0.5f, mScrHeight*0.5f - cu.get1(), mSize2, mPaint);
264 265
          }
265 266
        
266 267
        if( time-mTime > LOOP_TIME ) mTime = time;
......
274 275
      {
275 276
      if( mCurrEffect!=EFFECT_POINTS ) return true;   
276 277

  
277
      int xDown, yDown;
278
      int xDown = (int)event.getX() - mScrWidth/2;
279
      int yDown = mScrHeight/2 - (int)event.getY();
278 280

  
279 281
      switch(event.getAction())
280 282
        {
281
        case MotionEvent.ACTION_DOWN: xDown =              (int)event.getX();
282
                                      yDown = mScrHeight - (int)event.getY();
283
                                    
284
                                      float gx, gy;
283
        case MotionEvent.ACTION_DOWN: float gx, gy;
285 284
                                      Static3D dv;
286 285
                                      int len = mCenter.getNumPoints();
287 286
                                 
......
310 309
                                      break;
311 310
        case MotionEvent.ACTION_MOVE: if( moving>=0 )
312 311
                                        {
313
                                        xDown =              (int)event.getX();
314
                                        yDown = mScrHeight - (int)event.getY();
315

  
316 312
                                        mCenter.setPoint(moving, xDown, yDown, 0);
317 313
                                        }
318 314
                                      mRenderer.setRefresh();

Also available in: Unified diff