Project

General

Profile

« Previous | Next » 

Revision d7829514

Added by Leszek Koltunski over 4 years ago

1) Cube: convert it to the latest library. Main difference: objects are rendered better, individual cubits have rounded corners.
2) Examples: some adjustments to MeshJoin & Predeform
3) Library: fix a bug in main_vertex_shader's 'degree' function, which didn't work proprely in case of a vertex which was exactly at the center (i.e. vector PS was zero)

View differences:

src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
86 86
      quatInt1.add(mQuat1);
87 87
      quatInt2.add(mQuat2);
88 88

  
89
      mSinkAssociation = 15;
89
      mSinkAssociation = 0;
90 90
      mSink = new VertexEffectSink( sink, center, new Static4D(0,0,0,0.75f) );
91 91
      mSink.setMeshAssociation(mSinkAssociation);
92 92

  
......
214 214

  
215 215
      for(int i=0; i<MESHES; i++)
216 216
        {
217
        meshes[i] = new MeshTriangles(10);
217
        meshes[i] = new MeshTriangles(5);
218 218
        meshes[i].setEffectAssociation(0,association);
219 219
        association <<= 1;
220 220
        }
......
267 267
      VertexEffectDeform effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
268 268
      VertexEffectDeform effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
269 269

  
270
      effect1.setMeshAssociation(15);  // apply to all 4 meshes
271
      effect2.setMeshAssociation(15);  // apply to all 4 meshes
272
      effect3.setMeshAssociation(15);  // apply to all 4 meshes
273 270
      effect4.setMeshAssociation(14);  // apply to mesh[1], [2] and [3]
274 271
      effect5.setMeshAssociation( 2);  // apply only to mesh[1]
275 272
      effect6.setMeshAssociation( 4);  // apply only to mesh[2]
276 273
      effect7.setMeshAssociation( 8);  // apply only to mesh[3]
277
      effect8.setMeshAssociation(15);  // apply to all 4 meshes
278
      effect9.setMeshAssociation(15);  // apply to all 4 meshes
279
      effect10.setMeshAssociation(15); // apply to all 4 meshes
280
      effect11.setMeshAssociation(15); // apply to all 4 meshes
281 274

  
282 275
      result.apply(effect1);
283 276
      result.apply(effect2);
src/main/java/org/distorted/examples/predeform/PredeformActivity.java
330 330

  
331 331
    }
332 332

  
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334

  
335
  int getWidth()
336
    {
337
    return mNumCols;
338
    }
339

  
340
///////////////////////////////////////////////////////////////////////////////////////////////////
341

  
342
  int getHeight()
343
    {
344
    return mNumRows;
345
    }
346

  
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

  
349
  int getDepth()
350
    {
351
    return mNumSlic;
352
    }
353

  
354 333
///////////////////////////////////////////////////////////////////////////////////////////////////
355 334

  
356 335
  @Override
src/main/java/org/distorted/examples/predeform/PredeformEffect.java
204 204
      ///////////////////////////////////////////////////////////////////////////////////////
205 205

  
206 206
      case VERTEX_MOVE      :
207
      case DISTORT          : float ld = mAct.get().getWidth()/50.0f;
207
      case DISTORT          : float ld = 0.02f;
208 208
                              float xd = (mInter[0]-50)*ld;
209 209
                              float yd = (mInter[1]-50)*ld;
210 210
                              float zd = (mInter[2]-50)*ld;
211 211
                              mSta3.set(xd,yd,zd);
212 212
                              break;
213
      case DEFORM           : float le = mAct.get().getWidth()/50.0f;
213
      case DEFORM           : float le = 0.02f;
214 214
                              float xe = (mInter[0]-50)*le;
215 215
                              float ye = (mInter[1]-50)*le;
216 216
                              float ze = (mInter[2]-50)*le;
......
218 218
                              float re = (mInter[3])*le;
219 219
                              mSta1.set(re);
220 220
                              break;
221
      case WAVE             : float l2 = mAct.get().getWidth()/50.0f;
221
      case WAVE             : float l2 = 0.02f;
222 222
                              float x2 = (mInter[0]-50)*l2;
223 223
                              float y2 = (mInter[1]-50)*l2;
224 224
                              float z2 = (mInter[2]-50)*180 / 50.0f;
......
355 355
    {
356 356
    PredeformActivity act = mAct.get();
357 357

  
358
    float x = (mInterCenter[0]*0.012f - 0.6f)*act.getWidth();
359
    float y = (mInterCenter[1]*0.012f - 0.6f)*act.getHeight();
360
    float z = (mInterCenter[2]*0.012f - 0.6f)*act.getDepth();
358
    float x = (mInterCenter[0]*0.012f - 0.6f);
359
    float y = (mInterCenter[1]*0.012f - 0.6f);
360
    float z = (mInterCenter[2]*0.012f - 0.6f);
361 361

  
362 362
    if( mName.getType() == EffectType.MATRIX )
363 363
      {
......
396 396
    {
397 397
    PredeformActivity act = mAct.get();
398 398

  
399
    float factorX = act.getWidth() / 100.0f;
400
    float factorY = act.getHeight()/ 100.0f;
401
 // float factorZ = act.getDepth() / 100.0f;
399
    float factorX = 0.01f;
400
    float factorY = 0.01f;
401
 // float factorZ = 0.01f;
402 402

  
403 403
    int deduct = (mName.getType() == EffectType.VERTEX ? 50:0);
404 404

  
src/main/res/layout/meshjoinlayout.xml
29 29
            android:text="@string/color_yellow"
30 30
            android:onClick="onClick"
31 31
            android:layout_weight="1"
32
            android:checked="true"/>
32
            android:checked="false"/>
33 33
        <CheckBox
34 34
            android:layout_width="wrap_content"
35 35
            android:layout_height="match_parent"
......
37 37
            android:text="@string/color_green"
38 38
            android:onClick="onClick"
39 39
            android:layout_weight="1"
40
            android:checked="true"/>
40
            android:checked="false"/>
41 41
        <CheckBox
42 42
            android:layout_width="wrap_content"
43 43
            android:layout_height="match_parent"
......
45 45
            android:text="@string/color_blue"
46 46
            android:onClick="onClick"
47 47
            android:layout_weight="1"
48
            android:checked="true"/>
48
            android:checked="false"/>
49 49
        <CheckBox
50 50
            android:layout_width="wrap_content"
51 51
            android:layout_height="match_parent"
......
53 53
            android:text="@string/color_red"
54 54
            android:onClick="onClick"
55 55
            android:layout_weight="1"
56
            android:checked="true"/>
56
            android:checked="false"/>
57 57

  
58 58
    </LinearLayout>
59 59

  

Also available in: Unified diff