Project

General

Profile

« Previous | Next » 

Revision 0e161d26

Added by Leszek Koltunski over 2 years ago

Container Cube: mostly done.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectConstants.java
65 65
  public static final int SQU2_3 = ObjectType.SQU2_3.ordinal();
66 66
  public static final int WIND_3 = ObjectType.WIND_3.ordinal();
67 67
  public static final int FISH_3 = ObjectType.FISH_3.ordinal();
68
  public static final int CONT_2 = ObjectType.CONT_2.ordinal();
68 69
  }
src/main/java/org/distorted/objectlib/main/ObjectType.java
75 75
  MIRR_4 ( TwistyMirror.class        , new int[] {4,4,4}      , 24, R.drawable.mirr_4),
76 76
  SQU1_3 ( TwistySquare1.class       , new int[] {3,2,3}      , 24, R.drawable.squ1_3),
77 77
  SQU2_3 ( TwistySquare2.class       , new int[] {3,2,3}      , 24, R.drawable.squ2_3),
78
  CONT_2 ( TwistyContainer.class     , new int[] {2,2,2,2}    , 12, R.drawable.squ2_3),
78 79
  ;
79 80

  
80 81
  public static final int NUM_OBJECTS = values().length;
src/main/java/org/distorted/objectlib/main/TwistyObject.java
77 77
  public static final int COLOR_ORANGE  = 0xffff6200;
78 78
  public static final int COLOR_GREY    = 0xff727c7b;
79 79
  public static final int COLOR_VIOLET  = 0xff7700bb;
80
  public static final int COLOR_INTERNAL= 0xff000000;
80
  public static final int COLOR_INTERNAL= 0xffeeeeee;
81 81

  
82 82
  public static final int TEXTURE_HEIGHT = 256;
83 83
  static final int NUM_STICKERS_IN_ROW = 4;
