Project

General

Profile

« Previous | Next » 

Revision d99f3a48

Added by Leszek Koltunski over 3 years ago

Spearate the concept of number of layers of an object and its size.
In case of the Skewb family, this is no longer the same (Master Skewb has 3 layers but it's twice bigger than the 2-layered Skewb)

View differences:

src/main/java/org/distorted/objects/TwistyObject.java
99 99
  private Static3D[] mOrigPos;
100 100
  private Static3D mNodeScale;
101 101
  private Static4D mQuat;
102
  private int mSize;
102
  private int mNumLayers, mRealSize;
103 103
  private ObjectList mList;
104 104
  private MeshBase mMesh;
105 105
  private DistortedEffects mEffects;
......
116 116

  
117 117
///////////////////////////////////////////////////////////////////////////////////////////////////
118 118

  
119
  TwistyObject(int size, int fov, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh,
119
  TwistyObject(int numLayers, int realSize, int fov, Static4D quat, DistortedTexture nodeTexture, MeshSquare nodeMesh,
120 120
               DistortedEffects nodeEffects, int[][] moves, ObjectList list, Resources res, int screenWidth)
121 121
    {
122 122
    super(nodeTexture,nodeEffects,nodeMesh);
......
125 125

  
126 126
    resizeFBO(mNodeSize, (int)(NODE_RATIO*mNodeSize));
127 127

  
128
    mSize = size;
128
    mNumLayers = numLayers;
129
    mRealSize = realSize;
129 130
    mList = list;
130
    mOrigPos = getCubitPositions(size);
131
    mOrigPos = getCubitPositions(mNumLayers);
131 132

  
132 133
    QUATS = getQuats();
133 134
    NUM_CUBITS  = mOrigPos.length;
......
137 138
    NUM_FACES = getNumFaces();
138 139
    NUM_CUBIT_FACES = getNumCubitFaces();
139 140
    NUM_TEXTURES = getNumStickerTypes()*NUM_FACES;
140
    CUTS = getCuts(mSize);
141
    CUTS = getCuts(mNumLayers);
141 142
    NUM_CUTS = CUTS.length;
142 143

  
143 144
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
......
156 157
    mRotationAngleMiddle = new Static1D(0);
157 158
    mRotationAngleFinal  = new Static1D(0);
158 159

  
159
    float scale  = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mSize;
160
    float scale  = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
160 161
    mObjectScale = new Static3D(scale,scale,scale);
161 162
    mScaleEffect = new MatrixEffectScale(mObjectScale);
162 163
    mQuatEffect  = new MatrixEffectQuaternion(quat, CENTER);
......
199 200
    {
200 201
    if( mCreateFromDMesh )
201 202
      {
202
      int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mSize);
203
      int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers);
203 204
      int resourceID= list.getResourceIDs()[sizeIndex];
204 205

  
205 206
      InputStream is = res.openRawResource(resourceID);
......
249 250
    if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
250 251
    if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
251 252

  
252
    float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mSize;
253
    float scale = mObjectScreenRatio*mInitScreenRatio*mNodeSize/mRealSize;
253 254
    mObjectScale.set(scale,scale,scale);
254 255
    }
255 256

  
......
504 505

  
505 506
///////////////////////////////////////////////////////////////////////////////////////////////////
506 507

  
507
  public int getSize()
508
  public int getNumLayers()
508 509
    {
509
    return mSize;
510
    return mNumLayers;
510 511
    }
511 512

  
512 513
///////////////////////////////////////////////////////////////////////////////////////////////////
......
604 605

  
605 606
      for(int cubitface=0; cubitface<NUM_CUBIT_FACES; cubitface++)
606 607
        {
607
        color = getFaceColor(cubit,cubitface,mSize);
608
        color = getFaceColor(cubit,cubitface,mNumLayers);
608 609
        maps[cubitface] = new Static4D( color*ratio, 0.0f, ratio, 1.0f);
609 610
        }
610 611

  
......
632 633
      android.util.Log.e("object", "invalid rotation axis: "+axis);
633 634
      return;
634 635
      }
635
    if( row<0 || row>=mSize )
636
    if( row<0 || row>=mNumLayers )
636 637
      {
637 638
      android.util.Log.e("object", "invalid rotation row: "+row);
638 639
      return;

Also available in: Unified diff