Project

General

Profile

« Previous | Next » 

Revision a97e02b7

Added by Leszek Koltunski about 4 years ago

Objects must explicitly provide a list of offsets specifying where the cut planes are (rather than just a BASIC_STEP - the width of the layer - which is insufficient in case of objects which have layers of vastly different width, like the Master Skewb)

View differences:

src/main/java/org/distorted/objects/CubitFactory.java
242 242
    meshes[2] = meshes[0].copy(true);
243 243
    meshes[2].setEffectAssociation(0,4,0);
244 244

  
245
    float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F };
245
    float[] vertices1 = { 0,0, F,0, 7*F/8,(SQ3/8)*F, 5*F/8,(3*SQ3/8)*F, F/2,(SQ3/2)*F };
246 246
    float[] bands1 = computeBands(0,0,1,0,3);
247 247

  
248 248
    meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
......
268 268
    meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
269 269
    meshes[0].setEffectAssociation(0,1,0);
270 270

  
271
    float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
271
    float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 };
272 272
    float[] bands1 = computeBands(0,0,1,0,3);
273 273

  
274 274
    meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
src/main/java/org/distorted/objects/MovementSkewb.java
46 46

  
47 47
  int computeRowFromOffset(int face, int size, float offset)
48 48
    {
49
    return offset<DIST2D ? 0:1;
49
    return offset<DIST2D ? 0:size-1;
50 50
    }
51 51

  
52 52
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyCube.java
177 177

  
178 178
///////////////////////////////////////////////////////////////////////////////////////////////////
179 179

  
180
  float getBasicStep()
180
  float[] getCuts(int size)
181 181
    {
182
    return 1.0f;
182
    float[] cuts = new float[size-1];
183

  
184
    for(int i=0; i<size-1; i++)
185
      {
186
      cuts[i] = (2-size)*0.5f + i;
187
      }
188

  
189
    return cuts;
183 190
    }
184 191

  
185 192
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDiamond.java
166 166

  
167 167
///////////////////////////////////////////////////////////////////////////////////////////////////
168 168

  
169
  float getBasicStep()
169
  float[] getCuts(int size)
170 170
    {
171
    return SQ6/4;
171
    float[] cuts = new float[1];
172
    cuts[0] = 0.0f;
173
    return cuts;
172 174
    }
173 175

  
174 176
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino.java
163 163

  
164 164
///////////////////////////////////////////////////////////////////////////////////////////////////
165 165

  
166
  float getBasicStep()
166
  float[] getCuts(int size)
167 167
    {
168
    return SQ3;
168
    float[] cuts = new float[2];
169

  
170
    cuts[0] = -SQ3/3;
171
    cuts[1] = +SQ3/3;
172

  
173
    return cuts;
169 174
    }
170 175

  
171 176
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyHelicopter.java
231 231

  
232 232
///////////////////////////////////////////////////////////////////////////////////////////////////
233 233

  
234
  float getBasicStep()
234
  float[] getCuts(int size)
235 235
    {
236
    return SQ2/2;
236
    float[] cuts = new float[2];
237

  
238
    cuts[0] = -SQ2/4;
239
    cuts[1] = +SQ2/4;
240

  
241
    return cuts;
237 242
    }
238 243

  
239 244
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyObject.java
87 87
  final int NUM_CUBIT_FACES;
88 88
  final int NUM_AXIS;
89 89
  final int NUM_CUBITS;
90
  final float BASIC_STEP;
90
  final float[] CUTS;
91
  final int NUM_CUTS;
91 92

  
92 93
  private static float mInitScreenRatio;
93 94
  private static float mObjectScreenRatio = 1.0f;
......
106 107
  private Dynamic1D mRotationAngle;
107 108
  private Static3D mRotationAxis;
108 109
  private Static3D mObjectScale;
109
  private float mStart, mStep;
110 110

  
111 111
  float[] mRowChances;
112 112
  Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
......
137 137
    NUM_FACES = getNumFaces();
138 138
    NUM_CUBIT_FACES = getNumCubitFaces();
139 139
    NUM_TEXTURES = getNumStickerTypes()*NUM_FACES;
140
    BASIC_STEP = getBasicStep();
140
    CUTS = getCuts(mSize);
141
    NUM_CUTS = CUTS.length;
141 142

  
142 143
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
143 144
    if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
144 145

  
145
    computeStartAndStep(mOrigPos);
146 146
    mNodeScale= new Static3D(1,NODE_RATIO,1);
147 147
    mQuat = quat;
148 148

  
......
261 261
    }
