Project

General

Profile

« Previous | Next » 

Revision 16f34a98

Added by Leszek Koltunski about 3 years ago

Progress with any size Kilominx.

View differences:

src/main/java/org/distorted/objects/TwistyKilominx.java
188 188
  private float[] computeEdge(int numLayers, int edge, int part)
189 189
    {
190 190
    float D = numLayers/3.0f;
191

  
192 191
    float[] c1 = CORNERS[ mEdgeMap[edge][0] ];
193 192
    float[] c2 = CORNERS[ mEdgeMap[edge][1] ];
194
    float x = D * (c1[0]+c2[0]) / 2;
195
    float y = D * (c1[1]+c2[1]) / 2;
196
    float z = D * (c1[2]+c2[2]) / 2;
197 193

  
194
    int leftRight = 2*(part%2) -1;
198 195
    part /= 2;
199 196

  
200 197
    if( part==0 )
201 198
      {
199
      float T = 0.5f + leftRight/(numLayers-1.0f);
200
      float x = D * (T*c1[0]+(1.0f-T)*c2[0]);
201
      float y = D * (T*c1[1]+(1.0f-T)*c2[1]);
202
      float z = D * (T*c1[2]+(1.0f-T)*c2[2]);
203

  
202 204
      return new float[] { x, y, z };
203 205
      }
204 206
    else
......
206 208
      int mult = (part+1)/2;
207 209
      int dir  = (part+1)%2;
208 210
      float[] center = mCenterCoords[ mEdgeMap[edge][dir+2] ];
211
      float x = 0.5f * D * (c1[0]+c2[0]);
212
      float y = 0.5f * D * (c1[1]+c2[1]);
213
      float z = 0.5f * D * (c1[2]+c2[2]);
209 214

  
210 215
      float vX = D*center[0] - x;
211 216
      float vY = D*center[1] - y;
212 217
      float vZ = D*center[2] - z;
213 218

  
214
      float A = mult*D*COS18/(numLayers-1);
215
      A /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
219
      float T = 0.5f + leftRight*(mult*D*SIN18 + 1.0f)/(numLayers-1);
220
      x = D * (T*c1[0]+(1.0f-T)*c2[0]);
221
      y = D * (T*c1[1]+(1.0f-T)*c2[1]);
222
      z = D * (T*c1[2]+(1.0f-T)*c2[2]);
223

  
224
      float H = mult*D*COS18/(numLayers-1);
225
      H /= (float)Math.sqrt(vX*vX+vY*vY+vZ*vZ);
216 226

  
217
      return new float[] { x+A*vX, y+A*vY, z+A*vZ };
227
      return new float[] { x + H*vX, y + H*vY, z + H*vZ };
218 228
      }
219 229
    }
220 230

  
......
318 328
      {
319 329
      if( mCornerMeshes[indexCornerEdge]==null )
320 330
        {
321
        mCornerMeshes[indexCornerEdge] = FactoryCubit.getInstance().createMinxCornerMesh(ObjectList.KILO,numLayers);
331
        float width = (numLayers/3.0f)/(numLayers-1);
332
        mCornerMeshes[indexCornerEdge] = FactoryCubit.getInstance().createMinxCornerMesh(numLayers,width);
322 333
        }
323 334
      mesh = mCornerMeshes[indexCornerEdge].copy(true);
324 335
      }
......
332 343
        float height= tmp*COS18;
333 344
        float width = tmp + type*height*SIN18/COS18;
334 345

  
335
        mEdgeMeshes[indexCornerEdge][type] = FactoryCubit.getInstance().createKilominxEdgeMesh(numLayers,width,height);
346
        mEdgeMeshes[indexCornerEdge][type] = FactoryCubit.getInstance().createKilominxEdgeMesh(numLayers,width,height, (type%2)==0 );
336 347
        }
337 348

  
338 349
      mesh = mEdgeMeshes[indexCornerEdge][type].copy(true);

Also available in: Unified diff