1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2023 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// 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
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.objectlib.objects;
|
11
|
|
12
|
import org.distorted.library.type.Static3D;
|
13
|
import org.distorted.library.type.Static4D;
|
14
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
15
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
16
|
import org.distorted.objectlib.helpers.ObjectShape;
|
17
|
import org.distorted.objectlib.metadata.Metadata;
|
18
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
19
|
import org.distorted.objectlib.main.InitAssets;
|
20
|
import org.distorted.objectlib.metadata.ListObjects;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
|
24
|
public class TwistySquare0 extends TwistySquare
|
25
|
{
|
26
|
private int[][] mEdges;
|
27
|
private int[] mQuatIndex;
|
28
|
private float[][] mCenters;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
public TwistySquare0(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
33
|
{
|
34
|
super(iconMode, quat, move, scale, meta, asset);
|
35
|
}
|
36
|
|
37
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
38
|
|
39
|
float getFactor()
|
40
|
{
|
41
|
return 1.3f;
|
42
|
}
|
43
|
|
44
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45
|
|
46
|
public int[][] getScrambleEdges()
|
47
|
{
|
48
|
if( mEdges==null )
|
49
|
{
|
50
|
mEdges = new int[][]
|
51
|
{
|
52
|
{ 0,2,1,2,2,2, 9,1,10,1, 11,3,12,3,13,3 }, // 0
|
53
|
{ 0,2,1,2,2,2, 11,3,12,3,13,3 }, // 1 SL
|
54
|
{ 9,1,10,1, 11,4,12,4,13,4 }, // 2 LO
|
55
|
{ 0,4,1,4,2,4, 9,1,10,1, }, // 3 UP
|
56
|
{ 9,1,10,1, } // 4 UL
|
57
|
};
|
58
|
}
|
59
|
|
60
|
return mEdges;
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
public float[][] getCubitPositions(int[] numLayers)
|
66
|
{
|
67
|
if( mCenters ==null )
|
68
|
{
|
69
|
mCenters = new float[][]
|
70
|
{
|
71
|
{ 1.5f, 0.0f, 0.0f },
|
72
|
{-1.5f, 0.0f, 0.0f },
|
73
|
|
74
|
{ 1.5f, 1.0f, 1.5f },
|
75
|
{ 1.5f, 1.0f,-1.5f },
|
76
|
{-1.5f, 1.0f, 1.5f },
|
77
|
{-1.5f, 1.0f,-1.5f },
|
78
|
|
79
|
{ 1.5f,-1.0f, 1.5f },
|
80
|
{ 1.5f,-1.0f,-1.5f },
|
81
|
{-1.5f,-1.0f, 1.5f },
|
82
|
{-1.5f,-1.0f,-1.5f },
|
83
|
};
|
84
|
}
|
85
|
|
86
|
return mCenters;
|
87
|
}
|
88
|
|
89
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90
|
|
91
|
public Static4D getCubitQuats(int cubit, int[] numLayers)
|
92
|
{
|
93
|
if( mQuatIndex==null )
|
94
|
{
|
95
|
mQuatIndex = new int[]
|
96
|
{
|
97
|
0, 2,
|
98
|
0, 3, 1, 2,
|
99
|
0, 3, 1, 2,
|
100
|
};
|
101
|
}
|
102
|
|
103
|
return mObjectQuats[mQuatIndex[cubit]];
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
private float[][] getVertices(int variant)
|
109
|
{
|
110
|
if( variant==0 )
|
111
|
{
|
112
|
return new float[][]
|
113
|
{
|
114
|
{ -1.5f-X, 0.5f, 1.5f },
|
115
|
{ 0.0f, 0.5f, 1.5f },
|
116
|
{ 0.0f, 0.5f,-1.5f },
|
117
|
{ -1.5f+X, 0.5f,-1.5f },
|
118
|
{ -1.5f-X,-0.5f, 1.5f },
|
119
|
{ 0.0f,-0.5f, 1.5f },
|
120
|
{ 0.0f,-0.5f,-1.5f },
|
121
|
{ -1.5f+X,-0.5f,-1.5f }
|
122
|
};
|
123
|
}
|
124
|
else
|
125
|
{
|
126
|
return new float[][]
|
127
|
{
|
128
|
{ -1.5f-X, 0.5f, 0.0f },
|
129
|
{ 0.0f, 0.5f, 0.0f },
|
130
|
{ 0.0f, 0.5f,-1.5F+X },
|
131
|
{ -1.5f, 0.5f,-1.5f },
|
132
|
{ -1.5f-X,-0.5f, 0.0f },
|
133
|
{ 0.0f,-0.5f, 0.0f },
|
134
|
{ 0.0f,-0.5f,-1.5F+X },
|
135
|
{ -1.5f,-0.5f,-1.5f },
|
136
|
};
|
137
|
}
|
138
|
}
|
139
|
|
140
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141
|
|
142
|
public ObjectShape getObjectShape(int variant)
|
143
|
{
|
144
|
int[][] indices =
|
145
|
{
|
146
|
{4,5,1,0},
|
147
|
{5,6,2,1},
|
148
|
{6,7,3,2},
|
149
|
{7,4,0,3},
|
150
|
{0,1,2,3},
|
151
|
{7,6,5,4}
|
152
|
};
|
153
|
|
154
|
return new ObjectShape(getVertices(variant), indices);
|
155
|
}
|
156
|
|
157
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158
|
|
159
|
public ObjectFaceShape getObjectFaceShape(int variant)
|
160
|
{
|
161
|
float h1 = isInIconMode() ? 0.001f : 0.04f;
|
162
|
float h2 = isInIconMode() ? 0.001f : 0.02f;
|
163
|
int angle = 35;
|
164
|
float R = 0.2f;
|
165
|
float S = 0.8f;
|
166
|
float[][] bands = { {h1,angle,R,S,5,1,0}, {h2,angle,R,S,5,1,0}, {0.001f,angle,R,S,5,1,0} };
|
167
|
int[] indices;
|
168
|
|
169
|
if( variant==0 ) indices= new int[] { 0,0,1,2,2,2 };
|
170
|
else if( variant==1 ) indices= new int[] { 0,0,2,2,0,2 };
|
171
|
else indices= new int[] { 0,0,2,2,2,0 };
|
172
|
|
173
|
return new ObjectFaceShape(bands,indices,null);
|
174
|
}
|
175
|
|
176
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
177
|
|
178
|
public ObjectVertexEffects getVertexEffects(int variant)
|
179
|
{
|
180
|
float[][] corners = { {0.03f,0.05f} };
|
181
|
int[] indices = { 0,0,0,0,0,0,0,0 };
|
182
|
float[][] centers = { { -0.75f, 0.0f, variant==0 ? 0.0f : -0.75f } };
|
183
|
return FactoryCubit.generateVertexEffect(getVertices(variant),corners,indices,centers,indices);
|
184
|
}
|
185
|
|
186
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
187
|
|
188
|
public int getNumCubitVariants(int[] numLayers)
|
189
|
{
|
190
|
return 3;
|
191
|
}
|
192
|
|
193
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
194
|
|
195
|
public int getCubitVariant(int cubit, int[] numLayers)
|
196
|
{
|
197
|
return cubit<2 ? 0 : (cubit<6 ? 1:2 );
|
198
|
}
|
199
|
|
200
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
201
|
|
202
|
public float getStickerRadius()
|
203
|
{
|
204
|
return 0.12f;
|
205
|
}
|
206
|
|
207
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
208
|
|
209
|
public float getStickerStroke()
|
210
|
{
|
211
|
return isInIconMode() ? 0.20f : 0.10f;
|
212
|
}
|
213
|
|
214
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
215
|
// PUBLIC API
|
216
|
|
217
|
public int[][] getBasicAngles()
|
218
|
{
|
219
|
return new int[][] { {4,4,4},{2,2},{4,4,4} };
|
220
|
}
|
221
|
|
222
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223
|
|
224
|
public String getShortName()
|
225
|
{
|
226
|
return ListObjects.SQU0_3.name();
|
227
|
}
|
228
|
|
229
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
230
|
|
231
|
public String[][] getTutorials()
|
232
|
{
|
233
|
return new String[][] {
|
234
|
{"gb","RqFhpWTApOo","Square-0 Cube Tutorial","Michele Regano"},
|
235
|
{"es","A6mGEQC06mc","Tutorial Cómo hacer un Square-0","Pablo"},
|
236
|
{"fr","zMIjj46inXg","Résoudre le Square-0","rubik'sIngrid"},
|
237
|
};
|
238
|
}
|
239
|
}
|