Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistySquare.java @ a70b1e96

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.objects;
11

    
12
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SQUARE;
13
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14

    
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17
import org.distorted.objectlib.main.InitAssets;
18
import org.distorted.objectlib.main.InitData;
19
import org.distorted.objectlib.shape.ShapeHexahedron;
20
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
abstract class TwistySquare extends ShapeHexahedron
25
{
26
  static final float COS15 = (SQ6+SQ2)/4;
27
  static final float SIN15 = (SQ6-SQ2)/4;
28
  static final float     X = 3*(2-SQ3)/2;
29

    
30
  // The third, artificial axis is for the generic scrambling algorithm.
31
  // Otherwise it wouldn't be possible to rotate the LO and UP layers
32
  // consecutively.
33

    
34
  static final Static3D[] ROT_AXIS = new Static3D[]
35
    {
36
      new Static3D(0,+1,0),
37
      new Static3D(COS15,0,SIN15),
38
      new Static3D(0,-1,0),
39
    };
40

    
41
  private int[][] mBasicAngle;
42
  private float[][] mCuts;
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  TwistySquare(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
47
    {
48
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  abstract float getFactor();
54

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

    
57
  @Override
58
  public float[][] returnRotationFactor()
59
    {
60
    float C1 = getFactor();
61
    float C2 = 1.8f;
62
    float[] f1 = new float[] { C1,C1,C1,C1,C1,C1,C1,C1,C1,C1,C1,C1 };
63
    float[] f2 = new float[] { C2,C2 };
64
    return new float[][] { f1,f2,f1 };
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  @Override
70
  public int getInternalColor()
71
    {
72
    return 0xff333333;
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  void initializeBasicAngle()
78
    {
79
    mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
80
    }
81

    
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83

    
84
  public float[][] getCuts(int[] numLayers)
85
    {
86
    if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
87
    return mCuts;
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  public boolean[][] getLayerRotatable(int[] numLayers)
93
    {
94
    return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  public int getTouchControlType()
100
    {
101
    return TC_CHANGING_SQUARE;
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  public int getTouchControlSplit()
107
    {
108
    return TYPE_NOT_SPLIT;
109
    }
110

    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112

    
113
  public int[][][] getEnabled()
114
    {
115
    return null;
116
    }
117

    
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119

    
120
  public float[] getDist3D(int[] numLayers)
121
    {
122
    return TouchControlHexahedron.D3D;
123
    }
124

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

    
127
  public Static3D[] getFaceAxis()
128
    {
129
    return TouchControlHexahedron.FACE_AXIS;
130
    }
131

    
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133
// PUBLIC API
134

    
135
  public Static3D[] getRotationAxis()
136
    {
137
    return ROT_AXIS;
138
    }
139

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

    
142
  public int[][] getBasicAngles()
143
    {
144
    if( mBasicAngle ==null ) initializeBasicAngle();
145
    return mBasicAngle;
146
    }
147
}
(38-38/47)