Project

General

Profile

« Previous | Next » 

Revision d464f54f

Added by Leszek Koltunski about 3 years ago

Remove statics from the Dino classes.

View differences:

src/main/java/org/distorted/objects/TwistyCube.java
342 342

  
343 343
  int getFaceColor(int cubit, int cubitface, int numLayers)
344 344
    {
345
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_FACES;
345
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_TEXTURES;
346 346
    }
347 347

  
348 348
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino.java
45 45
           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
46 46
         };
47 47

  
48
  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
49

  
50 48
  private static final int[] FACE_COLORS = new int[]
51 49
         {
52 50
           COLOR_YELLOW, COLOR_WHITE,
......
54 52
           COLOR_RED   , COLOR_ORANGE
55 53
         };
56 54

  
57
  // All legal rotation quats of a RubikDino
58
  static final Static4D[] QUATS = new Static4D[]
59
         {
60
           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
61
           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
62
           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
63
           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
64
           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
65
           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
66
           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
67
           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
68
           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
69
           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
70
           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
71
           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
72
         };
73

  
74
  // centers of the 12 edges. Must be in the same order like QUATs above.
75
  static final float[][] CENTERS = new float[][]
76
         {
77
             { 0.0f, 1.5f, 1.5f },
78
             { 1.5f, 0.0f, 1.5f },
79
             { 0.0f,-1.5f, 1.5f },
80
             {-1.5f, 0.0f, 1.5f },
81
             { 1.5f, 1.5f, 0.0f },
82
             { 1.5f,-1.5f, 0.0f },
83
             {-1.5f,-1.5f, 0.0f },
84
             {-1.5f, 1.5f, 0.0f },
85
             { 0.0f, 1.5f,-1.5f },
86
             { 1.5f, 0.0f,-1.5f },
87
             { 0.0f,-1.5f,-1.5f },
88
             {-1.5f, 0.0f,-1.5f }
89
         };
90

  
91
  private static final double[][] VERTICES = new double[][]
92
          {
93
             {-1.5, 0.0, 0.0},
94
             { 1.5, 0.0, 0.0},
95
             { 0.0,-1.5, 0.0},
96
             { 0.0, 0.0,-1.5}
97
          };
98

  
99
  private static final int[][] VERT_INDEXES = new int[][]
100
          {
101
             {2,1,0},   // counterclockwise!
102
             {3,0,1},
103
             {2,3,1},
104
             {3,2,0},
105
          };
106

  
107
  private static final float[][] STICKERS = new float[][]
108
          {
109
             { 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 }
110
          };
111

  
112
  private static final ObjectSticker[] mStickers;
113

  
114
  static
115
    {
116
    float radius = 0.025f;
117
    float stroke = 0.050f;
118
    float[] radii = new float[] {radius,radius,radius};
119
    mStickers = new ObjectSticker[STICKERS.length];
120
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
121
    }
122

  
123 55
  private int mCurrState;
124 56
  private int mIndexExcluded;
125
  ScrambleState[] mStates;
126 57
  private int[][] mScrambleTable;
127 58
  private int[] mNumOccurences;
59
  private int[] mBasicAngle;
60
  private Static4D[] mQuats;
61
  private ObjectSticker[] mStickers;
62
  float[][] mCenters;
63
  ScrambleState[] mStates;
128 64

  
129 65
///////////////////////////////////////////////////////////////////////////////////////////////////
130 66

  
......
134 70
    super(size, size, quat, texture, mesh, effects, moves, obj, res, scrWidth);
135 71
    }
136 72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  private void initializeQuats()
76
    {
77
    mQuats = new Static4D[]
78
         {
79
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
80
         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
81
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
82
         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
83
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
84
         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
85
         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
86
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
87
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
88
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
89
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
90
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f )
91
         };
92
    }
93

  
137 94
///////////////////////////////////////////////////////////////////////////////////////////////////
138 95

  
139 96
  float getScreenRatio()
......
145 102

  
146 103
  Static4D[] getQuats()
147 104
    {
148
    return QUATS;
105
    if( mQuats==null ) initializeQuats();
106
    return mQuats;
149 107
    }
150 108

  
151 109
///////////////////////////////////////////////////////////////////////////////////////////////////
......
167 125

  
168 126
  int getNumStickerTypes(int numLayers)
169 127
    {
170
    return STICKERS.length;
128
    return 1;
171 129
    }
172 130

  
173 131
///////////////////////////////////////////////////////////////////////////////////////////////////
......
181 139

  
182 140
  float[][] getCubitPositions(int size)
