Project

General

Profile

« Previous | Next » 

Revision 680469e6

Added by Leszek Koltunski about 3 years ago

Convert the Redi Cube to the new engine.

View differences:

src/main/java/org/distorted/helpers/FactoryCubit.java
43 43
  private static final float SQ2 = (float)Math.sqrt(2);
44 44
  private static final float SQ3 = (float)Math.sqrt(3);
45 45
  private static final float SQ5 = (float)Math.sqrt(5);
46
  private static final float SQ6 = (float)Math.sqrt(6);
47 46

  
48 47
  private static final Static1D RADIUS = new Static1D(1);
49 48
  private static FactoryCubit mThis;
......
238 237
      }
239 238
    }
240 239

  
241
///////////////////////////////////////////////////////////////////////////////////////////////////
242

  
243
  MeshBase createFacesHelicopterFace()
244
    {
245
    MeshBase[] meshes = new MeshBase[4];
246

  
247
    float E = 0.5f;
248
    float F = SQ2/4;
249
    float G = 1.0f/12;
250
    float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
251
    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
252

  
253
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
254
    meshes[0].setEffectAssociation(0,1,0);
255

  
256
    float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
257
    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
258

  
259
    meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
260
    meshes[1].setEffectAssociation(0,2,0);
261

  
262
    float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
263

  
264
    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
265
    meshes[2].setEffectAssociation(0,4,0);
266
    meshes[3] = meshes[2].copy(true);
267
    meshes[3].setEffectAssociation(0,8,0);
268

  
269
    return new MeshJoined(meshes);
270
    }
271

  
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

  
274
  MeshBase createFacesRediEdge()
275
    {
276
    MeshBase[] meshes = new MeshPolygon[6];
277

  
278
    float F = 0.25f;
279
    float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
280
    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
281

  
282
    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
283
    meshes[0].setEffectAssociation(0,1,0);
284
    meshes[1] = meshes[0].copy(true);
285
    meshes[1].setEffectAssociation(0,2,0);
286

  
287
    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
288
    float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
289

  
290
    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
291
    meshes[2].setEffectAssociation(0,4,0);
292
    meshes[3] = meshes[2].copy(true);
293
    meshes[3].setEffectAssociation(0,8,0);
294

  
295
    float X = 0.25f*SQ2;
296
    float Y = SQ6/16;
297
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
298

  
299
    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
300
    meshes[4].setEffectAssociation(0,16,0);
301
    meshes[5] = meshes[4].copy(true);
302
    meshes[5].setEffectAssociation(0,32,0);
303

  
304
    return new MeshJoined(meshes);
305
    }
306

  
307
///////////////////////////////////////////////////////////////////////////////////////////////////
308

  
309
  MeshBase createFacesRediCorner()
310
    {
311
    MeshBase[] meshes = new MeshBase[6];
312

  
313
    float E = 0.5f;
314
    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
315
    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
316

  
317
    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
318
    meshes[0].setEffectAssociation(0,1,0);
319
    meshes[1] = meshes[0].copy(true);
320
    meshes[1].setEffectAssociation(0,2,0);
321
    meshes[2] = meshes[0].copy(true);
322
    meshes[2].setEffectAssociation(0,4,0);
323

  
324
    float F = 0.5f;
325
    float X = 0.5f;
326
    float G = 0.72f;
327
    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
328
    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
329

  
330
    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
331
    meshes[3].setEffectAssociation(0,8,0);
332
    meshes[4] = meshes[3].copy(true);
333
    meshes[4].setEffectAssociation(0,16,0);
334
    meshes[5] = meshes[3].copy(true);
335
    meshes[5].setEffectAssociation(0,32,0);
336

  
337
    return new MeshJoined(meshes);
338
    }
339

  
340 240
///////////////////////////////////////////////////////////////////////////////////////////////////
341 241

  
342 242
  MeshBase createFacesIvyCorner()
......
722 622

  
723 623
///////////////////////////////////////////////////////////////////////////////////////////////////
724 624
// EFFECTS
725
///////////////////////////////////////////////////////////////////////////////////////////////////
726

  
727
  VertexEffect[] createVertexEffectsRediEdge()
