Project

General

Profile

« Previous | Next » 

Revision 1bb5d3b7

Added by Leszek Koltunski over 2 years ago

Add testing of MeshPolygon to the MeshFile app.

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
38 38
import org.distorted.library.main.DistortedTexture;
39 39
import org.distorted.library.mesh.MeshBase;
40 40
import org.distorted.library.mesh.MeshFile;
41
import org.distorted.library.mesh.MeshPolygon;
41 42
import org.distorted.library.type.DynamicQuat;
42 43
import org.distorted.library.type.Static3D;
43 44
import org.distorted.library.type.Static4D;
44 45

  
46
import org.distorted.objectlib.helpers.FactoryCubit;
47

  
45 48
import java.io.DataInputStream;
46 49
import java.io.IOException;
47 50
import java.io.InputStream;
......
49 52
import javax.microedition.khronos.egl.EGLConfig;
50 53
import javax.microedition.khronos.opengles.GL10;
51 54

  
55
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON;
52 56
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL;
53 57

  
54 58
///////////////////////////////////////////////////////////////////////////////////////////////////
......
172 176

  
173 177
      long t1 = System.currentTimeMillis();
174 178

  
175
      if( resourceID!=PROCEDURAL )
179
      if( resourceID==PROCEDURAL )
176 180
        {
177
        openMesh(resourceID);
181
        createMesh();
182
        }
183
      else if( resourceID==POLYGON )
184
        {
185
        createPolygon();
178 186
        }
179 187
      else
180 188
        {
181
        createMesh();
189
        openMesh(resourceID);
182 190
        }
183 191

  
184 192
      long t2 = System.currentTimeMillis();
......
199 207
      int[] colors;
200 208
      float F = 0.5f;
201 209
      float E = SQ3/2;
202
      float G = SQ2/4;
203 210

  
204 211
      switch(resourceID)
205 212
          {
206 213
          case  R.raw.deferredjob:
207 214
          case  R.raw.meshjoin   :
208 215
          case  PROCEDURAL       :
216
          case  POLYGON          :
209 217
          case  R.raw.predeform  : return createWhiteTexture();
210 218

  
211 219
          case  R.raw.cube2      :
......
250 258
      return bitmap;
251 259
      }
252 260

  
261
///////////////////////////////////////////////////////////////////////////////////////////////////
262

  
263
    private void createPolygon()
264
      {
265
      float A = 0.5f;
266
      float B = 0.1f;
267

  
268
      int extraIndex    = 1;
269
      int extraVertices = 2;
270
      int numBands      = 3;
271

  
272
      float[] vertices = new float[] { -A,-A, A,-A, A,A, -A,A };
273
      float[] bands = new float[2*numBands];
274

  
275
      for(int i=0; i<numBands; i++)
276
        {
277
        bands[2*i  ] = 1 + i/(1.0f-numBands);
278
        bands[2*i+1] = B/(numBands-1)*i;
279
        }
280

  
281
      mMesh = new MeshPolygon(vertices,bands,extraIndex,extraVertices);
282
      mMesh.setEffectAssociation(0,0,0);
283
      mMesh.setShowNormals(true);
284
      }
285

  
253 286
///////////////////////////////////////////////////////////////////////////////////////////////////
254 287

  
255 288
    private void createMesh()

Also available in: Unified diff