183 141
    {
184
    return CENTERS;
142
    if( mCenters ==null )
143
      {
144
      mCenters = new float[][]
145
         {
146
             { 0.0f, 1.5f, 1.5f },
147
             { 1.5f, 0.0f, 1.5f },
148
             { 0.0f,-1.5f, 1.5f },
149
             {-1.5f, 0.0f, 1.5f },
150
             { 1.5f, 1.5f, 0.0f },
151
             { 1.5f,-1.5f, 0.0f },
152
             {-1.5f,-1.5f, 0.0f },
153
             {-1.5f, 1.5f, 0.0f },
154
             { 0.0f, 1.5f,-1.5f },
155
             { 1.5f, 0.0f,-1.5f },
156
             { 0.0f,-1.5f,-1.5f },
157
             {-1.5f, 0.0f,-1.5f }
158
         };
159
      }
160

  
161
    return mCenters;
185 162
    }
186 163

  
187 164
///////////////////////////////////////////////////////////////////////////////////////////////////
188 165

  
189 166
  ObjectShape getObjectShape(int cubit, int numLayers)
190 167
    {
168
    double[][] vertices = new double[][] { {-1.5, 0.0, 0.0},{ 1.5, 0.0, 0.0},{ 0.0,-1.5, 0.0},{ 0.0, 0.0,-1.5} };
169
    int[][] vert_indices= new int[][] { {2,1,0},{3,0,1},{2,3,1},{3,2,0} };
191 170
    float[][] bands     = new float[][] { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} };
192 171
    int[] bandIndices   = new int[] { 0,0,1,1 };
193 172
    float[][] corners   = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} };
194 173
    int[] cornerIndices = new int[] { 0,0,1,1 };
195 174
    float[][] centers   = new float[][] { {0.0f, -0.75f, -0.75f} };
196 175
    int[] centerIndices = new int[] { 0,0,0,0 };
197
    return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
176
    return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
198 177
    }
199 178

  
200 179
///////////////////////////////////////////////////////////////////////////////////////////////////
201 180

  
202 181
  Static4D getQuat(int cubit, int numLayers)
203 182
    {
204
    return QUATS[cubit];
183
    if( mQuats==null ) initializeQuats();
184
    return mQuats[cubit];
205 185
    }
206 186

  
207 187
///////////////////////////////////////////////////////////////////////////////////////////////////
......
229 209

  
230 210
  ObjectSticker retSticker(int face)
231 211
    {
212
    if( mStickers==null )
213
      {
214
      float[][] STICKERS = new float[][] { { 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 } };
215
      float radius = 0.025f;
216
      float stroke = 0.050f;
217
      float[] radii = new float[] {radius,radius,radius};
218
      mStickers     = new ObjectSticker[STICKERS.length];
219
      mStickers[0]  = new ObjectSticker(STICKERS[0],null,radii,stroke);
220
      }
221

  
232 222
    return mStickers[face/NUM_FACES];
233 223
    }
234 224

  
......
299 289

  
300 290
  public int[] getBasicAngle()
301 291
    {
302
    return BASIC_ANGLE;
292
    if( mBasicAngle==null ) mBasicAngle = new int[] { 3,3,3,3 };
293
    return mBasicAngle;
303 294
    }
304 295

  
305 296
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino4.java
32 32

  
33 33
public class TwistyDino4 extends TwistyDino
34 34
{
35
  private static final int[] mFaceMap = { 4, 2, 2, 4, 0, 2, 1, 4, 0, 0, 1, 1 };
35
  private int[] mFaceMap;
36 36

  
37 37
///////////////////////////////////////////////////////////////////////////////////////////////////
38 38

  
......
66 66

  
67 67
  int getFaceColor(int cubit, int cubitface, int size)
68 68
    {
69
    if( mFaceMap==null ) mFaceMap = new int[] { 4, 2, 2, 4, 0, 2, 1, 4, 0, 0, 1, 1 };
69 70
    return (cubitface==0 || cubitface==1) ? mFaceMap[cubit] : NUM_TEXTURES;
70 71
    }
71 72

  
src/main/java/org/distorted/objects/TwistyDino6.java
32 32

  
33 33
public class TwistyDino6 extends TwistyDino
34 34
{
35
  private static final int[] mFaceMap = {4,2, 0,4, 4,3, 1,4,
36
                                         2,0, 3,0, 3,1, 2,1,
37
                                         5,2, 0,5, 5,3, 1,5 };
35
  private int[] mFaceMap;
38 36

  
39 37
///////////////////////////////////////////////////////////////////////////////////////////////////
40 38

  
......
68 66

  
69 67
  int getFaceColor(int cubit, int cubitface, int size)
70 68
    {
69
    if( mFaceMap==null )
70
      {
71
      mFaceMap = new int[] { 4,2, 0,4, 4,3, 1,4, 2,0, 3,0, 3,1, 2,1, 5,2, 0,5, 5,3, 1,5 };
72
      }
73

  
71 74
    switch(cubitface)
72 75
      {
73 76
      case 0 : return mFaceMap[2*cubit];
74 77
      case 1 : return mFaceMap[2*cubit+1];
75
      default: return NUM_FACES;
78
      default: return NUM_TEXTURES;
76 79
      }
77 80
    }
78 81

  

Also available in: Unified diff