728
    {
729
    Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
730
    Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
731
    Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
732
    Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
733
    Static3D flipZ = new Static3D(1,1,-1);
734
    Static3D flipX = new Static3D(-1,1,1);
735
    Static3D scale = new Static3D(2,2,2);
736
    Static3D cent0 = new Static3D(0,0, 0);
737
    Static3D cent1 = new Static3D(0,0, -1.5f);
738
    Static3D axisX = new Static3D(1,0, 0);
739
    Static3D axisY = new Static3D(0,1, 0);
740
    Static3D axis  = new Static3D(0,SQ2/2,-SQ2/2);
741
    Static1D angle1= new Static1D(90);
742
    Static1D angle2= new Static1D(45);
743
    Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
744

  
745
    VertexEffect[] effect = new VertexEffect[12];
746

  
747
    effect[0] = new VertexEffectScale(scale);
748
    effect[1] = new VertexEffectMove(move0);
749
    effect[2] = new VertexEffectScale(flipZ);
750
    effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
751
    effect[4] = new VertexEffectMove(move1);
752
    effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
753
    effect[6] = new VertexEffectMove(move2);
754
    effect[7] = new VertexEffectScale(flipX);
755
    effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
756
    effect[9] = new VertexEffectMove(move3);
757
    effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
758
    effect[11]= new VertexEffectScale(flipX);
759

  
760
    effect[0].setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
761
    effect[1].setMeshAssociation( 3,-1);  // meshes 0,1
762
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
763
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
764
    effect[4].setMeshAssociation(12,-1);  // meshes 2,3
765
    effect[5].setMeshAssociation(60,-1);  // meshes 2,3,4,5
766
    effect[6].setMeshAssociation(12,-1);  // meshes 2,3
767
    effect[7].setMeshAssociation( 8,-1);  // mesh 3
768
    effect[8].setMeshAssociation(48,-1);  // meshes 4,5
769
    effect[9].setMeshAssociation(48,-1);  // meshes 4,5
770
    effect[10].setMeshAssociation(48,-1); // meshes 4,5
771
    effect[11].setMeshAssociation(32,-1); // mesh 5
772

  
773
    return effect;
774
    }
775

  
776
///////////////////////////////////////////////////////////////////////////////////////////////////
777

  
778
  VertexEffect[] createVertexEffectsRediCorner()
779
    {
780
    Static3D axisY   = new Static3D(0,1,0);
781
    Static3D axisX   = new Static3D(1,0,0);
782
    Static3D axisZ   = new Static3D(0,0,1);
783
    Static3D center  = new Static3D(0,0,0);
784
    Static1D angle90 = new Static1D(90);
785
    Static1D angle270= new Static1D(270);
786
    Static1D angle45 = new Static1D(-45);
787
    Static3D scale   = new Static3D(1.0f, SQ2, 1.0f);
788

  
789
    VertexEffect[] effect = new VertexEffect[7];
790

  
791
    effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
792
    effect[1] = new VertexEffectRotate( angle270, axisX, center );
793
    effect[2] = new VertexEffectRotate( angle90 , axisY, center );
794
    effect[3] = new VertexEffectScale(scale);
795
    effect[4] = new VertexEffectRotate( angle45 , axisX, center );
796
    effect[5] = new VertexEffectRotate( angle90 , axisY, center );
797
    effect[6] = new VertexEffectRotate( angle270, axisZ, center );
798

  
799
    effect[0].setMeshAssociation( 7,-1);  // 0,1,2
800
    effect[1].setMeshAssociation( 2,-1);  // 1
801
    effect[2].setMeshAssociation( 4,-1);  // 2
802
    effect[3].setMeshAssociation(56,-1);  // 3,4,5
803
    effect[4].setMeshAssociation(56,-1);  // 3,4,5
804
    effect[5].setMeshAssociation(16,-1);  // 4
805
    effect[6].setMeshAssociation(32,-1);  // 5
806

  
807
    return effect;
808
    }
809

  
810 625
///////////////////////////////////////////////////////////////////////////////////////////////////
811 626

  
812 627
  VertexEffect[] createVertexEffectsIvyCorner()
......
1198 1013

  
1199 1014
///////////////////////////////////////////////////////////////////////////////////////////////////
1200 1015
// OBJECTS
1201
///////////////////////////////////////////////////////////////////////////////////////////////////
1202

  
1203
  public MeshBase createRediEdgeMesh()
1204
    {
1205
    MeshBase mesh = createFacesRediEdge();
1206
    VertexEffect[] effects = createVertexEffectsRediEdge();
1207
    for( VertexEffect effect : effects ) mesh.apply(effect);
1208

  
1209
    Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
1210
    Static3D[] vertices = new Static3D[2];
1211
    vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
1212
    vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
1213
    roundCorners(mesh,center,vertices,0.06f,0.20f);
1214

  
1215
    mesh.mergeEffComponents();
1216

  
1217
    return mesh;
1218
    }
1219

  
1220
///////////////////////////////////////////////////////////////////////////////////////////////////
1221

  
1222
  public MeshBase createRediCornerMesh()
1223
    {
1224
    MeshBase mesh = createFacesRediCorner();
1225
    VertexEffect[] effects = createVertexEffectsRediCorner();
1226
    for( VertexEffect effect : effects ) mesh.apply(effect);
1227

  
1228
    Static3D center = new Static3D(0,0,0);
1229
    Static3D[] vertices = new Static3D[8];
1230
    vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
1231
    vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
1232
    vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
1233
    vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
1234
    vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
1235
    vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
1236
    vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
1237
    vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
1238

  
1239
    roundCorners(mesh,center,vertices,0.06f,0.12f);
1240

  
1241
    mesh.mergeEffComponents();
1242

  
1243
    return mesh;
1244
    }
1245

  
1246 1016
///////////////////////////////////////////////////////////////////////////////////////////////////
1247 1017

  
1248 1018
  public MeshBase createIvyCornerMesh()

Also available in: Unified diff