Project

General

Profile

« Previous | Next » 

Revision b2adcd57

Added by Leszek Koltunski over 1 year ago

Beginnings of MeshMultigon (does not work yet)

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
43 43
{
44 44
    final static int PROCEDURAL = -1;
45 45
    final static int POLYGON    = -2;
46
    final static int MULTIGON   = -3;
46 47

  
47 48
    private LinearLayout mLayout;
48 49
    private int mResource;
49 50
    private String[] mNames = new String[] { "polygon"    ,
51
                                             "multigon"   ,
50 52
                                             "procedural" ,
51 53
                                             "deferredjob",
52 54
                                             "meshjoin"   ,
......
188 190
        switch(pos)
189 191
          {
190 192
          case  0: mResource = POLYGON          ; break;
191
          case  1: mResource = PROCEDURAL       ; break;
192
          case  2: mResource = R.raw.deferredjob; break;
193
          case  3: mResource = R.raw.meshjoin   ; break;
194
          case  4: mResource = R.raw.predeform  ; break;
195
          case  5: mResource = R.raw.cube2      ; break;
196
          case  6: mResource = R.raw.cube3      ; break;
197
          case  7: mResource = R.raw.cube4      ; break;
198
          case  8: mResource = R.raw.cube5      ; break;
199
          case  9: mResource = R.raw.pyra3      ; break;
200
          case 10: mResource = R.raw.pyra4      ; break;
201
          case 11: mResource = R.raw.pyra5      ; break;
202
          case 12: mResource = R.raw.dino       ; break;
203
          case 13: mResource = R.raw.skewb      ; break;
193
          case  1: mResource = MULTIGON         ; break;
194
          case  2: mResource = PROCEDURAL       ; break;
195
          case  3: mResource = R.raw.deferredjob; break;
196
          case  4: mResource = R.raw.meshjoin   ; break;
197
          case  5: mResource = R.raw.predeform  ; break;
198
          case  6: mResource = R.raw.cube2      ; break;
199
          case  7: mResource = R.raw.cube3      ; break;
200
          case  8: mResource = R.raw.cube4      ; break;
201
          case  9: mResource = R.raw.cube5      ; break;
202
          case 10: mResource = R.raw.pyra3      ; break;
203
          case 11: mResource = R.raw.pyra4      ; break;
204
          case 12: mResource = R.raw.pyra5      ; break;
205
          case 13: mResource = R.raw.dino       ; break;
206
          case 14: mResource = R.raw.skewb      ; break;
204 207
          }
205 208
        }
206 209
      }
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.MeshMultigon;
41 42
import org.distorted.library.mesh.MeshPolygon;
42 43
import org.distorted.library.type.DynamicQuat;
43 44
import org.distorted.library.type.Static3D;
......
58 59
import javax.microedition.khronos.egl.EGLConfig;
59 60
import javax.microedition.khronos.opengles.GL10;
60 61

  
62
import static org.distorted.examples.meshfile.MeshFileActivity.MULTIGON;
61 63
import static org.distorted.examples.meshfile.MeshFileActivity.POLYGON;
62 64
import static org.distorted.examples.meshfile.MeshFileActivity.PROCEDURAL;
63 65
import static org.distorted.objectlib.main.TwistyObject.MESH_NICE;
......
186 188
        {
187 189
        createPolygon();
188 190
        }
191
      else if( resourceID==MULTIGON )
192
        {
193
        createMultigon();
194
        }
189 195
      else
190 196
        {
191 197
        openMesh(resourceID);
......
214 220
          resourceID == R.raw.meshjoin    ||
215 221
          resourceID == PROCEDURAL        ||
216 222
          resourceID == POLYGON           ||
223
          resourceID == MULTIGON          ||
217 224
          resourceID == R.raw.predeform    ) return createWhiteTexture();
218 225

  
219 226
      if( resourceID == R.raw.cube2       ||
......
296 303
      mMesh.setShowNormals(true);
297 304
      }
298 305

  
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

  
308
    private void createMultigon()
309
      {
310
      float A = 0.5f;
311
      int extraIndex    = 1;
312
      int extraVertices = 1;
313

  
314
      float[] v1 = new float[] { -A,-A,  A,-A,  A,A, -A,A };
315
      float[] v2 = new float[] {  A,-A,2*A,-A,2*A,A,  A,A };
316
      float[][] vertices = new float[][] {v1,v2};
317

  
318
      float[] c1 = new float[] { 0,0 };
319
      float[] c2 = new float[] { 1.5f*A,0 };
320
      float[][] centers = new float[][] { c1,c2 };
321

  
322
      float C = 0.5f;
323
      float[] bands = new float[] { 1.0f, 0.00f*C, 0.9f, 0.04f*C,  0.8f, 0.07f*C, 0.5f, 0.09f*C, 0.0f, 0.10f*C};
324

  
325
/*
326
      float B = 0.04f;
327
      int numBands = 5;
328
      float[] bands = new float[2*numBands];
329

  
330
      for(int i=0; i<numBands; i++)
331
        {
332
        bands[2*i  ] = 1 + i/(1.0f-numBands);
333
        bands[2*i+1] = B/(numBands-1)*i;
334
        }
335
*/
336
      mMesh = new MeshMultigon(vertices,bands,extraIndex,extraVertices,centers);
337
      mMesh.setEffectAssociation(0,0,0);
338
      mMesh.setShowNormals(true);
339
      }
340

  
299 341
///////////////////////////////////////////////////////////////////////////////////////////////////
300 342

  
301 343
    private void createMesh()

Also available in: Unified diff