Project

General

Profile

« Previous | Next » 

Revision 4d49605b

Added by Leszek Koltunski over 1 year ago

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

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
119 119
      super.onDestroy();
120 120
      }
121 121

  
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

  
124
    public void onNormals(View v)
125
      {
126
      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
127
      MeshFileRenderer renderer = view.getRenderer();
128
      renderer.flipNormals();
129
      }
130

  
122 131
///////////////////////////////////////////////////////////////////////////////////////////////////
123 132

  
124 133
    public void Open(View v)
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];
src/main/res/layout/meshfilelayout.xml
24 24
        android:layout_width="match_parent"
25 25
        android:layout_height="wrap_content">
26 26

  
27
        <CheckBox
28
            android:layout_width="wrap_content"
29
            android:layout_height="match_parent"
30
            android:id="@+id/meshfileNormals"
31
            android:layout_weight="0.2"
32
            android:onClick="onNormals"
33
            android:checked="false"/>
34

  
27 35
        <Spinner
28 36
            android:layout_width="0dp"
29 37
            android:layout_height="wrap_content"
30
            android:layout_weight="0.5"
38
            android:layout_weight="0.9"
31 39
            android:id="@+id/meshfileSpinner"/>
32 40

  
33 41
        <Button

Also available in: Unified diff