Project

General

Profile

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

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

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