Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 6133be67 Leszek Koltunski
// 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 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.objectlib.objects;
11
12 0c5d8bf7 Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SQUARE;
13 c9c71c3f Leszek Koltunski
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
14 29b82486 Leszek Koltunski
15
import org.distorted.library.type.Static3D;
16
import org.distorted.library.type.Static4D;
17 cf93ea4e Leszek Koltunski
import org.distorted.objectlib.main.InitAssets;
18 ae9d9227 leszek
import org.distorted.objectlib.metadata.Metadata;
19 b31249d6 Leszek Koltunski
import org.distorted.objectlib.shape.ShapeHexahedron;
20 4c9ca251 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
21 29b82486 Leszek Koltunski
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
24 386af988 Leszek Koltunski
abstract class TwistySquare extends ShapeHexahedron
25 29b82486 Leszek Koltunski
{
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 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
42 29b82486 Leszek Koltunski
  private float[][] mCuts;
43
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45
46 ae9d9227 leszek
  TwistySquare(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
47 29b82486 Leszek Koltunski
    {
48 ae9d9227 leszek
    super(iconMode, meta.getNumLayers()[0], quat, move, scale, meta, asset);
49 29b82486 Leszek Koltunski
    }
50
51 a70b1e96 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 7ec32155 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69
  @Override
70
  public int getInternalColor()
71
    {
72
    return 0xff333333;
73
    }
74
75 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77
  void initializeBasicAngle()
78
    {
79 beee90ab Leszek Koltunski
    mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
80 29b82486 Leszek Koltunski
    }
81
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83
84 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
85 29b82486 Leszek Koltunski
    {
86 1f264f3e Leszek Koltunski
    if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
87 29b82486 Leszek Koltunski
    return mCuts;
88
    }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
92 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
93 29b82486 Leszek Koltunski
    {
94 59c20632 Leszek Koltunski
    return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
95 29b82486 Leszek Koltunski
    }
96
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
99 11fa413d Leszek Koltunski
  public int getTouchControlType()
100 29b82486 Leszek Koltunski
    {
101 0c5d8bf7 Leszek Koltunski
    return TC_CHANGING_SQUARE;
102 29b82486 Leszek Koltunski
    }
103
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105
106 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
107 29b82486 Leszek Koltunski
    {
108 59c20632 Leszek Koltunski
    return TYPE_NOT_SPLIT;
109
    }
110
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
113
  public int[][][] getEnabled()
114
    {
115 82904e62 Leszek Koltunski
    return null;
116 59c20632 Leszek Koltunski
    }
117
118
///////////////////////////////////////////////////////////////////////////////////////////////////
119
120
  public float[] getDist3D(int[] numLayers)
121
    {
122 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
123
    }
124
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126
127
  public Static3D[] getFaceAxis()
128
    {
129
    return TouchControlHexahedron.FACE_AXIS;
130 59c20632 Leszek Koltunski
    }
131
132 ebe8c08e leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
133
134
  public float[][][] getStickerAngles()
135
    {
136
    return null;
137
    }
138
139 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
140
// PUBLIC API
141
142
  public Static3D[] getRotationAxis()
143
    {
144
    return ROT_AXIS;
145 29b82486 Leszek Koltunski
    }
146
147
///////////////////////////////////////////////////////////////////////////////////////////////////
148
149 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
150 29b82486 Leszek Koltunski
    {
151
    if( mBasicAngle ==null ) initializeBasicAngle();
152
    return mBasicAngle;
153
    }
154
}