Project

General

Profile

« Previous | Next » 

Revision b32444ee

Added by Leszek Koltunski about 4 years ago

More work on making new types of RubikObjects easily creatable.

View differences:

src/main/java/org/distorted/object/RubikObject.java
29 29
import org.distorted.library.main.DistortedEffects;
30 30
import org.distorted.library.main.DistortedNode;
31 31
import org.distorted.library.main.DistortedTexture;
32
import org.distorted.library.mesh.MeshCubes;
32
import org.distorted.library.mesh.MeshBase;
33 33
import org.distorted.library.mesh.MeshRectangles;
34 34
import org.distorted.library.message.EffectListener;
35 35
import org.distorted.library.type.Dynamic1D;
......
47 47

  
48 48
  private static final int POST_ROTATION_MILLISEC = 500;
49 49
  private final int NUM_CUBITS;
50
  private final int[][] CUBIT_POSITIONS;
51 50
  private int mRotRow;
52 51
  private Static3D mRotAxis;
53 52
  private Static3D mMove, mScale, mNodeMove, mNodeScale;
54 53
  private Static4D mQuatAccumulated;
55 54
  private DistortedTexture mNodeTexture;
55
  private Cubit[] mCubits;
56 56

  
57 57
  int mSize;
58 58

  
......
65 65
  MatrixEffectQuaternion mQuatCEffect;
66 66
  MatrixEffectQuaternion mQuatAEffect;
67 67

  
68
  private Cubit[] mCubits;
69

  
70 68
///////////////////////////////////////////////////////////////////////////////////////////////////
71 69

  
72 70
  RubikObject(int size, Static4D quatCur, Static4D quatAcc, DistortedTexture texture, MeshRectangles mesh, DistortedEffects effects)
......
75 73

  
76 74
    LEGAL_QUATS = getLegalQuats();
77 75
    NUM_CUBITS  = getNumCubits(size);
78
    CUBIT_POSITIONS = getCubitPositions(size);
79 76

  
80 77
    mNodeTexture = texture;
81 78
    mSize = size;
......
107 104
    effects.apply(nodeScaleEffect);
108 105
    effects.apply(nodeMoveEffect);
109 106

  
110

  
111 107
    mCubits = new Cubit[NUM_CUBITS];
112

  
113 108
    mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
114 109

  
115 110
    int vertices = (int)(24.0f/mSize + 2.0f);
111
    int[][] positions = getCubitPositions(size);
116 112

  
117 113
    for(int i=0; i<NUM_CUBITS; i++)
118 114
      {
119
      int x = CUBIT_POSITIONS[i][0];
120
      int y = CUBIT_POSITIONS[i][1];
121
      int z = CUBIT_POSITIONS[i][2];
115
      int x = positions[i][0];
116
      int y = positions[i][1];
117
      int z = positions[i][2];
122 118

  
123
      mCubits[i] = new Cubit( this ,createMesh(vertices,x,y,z), new Static3D(x,y,z) );
119
      mCubits[i] = new Cubit( this ,createCubitMesh(vertices,x,y,z), new Static3D(x,y,z) );
124 120
      attach(mCubits[i].mNode);
125 121
      }
126 122
    }
......
359 355
  abstract int[][] getCubitPositions(int size);
360 356
  abstract float[] getLegalQuats();
361 357
  abstract boolean belongsToRotation(Static3D position, Static3D axis, int row);
362
  abstract MeshCubes createMesh(int vertices,int x, int y, int z);
358
  abstract MeshBase createCubitMesh(int vertices, int x, int y, int z);
363 359

  
364 360
  public abstract void createTexture();
365 361
  }

Also available in: Unified diff