Project

General

Profile

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

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

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