Project

General

Profile

Download (11.5 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / main / TwistyJson.java @ 97a6aa87

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.main;
21

    
22
import java.io.InputStream;
23

    
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26
import org.distorted.objectlib.helpers.ObjectFaceShape;
27
import org.distorted.objectlib.helpers.ObjectShape;
28
import org.distorted.objectlib.helpers.ObjectSticker;
29
import org.distorted.objectlib.scrambling.ScrambleState;
30
import org.distorted.objectlib.json.JsonReader;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class TwistyJson extends TwistyObject
35
{
36
  private JsonReader mReader;
37

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

    
40
  public TwistyJson(InputStream jsonStream, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream)
41
    {
42
    super(jsonStream, meshState, iconMode, quat, move, scale, meshStream);
43
    }
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  @Override
48
  public int[][] getSolvedQuats()
49
    {
50
    return mReader.getSolvedQuats();
51
    }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  @Override
56
  public Static4D[] getQuats()
57
    {
58
    return mReader.getQuats();
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62

    
63
  @Override
64
  public int getSolvedFunctionIndex()
65
    {
66
    return mReader.getSolvedFunctionIndex();
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  @Override
72
  public int getNumCubitFaces()
73
    {
74
    return mReader.getNumCubitFaces();
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

    
79
  @Override
80
  public int getVariantFaceColor(int variant, int face)
81
    {
82
    return mReader.getVariantFaceColor(variant,face);
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
  @Override
88
  public int getCubitFaceMap(int cubit, int face)
89
    {
90
    return mReader.getCubitFaceFace(cubit,face);
91
    }
92

    
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

    
95
  @Override
96
  public int getNumStickerTypes()
97
    {
98
    return mReader.getNumStickerTypes();
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  @Override
104
  public ObjectSticker retSticker(int sticker)
105
    {
106
    return mReader.retSticker(sticker);
107
    }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  @Override
112
  public int getScrambleType()
113
    {
114
    return mReader.getScrambleType();
115
    }
116

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

    
119
  @Override
120
  public boolean shouldResetTextureMaps()
121
    {
122
    return mReader.shouldResetTextureMaps();
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  @Override
128
  public int getInternalColor()
129
    {
130
    return mReader.getInternalColor();
131
    }
132

    
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

    
135
  public void setReader(JsonReader reader)
136
    {
137
    mReader = reader;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  public ScrambleState[] getScrambleStates()
143
    {
144
    return mReader.getScrambleStates();
145
    }
146

    
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148

    
149
  public float[][] getCuts(int[] numLayers)
150
    {
151
    return mReader.getCuts();
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
  public boolean[][] getLayerRotatable(int[] numLayers)
157
    {
158
    return mReader.getLayerRotatable();
159
    }
160

    
161
///////////////////////////////////////////////////////////////////////////////////////////////////
162

    
163
  public int getTouchControlType()
164
    {
165
    return mReader.getMovementType();
166
    }
167

    
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

    
170
  public int getTouchControlSplit()
171
    {
172
    return mReader.getMovementSplit();
173
    }
174

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

    
177
  public int[][][] getEnabled()
178
    {
179
    return mReader.getEnabled();
180
    }
181

    
182
///////////////////////////////////////////////////////////////////////////////////////////////////
183

    
184
  public float[] getDist3D(int[] numLayers)
185
    {
186
    return mReader.getDist3D();
187
    }
188

    
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190
// this is only needed when computing sticker colors which here we do via the retSticker() method.
191

    
192
  public Static3D[] getFaceAxis()
193
    {
194
    return null;
195
    }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

    
199
  public float[][] getCubitPositions(int[] numLayers)
200
    {
201
    return mReader.getCubitPositions();
202
    }
203

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205

    
206
  public ObjectShape getObjectShape(int variant)
207
    {
208
    return mReader.getObjectShape(variant);
209
    }
210

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

    
213
  public ObjectFaceShape getObjectFaceShape(int variant)
214
    {
215
    return mReader.getObjectFaceShape(variant);
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

    
220
  public Static4D getCubitQuats(int cubit, int[] numLayers)
221
    {
222
    return mReader.getCubitQuats(cubit);
223
    }
224

    
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226

    
227
  public int getNumCubitVariants(int[] numLayers)
228
    {
229
    return mReader.getNumCubitVariants();
230
    }
231

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

    
234
  public int getCubitVariant(int cubit, int[] numLayers)
235
    {
236
    return mReader.getCubitVariant(cubit);
237
    }
238

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240
// fake, this will never be called
241

    
242
  public float getStickerStroke()
243
    {
244
    return 0.0f;
245
    }
246

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248
// fake, this will never be called
249

    
250
  public float getStickerRadius()
251
    {
252
    return 0.0f;
253
    }
254

    
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
// fake, this will never be called
257

    
258
  public float[][] getStickerAngles()
259
    {
260
    return null;
261
    }
262

    
263
///////////////////////////////////////////////////////////////////////////////////////////////////
264
// PUBLIC API
265

    
266
  public Static3D[] getRotationAxis()
267
    {
268
    return mReader.getRotationAxis();
269
    }
270

    
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

    
273
  public int[] getBasicAngles()
274
    {
275
    return mReader.getBasicAngle();
276
    }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

    
280
  public int getNumScramble()
281
    {
282
    return mReader.getNumScrambles();
283
    }
284

    
285
///////////////////////////////////////////////////////////////////////////////////////////////////
286

    
287
  public long getSignature()
288
    {
289
    return mReader.getSignature();
290
    }
291

    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293

    
294
  public String getObjectName()
295
    {
296
    return mReader.getObjectName();
297
    }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
  public String getInventor()
302
    {
303
    return mReader.getInventor();
304
    }
305

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

    
308
  public int getYearOfInvention()
309
    {
310
    return mReader.getYearOfInvention();
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314

    
315
  public int getComplexity()
316
    {
317
    return mReader.getComplexity();
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  public int getNumFaces()
323
    {
324
    return mReader.getNumFaces();
325
    }
326

    
327
///////////////////////////////////////////////////////////////////////////////////////////////////
328

    
329
  public int getNumFaceColors()
330
    {
331
    return mReader.getNumFaceColors();
332
    }
333

    
334
///////////////////////////////////////////////////////////////////////////////////////////////////
335

    
336
  public int getColor(int face)
337
    {
338
    return mReader.getColor(face);
339
    }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342

    
343
  public String getShortName()
344
    {
345
    return mReader.getShortName();
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public String[][] getTutorials()
351
    {
352
    return mReader.getTutorials();
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  public int getFOV()
358
    {
359
    switch( mReader.getNumFaces() )
360
      {
361
      case  4: return ShapeTetrahedron.FOV;
362
      case  6: return ShapeHexahedron.FOV;
363
      case  8: return ShapeOctahedron.FOV;
364
      case 12: return ShapeDodecahedron.FOV;
365
      }
366

    
367
    return 0;
368
    }
369

    
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371

    
372
  public float getScreenRatio()
373
    {
374
    switch( mReader.getNumFaces() )
375
      {
376
      case  4: return ShapeTetrahedron.RATIO;
377
      case  6: return ShapeHexahedron.RATIO;
378
      case  8: return ShapeOctahedron.RATIO;
379
      case 12: return ShapeDodecahedron.RATIO;
380
      }
381

    
382
    return 0.0f;
383
    }
384
}
(10-10/12)