Project

General

Profile

Download (6.61 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / TwistyBandaged2Bar.java @ 31cd7256

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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.objects;
21

    
22
import android.content.res.Resources;
23

    
24
import org.distorted.library.main.DistortedEffects;
25
import org.distorted.library.main.DistortedTexture;
26
import org.distorted.library.mesh.MeshSquare;
27
import org.distorted.library.type.Static4D;
28
import org.distorted.main.R;
29

    
30
import java.util.Random;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
class TwistyBandaged2Bar extends TwistyBandagedAbstract
35
{
36
  private static final float[][] POSITIONS = new float[][]
37
      {
38
       { 0.0f, +1.0f,  1.0f, 0.0f, +1.0f,  0.0f, 0.0f, +1.0f, -1.0f},
39
       {-1.0f, -1.0f,  0.0f, 0.0f, -1.0f,  0.0f, 1.0f, -1.0f,  0.0f},
40
       {-1.0f, +1.0f, +1.0f},
41
       {-1.0f, +1.0f,  0.0f},
42
       {-1.0f, +1.0f, -1.0f},
43
       {-1.0f,  0.0f, +1.0f},
44
       {-1.0f,  0.0f,  0.0f},
45
       {-1.0f,  0.0f, -1.0f},
46
       {-1.0f, -1.0f, +1.0f},
47
       {-1.0f, -1.0f, -1.0f},
48
       {+1.0f, +1.0f, +1.0f},
49
       {+1.0f, +1.0f,  0.0f},
50
       {+1.0f, +1.0f, -1.0f},
51
       {+1.0f,  0.0f, +1.0f},
52
       {+1.0f,  0.0f,  0.0f},
53
       {+1.0f,  0.0f, -1.0f},
54
       {+1.0f, -1.0f, +1.0f},
55
       {+1.0f, -1.0f, -1.0f},
56
       { 0.0f,  0.0f, +1.0f},
57
       { 0.0f, -1.0f, +1.0f},
58
       { 0.0f,  0.0f, -1.0f},
59
       { 0.0f, -1.0f, -1.0f}
60
      };
61

    
62
  private final double[][] VERTICES_SMALL = new double[][]
63
          {
64
              { 0.5, 0.5, 0.5 },
65
              { 0.5, 0.5,-0.5 },
66
              { 0.5,-0.5, 0.5 },
67
              { 0.5,-0.5,-0.5 },
68
              {-0.5, 0.5, 0.5 },
69
              {-0.5, 0.5,-0.5 },
70
              {-0.5,-0.5, 0.5 },
71
              {-0.5,-0.5,-0.5 },
72
          };
73

    
74
  private final double[][] VERTICES_BIG = new double[][]
75
          {
76
              // TODO
77
          };
78

    
79
  private final int[][] VERT_INDEXES = new int[][]
80
          {
81
              {2,3,1,0},   // counterclockwise!
82
              {7,6,4,5},
83
              {4,0,1,5},
84
              {7,3,2,6},
85
              {6,2,0,4},
86
              {3,7,5,1}
87
          };
88

    
89
  private static final int[] QUAT_INDICES = new int[] { 2 };
90

    
91
///////////////////////////////////////////////////////////////////////////////////////////////////
92

    
93
  TwistyBandaged2Bar(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
94
                     DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
95
    {
96
    super(size, quat, texture, mesh, effects, moves, ObjectList.BAN2, res, scrWidth);
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  double[][] getVertices(int cubitType)
102
    {
103
     if( cubitType==0 )  // Small cubit
104
      {
105
      return VERTICES_SMALL;
106
      }
107
    if( cubitType==1 )  // Big cubit
108
      {
109
      return VERTICES_BIG;
110
      }
111

    
112
    return null;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  int[][] getVertIndexes(int cubitType)
118
    {
119
    return VERT_INDEXES;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

    
124
  int getNumCubitTypes(int numLayers)
125
    {
126
    return 2;
127
    }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

    
131
  float[][] getPositions()
132
    {
133
    return POSITIONS;
134
    }
135

    
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137

    
138
  int[] getQuatIndices()
139
    {
140
    return QUAT_INDICES;
141
    }
142

    
143
///////////////////////////////////////////////////////////////////////////////////////////////////
144
// PUBLIC API
145

    
146
  public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
147
    {
148
    if( num==0 )
149
      {
150
      int random = rnd.nextInt(4);
151

    
152
      scramble[num][0] = 1;
153
      scramble[num][1] = random>1      ?  2:0;
154
      scramble[num][2] = random%2 == 0 ? -1:1;
155
      }
156
    else
157
      {
158
      boolean even = ((num%2) == 0);
159
      int angle = rnd.nextInt(4);
160

    
161
      scramble[num][0] = even ? 1 : scramble[0][1];
162
      scramble[num][1] = rnd.nextInt(3);
163

    
164
      if( even == (scramble[num][1]==1) )
165
        {
166
        switch(angle)
167
          {
168
          case 0: scramble[num][2] = -2; break;
169
          case 1: scramble[num][2] = -1; break;
170
          case 2: scramble[num][2] =  1; break;
171
          case 3: scramble[num][2] =  2; break;
172
          }
173
        }
174
      else
175
        {
176
        scramble[num][2] = angle>1 ? 2:-2;
177
        }
178
      }
179
    }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

    
183
  public int getObjectName(int numLayers)
184
    {
185
    return R.string.bandaged_2bar;
186
    }
187

    
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189

    
190
  public int getInventor(int numLayers)
191
    {
192
    return R.string.bandaged_2bar_inventor;
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  public int getComplexity(int numLayers)
198
    {
199
    return 8;
200
    }
201
}
(14-14/33)