Project

General

Profile

« Previous | Next » 

Revision b2adcd57

Added by Leszek Koltunski 11 months ago

Beginnings of MeshMultigon (does not work yet)

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.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