Project

General

Profile

« Previous | Next » 

Revision 7994b456

Added by Leszek Koltunski over 2 years ago

cleaning up.

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
234 234
    boolean fromDMESH = (stream!=null && meshState==MESH_NICE);
235 235
    mNumCubitVariants = getNumCubitVariants(mNumLayers);
236 236
    mShapes = new ObjectShape[mNumCubitVariants];
237
    createMeshAndCubits(stream,meshState,fromDMESH);
237
    createMeshAndCubits(stream,meshState,fromDMESH,fromJSON);
238 238
    setUpTextures(fromDMESH,fromJSON);
239 239
    createDataStructuresForSolved(mNumLayers);
240 240

  
......
255 255
    mNode = new DistortedNode(mTexture,mEffects,mMesh);
256 256
    }
257 257

  
258
///////////////////////////////////////////////////////////////////////////////////////////////////
259

  
260
  private void setUpTextures(boolean fromDMESH, boolean fromJSON)
261
    {
262
    mTexture = new DistortedTexture();
263

  
264
    if( fromJSON )
265
      {
266
      mNumStickerTypes = getNumStickerTypes();
267
      mNumCubitFaces = getNumCubitFaces();
268
      }
269
    else
270
      {
271
      FactoryCubit factory = FactoryCubit.getInstance();
272

  
273
      if( fromDMESH )
274
        {
275
        for(int i=0; i<mNumCubitVariants; i++) mShapes[i] = getObjectShape(i);
276
        mNumCubitFaces = ObjectShape.computeNumComponents(mShapes);
277

  
278
        factory.clear();
279
        for(int i=0; i<mNumCubitVariants; i++) factory.createNewFaceTransform(mShapes[i]);
280
        }
281

  
282
      mStickerCoords   = factory.getOuterStickerCoords();
283
      mStickerVariants = factory.getStickerVariants();
284
      mStickerScales   = factory.getOuterStickerScales();
285
      mNumStickerTypes = mStickerCoords.length;
286

  
287
      adjustStickerCoords();
288
      }
289

  
290
    NUM_TEXTURES = NUM_FACE_COLORS*mNumStickerTypes;
291
    mNumTexCols = NUM_STICKERS_IN_ROW;
292
    mNumTexRows = (NUM_TEXTURES+1)/NUM_STICKERS_IN_ROW;
293
    if( mNumTexCols*mNumTexRows < NUM_TEXTURES+1 ) mNumTexRows++;
294

  
295
    if( !fromDMESH || shouldResetTextureMaps() ) resetAllTextureMaps();
296
    setTexture();
297
    }
298

  
299 258
///////////////////////////////////////////////////////////////////////////////////////////////////
300 259

  
301 260
  private Static3D getPos(float[] origPos)
......
321 280

  
322 281
///////////////////////////////////////////////////////////////////////////////////////////////////
323 282

  
324
  private void createMeshAndCubits(InputStream stream, int meshState, boolean fromDMESH)
283
  private void createMeshAndCubits(InputStream stream, int meshState, boolean fromDMESH, boolean fromJSON)
325 284
    {
326 285
    if( fromDMESH )
327 286
      {
......
342 301
        CUBITS[i] = new Cubit(this,mOrigPos[i], NUM_AXIS);
343 302
        mMesh.setEffectAssociation(i, CUBITS[i].computeAssociation(), 0);
344 303
        }
304

  
305
      if( !fromJSON )
306
        {
307
        for(int i=0; i<mNumCubitVariants; i++) mShapes[i] = getObjectShape(i);
308
        mNumCubitFaces = ObjectShape.computeNumComponents(mShapes);
309

  
310
        FactoryCubit factory = FactoryCubit.getInstance();
311
        factory.clear();
312
        for(int i=0; i<mNumCubitVariants; i++) factory.createNewFaceTransform(mShapes[i]);
313
        }
345 314
      }
346 315
    else
347 316
      {
......
388 357
    return mesh;
389 358
    }
390 359

  
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361

  
362
  private void setUpTextures(boolean fromDMESH, boolean fromJSON)
363
    {
364
    mTexture = new DistortedTexture();
365

  
366
    if( fromJSON )
367
      {
368
      mNumStickerTypes = getNumStickerTypes();
369
      mNumCubitFaces = getNumCubitFaces();
370
      }
371
    else
372
      {
373
      FactoryCubit factory = FactoryCubit.getInstance();
374
      mStickerCoords   = factory.getOuterStickerCoords();
375
      mStickerVariants = factory.getStickerVariants();
376
      mStickerScales   = factory.getOuterStickerScales();
377
      mNumStickerTypes = mStickerCoords.length;
378
      adjustStickerCoords();
379
      }
380

  
381
    NUM_TEXTURES = NUM_FACE_COLORS*mNumStickerTypes;
382
    mNumTexCols = NUM_STICKERS_IN_ROW;
383
    mNumTexRows = (NUM_TEXTURES+1)/NUM_STICKERS_IN_ROW;
384
    if( mNumTexCols*mNumTexRows < NUM_TEXTURES+1 ) mNumTexRows++;
385

  
386
    if( !fromDMESH || shouldResetTextureMaps() ) resetAllTextureMaps();
387
    setTexture();
388
    }
389

  
391 390
///////////////////////////////////////////////////////////////////////////////////////////////////
392 391

  
393 392
  private void createDataStructuresForSolved(int[] numLayers)

Also available in: Unified diff