Project

General

Profile

« Previous | Next » 

Revision 962437b5

Added by Leszek Koltunski about 4 years ago

Add the Redi Cube: part2.

View differences:

src/main/java/org/distorted/objects/CubitFactory.java
1147 1147
                       0.90f   , D,
1148 1148
                       0.0f    , D };
1149 1149

  
1150
    float[] vertices2 = { -0.5f*SQ2, SQ6/8, -0.75f*SQ2, -SQ6/8, +0.75f*SQ2, -SQ6/8, +0.5f*SQ2, SQ6/8 };
1150
    float X = 0.25f*SQ2;
1151
    float Y = SQ6/16;
1152

  
1153
    float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
1151 1154

  
1152 1155
    meshes[4] = new MeshPolygon(vertices2, bands2, 1, 1);
1153 1156
    meshes[4].setEffectAssociation(0,16,0);
......
1185 1188
    VertexEffect effect10= new VertexEffectRotate(angle3,axis ,cent1);
1186 1189
    VertexEffect effect11= new VertexEffectScale(flipX);
1187 1190

  
1188
    effect0.setMeshAssociation(15,-1);  // meshes 0,1,2,3
1191
    effect0.setMeshAssociation(63,-1);  // meshes 0,1,2,3,4,5
1189 1192
    effect1.setMeshAssociation( 3,-1);  // meshes 0,1
1190 1193
    effect2.setMeshAssociation( 2,-1);  // mesh 1
1191 1194
    effect3.setMeshAssociation( 2,-1);  // mesh 1
......
1215 1218

  
1216 1219
    mesh.mergeEffComponents();
1217 1220

  
1221
    return mesh;
1222
    }
1223

  
1224
///////////////////////////////////////////////////////////////////////////////////////////////////
1225

  
1226
  MeshBase createRediCornerMesh()
1227
    {
1228
    final int MESHES=6;
1229

  
1230
    float D = 0.027f;
1231
    float E = 0.5f;
1232
    float[] vertices1 = { -E,-E, +E,-E, +E,+E, -E,+E };
1233

  
1234
    float[] bands1 = new float[] { 1.0f    ,-D,
1235
                                  1.0f-D/2,-D*0.55f,
1236
                                  1.0f-D  ,-D*0.25f,
1237
                                  1.0f-2*D, 0.0f,
1238
                                  0.50f   , 0.040f,
1239
                                  0.0f    , 0.048f };
1240

  
1241
    MeshBase[] meshes = new MeshBase[MESHES];
1242
    meshes[0] = new MeshPolygon(vertices1,bands1,2,2);
1243
    meshes[0].setEffectAssociation(0,1,0);
1244
    meshes[1] = meshes[0].copy(true);
1245
    meshes[1].setEffectAssociation(0,2,0);
1246
    meshes[2] = meshes[0].copy(true);
1247
    meshes[2].setEffectAssociation(0,4,0);
1248

  
1249
    float F = SQ2/2;
1250
    float X = 0.5f;
1251

  
1252
    float[] vertices2 = { -E,+F, -E+X,0, -E,-F, +E,-F, +E-X,0, +E,+F };
1253

  
1254
    float[] bands2 = new float[] { 1.0f,0.0f,
1255
                                   0.0f,0.0f };
1256

  
1257
    meshes[3] = new MeshPolygon(vertices2,bands2,0,0);
1258
    meshes[3].setEffectAssociation(0,8,0);
1259
    meshes[4] = meshes[3].copy(true);
1260
    meshes[4].setEffectAssociation(0,16,0);
1261
    meshes[5] = meshes[3].copy(true);
1262
    meshes[5].setEffectAssociation(0,32,0);
1263

  
1264
    MeshBase mesh = new MeshJoined(meshes);
1265

  
1266
    Static3D axisY   = new Static3D(0,1,0);
1267
    Static3D axisX   = new Static3D(1,0,0);
1268
    Static3D axisZ   = new Static3D(0,0,1);
1269
    Static3D center  = new Static3D(0,0,0);
1270
    Static1D angle90 = new Static1D(90);
1271
    Static1D angle270= new Static1D(270);
1272
    Static1D angle45 = new Static1D(-45);
1273

  
1274
    float d1 = 1.0f;
1275
    float d2 =-0.05f;
1276
    float d3 = 0.12f;
1277

  
1278
    Static3D dCen0 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(+0.5f) );
1279
    Static3D dCen1 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(-0.5f) );
1280
    Static3D dCen2 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(+0.5f) );
1281
    Static3D dCen3 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(-0.5f) );
1282
    Static3D dCen4 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(+0.5f) );