262 262

  
263 263
///////////////////////////////////////////////////////////////////////////////////////////////////
264
// Cast centers of all Cubits on the first rotation Axis and compute the leftmost and rightmost
265
// one. From there compute the 'start' (i.e. the leftmost) and 'step' (i.e. distance between two
266
// consecutive).
267
// it is assumed that other rotation axis have the same 'start' and 'step' - this is the case with
268
// the Cube and the Pyraminx.
269
// Start and Step are then needed to compute which rotation row (with respect to a given axis) a
270
// given Cubit belongs to.
271 264

  
272
  private void computeStartAndStep(Static3D[] pos)
265
  int computeRow(float x, float y, float z, int rotIndex)
273 266
    {
274
    float min = Float.MAX_VALUE;
275
    float max = Float.MIN_VALUE;
276
    float axisX = ROTATION_AXIS[0].get0();
277
    float axisY = ROTATION_AXIS[0].get1();
278
    float axisZ = ROTATION_AXIS[0].get2();
279
    float tmp;
267
    Static3D axis = ROTATION_AXIS[rotIndex];
268
    float tmp = x*axis.get0() + y*axis.get1() + z*axis.get2();
280 269

  
281
    for(int i=0; i<NUM_CUBITS; i++)
270
    for(int i=0; i<NUM_CUTS; i++)
282 271
      {
283
      tmp = pos[i].get0()*axisX + pos[i].get1()*axisY + pos[i].get2()*axisZ;
284
      if( tmp<min ) min=tmp;
285
      if( tmp>max ) max=tmp;
272
      if( tmp<CUTS[i] ) return i;
286 273
      }
287 274

  
288
    mStart = min;
289
    mStep  = (max-min+BASIC_STEP)/mSize;
275
    return NUM_CUTS;
290 276
    }
291 277

  
292 278
///////////////////////////////////////////////////////////////////////////////////////////////////
......
297 283
    return ((1<<cubitRow)&rowBitmap)!=0;
298 284
    }
299 285

  
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

  
302
  int computeRow(float x, float y, float z, int rotIndex)
303
    {
304
    Static3D axis = ROTATION_AXIS[rotIndex];
305
    float tmp = x*axis.get0() + y*axis.get1() + z*axis.get2();
306

  
307
    return (int)((tmp-mStart)/mStep +0.5f);
308
    }
309

  
310 286
///////////////////////////////////////////////////////////////////////////////////////////////////
311 287
// note the minus in front of the sin() - we rotate counterclockwise
312 288
// when looking towards the direction where the axis increases in values.
......
826 802
  abstract int getFaceColor(int cubit, int cubitface, int size);
827 803
  abstract float returnMultiplier();
828 804
  abstract float[] getRowChances();
829
  abstract float getBasicStep();
805
  abstract float[] getCuts(int size);
830 806
  abstract boolean shouldResetTextureMaps();
831 807

  
832 808
  public abstract boolean isSolved();
src/main/java/org/distorted/objects/TwistyPyraminx.java
155 155

  
156 156
///////////////////////////////////////////////////////////////////////////////////////////////////
157 157

  
158
  float getBasicStep()
158
  float[] getCuts(int size)
159 159
    {
160
    return SQ6/3;
160
    float[] cuts = new float[size-1];
161

  
162
    for(int i=0; i<size-1; i++)
163
      {
164
      cuts[i] = (1.0f-0.25f*size+i)*(SQ6/3);
165
      }
166

  
167
    return cuts;
161 168
    }
162 169

  
163 170
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRedi.java
180 180

  
181 181
///////////////////////////////////////////////////////////////////////////////////////////////////
182 182

  
183
  float getBasicStep()
183
  float[] getCuts(int size)
184 184
    {
185
    return SQ3;
185
    float[] cuts = new float[2];
186

  
187
    cuts[0] = -SQ3/3 -0.05f;
188
    cuts[1] = +SQ3/3 +0.05f;
189

  
190
    return cuts;
186 191
    }
187 192

  
188 193
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySkewb.java
185 185

  
186 186
///////////////////////////////////////////////////////////////////////////////////////////////////
187 187

  
188
  float getBasicStep()
188
  float[] getCuts(int size)
189 189
    {
190
    return SQ3;
190
    float[] cuts = new float[size-1];
191

  
192
    switch(size)
193
      {
194
      case 2: cuts[0] = 0;
195
              break;
196
      case 3: cuts[0] = -SQ3/12;
197
              cuts[1] = +SQ3/12;
198
              break;
199
      }
200
    return cuts;
191 201
    }
192 202

  
193 203
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff