Project

General

Profile

« Previous | Next » 

Revision 849e0034

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/monalisa/MonaLisaRenderer.java
51 51
    private MeshRectangles mMesh;
52 52
    private DistortedScreen mScreen;
53 53
    private Static3D mScale;
54
    private Static3D mCenterLeft, mCenterRight;
55 54

  
56 55
///////////////////////////////////////////////////////////////////////////////////////////////////
57 56

  
......
59 58
      {
60 59
      mView = v;
61 60

  
62
      // two points, centers of the Distort effect
63
      // the left and right tip of the mouth
64
      // (0,0,0) for now because we don't know the size of the bitmap yet.
65
      mCenterLeft  = new Static3D(0,0,0);
66
      mCenterRight = new Static3D(0,0,0);
61
      // MonaLisa bitmap is 320x366, this is thus (90,108) pixels from the lower-left corner
62
      Static3D centerLeft  = new Static3D( 90-320/2, 108-366/2,0);
63
      // (176,111) from the lower left
64
      Static3D centerRight = new Static3D(176-320/2, 111-366/2,0);
67 65

  
68 66
      // two regions defining the areas affected by the Distort effect
69 67
      Static4D rLeft  = new Static4D(-10, 10, 0, 25);
......
85 83
      dRight.add( new Static3D( 20, 10, 0) );
86 84

  
87 85
      mEffects = new DistortedEffects();
88
      mEffects.apply( new VertexEffectDistort(dLeft , mCenterLeft , rLeft ) );
89
      mEffects.apply( new VertexEffectDistort(dRight, mCenterRight, rRight) );
86
      mEffects.apply( new VertexEffectDistort(dLeft , centerLeft , rLeft ) );
87
      mEffects.apply( new VertexEffectDistort(dRight, centerRight, rRight) );
90 88

  
91 89
      mScale= new Static3D(1,1,1);
92 90
      mEffects.apply(new MatrixEffectScale(mScale));
......
136 134
      int bmpHeight = bitmap.getHeight();
137 135
      int bmpWidth  = bitmap.getWidth();
138 136

  
139
      // Now we know the size of the bitmap, we can set the centers of effects
140
      // to (90,108) from the lower-left corner (CenterLeft) and (176,111) from the corner.
141
      mCenterLeft .set( 90 - bmpWidth/2, 108 - bmpHeight/2, 0);
142
      mCenterRight.set(176 - bmpWidth/2, 111 - bmpHeight/2, 0);
143

  
144 137
      // We could have gotten here after the activity went to the background
145 138
      // for a brief amount of time; in this case mTexture is already created.
146 139
      // Do not leak memory by creating it the second time around.

Also available in: Unified diff