Project

General

Profile

« Previous | Next » 

Revision 231771f3

Added by Leszek Koltunski over 3 years ago

Convert RubikPyraminx to the new MeshPolygon - better quality of the mesh and less vertices!

View differences:

src/main/java/org/distorted/objects/RubikPyraminx.java
27 27
import org.distorted.library.effect.VertexEffectMove;
28 28
import org.distorted.library.effect.VertexEffectRotate;
29 29
import org.distorted.library.effect.VertexEffectScale;
30
import org.distorted.library.effect.VertexEffectSink;
31 30
import org.distorted.library.main.DistortedEffects;
32 31
import org.distorted.library.main.DistortedTexture;
33 32
import org.distorted.library.mesh.MeshBase;
34 33
import org.distorted.library.mesh.MeshJoined;
34
import org.distorted.library.mesh.MeshPolygon;
35 35
import org.distorted.library.mesh.MeshSquare;
36
import org.distorted.library.mesh.MeshTriangle;
37 36
import org.distorted.library.type.Static1D;
38 37
import org.distorted.library.type.Static3D;
39 38
import org.distorted.library.type.Static4D;
......
253 252
    final float angleFaces = (float)((180/Math.PI)*(2*Math.asin(SQ3/3))); // angle between two faces of a tetrahedron
254 253
    final int MESHES=4;
255 254

  
255
    int size = getSize();
256

  
256 257
    int association = 1;
257
    MeshBase[] meshes = new MeshTriangle[MESHES];
258
    MeshBase[] meshes;
259

  
260
    float D = 0.01f;
261
    float E = 0.5f - D*SQ2;
262
    float F = 0.5f - D*SQ2*SQ3;
263
    float[] bands;
264
    int extraI, extraV;
265

  
266
    float[] vertices = { -F,-E, +F,-E, 0.0f,E-D*SQ2};
267

  
268
    switch(size)
269
      {
270
      case 3 : bands = new float[] { 1.0f    ,-D,
271
                                     1.0f-D/2,-D*0.55f,
272
                                     1.0f-D  ,-D*0.25f,
273
                                     1.0f-2*D,+D*0.25f,
274
                                     0.50f, 0.050f,
275
                                     0.0f, 0.055f };
276
                      extraI = 2;
277
                      extraV = 2;
278
                      break;
279
      case 4 : bands = new float[] { 1.0f    ,-D,
280
                                     1.0f-D*1.2f,-D*0.55f,
281
                                     1.0f-2*D, +D*0.25f,
282
                                     0.50f, 0.050f,
283
                                     0.0f, 0.055f };
284
                      extraI = 2;
285
                      extraV = 2;
286
                      break;
287
      default: bands = new float[] { 1.0f    ,-D,
288
                                     1.0f-D*1.2f,-D*0.55f,
289
                                     1.0f-2*D, +D*0.25f,
290
                                     0.50f, 0.050f,
291
                                     0.0f, 0.055f };
292
                      extraI = 2;
293
                      extraV = 1;
294
                      break;
295
      }
258 296

  
259
    meshes[0] = new MeshTriangle(9);
297
    meshes = new MeshPolygon[MESHES];
298
    meshes[0] = new MeshPolygon(vertices, bands, extraI,extraV);
260 299
    meshes[0].setEffectAssociation(0,association,0);
261 300

  
262 301
    for(int i=1; i<MESHES; i++)
......
298 337
    Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
299 338
    Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
300 339

  
301
    Static3D center = new Static3D(0,0,0);
302
    Static4D region = new Static4D(0,0,0,0.6f);
303

  
304 340
    VertexEffectScale   effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
305 341
    VertexEffectRotate  effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
306 342
    VertexEffectMove    effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
......
314 350
    VertexEffectDeform  effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
315 351
    VertexEffectDeform  effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
316 352

  
317
    VertexEffectSink    effect12= new VertexEffectSink( new Static1D(1.3f), center, region );
318

  
319 353
    effect4.setMeshAssociation(14,-1);  // apply to mesh[1], [2] and [3]
320 354
    effect5.setMeshAssociation( 2,-1);  // apply only to mesh[1]
321 355
    effect6.setMeshAssociation( 4,-1);  // apply only to mesh[2]
......
332 366
    result.apply(effect9);
333 367
    result.apply(effect10);
334 368
    result.apply(effect11);
335
    result.apply(effect12);
336 369

  
337 370
    if( mRotArray[cubit]>=0 )
338 371
      {

Also available in: Unified diff