1283
    Static3D dCen5 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(-0.5f) );
1284
    Static3D dCen6 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(+0.5f) );
1285
    Static3D dCen7 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(-0.5f) );
1286

  
1287
    Static3D dVec0 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(+0.5f) );
1288
    Static3D dVec1 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(-0.5f) );
1289
    Static3D dVec2 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(+0.5f) );
1290
    Static3D dVec3 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(-0.5f) );
1291
    Static3D dVec4 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(+0.5f) );
1292
    Static3D dVec5 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(-0.5f) );
1293
    Static3D dVec6 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(+0.5f) );
1294
    Static3D dVec7 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(-0.5f) );
1295

  
1296
    Static4D dReg  = new Static4D(0,0,0,d3);
1297
    Static1D dRad  = new Static1D(1);
1298

  
1299
    VertexEffect effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
1300
    VertexEffect effect1 = new VertexEffectRotate( angle270, axisX, center );
1301
    VertexEffect effect2 = new VertexEffectRotate( angle90 , axisY, center );
1302
    VertexEffect effect3 = new VertexEffectRotate( angle45 , axisX, center );
1303
    VertexEffect effect4 = new VertexEffectRotate( angle90 , axisY, center );
1304
    VertexEffect effect5 = new VertexEffectRotate( angle270, axisZ, center );
1305

  
1306
    VertexEffect effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
1307
    VertexEffect effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
1308
    VertexEffect effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
1309
    VertexEffect effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
1310
    VertexEffect effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
1311
    VertexEffect effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
1312
    VertexEffect effect12= new VertexEffectDeform(dVec6, dRad, dCen6, dReg);
1313
    VertexEffect effect13= new VertexEffectDeform(dVec7, dRad, dCen7, dReg);
1314

  
1315
    effect0.setMeshAssociation( 7,-1);  // 0,1,2
1316
    effect1.setMeshAssociation( 2,-1);  // 1
1317
    effect2.setMeshAssociation( 4,-1);  // 2
1318
    effect3.setMeshAssociation(56,-1);  // 3
1319
    effect4.setMeshAssociation(16,-1);  // 4
1320
    effect5.setMeshAssociation(32,-1);  // 5
1321

  
1322
    mesh.apply(effect0);
1323
    mesh.apply(effect1);
1324
    mesh.apply(effect2);
1325
    mesh.apply(effect3);
1326
    mesh.apply(effect4);
1327
    mesh.apply(effect5);
1328

  
1329
    mesh.apply(effect6);
1330
    mesh.apply(effect7);
1331
    mesh.apply(effect8);
1332
    mesh.apply(effect9);
1333
    mesh.apply(effect10);
1334
    mesh.apply(effect11);
1335
    mesh.apply(effect12);
1336
    mesh.apply(effect13);
1337

  
1338
    mesh.mergeEffComponents();
1339

  
1218 1340
    return mesh;
1219 1341
    }
1220 1342
  }
src/main/java/org/distorted/objects/TwistyRedi.java
113 113
  // YELLOW 6 WHITE 7 BLUE 8 GREEN 9 RED 10 BROWN 11
114 114
  private static final int[][] mFaceMap = new int[][]
115 115
         {
116
           {  0,12, 2,12, 4,12 },
117
           {  0,12, 5,12, 2,12 },
118
           {  0,12, 4,12, 3,12 },
119
           {  0,12, 3,12, 5,12 },
120
           {  4,12, 2,12, 1,12 },
121
           {  1,12, 2,12, 5,12 },
122
           {  1,12, 3,12, 4,12 },
123
           {  5,12, 3,12, 1,12 },
116
           {  4, 2, 0,12,12,12 },
117
           {  2, 5, 0,12,12,12 },
118
           {  3, 4, 0,12,12,12 },
119
           {  5, 3, 0,12,12,12 },
120
           {  1, 2, 4,12,12,12 },
121
           {  5, 2, 1,12,12,12 },
122
           {  4, 3, 1,12,12,12 },
123
           {  1, 3, 5,12,12,12 },
124 124

  
125 125
           { 10, 8,12,12,12,12 },
126 126
           {  6,10,12,12,12,12 },
......
242 242

  
243 243
    if( cubit<8 )
244 244
      {
245
      if( mCornerMesh==null ) mCornerMesh = CubitFactory.getInstance().createCubeMesh(0);
245
      if( mCornerMesh==null ) mCornerMesh = CubitFactory.getInstance().createRediCornerMesh();
246 246
      mesh = mCornerMesh.copy(true);
247 247
      }
248 248
    else

Also available in: Unified diff