src/main/java/org/distorted/objectlib/objects/TwistyContainer.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.objects;
21

  
22
import org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.helpers.QuatGroupGenerator;
27
import org.distorted.objectlib.helpers.ScrambleState;
28
import org.distorted.objectlib.main.ObjectControl;
29
import org.distorted.objectlib.main.ObjectType;
30
import org.distorted.objectlib.main.ShapeHexahedron;
31
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
32

  
33
import java.io.InputStream;
34

  
35
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD;
36
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
public class TwistyContainer extends ShapeHexahedron
41
{
42
  static final Static3D[] ROT_AXIS = new Static3D[]
43
         {
44
           new Static3D( SQ6/3,-SQ3/3,  0.0f),
45
           new Static3D( SQ6/3, SQ3/3,  0.0f),
46
           new Static3D(  0.0f,-SQ3/3, SQ6/3),
47
           new Static3D(  0.0f, SQ3/3, SQ6/3)
48
         };
49

  
50
  private ScrambleState[] mStates;
51
  private int[] mBasicAngle;
52
  private float[][] mCuts;
53
  private int[] mRotQuat;
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public TwistyContainer(int[] numL, int meshState, Static4D quat, Static3D move, float scale, InputStream stream)
58
    {
59
    super(numL, meshState, numL[0], quat, move, scale, stream);
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public ScrambleState[] getScrambleStates()
65
    {
66
    if( mStates==null )
67
      {
68
      int[] tmp = {0,-1,0, 0,1,0, 1,-1,0, 1,1,0 };
69

  
70
      mStates = new ScrambleState[]
71
        {
72
        new ScrambleState( new int[][] {tmp,tmp,tmp,tmp} )
73
        };
74
      }
75

  
76
    return mStates;
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  public float[][] getCuts(int[] numLayers)
82
    {
83
    if( mCuts==null )
84
      {
85
      float[] c = {0};
86
      mCuts = new float[][] {c,c,c,c};
87
      }
88

  
89
    return mCuts;
90
    }
91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
  public boolean[][] getLayerRotatable(int[] numLayers)
95
    {
96
    boolean[] tmp = {true,true};
97
    return new boolean[][] { tmp,tmp,tmp,tmp };
98
    }
99

  
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101

  
102
  public int getTouchControlType()
103
    {
104
    return TC_CHANGING_SHAPEMOD;
105
    }
106

  
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

  
109
  public int getTouchControlSplit()
110
    {
111
    return TYPE_NOT_SPLIT;
112
    }
113

  
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115

  
116
  public int[][][] getEnabled()
117
    {
118
    return null;
119
    }
120

  
121
///////////////////////////////////////////////////////////////////////////////////////////////////
122

  
123
  public float[] getDist3D(int[] numLayers)
124
    {
125
    return new float[] { 0.5f,0.5f,SQ2/2,SQ2/2,0.5f,0.5f};
126
    }
127

  
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129

  
130
  public Static3D[] getFaceAxis()
131
    {
132
    return TouchControlHexahedron.FACE_AXIS;
133
    }
134

  
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136

  
137
  public float[][] getCubitPositions(int[] numLayers)
138
    {
139
    return new float[][]
140
        {
141
            { 0.0f,  -SQ2, 0.0f},
142
            { 0.0f,  +SQ2, 0.0f},
143

  
144
            {-1.0f,  0.0f, 1.0f},
145
            { 1.0f,  0.0f, 1.0f},
146
            { 1.0f,  0.0f,-1.0f},
147
            {-1.0f,  0.0f,-1.0f},
148

  
149
            { 0.0f,-SQ2/2, 1.0f},
150
            { 0.0f,+SQ2/2, 1.0f},
151
            { 1.0f,-SQ2/2, 0.0f},
152
            { 1.0f, SQ2/2, 0.0f},
153
            { 0.0f,-SQ2/2,-1.0f},
154
            { 0.0f,+SQ2/2,-1.0f},
155
            {-1.0f,-SQ2/2, 0.0f},
156
            {-1.0f, SQ2/2, 0.0f},
157
        };
158
    }
159

  
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161

  
162
  public Static4D getCubitQuats(int cubit, int[] numLayers)
163
    {
164
    switch(cubit)
165
      {
166
      case  0: return mObjectQuats[ 0];
167
      case  1: return mObjectQuats[10];
168

  
169
      case  2: return mObjectQuats[11];
170
      case  3: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
171
      case  4: return mObjectQuats[ 0];
172
      case  5: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
173

  
174
      case  6: return mObjectQuats[ 0];
175
      case  7: return new Static4D( 0.0f, 0.0f, 1.0f, 0.0f);
176
      case  8: return new Static4D( 0.0f, SQ2/2, 0.0f,-SQ2/2);
177
      case  9: return mObjectQuats[10];
178
      case 10: return mObjectQuats[11];
179
      case 11: return new Static4D( 1.0f, 0.0f, 0.0f, 0.0f);
180
      case 12: return new Static4D( 0.0f, SQ2/2, 0.0f, SQ2/2);
181
      case 13: return mObjectQuats[ 9];
182
      }
183

  
184
    return null;
185
    }
186

  
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

  
189
  public ObjectShape getObjectShape(int variant)
190
    {
191
    if( variant==0 )
192
      {
193
      float[][] vertices= { {-1,0,1},{1,0,1},{1,0,-1},{-1,0,-1},{0,SQ2,0} };
194
      int[][] indices   = { {3,2,1,0},{0,1,4},{1,2,4},{2,3,4},{3,0,4} };
195
      return new ObjectShape(vertices, indices);
196
      }
197
    else if( variant==1 )
198
      {
199
      float[][] vertices= { {-1,0,1},{0,0,1},{-1,0,0},{0,SQ2,0},{0,-SQ2,0} };
200
      int[][] indices   = { {4,3,1},{4,3,2},{2,0,3},{0,1,3},{1,0,4},{0,2,4} };
201
      return new ObjectShape(vertices, indices);
202
      }
203
    else
204
      {
205
      float[][] vertices= { {-1,-SQ2/2,0},{1,-SQ2/2,0},{0,SQ2/2,0},{0,SQ2/2,-1} };
206
      int[][] indices   = { {0,1,2},{0,2,3},{1,3,2},{1,0,3} };
207
      return new ObjectShape(vertices, indices);
208
      }
209
    }
210

  
211
///////////////////////////////////////////////////////////////////////////////////////////////////
212

  
213
  public ObjectFaceShape getObjectFaceShape(int variant)
214
    {
215
    if( variant==0 )
216
      {
217
      float[][] bands   = { {0.020f,35,0.16f,0.7f,5,1,1}, {0.000f,35,0.16f,0.7f,5,1,1} };
218
      int[] bandIndices = { 0,1,1,1,1 };
219
      float[][] corners = { {0.05f,0.25f} };
220
      int[] indices     = { 0,0,0,0,-1 };
221
      float[][] centers = { { 0.0f, SQ2, 0.0f} };
222
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
223
      }
224
    else if( variant==1 )
225
      {
226
      float[][] bands   = { {0.020f,35,0.16f,0.7f,5,1,1}, {0.000f,35,0.16f,0.7f,5,1,1} };
227
      int[] bandIndices = { 0,0,1,1,1,1 };
228
      float[][] corners = { {0.05f,0.25f} };
229
      int[] indices     = { -1,0,0,0,0 };
230
      float[][] centers = { {-1,0,1} };
231
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
232
      }
233
    else
234
      {
235
      float[][] bands   = { {0.020f,35,0.16f,0.7f,5,1,1}, {0.000f,35,0.16f,0.7f,5,1,1} };
236
      int[] bandIndices = { 0,1,1,1 };
237
      float[][] corners = { {0.05f,0.25f} };
238
      int[] indices     = { 0,0,0,-1 };
239
      float[][] centers = { {0.0f, SQ2/2, -1.0f} };
240
      return new ObjectFaceShape(bands,bandIndices,corners,indices,centers,indices,null);
241
      }
242
    }
243

  
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245

  
246
  public int getNumCubitVariants(int[] numLayers)
247
    {
248
    return 3;
249
    }
250

  
251
///////////////////////////////////////////////////////////////////////////////////////////////////
252

  
253
  public int getCubitVariant(int cubit, int[] numLayers)
254
    {
255
    return cubit<2 ? 0 : (cubit<6 ? 1:2);
256
    }
257

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

  
260
  public float getStickerRadius()
261
    {
262
    return 0.08f;
263
    }
264

  
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266

  
267
  public float getStickerStroke()
268
    {
269
    return ObjectControl.isInIconMode() ? 0.16f : 0.08f;
270
    }
271

  
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273

  
274
  public float[][] getStickerAngles()
275
    {
276
    return null;
277
    }
278

  
279
///////////////////////////////////////////////////////////////////////////////////////////////////
280
// PUBLIC API
281

  
282
  public Static3D[] getRotationAxis()
283
    {
284
    return ROT_AXIS;
285
    }
286

  
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

  
289
  public int[] getBasicAngles()
290
    {
291
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
292
    return mBasicAngle;
293
    }
294

  
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

  
297
  public ObjectType intGetObjectType(int[] numLayers)
298
    {
299
    return ObjectType.CONT_2;
300
    }
301

  
302
///////////////////////////////////////////////////////////////////////////////////////////////////
303

  
304
  public String getObjectName()
305
    {
306
    return "Container";
307
    }
308

  
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

  
311
  public String getInventor()
312
    {
313
    return "Tony Fisher";
314
    }
315

  
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

  
318
  public int getYearOfInvention()
319
    {
320
    return 1998;
321
    }
322

  
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

  
325
  public int getComplexity()
326
    {
327
    return 2;
328
    }
329
}
src/main/java/org/distorted/objectlib/objects/TwistyWindmill.java
313 313
      final float d = h*X/3;
314 314
      final float l = X/2;
315 315

  
316
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,1}, {0.01f,20,0.2f,0.4f,5,1,1} };
316
      float[][] bands   = { {0.025f,20,0.2f,0.4f,5,1,1}, {0.0f,20,0.2f,0.4f,5,1,1} };
