Project

General

Profile

« Previous | Next » 

Revision 728cff8b

Added by Leszek Koltunski about 3 years ago

Convert the Helicopter face cubits to the new engine.

View differences:

src/main/java/org/distorted/helpers/FactoryCubit.java
722 722

  
723 723
///////////////////////////////////////////////////////////////////////////////////////////////////
724 724
// EFFECTS
725
///////////////////////////////////////////////////////////////////////////////////////////////////
726

  
727
  VertexEffect[] createVertexEffectsHelicopterFace()
728
    {
729
    float E = 0.5f;
730
    float F = SQ2/4;
731

  
732
    Static3D move0  = new Static3D(-E/4, -E/4, 0);
733
    Static3D move1  = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0);
734
    Static3D move2  = new Static3D(-E/2, F/3, 0);
735
    Static3D move3  = new Static3D(+E/2, F/3, 0);
736
    Static3D move4  = new Static3D(+E/3,+E/3, 0);
737
    Static1D angle1 = new Static1D(135);
738
    Static1D angle2 = new Static1D(90);
739
    Static1D angle3 = new Static1D(-90);
740
    Static1D angle4 = new Static1D(-135);
741
    Static3D axisX  = new Static3D(1,0,0);
742
    Static3D axisY  = new Static3D(0,1,0);
743
    Static3D axisZ  = new Static3D(0,0,1);
744
    Static3D axis1  = new Static3D(1,-1,0);
745
    Static3D center = new Static3D(0,0,0);
746
    Static3D center1= new Static3D(-E/2,-E/2,0);
747

  
748
    VertexEffect[] effect = new VertexEffect[10];
749

  
750
    effect[0] = new VertexEffectMove(move0);
751
    effect[1] = new VertexEffectRotate(angle1, axisZ, center);
752
    effect[2] = new VertexEffectMove(move1);
753
    effect[3] = new VertexEffectRotate(angle2, axis1, center1);
754
    effect[4] = new VertexEffectMove(move2);
755
    effect[5] = new VertexEffectMove(move3);
756
    effect[6] = new VertexEffectRotate(angle3, axisZ, center);
757
    effect[7] = new VertexEffectRotate(angle4, axisX, center);
758
    effect[8] = new VertexEffectRotate(angle1, axisY, center);
759
    effect[9] = new VertexEffectMove(move4);
760

  
761
    effect[0].setMeshAssociation( 1,-1);  // mesh 0
762
    effect[1].setMeshAssociation( 2,-1);  // mesh 1
763
    effect[2].setMeshAssociation( 2,-1);  // mesh 1
764
    effect[3].setMeshAssociation( 2,-1);  // mesh 1
765
    effect[4].setMeshAssociation( 4,-1);  // mesh 2
766
    effect[5].setMeshAssociation( 8,-1);  // mesh 3
767
    effect[6].setMeshAssociation( 8,-1);  // mesh 3
768
    effect[7].setMeshAssociation( 4,-1);  // mesh 2
769
    effect[8].setMeshAssociation( 8,-1);  // mesh 3
770
    effect[9].setMeshAssociation(15,-1);  // meshes 0,1,2,3
771

  
772
    return effect;
773
    }
774

  
775 725
///////////////////////////////////////////////////////////////////////////////////////////////////
776 726

  
777 727
  VertexEffect[] createVertexEffectsRediEdge()
......
1250 1200
// OBJECTS
1251 1201
///////////////////////////////////////////////////////////////////////////////////////////////////
1252 1202

  
1253
  public MeshBase createHelicopterFaceMesh()
1254
    {
1255
    MeshBase mesh = createFacesHelicopterFace();
1256
    VertexEffect[] effects = createVertexEffectsHelicopterFace();
1257
    for( VertexEffect effect : effects ) mesh.apply(effect);
1258

  
1259
    float E = 0.5f;
1260
    Static3D roundingCenter = new Static3D(-E/2 + E/3,-E/2 + E/3,-E/2);
1261

  
1262
    Static3D[] verticesType1 = new Static3D[1];
1263
    verticesType1[0] = new Static3D(E/3,E/3,0.0f);
1264
    roundCorners(mesh,roundingCenter,verticesType1,0.06f,0.15f);
1265

  
1266
    Static3D[] verticesType2 = new Static3D[2];
1267
    verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
1268
    verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
1269
    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
1270

  
1271
    mesh.mergeEffComponents();
1272
    mesh.addEmptyTexComponent();
1273
    mesh.addEmptyTexComponent();
1274

  
1275
    return mesh;
1276
    }
1277

  
1278
///////////////////////////////////////////////////////////////////////////////////////////////////
1279
// Redi cube
1280

  
1281 1203
  public MeshBase createRediEdgeMesh()
1282 1204
    {
1283 1205
    MeshBase mesh = createFacesRediEdge();
src/main/java/org/distorted/objects/TwistyHelicopter.java
208 208
  private static final double[][] VERTICES_FACE = new double[][]
209 209
          {
210 210
            { 0.00f +E, 0.00f +E, 0.00f },
211
            { 0.50f +E, 0.00f +E, 0.00f },
212
            { 0.00f +E, 0.50f +E, 0.00f },
213
            { 0.25f +E, 0.25f +E,-0.25f },
211
            {-0.50f +E, 0.00f +E, 0.00f },
212
            { 0.00f +E,-0.50f +E, 0.00f },
213
            {-0.25f +E,-0.25f +E,-0.25f },
214 214
          };
215 215

  
216 216
  private static final int[][] VERT_INDEXES_FACE = new int[][]
......
234 234
                   MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
235 235
    {
236 236
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.HELI, res, scrWidth);
237

  
238
    createFaceDataStructures();
237 239
    }
238 240

  
239 241
///////////////////////////////////////////////////////////////////////////////////////////////////
......
362 364
      }
363 365
    else
364 366
      {
365
      if( mMeshes[1]==null ) mMeshes[1] = FactoryCubit.getInstance().createHelicopterFaceMesh();
366
        /*
367
      if( mMeshes[1]==null )
367 368
        {
368 369
        float[][] bands= new float[][]
369 370
          {
......
384 385
                                                centers, centerIndexes,
385 386
                                                getNumCubitFaces() );
386 387
        }
387

  
388
         */
389 388
      mesh = mMeshes[1].copy(true);
390 389
      }
391 390

  
......
407 406

  
408 407
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
409 408
    {
410
    float R = 0.023f;
411
    float S = 0.035f;
412
    float E = 0.5f;
413
    float[] vertices = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
409
    float R = 0.03f;
410
    float S = 0.05f;
414 411

  
415 412
    FactorySticker factory = FactorySticker.getInstance();
416
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, S, FACE_COLORS[face], R);
413
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], S, FACE_COLORS[face], R);
417 414
    }
418 415

  
419 416
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff