Project

General

Profile

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

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

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 82eb152a Leszek Koltunski
import java.io.InputStream;
16 29b82486 Leszek Koltunski
17
import org.distorted.library.type.Static3D;
18
import org.distorted.library.type.Static4D;
19 a8295031 Leszek Koltunski
import org.distorted.objectlib.main.InitData;
20 386af988 Leszek Koltunski
import org.distorted.objectlib.main.ShapeHexahedron;
21 4c9ca251 Leszek Koltunski
import org.distorted.objectlib.touchcontrol.TouchControlHexahedron;
22 29b82486 Leszek Koltunski
23
///////////////////////////////////////////////////////////////////////////////////////////////////
24
25 386af988 Leszek Koltunski
abstract class TwistySquare extends ShapeHexahedron
26 29b82486 Leszek Koltunski
{
27
  static final float COS15 = (SQ6+SQ2)/4;
28
  static final float SIN15 = (SQ6-SQ2)/4;
29
  static final float     X = 3*(2-SQ3)/2;
30
31
  // The third, artificial axis is for the generic scrambling algorithm.
32
  // Otherwise it wouldn't be possible to rotate the LO and UP layers
33
  // consecutively.
34
35
  static final Static3D[] ROT_AXIS = new Static3D[]
36
    {
37
      new Static3D(0,+1,0),
38
      new Static3D(COS15,0,SIN15),
39
      new Static3D(0,-1,0),
40
    };
41
42 beee90ab Leszek Koltunski
  private int[][] mBasicAngle;
43 29b82486 Leszek Koltunski
  private float[][] mCuts;
44
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47 a8295031 Leszek Koltunski
  TwistySquare(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
48 29b82486 Leszek Koltunski
    {
49 a8295031 Leszek Koltunski
    super(data, meshState, iconMode, data.getNumLayers()[0], quat, move, scale, stream);
50 29b82486 Leszek Koltunski
    }
51
52 7ec32155 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
53
54
  @Override
55
  public int getInternalColor()
56
    {
57
    return 0xff333333;
58
    }
59
60 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
61
62
  void initializeBasicAngle()
63
    {
64 beee90ab Leszek Koltunski
    mBasicAngle = new int[][] { {12,12,12},{2,2},{12,12,12} };
65 29b82486 Leszek Koltunski
    }
66
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68
69 7bbfc84f Leszek Koltunski
  public float[][] getCuts(int[] numLayers)
70 29b82486 Leszek Koltunski
    {
71 1f264f3e Leszek Koltunski
    if( mCuts==null ) mCuts = new float[][] { {-0.5f,+0.5f}, {0.0f}, {-0.5f,+0.5f} };
72 29b82486 Leszek Koltunski
    return mCuts;
73
    }
74
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
78 29b82486 Leszek Koltunski
    {
79 59c20632 Leszek Koltunski
    return new boolean[][] { {true,false,true}, {true,true}, {true,false,true} };
80 29b82486 Leszek Koltunski
    }
81
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83
84 11fa413d Leszek Koltunski
  public int getTouchControlType()
85 29b82486 Leszek Koltunski
    {
86 0c5d8bf7 Leszek Koltunski
    return TC_CHANGING_SQUARE;
87 29b82486 Leszek Koltunski
    }
88
89
///////////////////////////////////////////////////////////////////////////////////////////////////
90
91 11fa413d Leszek Koltunski
  public int getTouchControlSplit()
92 29b82486 Leszek Koltunski
    {
93 59c20632 Leszek Koltunski
    return TYPE_NOT_SPLIT;
94
    }
95
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
98
  public int[][][] getEnabled()
99
    {
100 82904e62 Leszek Koltunski
    return null;
101 59c20632 Leszek Koltunski
    }
102
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104
105
  public float[] getDist3D(int[] numLayers)
106
    {
107 4c9ca251 Leszek Koltunski
    return TouchControlHexahedron.D3D;
108
    }
109
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111
112
  public Static3D[] getFaceAxis()
113
    {
114
    return TouchControlHexahedron.FACE_AXIS;
115 59c20632 Leszek Koltunski
    }
116
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118
// PUBLIC API
119
120
  public Static3D[] getRotationAxis()
121
    {
122
    return ROT_AXIS;
123 29b82486 Leszek Koltunski
    }
124
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126
127 beee90ab Leszek Koltunski
  public int[][] getBasicAngles()
128 29b82486 Leszek Koltunski
    {
129
    if( mBasicAngle ==null ) initializeBasicAngle();
130
    return mBasicAngle;
131
    }
132
}