Project

General

Profile

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

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

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 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
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 cf93ea4e Leszek Koltunski
  TwistySquare(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InitData data, InitAssets asset)
47 29b82486 Leszek Koltunski
    {
48 cf93ea4e Leszek Koltunski
    super(meshState, iconMode, data.getNumLayers()[0], quat, move, scale, data, asset);
49 29b82486 Leszek Koltunski
    }
50
51 7ec32155 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
52
53
  @Override
54
  public int getInternalColor()
55
    {
56
    return 0xff333333;
57
    }
58
59 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
60
61
  void initializeBasicAngle()
62
    {
63 beee90ab Leszek Koltunski
    mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
64 29b82486 Leszek Koltunski
    }
65
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
69 29b82486 Leszek Koltunski
    {
70 1f264f3e Leszek Koltunski
    if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
71 29b82486 Leszek Koltunski
    return mCuts;
72
    }
73
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
76 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
77 29b82486 Leszek Koltunski
    {
78 59c20632 Leszek Koltunski
    return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
79 29b82486 Leszek Koltunski
    }
80
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83 11fa413d Leszek Koltunski
  public int getTouchControlType()
84 29b82486 Leszek Koltunski
    {
85 0c5d8bf7 Leszek Koltunski
    return TC_CHANGING_SQUARE;
86 29b82486 Leszek Koltunski
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
91 29b82486 Leszek Koltunski
    {
92 59c20632 Leszek Koltunski
    return TYPE_NOT_SPLIT;
93
    }
94
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
97
  public int[][][] getEnabled()
98
    {
99 82904e62 Leszek Koltunski
    return null;
100 59c20632 Leszek Koltunski
    }
101
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103
104
  public float[] getDist3D(int[] numLayers)
105
    {
106 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
107
    }
108
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
111
  public Static3D[] getFaceAxis()
112
    {
113
    return TouchControlHexahedron.FACE_AXIS;
114 59c20632 Leszek Koltunski
    }
115
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
// PUBLIC API
118
119
  public Static3D[] getRotationAxis()
120
    {
121
    return ROT_AXIS;
122 29b82486 Leszek Koltunski
    }
123
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125
126 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
127 29b82486 Leszek Koltunski
    {
128
    if( mBasicAngle ==null ) initializeBasicAngle();
129
    return mBasicAngle;
130
    }
131
}