Project

General

Profile

« Previous | Next » 

Revision f10a88a8

Added by Leszek Koltunski over 2 years ago

Move 1) bandaged 3x3 2) normals cubes 3) octahedrons 4) both dinos to the new cubit creation scheme.

View differences:

src/main/java/org/distorted/objects/TwistyCube.java
22 22
import android.content.res.Resources;
23 23

  
24 24
import org.distorted.helpers.FactoryCubit;
25
import org.distorted.helpers.ObjectShape;
25 26
import org.distorted.helpers.ObjectSticker;
27
import org.distorted.library.effect.MatrixEffectQuaternion;
26 28
import org.distorted.library.main.DistortedEffects;
27 29
import org.distorted.library.main.DistortedTexture;
28 30
import org.distorted.library.mesh.MeshBase;
......
137 139
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.CUBE, res, scrWidth);
138 140
    }
139 141

  
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

  
144
  private Static4D getQuat(int cubit, int numLayers)
145
    {
146
    return QUATS[0];
147
    }
148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

  
151
  private int getNumCubitVariants(int numLayers)
152
    {
153
    return 1;
154
    }
155

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

  
158
  int getCubitVariant(int cubit, int numLayers)
159
    {
160
    return 0;
161
    }
162

  
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164

  
165
  ObjectShape getObjectShape(int cubit, int numLayers)
166
    {
167
    int extraI, extraV, num;
168
    float height;
169

  
170
    switch(numLayers)
171
      {
172
      case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
173
      case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
174
      case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
175
      default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
176
      }
177

  
178
    float[][] bands     = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
179
    int[] bandIndices   = new int[] { 0,0,0,0,0,0};
180
    float[][] corners   = new float[][] { {0.036f,0.12f} };
181
    int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 };
182
    float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
183
    int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
184

  
185
    return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
186
    }
187

  
140 188
///////////////////////////////////////////////////////////////////////////////////////////////////
141 189

  
142 190
  MeshBase createCubitMesh(int cubit, int numLayers)
143 191
    {
192
    int variant = getCubitVariant(cubit,numLayers);
193

  
144 194
    if( mMeshes==null )
145 195
      {
146 196
      FactoryCubit factory = FactoryCubit.getInstance();
147 197
      factory.clear();
148
      mMeshes = new MeshBase[1];
198
      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
149 199
      }
150 200

  
151
    if( mMeshes[0]==null )
201
    if( mMeshes[variant]==null )
152 202
      {
153
      int extraI, extraV, num;
154
      float height;
155

  
156
      switch(numLayers)
157
        {
158
        case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break;
159
        case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break;
160
        case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break;
161
        default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break;
162
        }
163

  
164
      float[][] bands     = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} };
165
      int[] bandIndexes   = new int[] { 0,0,0,0,0,0};
166
      float[][] corners   = new float[][] { {0.036f,0.12f} };
167
      int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
168
      float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
169
      int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
170

  
203
      ObjectShape shape = getObjectShape(cubit,numLayers);
171 204
      FactoryCubit factory = FactoryCubit.getInstance();
172

  
173
      factory.createNewFaceTransform(VERTICES,VERT_INDEXES);
174
      mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES,
175
                                              bands, bandIndexes,
176
                                              corners, cornerIndexes,
177
                                              centers, centerIndexes,
178
                                              getNumCubitFaces(), null );
205
      factory.createNewFaceTransform(shape);
206
      mMeshes[variant] = factory.createRoundedSolid(shape);
179 207
      }
180 208

  
181
    return mMeshes[0].copy(true);
209
    MeshBase mesh = mMeshes[variant].copy(true);
210
    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
211
    mesh.apply(quat,0xffffffff,0);
212

  
213
    return mesh;
182 214
    }
183 215

  
184 216
///////////////////////////////////////////////////////////////////////////////////////////////////
......
277 309

  
278 310
///////////////////////////////////////////////////////////////////////////////////////////////////
279 311

  
280
  int getFaceColor(int cubit, int cubitface, int size)
312
  int getFaceColor(int cubit, int cubitface, int numLayers)
281 313
    {
282
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(size-1)):1) ? cubitface : NUM_FACES;
314
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_FACES;
283 315
    }
284 316

  
285 317
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff