Project

General

Profile

« Previous | Next » 

Revision 7c55263f

Added by Leszek Koltunski over 4 years ago

Library: introduce a new form of the MeshRectangular grid, where the individual rows and columns can be each of different width. This help reduce the number of vertices in objects as typically we are only interested at distorting a certain subregion.

Modify the Bean app to take advantage of this.

View differences:

src/main/java/org/distorted/examples/bean/BeanRenderer.java
138 138
     mTexture.setTexture(bitmap);
139 139

  
140 140
     // we need a denser Mesh lattice this time for the Distorts to look good.
141
     if( mMesh==null ) mMesh = new MeshRectangles(25, (int)(25*mBmpRatio));
141

  
142
     float PART = 0.47f;
143

  
144
     int width = 25;
145
     int height= (int)((25*mBmpRatio)*PART);
146

  
147
     float[] xLoc = new float[width +1];
148
     float[] yLoc = new float[height+1];
149

  
150
     xLoc[0] = -0.5f;
151
     yLoc[0] = -0.5f;
152

  
153
     for(int i=1; i<=width; i++) xLoc[i] = 1.0f/width;
154
     for(int i=1; i<height; i++) yLoc[i] = PART/height;
155

  
156
     yLoc[height] = (height-(height-1)*PART)/height;
157

  
158
     if( mMesh==null ) mMesh = new MeshRectangles(xLoc,yLoc);
142 159

  
143 160
     mScreen.detachAll();
144 161
     mScreen.attach(mTexture,mEffects,mMesh);
src/main/java/org/distorted/examples/meshfile/MeshFileSurfaceView.java
95 95

  
96 96
///////////////////////////////////////////////////////////////////////////////////////////////////
97 97

  
98
    @Override public boolean onTouchEvent(MotionEvent event) 
98
    @Override
99
    public boolean onTouchEvent(MotionEvent event)
99 100
      {
100 101
      int action = event.getAction();
101 102
      int x = (int)event.getX();

Also available in: Unified diff