317 317
      int[] bandIndices = { 0,0,0,1,1 };
318 318
      float[][] corners = { {0.04f,0.09f} };
319 319
      int[] indices     = { 0,0,0,0,-1,-1 };
......
326 326
      final float H = 3*h/X;
327 327
      final float l = (3-X)/2;
328 328

  
329
      float[][] bands   = { {0.03f,20,0.2f,0.4f,5,1,1}, {0.01f,20,0.2f,0.4f,5,1,1} };
329
      float[][] bands   = { {0.03f,20,0.2f,0.4f,5,1,1}, {0.0f,20,0.2f,0.4f,5,1,1} };
330 330
      int[] bandIndices = { 0,0,0,1,1,1 };
331 331
      float[][] corners = { {0.03f,0.09f} };
332 332
      int[] indices     = { 0,0,0,0,-1,-1,-1,-1 };
......
335 335
      }
336 336
    else
337 337
      {
338
      float[][] bands   = { {0.05f,35,0.25f,0.7f,5,1,0}, {0.01f,35,0.25f,0.7f,5,1,0} };
338
      float[][] bands   = { {0.05f,35,0.25f,0.7f,5,1,0}, {0.0f,35,0.25f,0.7f,5,1,0} };
339 339
      int[] bandIndices = { 1,0,0,1,1,1 };
340 340
      float[][] corners = { {0.04f,0.12f} };
341 341
      int[] indices     = { 0,0,0,0,0,0,0,0 };

Also available in: Unified diff