Project

General

Profile

« Previous | Next » 

Revision 4d49605b

Added by Leszek Koltunski 11 months ago

Make it possible to control if we can see the normal vectors.

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
78 78
    private MeshBase mMesh;
79 79
    private long mTime;
80 80
    private float mCurrentScale;
81
    private boolean mNormals;
81 82

  
82 83
    Static4D mQuat1, mQuat2;
83 84
    int mScreenMin;
......
94 95
      Static3D center=new Static3D(0,0,0);
95 96

  
96 97
      mCurrentScale = DEFAULT_SCALE;
98
      mNormals = false;
97 99

  
98 100
      mQuat1 = new Static4D(0,0,0,1);
99 101
      mQuat2 = new Static4D(0,0,0,1);
......
167 169
      mScale.set(factor,factor,factor);
168 170
      }
169 171

  
172
///////////////////////////////////////////////////////////////////////////////////////////////////
173

  
174
    void flipNormals()
175
      {
176
      mNormals = !mNormals;
177
      if( mMesh!=null ) mMesh.setShowNormals(mNormals);
178
      }
179

  
170 180
///////////////////////////////////////////////////////////////////////////////////////////////////
171 181

  
172 182
    void open(int resourceID)
......
297 307

  
298 308
      mMesh = new MeshPolygon(vertices,bands,edgesUp,vertsUp,extraIndex,extraVertices,0.0f,0.0f);
299 309
      mMesh.setEffectAssociation(0,0,0);
300
      mMesh.setShowNormals(true);
301 310
      }
302 311

  
303 312
///////////////////////////////////////////////////////////////////////////////////////////////////
......
346 355
        {
347 356
        mMesh.setEffectAssociation(i, 0, i);
348 357
        }
349

  
350
     // mMesh.setShowNormals(true);
351 358
      }
352 359

  
353 360
///////////////////////////////////////////////////////////////////////////////////////////////////
354 361

  
355 362
    private void createMesh()
356 363
      {
364
      /*
357 365
      float A = 2.0f;
358 366

  
359 367
      float[][] vertices =
......
403 411
      float[][] corners= { {0.036f,0.12f} };
404 412
      float[][] centers= { {0.0f, 0.0f, 0.0f} };
405 413
      int[] ind    = { 0,0,-1,-1,-1,-1,-1,-1, 0,0,0,0,0,0,0,0 };
414
      */
415
      float[][] vertices = { {-1.5f, 0.0f, 0.0f},{ 1.5f, 0.0f, 0.0f},{ 0.0f,-1.5f, 0.0f},{ 0.0f, 0.0f,-1.5f},{0,0,0} };
416
      int[][][] vertIndices = { {{2,1,4},{4,0,2}},{{3,0,4},{4,1,3}},{{2,3,1}},{{3,2,0}} };
417
      float h1 = 0.035f;
418
      float h2 = 0.010f;
419
      int angle = 30;
420
      float R = 0.7f;
421
      float S = 0.5f;
422
      int N   = 6;
423
      int exI = 2;
424
      int exV = 2;
425
      float[][] bands  = { {h1,angle,R,S,N,exI,exV}, {h2,angle,R,S,N,exI,exV} };
426
      int[] bandIndices= { 0,0,1,1 };
427
      float[] convex = null;
428
      float[][] corners   = { {0.07f,0.40f}, {0.05f,0.30f} };
429
      int[] cornerIndices = { 0,0,1,1,-1 };
430
      float[][] centers   = { {0.0f, -0.75f, -0.75f} };
431
      int[] centerIndices = { 0,0,0,0,-1 };
406 432

  
407 433
      ObjectShape shape = new ObjectShape(vertices, vertIndices);
408 434
      ObjectFaceShape face = new ObjectFaceShape(bands, bandIndices, convex);
409
      ObjectVertexEffects effects = FactoryCubit.generateVertexEffect(vertices,corners,ind,centers,ind);
435
      ObjectVertexEffects effects = FactoryCubit.generateVertexEffect(vertices,corners,cornerIndices,centers,centerIndices);
410 436

  
411 437
      int numFaces = shape.getNumFaces();
412 438
      int[] outer = new int[numFaces];

Also available in: Unified diff