Revision 2946f04a
Added by Leszek Koltunski 9 months ago
src/main/java/org/distorted/objectlib/main/TwistyObjectControllable.java | ||
---|---|---|
414 | 414 |
// If we are rotating a ghost, and it is ghostBlocked, change the axis, angle and rowBitmap so that |
415 | 415 |
// the puzzle unblocks. |
416 | 416 |
// |
417 |
// Elsewhere, on the ghost scrambling algorithms, we will force the first scramble move to be
|
|
418 |
// along the ghostAxis so a) should never happen.
|
|
417 |
// Elsewhere, in the ghost scrambling algorithms, we also need to force the first scramble move to
|
|
418 |
// be along the ghostAxis.
|
|
419 | 419 |
|
420 | 420 |
synchronized long addRotation(EffectListener listener, int axis, int rowBitmap, int angle, long durationMillis ) |
421 | 421 |
{ |
src/main/java/org/distorted/objectlib/metadata/ListObjects.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
public enum ListObjects |
25 | 25 |
{ |
26 |
GHOST1 ( new MetadataGhostTest1() ), |
|
27 |
GHOST2 ( new MetadataGhostTest2() ), |
|
26 |
GHOST_222 ( new MetadataGhostTest222() ), |
|
27 |
GHOST_422 ( new MetadataGhostTest422() ), |
|
28 |
GHOST_622 ( new MetadataGhostTest622() ), |
|
28 | 29 |
|
29 | 30 |
CUBE_2 ( new MetadataCUBE_2() ), |
30 | 31 |
CUBE_3 ( new MetadataCUBE_3() ), |
src/main/java/org/distorted/objectlib/metadata/MetadataGhostTest1.java | ||
---|---|---|
1 |
|
|
2 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
3 |
// Copyright 2023 Leszek Koltunski // |
|
4 |
// // |
|
5 |
// This file is part of Magic Cube. // |
|
6 |
// // |
|
7 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
8 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
9 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
10 |
|
|
11 |
package org.distorted.objectlib.metadata; |
|
12 |
|
|
13 |
import org.distorted.objectlib.R; |
|
14 |
import org.distorted.objectlib.objects.TwistyGhostTest1; |
|
15 |
|
|
16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
17 |
|
|
18 |
public class MetadataGhostTest1 extends Metadata |
|
19 |
{ |
|
20 |
public static int INDEX = 100000; |
|
21 |
public MetadataGhostTest1() { super( TwistyGhostTest1.class, new int[] {4,2,2}, 0, null, INDEX); } |
|
22 |
public int numScrambles() { return 10; } |
|
23 |
public int icon() { return R.drawable.o2_2; } |
|
24 |
public boolean getActive() { return false; } |
|
25 |
public String getAuthor() { return "Unknown"; } |
|
26 |
public int getYearOfInvention() { return 0; } |
|
27 |
public float getDifficulty() { return 1.0f; } |
|
28 |
public String getObjectName() { return "Ghost1"; } |
|
29 |
public int getCategory() { return CATEGORY_SHAPE_OTH | CATEGORY_AXIS_OTHE | CATEGORY_GHOST; } |
|
30 |
} |
src/main/java/org/distorted/objectlib/metadata/MetadataGhostTest2.java | ||
---|---|---|
1 |
|
|
2 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
3 |
// Copyright 2023 Leszek Koltunski // |
|
4 |
// // |
|
5 |
// This file is part of Magic Cube. // |
|
6 |
// // |
|
7 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
8 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
9 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
10 |
|
|
11 |
package org.distorted.objectlib.metadata; |
|
12 |
|
|
13 |
import org.distorted.objectlib.R; |
|
14 |
import org.distorted.objectlib.objects.TwistyGhostTest2; |
|
15 |
|
|
16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
17 |
|
|
18 |
public class MetadataGhostTest2 extends Metadata |
|
19 |
{ |
|
20 |
public static int INDEX = 100001; |
|
21 |
public MetadataGhostTest2() { super( TwistyGhostTest2.class, new int[] {2,2,2}, 0, null, INDEX); } |
|
22 |
public int numScrambles() { return 10; } |
|
23 |
public int icon() { return R.drawable.o2_2; } |
|
24 |
public boolean getActive() { return false; } |
|
25 |
public String getAuthor() { return "Unknown"; } |
|
26 |
public int getYearOfInvention() { return 0; } |
|
27 |
public float getDifficulty() { return 1.0f; } |
|
28 |
public String getObjectName() { return "Ghost2"; } |
|
29 |
public int getCategory() { return CATEGORY_SHAPE_OTH | CATEGORY_AXIS_OTHE | CATEGORY_GHOST; } |
|
30 |
} |
src/main/java/org/distorted/objectlib/metadata/MetadataGhostTest222.java | ||
---|---|---|
1 |
|
|
2 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
3 |
// Copyright 2023 Leszek Koltunski // |
|
4 |
// // |
|
5 |
// This file is part of Magic Cube. // |
|
6 |
// // |
|
7 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
8 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
9 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
10 |
|
|
11 |
package org.distorted.objectlib.metadata; |
|
12 |
|
|
13 |
import org.distorted.objectlib.R; |
|
14 |
import org.distorted.objectlib.objects.TwistyGhostTest; |
|
15 |
|
|
16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
17 |
|
|
18 |
public class MetadataGhostTest222 extends Metadata |
|
19 |
{ |
|
20 |
public static int INDEX = 100002; |
|
21 |
public MetadataGhostTest222() { super( TwistyGhostTest.class, new int[] {2,2,2}, 0, null, INDEX); } |
|
22 |
public int numScrambles() { return 10; } |
|
23 |
public int icon() { return R.drawable.o2_2; } |
|
24 |
public boolean getActive() { return true; } |
|
25 |
public String getAuthor() { return "Unknown"; } |
|
26 |
public String getObjectName() { return "Ghost222"; } |
|
27 |
public int getCategory() { return CATEGORY_SHAPE_OTH | CATEGORY_AXIS_OTHE | CATEGORY_GHOST; } |
|
28 |
} |
src/main/java/org/distorted/objectlib/metadata/MetadataGhostTest422.java | ||
---|---|---|
1 |
|
|
2 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
3 |
// Copyright 2023 Leszek Koltunski // |
|
4 |
// // |
|
5 |
// This file is part of Magic Cube. // |
|
6 |
// // |
|
7 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
8 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
9 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
10 |
|
|
11 |
package org.distorted.objectlib.metadata; |
|
12 |
|
|
13 |
import org.distorted.objectlib.R; |
|
14 |
import org.distorted.objectlib.objects.TwistyGhostTest; |
|
15 |
|
|
16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
17 |
|
|
18 |
public class MetadataGhostTest422 extends Metadata |
|
19 |
{ |
|
20 |
public static int INDEX = 100004; |
|
21 |
public MetadataGhostTest422() { super( TwistyGhostTest.class, new int[] {4,2,2}, 0, null, INDEX); } |
|
22 |
public int numScrambles() { return 10; } |
|
23 |
public int icon() { return R.drawable.o2_2; } |
|
24 |
public boolean getActive() { return true; } |
|
25 |
public String getAuthor() { return "Unknown"; } |
|
26 |
public String getObjectName() { return "Ghost422"; } |
|
27 |
public int getCategory() { return CATEGORY_SHAPE_OTH | CATEGORY_AXIS_OTHE | CATEGORY_GHOST; } |
|
28 |
} |
src/main/java/org/distorted/objectlib/metadata/MetadataGhostTest622.java | ||
---|---|---|
1 |
|
|
2 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
3 |
// Copyright 2023 Leszek Koltunski // |
|
4 |
// // |
|
5 |
// This file is part of Magic Cube. // |
|
6 |
// // |
|
7 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
8 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
9 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
10 |
|
|
11 |
package org.distorted.objectlib.metadata; |
|
12 |
|
|
13 |
import org.distorted.objectlib.R; |
|
14 |
import org.distorted.objectlib.objects.TwistyGhostTest; |
|
15 |
|
|
16 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
17 |
|
|
18 |
public class MetadataGhostTest622 extends Metadata |
|
19 |
{ |
|
20 |
public static int INDEX = 100006; |
|
21 |
public MetadataGhostTest622() { super( TwistyGhostTest.class, new int[] {6,2,2}, 0, null, INDEX); } |
|
22 |
public int numScrambles() { return 10; } |
|
23 |
public int icon() { return R.drawable.o2_2; } |
|
24 |
public boolean getActive() { return true; } |
|
25 |
public String getAuthor() { return "Unknown"; } |
|
26 |
public String getObjectName() { return "Ghost622"; } |
|
27 |
public int getCategory() { return CATEGORY_SHAPE_OTH | CATEGORY_AXIS_OTHE | CATEGORY_GHOST; } |
|
28 |
} |
src/main/java/org/distorted/objectlib/objects/TwistyGhostTest.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2019 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD; |
|
13 |
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT; |
|
14 |
|
|
15 |
import org.distorted.library.effect.EffectName; |
|
16 |
import org.distorted.library.type.Static3D; |
|
17 |
import org.distorted.library.type.Static4D; |
|
18 |
import org.distorted.objectlib.helpers.FactoryCubit; |
|
19 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
|
20 |
import org.distorted.objectlib.helpers.ObjectShape; |
|
21 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
|
22 |
import org.distorted.objectlib.main.InitAssets; |
|
23 |
import org.distorted.objectlib.metadata.Metadata; |
|
24 |
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator; |
|
25 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
|
26 |
import org.distorted.objectlib.touchcontrol.TouchControlCuboids; |
|
27 |
|
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
29 |
|
|
30 |
public class TwistyGhostTest extends ShapeHexahedron |
|
31 |
{ |
|
32 |
private static final int GHOST_ANGLE = 28; |
|
33 |
|
|
34 |
static final Static3D[] ROT_AXIS = new Static3D[] |
|
35 |
{ |
|
36 |
new Static3D(1,0,0), |
|
37 |
new Static3D(0,1,0), |
|
38 |
new Static3D(0,0,1) |
|
39 |
}; |
|
40 |
|
|
41 |
private int[][] mEdges; |
|
42 |
private float[][] mCuts; |
|
43 |
private int[][] mBasicAngle; |
|
44 |
private int[] mQuatIndex; |
|
45 |
private float[][] mPosition; |
|
46 |
|
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
|
|
49 |
public TwistyGhostTest(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset) |
|
50 |
{ |
|
51 |
super(iconMode, (meta.getNumLayers()[0]+meta.getNumLayers()[1]+meta.getNumLayers()[2])/3.0f, quat, move, scale, meta, asset); |
|
52 |
} |
|
53 |
|
|
54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
55 |
|
|
56 |
@Override |
|
57 |
public int getGhostAngle() |
|
58 |
{ |
|
59 |
return GHOST_ANGLE; |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
@Override |
|
65 |
public int getGhostFirstRow() |
|
66 |
{ |
|
67 |
return (1+getNumLayers()[0]) / 2; |
|
68 |
} |
|
69 |
|
|
70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
71 |
|
|
72 |
public int[][] getScrambleEdges() |
|
73 |
{ |
|
74 |
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle); |
|
75 |
return mEdges; |
|
76 |
} |
|
77 |
|
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
private float[][] getVertices(int variant) |
|
81 |
{ |
|
82 |
float D = variant==0 ? 0.0f : (float)Math.tan( (Math.PI*GHOST_ANGLE)/180 ); |
|
83 |
|
|
84 |
return new float[][] |
|
85 |
{ |
|
86 |
{ 0.5f, 0.5f-D, 0.5f }, |
|
87 |
{ 0.5f, 0.5f ,-0.5f }, |
|
88 |
{ 0.5f,-0.5f , 0.5f }, |
|
89 |
{ 0.5f,-0.5f ,-0.5f-D }, |
|
90 |
{-0.5f, 0.5f-D, 0.5f }, |
|
91 |
{-0.5f, 0.5f ,-0.5f }, |
|
92 |
{-0.5f,-0.5f , 0.5f }, |
|
93 |
{-0.5f,-0.5f ,-0.5f-D }, |
|
94 |
}; |
|
95 |
} |
|
96 |
|
|
97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
|
99 |
public ObjectShape getObjectShape(int variant) |
|
100 |
{ |
|
101 |
int[][] indices = |
|
102 |
{ |
|
103 |
{2,3,1,0}, |
|
104 |
{7,6,4,5}, |
|
105 |
{4,0,1,5}, |
|
106 |
{7,3,2,6}, |
|
107 |
{6,2,0,4}, |
|
108 |
{3,7,5,1} |
|
109 |
}; |
|
110 |
|
|
111 |
return new ObjectShape(getVertices(variant), indices); |
|
112 |
} |
|
113 |
|
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
public ObjectFaceShape getObjectFaceShape(int variant) |
|
117 |
{ |
|
118 |
float height = isInIconMode() ? 0.001f : 0.045f; |
|
119 |
int angle = 35; |
|
120 |
float R = 0.5f; |
|
121 |
float S = 0.7f; |
|
122 |
float[][] bands = { {height,angle,R,S,6,2,2}, {0.001f,angle,R,S,6,2,2} }; |
|
123 |
int[] indices = new int[] {1,0,1,0,1,0}; |
|
124 |
|
|
125 |
return new ObjectFaceShape(bands,indices, null); |
|
126 |
} |
|
127 |
|
|
128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
129 |
|
|
130 |
public ObjectVertexEffects getVertexEffects(int variant) |
|
131 |
{ |
|
132 |
float[][] corners = {{0.036f, 0.12f}}; |
|
133 |
float[][] centers = {{0,0,0}}; |
|
134 |
int[] indices = {0,0,0,0,0,0,0,0}; |
|
135 |
|
|
136 |
if( variant==0 ) |
|
137 |
{ |
|
138 |
return FactoryCubit.generateVertexEffect(getVertices(variant), corners, indices, centers, indices); |
|
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
float[][] vertices = getVertices(variant); |
|
143 |
int numEff = vertices.length+1; |
|
144 |
String[] names = new String[numEff]; |
|
145 |
float[][] vars = new float[numEff][]; |
|
146 |
float[][] cents= new float[numEff][]; |
|
147 |
float[][] regs = new float[numEff][]; |
|
148 |
boolean[] uses = new boolean[numEff]; |
|
149 |
String NAME = EffectName.DEFORM.name(); |
|
150 |
|
|
151 |
for(int i=0; i<numEff-1; i++) |
|
152 |
{ |
|
153 |
int index = indices[i]; |
|
154 |
|
|
155 |
float[] ce = centers[index]; |
|
156 |
float[] ve = vertices[i]; |
|
157 |
float S = corners[index][0]; |
|
158 |
float R = corners[index][1]; |
|
159 |
|
|
160 |
float CX = ve[0]; |
|
161 |
float CY = ve[1]; |
|
162 |
float CZ = ve[2]; |
|
163 |
float X = S*(ce[0]-CX); |
|
164 |
float Y = S*(ce[1]-CY); |
|
165 |
float Z = S*(ce[2]-CZ); |
|
166 |
|
|
167 |
names[i]= NAME; |
|
168 |
vars[i] = new float[] { 0, X,Y,Z, 1 }; |
|
169 |
cents[i]= new float[] { CX, CY, CZ }; |
|
170 |
regs[i] = new float[] { 0,0,0, R }; |
|
171 |
uses[i] = false; |
|
172 |
} |
|
173 |
|
|
174 |
names[numEff-1] = EffectName.VERTEX_ROTATE.name(); |
|
175 |
vars[numEff-1] = new float[] { 0,-GHOST_ANGLE,1,0,0 }; // see VertexEffect.constructEffect |
|
176 |
cents[numEff-1] = new float[] { 0.0f,0.5f,-0.5f }; |
|
177 |
regs[numEff-1] = new float[] { 0,0,0,0 }; |
|
178 |
uses[numEff-1] = true; |
|
179 |
|
|
180 |
return new ObjectVertexEffects(names,vars,cents,regs,uses); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
185 |
|
|
186 |
public float[][] getCubitPositions() |
|
187 |
{ |
|
188 |
if( mPosition==null ) |
|
189 |
{ |
|
190 |
final float D = 0.5f; |
|
191 |
int numL = getNumLayers()[0]; |
|
192 |
mPosition = new float[4*numL][]; |
|
193 |
|
|
194 |
for(int l=0, k=1-numL; l<numL; l++, k+=2) |
|
195 |
{ |
|
196 |
mPosition[4*l ] = new float[] {k*D,-D,-D}; |
|
197 |
mPosition[4*l+1] = new float[] {k*D,-D, D}; |
|
198 |
mPosition[4*l+2] = new float[] {k*D, D,-D}; |
|
199 |
mPosition[4*l+3] = new float[] {k*D, D, D}; |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
return mPosition; |
|
204 |
} |
|
205 |
|
|
206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
207 |
|
|
208 |
public Static4D getCubitOrigQuat(int cubit) |
|
209 |
{ |
|
210 |
if( mQuatIndex==null ) |
|
211 |
{ |
|
212 |
int numL = getNumLayers()[0]; |
|
213 |
int firstR = getGhostFirstRow(); |
|
214 |
mQuatIndex = new int[4*numL]; |
|
215 |
|
|
216 |
for(int l=0; l<firstR; l++) |
|
217 |
{ |
|
218 |
mQuatIndex[4*l ] = 0; |
|
219 |
mQuatIndex[4*l+1] = 1; |
|
220 |
mQuatIndex[4*l+2] = 3; |
|
221 |
mQuatIndex[4*l+3] = 2; |
|
222 |
} |
|
223 |
for(int l=firstR; l<numL; l++) |
|
224 |
{ |
|
225 |
mQuatIndex[4*l ] = 3; |
|
226 |
mQuatIndex[4*l+1] = 0; |
|
227 |
mQuatIndex[4*l+2] = 2; |
|
228 |
mQuatIndex[4*l+3] = 1; |
|
229 |
} |
|
230 |
} |
|
231 |
|
|
232 |
return mObjectQuats[mQuatIndex[cubit]]; |
|
233 |
} |
|
234 |
|
|
235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
236 |
|
|
237 |
public int getNumCubitVariants() |
|
238 |
{ |
|
239 |
return 2; |
|
240 |
} |
|
241 |
|
|
242 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
243 |
|
|
244 |
public int getCubitVariant(int cubit) |
|
245 |
{ |
|
246 |
return cubit<4*getGhostFirstRow() ? 0:1; |
|
247 |
} |
|
248 |
|
|
249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
250 |
|
|
251 |
public float[][] getCuts() |
|
252 |
{ |
|
253 |
if( mCuts==null ) |
|
254 |
{ |
|
255 |
int numL = getNumLayers()[0]; |
|
256 |
float[] c1 = new float[numL-1]; |
|
257 |
for(int c=0; c<numL-1; c++) c1[c] = c+1-0.5f*numL; |
|
258 |
float[] c2 = {0}; |
|
259 |
mCuts = new float[][] { c1,c2,c2 }; |
|
260 |
} |
|
261 |
|
|
262 |
return mCuts; |
|
263 |
} |
|
264 |
|
|
265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
266 |
|
|
267 |
public boolean[][] getLayerRotatable() |
|
268 |
{ |
|
269 |
int numL = getNumLayers()[0]; |
|
270 |
boolean[] r1 = new boolean[numL]; |
|
271 |
for(int l=0; l<numL; l++) r1[l] = true; |
|
272 |
boolean[] r2 = new boolean[] {true,true}; |
|
273 |
|
|
274 |
return new boolean[][] { r1,r2,r2 }; |
|
275 |
} |
|
276 |
|
|
277 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
278 |
|
|
279 |
public int getTouchControlType() |
|
280 |
{ |
|
281 |
return TC_CHANGING_SHAPEMOD; |
|
282 |
} |
|
283 |
|
|
284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
285 |
|
|
286 |
public int getTouchControlSplit() |
|
287 |
{ |
|
288 |
return TYPE_NOT_SPLIT; |
|
289 |
} |
|
290 |
|
|
291 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
292 |
|
|
293 |
public int[][][] getEnabled() |
|
294 |
{ |
|
295 |
return null; |
|
296 |
} |
|
297 |
|
|
298 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
299 |
|
|
300 |
public float[] getDist3D() |
|
301 |
{ |
|
302 |
int[] numLayers = getNumLayers(); |
|
303 |
float x = numLayers[0]; |
|
304 |
float y = numLayers[1]; |
|
305 |
float z = numLayers[2]; |
|
306 |
float a = (x+y+z)/1.5f; |
|
307 |
|
|
308 |
return new float[] {x/a,x/a,y/a,y/a,z/a,z/a}; |
|
309 |
} |
|
310 |
|
|
311 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
312 |
|
|
313 |
public Static3D[] getFaceAxis() |
|
314 |
{ |
|
315 |
return TouchControlCuboids.FACE_AXIS; |
|
316 |
} |
|
317 |
|
|
318 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
319 |
|
|
320 |
public float getStickerRadius() |
|
321 |
{ |
|
322 |
return 0.10f; |
|
323 |
} |
|
324 |
|
|
325 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
326 |
|
|
327 |
public float getStickerStroke() |
|
328 |
{ |
|
329 |
return isInIconMode() ? 0.16f : 0.08f ; |
|
330 |
} |
|
331 |
|
|
332 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
333 |
|
|
334 |
public float[][][] getStickerAngles() |
|
335 |
{ |
|
336 |
return null; |
|
337 |
} |
|
338 |
|
|
339 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
340 |
// PUBLIC API |
|
341 |
|
|
342 |
public Static3D[] getRotationAxis() |
|
343 |
{ |
|
344 |
return ROT_AXIS; |
|
345 |
} |
|
346 |
|
|
347 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
348 |
|
|
349 |
public String getShortName() |
|
350 |
{ |
|
351 |
return "GHOST_"+getNumLayers()[0]; |
|
352 |
} |
|
353 |
|
|
354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
355 |
|
|
356 |
public int[][] getBasicAngles() |
|
357 |
{ |
|
358 |
if( mBasicAngle==null ) |
|
359 |
{ |
|
360 |
int numL = getNumLayers()[0]; |
|
361 |
int val = numL==2 ? 4:2; |
|
362 |
int[] a1 = new int[numL]; |
|
363 |
for(int l=0; l<numL; l++) a1[l] = 4; |
|
364 |
int[] a2 = {val,val}; |
|
365 |
mBasicAngle = new int[][] { a1,a2,a2 }; |
|
366 |
} |
|
367 |
return mBasicAngle; |
|
368 |
} |
|
369 |
|
|
370 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
371 |
|
|
372 |
public String[][] getTutorials() |
|
373 |
{ |
|
374 |
return null; |
|
375 |
} |
|
376 |
} |
src/main/java/org/distorted/objectlib/objects/TwistyGhostTest1.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2019 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD; |
|
13 |
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT; |
|
14 |
|
|
15 |
import org.distorted.library.effect.EffectName; |
|
16 |
import org.distorted.library.type.Static3D; |
|
17 |
import org.distorted.library.type.Static4D; |
|
18 |
import org.distorted.objectlib.helpers.FactoryCubit; |
|
19 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
|
20 |
import org.distorted.objectlib.helpers.ObjectShape; |
|
21 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
|
22 |
import org.distorted.objectlib.main.InitAssets; |
|
23 |
import org.distorted.objectlib.metadata.Metadata; |
|
24 |
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator; |
|
25 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
|
26 |
import org.distorted.objectlib.touchcontrol.TouchControlCuboids; |
|
27 |
|
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
29 |
|
|
30 |
public class TwistyGhostTest1 extends ShapeHexahedron |
|
31 |
{ |
|
32 |
private static final int GHOST_ANGLE = 28; |
|
33 |
|
|
34 |
static final Static3D[] ROT_AXIS = new Static3D[] |
|
35 |
{ |
|
36 |
new Static3D(1,0,0), |
|
37 |
new Static3D(0,1,0), |
|
38 |
new Static3D(0,0,1) |
|
39 |
}; |
|
40 |
|
|
41 |
private int[][] mEdges; |
|
42 |
private float[][] mCuts; |
|
43 |
private int[][] mBasicAngle; |
|
44 |
private int[] mQuatIndex; |
|
45 |
private float[][] mPosition; |
|
46 |
|
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
|
|
49 |
public TwistyGhostTest1(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset) |
|
50 |
{ |
|
51 |
super(iconMode, (meta.getNumLayers()[0]+meta.getNumLayers()[1]+meta.getNumLayers()[2])/3.0f, quat, move, scale, meta, asset); |
|
52 |
} |
|
53 |
|
|
54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
55 |
|
|
56 |
@Override |
|
57 |
public int getGhostAngle() |
|
58 |
{ |
|
59 |
return GHOST_ANGLE; |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
@Override |
|
65 |
public int getGhostFirstRow() |
|
66 |
{ |
|
67 |
return 2; |
|
68 |
} |
|
69 |
|
|
70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
71 |
|
|
72 |
public int[][] getScrambleEdges() |
|
73 |
{ |
|
74 |
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle); |
|
75 |
return mEdges; |
|
76 |
} |
|
77 |
|
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
private float[][] getVertices(int variant) |
|
81 |
{ |
|
82 |
float D = variant==0 ? 0.0f : (float)Math.tan( (Math.PI*GHOST_ANGLE)/180 ); |
|
83 |
|
|
84 |
return new float[][] |
|
85 |
{ |
|
86 |
{ 0.5f, 0.5f-D, 0.5f }, |
|
87 |
{ 0.5f, 0.5f ,-0.5f }, |
|
88 |
{ 0.5f,-0.5f , 0.5f }, |
|
89 |
{ 0.5f,-0.5f ,-0.5f-D }, |
|
90 |
{-0.5f, 0.5f-D, 0.5f }, |
|
91 |
{-0.5f, 0.5f ,-0.5f }, |
|
92 |
{-0.5f,-0.5f , 0.5f }, |
|
93 |
{-0.5f,-0.5f ,-0.5f-D }, |
|
94 |
}; |
|
95 |
} |
|
96 |
|
|
97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
|
99 |
public ObjectShape getObjectShape(int variant) |
|
100 |
{ |
|
101 |
int[][] indices = |
|
102 |
{ |
|
103 |
{2,3,1,0}, |
|
104 |
{7,6,4,5}, |
|
105 |
{4,0,1,5}, |
|
106 |
{7,3,2,6}, |
|
107 |
{6,2,0,4}, |
|
108 |
{3,7,5,1} |
|
109 |
}; |
|
110 |
|
|
111 |
return new ObjectShape(getVertices(variant), indices); |
|
112 |
} |
|
113 |
|
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
public ObjectFaceShape getObjectFaceShape(int variant) |
|
117 |
{ |
|
118 |
float height = isInIconMode() ? 0.001f : 0.045f; |
|
119 |
int angle = 35; |
|
120 |
float R = 0.5f; |
|
121 |
float S = 0.7f; |
|
122 |
|
|
123 |
float[][] bands = |
|
124 |
{ |
|
125 |
{height,angle,R,S,6,2,2}, |
|
126 |
{0.001f,angle,R,S,6,2,2}, |
|
127 |
}; |
|
128 |
|
|
129 |
int[] indices = new int[] {1,0,1,0,1,0}; |
|
130 |
|
|
131 |
return new ObjectFaceShape(bands,indices, null); |
|
132 |
} |
|
133 |
|
|
134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
|
|
136 |
public ObjectVertexEffects getVertexEffects(int variant) |
|
137 |
{ |
|
138 |
float[][] corners = {{0.036f, 0.12f}}; |
|
139 |
float[][] centers = {{0,0,0}}; |
|
140 |
int[] indices = {0,0,0,0,0,0,0,0}; |
|
141 |
|
|
142 |
if( variant==0 ) |
|
143 |
{ |
|
144 |
return FactoryCubit.generateVertexEffect(getVertices(variant), corners, indices, centers, indices); |
|
145 |
} |
|
146 |
else |
|
147 |
{ |
|
148 |
float[][] vertices = getVertices(variant); |
|
149 |
int numEff = vertices.length+1; |
|
150 |
String[] names = new String[numEff]; |
|
151 |
float[][] vars = new float[numEff][]; |
|
152 |
float[][] cents= new float[numEff][]; |
|
153 |
float[][] regs = new float[numEff][]; |
|
154 |
boolean[] uses = new boolean[numEff]; |
|
155 |
String NAME = EffectName.DEFORM.name(); |
|
156 |
|
|
157 |
for(int i=0; i<numEff-1; i++) |
|
158 |
{ |
|
159 |
int index = indices[i]; |
|
160 |
|
|
161 |
float[] ce = centers[index]; |
|
162 |
float[] ve = vertices[i]; |
|
163 |
float S = corners[index][0]; |
|
164 |
float R = corners[index][1]; |
|
165 |
|
|
166 |
float CX = ve[0]; |
|
167 |
float CY = ve[1]; |
|
168 |
float CZ = ve[2]; |
|
169 |
float X = S*(ce[0]-CX); |
|
170 |
float Y = S*(ce[1]-CY); |
|
171 |
float Z = S*(ce[2]-CZ); |
|
172 |
|
|
173 |
names[i]= NAME; |
|
174 |
vars[i] = new float[] { 0, X,Y,Z, 1 }; |
|
175 |
cents[i]= new float[] { CX, CY, CZ }; |
|
176 |
regs[i] = new float[] { 0,0,0, R }; |
|
177 |
uses[i] = false; |
|
178 |
} |
|
179 |
|
|
180 |
names[numEff-1] = EffectName.VERTEX_ROTATE.name(); |
|
181 |
vars[numEff-1] = new float[] { 0,-GHOST_ANGLE,1,0,0 }; // see VertexEffect.constructEffect |
|
182 |
cents[numEff-1] = new float[] { 0.0f,0.5f,-0.5f }; |
|
183 |
regs[numEff-1] = new float[] { 0,0,0,0 }; |
|
184 |
uses[numEff-1] = true; |
|
185 |
|
|
186 |
return new ObjectVertexEffects(names,vars,cents,regs,uses); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 |
|
|
192 |
public float[][] getCubitPositions() |
|
193 |
{ |
|
194 |
if( mPosition==null ) |
|
195 |
{ |
|
196 |
final float D = 0.5f; |
|
197 |
|
|
198 |
mPosition = new float[][] |
|
199 |
{ |
|
200 |
{-3*D,-D,-D }, |
|
201 |
{-3*D,-D, D }, |
|
202 |
{-3*D, D,-D }, |
|
203 |
{-3*D, D, D }, |
|
204 |
{ -D,-D,-D }, |
|
205 |
{ -D,-D, D }, |
|
206 |
{ -D, D,-D }, |
|
207 |
{ -D, D, D }, |
|
208 |
|
|
209 |
{ D,-D,-D }, |
|
210 |
{ D,-D, D }, |
|
211 |
{ D, D,-D }, |
|
212 |
{ D, D, D }, |
|
213 |
{ 3*D,-D,-D }, |
|
214 |
{ 3*D,-D, D }, |
|
215 |
{ 3*D, D,-D }, |
|
216 |
{ 3*D, D, D }, |
|
217 |
}; |
|
218 |
} |
|
219 |
|
|
220 |
return mPosition; |
|
221 |
} |
|
222 |
|
|
223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
224 |
|
|
225 |
public Static4D getCubitOrigQuat(int cubit) |
|
226 |
{ |
|
227 |
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,3,2,0,1,3,2, 3,0,2,1,3,0,2,1 }; |
|
228 |
return mObjectQuats[mQuatIndex[cubit]]; |
|
229 |
} |
|
230 |
|
|
231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
232 |
|
|
233 |
public int getNumCubitVariants() |
|
234 |
{ |
|
235 |
return 2; |
|
236 |
} |
|
237 |
|
|
238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
239 |
|
|
240 |
public int getCubitVariant(int cubit) |
|
241 |
{ |
|
242 |
return cubit<8 ? 0:1; |
|
243 |
} |
|
244 |
|
|
245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
246 |
|
|
247 |
public float[][] getCuts() |
|
248 |
{ |
|
249 |
if( mCuts==null ) |
|
250 |
{ |
|
251 |
float[] c1 = {-1,0,1}; |
|
252 |
float[] c2 = {0}; |
|
253 |
mCuts = new float[][] { c1,c2,c2 }; |
|
254 |
} |
|
255 |
|
|
256 |
return mCuts; |
|
257 |
} |
|
258 |
|
|
259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
260 |
|
|
261 |
public boolean[][] getLayerRotatable() |
|
262 |
{ |
|
263 |
boolean[] r1 = new boolean[] {true,true,true,true}; |
|
264 |
boolean[] r2 = new boolean[] {true,true}; |
|
265 |
return new boolean[][] { r1,r2,r2 }; |
|
266 |
} |
|
267 |
|
|
268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 |
|
|
270 |
public int getTouchControlType() |
|
271 |
{ |
|
272 |
return TC_CHANGING_SHAPEMOD; |
|
273 |
} |
|
274 |
|
|
275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
276 |
|
|
277 |
public int getTouchControlSplit() |
|
278 |
{ |
|
279 |
return TYPE_NOT_SPLIT; |
|
280 |
} |
|
281 |
|
|
282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
283 |
|
|
284 |
public int[][][] getEnabled() |
|
285 |
{ |
|
286 |
return null; |
|
287 |
} |
|
288 |
|
|
289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
290 |
|
|
291 |
public float[] getDist3D() |
|
292 |
{ |
|
293 |
int[] numLayers = getNumLayers(); |
|
294 |
float x = numLayers[0]; |
|
295 |
float y = numLayers[1]; |
|
296 |
float z = numLayers[2]; |
|
297 |
float a = (x+y+z)/1.5f; |
|
298 |
|
|
299 |
return new float[] {x/a,x/a,y/a,y/a,z/a,z/a}; |
|
300 |
} |
|
301 |
|
|
302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
303 |
|
|
304 |
public Static3D[] getFaceAxis() |
|
305 |
{ |
|
306 |
return TouchControlCuboids.FACE_AXIS; |
|
307 |
} |
|
308 |
|
|
309 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
310 |
|
|
311 |
public float getStickerRadius() |
|
312 |
{ |
|
313 |
return 0.10f; |
|
314 |
} |
|
315 |
|
|
316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
317 |
|
|
318 |
public float getStickerStroke() |
|
319 |
{ |
|
320 |
return isInIconMode() ? 0.16f : 0.08f ; |
|
321 |
} |
|
322 |
|
|
323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
324 |
|
|
325 |
public float[][][] getStickerAngles() |
|
326 |
{ |
|
327 |
return null; |
|
328 |
} |
|
329 |
|
|
330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
331 |
// PUBLIC API |
|
332 |
|
|
333 |
public Static3D[] getRotationAxis() |
|
334 |
{ |
|
335 |
return ROT_AXIS; |
|
336 |
} |
|
337 |
|
|
338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
339 |
|
|
340 |
public String getShortName() |
|
341 |
{ |
|
342 |
return "GHOST1"; |
|
343 |
} |
|
344 |
|
|
345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
346 |
|
|
347 |
public int[][] getBasicAngles() |
|
348 |
{ |
|
349 |
if( mBasicAngle==null ) |
|
350 |
{ |
|
351 |
int[] a1 = {4,4,4,4}; |
|
352 |
int[] a2 = {2,2}; |
|
353 |
mBasicAngle = new int[][] { a1,a2,a2 }; |
|
354 |
} |
|
355 |
return mBasicAngle; |
|
356 |
} |
|
357 |
|
|
358 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
359 |
|
|
360 |
public String[][] getTutorials() |
|
361 |
{ |
|
362 |
return null; |
|
363 |
} |
|
364 |
} |
src/main/java/org/distorted/objectlib/objects/TwistyGhostTest2.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2019 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 static org.distorted.objectlib.touchcontrol.TouchControl.TC_CHANGING_SHAPEMOD; |
|
13 |
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT; |
|
14 |
|
|
15 |
import org.distorted.library.effect.EffectName; |
|
16 |
import org.distorted.library.type.Static3D; |
|
17 |
import org.distorted.library.type.Static4D; |
|
18 |
import org.distorted.objectlib.helpers.FactoryCubit; |
|
19 |
import org.distorted.objectlib.helpers.ObjectFaceShape; |
|
20 |
import org.distorted.objectlib.helpers.ObjectShape; |
|
21 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
|
22 |
import org.distorted.objectlib.main.InitAssets; |
|
23 |
import org.distorted.objectlib.metadata.Metadata; |
|
24 |
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator; |
|
25 |
import org.distorted.objectlib.shape.ShapeHexahedron; |
|
26 |
import org.distorted.objectlib.touchcontrol.TouchControlCuboids; |
|
27 |
|
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
29 |
|
|
30 |
public class TwistyGhostTest2 extends ShapeHexahedron |
|
31 |
{ |
|
32 |
private static final int GHOST_ANGLE = 24; |
|
33 |
|
|
34 |
static final Static3D[] ROT_AXIS = new Static3D[] |
|
35 |
{ |
|
36 |
new Static3D(1,0,0), |
|
37 |
new Static3D(0,1,0), |
|
38 |
new Static3D(0,0,1) |
|
39 |
}; |
|
40 |
|
|
41 |
private int[][] mEdges; |
|
42 |
private float[][] mCuts; |
|
43 |
private int[][] mBasicAngle; |
|
44 |
private int[] mQuatIndex; |
|
45 |
private float[][] mPosition; |
|
46 |
|
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
|
|
49 |
public TwistyGhostTest2(int iconMode, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset) |
|
50 |
{ |
|
51 |
super(iconMode, (meta.getNumLayers()[0]+meta.getNumLayers()[1]+meta.getNumLayers()[2])/3.0f, quat, move, scale, meta, asset); |
|
52 |
} |
|
53 |
|
|
54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
55 |
|
|
56 |
@Override |
|
57 |
public int getGhostAngle() |
|
58 |
{ |
|
59 |
return GHOST_ANGLE; |
|
60 |
} |
|
61 |
|
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
63 |
|
|
64 |
@Override |
|
65 |
public int getGhostFirstRow() |
|
66 |
{ |
|
67 |
return 1; |
|
68 |
} |
|
69 |
|
|
70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
71 |
|
|
72 |
public int[][] getScrambleEdges() |
|
73 |
{ |
|
74 |
if( mEdges==null ) mEdges = ScrambleEdgeGenerator.getScrambleEdgesSingle(mBasicAngle); |
|
75 |
return mEdges; |
|
76 |
} |
|
77 |
|
|
78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
79 |
|
|
80 |
private float[][] getVertices(int variant) |
|
81 |
{ |
|
82 |
float D = variant==0 ? 0.0f : (float)Math.tan( (Math.PI*GHOST_ANGLE)/180 ); |
|
83 |
|
|
84 |
return new float[][] |
|
85 |
{ |
|
86 |
{ 0.5f, 0.5f-D, 0.5f }, |
|
87 |
{ 0.5f, 0.5f ,-0.5f }, |
|
88 |
{ 0.5f,-0.5f , 0.5f }, |
|
89 |
{ 0.5f,-0.5f ,-0.5f-D }, |
|
90 |
{-0.5f, 0.5f-D, 0.5f }, |
|
91 |
{-0.5f, 0.5f ,-0.5f }, |
|
92 |
{-0.5f,-0.5f , 0.5f }, |
|
93 |
{-0.5f,-0.5f ,-0.5f-D }, |
|
94 |
}; |
|
95 |
} |
|
96 |
|
|
97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
98 |
|
|
99 |
public ObjectShape getObjectShape(int variant) |
|
100 |
{ |
|
101 |
int[][] indices = |
|
102 |
{ |
|
103 |
{2,3,1,0}, |
|
104 |
{7,6,4,5}, |
|
105 |
{4,0,1,5}, |
|
106 |
{7,3,2,6}, |
|
107 |
{6,2,0,4}, |
|
108 |
{3,7,5,1} |
|
109 |
}; |
|
110 |
|
|
111 |
return new ObjectShape(getVertices(variant), indices); |
|
112 |
} |
|
113 |
|
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
public ObjectFaceShape getObjectFaceShape(int variant) |
|
117 |
{ |
|
118 |
float height = isInIconMode() ? 0.001f : 0.045f; |
|
119 |
int angle = 35; |
|
120 |
float R = 0.5f; |
|
121 |
float S = 0.7f; |
|
122 |
|
|
123 |
float[][] bands = |
|
124 |
{ |
|
125 |
{height,angle,R,S,6,2,2}, |
|
126 |
{0.001f,angle,R,S,6,2,2}, |
|
127 |
}; |
|
128 |
|
|
129 |
int[] indices = new int[] {1,0,1,0,1,0}; |
|
130 |
|
|
131 |
return new ObjectFaceShape(bands,indices, null); |
|
132 |
} |
|
133 |
|
|
134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
|
|
136 |
public ObjectVertexEffects getVertexEffects(int variant) |
|
137 |
{ |
|
138 |
float[][] corners = {{0.036f, 0.12f}}; |
|
139 |
float[][] centers = {{0,0,0}}; |
|
140 |
int[] indices = {0,0,0,0,0,0,0,0}; |
|
141 |
|
|
142 |
if( variant==0 ) |
|
143 |
{ |
|
144 |
return FactoryCubit.generateVertexEffect(getVertices(variant), corners, indices, centers, indices); |
|
145 |
} |
|
146 |
else |
|
147 |
{ |
|
148 |
float[][] vertices = getVertices(variant); |
|
149 |
int numEff = vertices.length+1; |
|
150 |
String[] names = new String[numEff]; |
|
151 |
float[][] vars = new float[numEff][]; |
|
152 |
float[][] cents= new float[numEff][]; |
|
153 |
float[][] regs = new float[numEff][]; |
|
154 |
boolean[] uses = new boolean[numEff]; |
|
155 |
String NAME = EffectName.DEFORM.name(); |
|
156 |
|
|
157 |
for(int i=0; i<numEff-1; i++) |
|
158 |
{ |
|
159 |
int index = indices[i]; |
|
160 |
|
|
161 |
float[] ce = centers[index]; |
|
162 |
float[] ve = vertices[i]; |
|
163 |
float S = corners[index][0]; |
|
164 |
float R = corners[index][1]; |
|
165 |
|
|
166 |
float CX = ve[0]; |
|
167 |
float CY = ve[1]; |
|
168 |
float CZ = ve[2]; |
|
169 |
float X = S*(ce[0]-CX); |
|
170 |
float Y = S*(ce[1]-CY); |
|
171 |
float Z = S*(ce[2]-CZ); |
|
172 |
|
|
173 |
names[i]= NAME; |
|
174 |
vars[i] = new float[] { 0, X,Y,Z, 1 }; |
|
175 |
cents[i]= new float[] { CX, CY, CZ }; |
|
176 |
regs[i] = new float[] { 0,0,0, R }; |
|
177 |
uses[i] = false; |
|
178 |
} |
|
179 |
|
|
180 |
names[numEff-1] = EffectName.VERTEX_ROTATE.name(); |
|
181 |
vars[numEff-1] = new float[] { 0,-GHOST_ANGLE,1,0,0 }; // see VertexEffect.constructEffect |
|
182 |
cents[numEff-1] = new float[] { 0.0f,0.5f,-0.5f }; |
|
183 |
regs[numEff-1] = new float[] { 0,0,0,0 }; |
|
184 |
uses[numEff-1] = true; |
|
185 |
|
|
186 |
return new ObjectVertexEffects(names,vars,cents,regs,uses); |
|
187 |
} |
|
188 |
} |
|
189 |
|
|
190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 |
|
|
192 |
public float[][] getCubitPositions() |
|
193 |
{ |
|
194 |
if( mPosition==null ) |
|
195 |
{ |
|
196 |
final float D = 0.5f; |
|
197 |
|
|
198 |
mPosition = new float[][] |
|
199 |
{ |
|
200 |
{ -D,-D,-D }, |
|
201 |
{ -D,-D, D }, |
|
202 |
{ -D, D,-D }, |
|
203 |
{ -D, D, D }, |
|
204 |
|
|
205 |
{ D,-D,-D }, |
|
206 |
{ D,-D, D }, |
|
207 |
{ D, D,-D }, |
|
208 |
{ D, D, D }, |
|
209 |
}; |
|
210 |
} |
|
211 |
|
|
212 |
return mPosition; |
|
213 |
} |
|
214 |
|
|
215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
216 |
|
|
217 |
public Static4D getCubitOrigQuat(int cubit) |
|
218 |
{ |
|
219 |
if( mQuatIndex==null ) mQuatIndex = new int[] { 0,1,3,2, 3,0,2,1 }; |
|
220 |
return mObjectQuats[mQuatIndex[cubit]]; |
|
221 |
} |
|
222 |
|
|
223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
224 |
|
|
225 |
public int getNumCubitVariants() |
|
226 |
{ |
|
227 |
return 2; |
|
228 |
} |
|
229 |
|
|
230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
231 |
|
|
232 |
public int getCubitVariant(int cubit) |
|
233 |
{ |
|
234 |
return cubit<4 ? 0:1; |
|
235 |
} |
|
236 |
|
|
237 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
238 |
|
|
239 |
public float[][] getCuts() |
|
240 |
{ |
|
241 |
if( mCuts==null ) |
|
242 |
{ |
|
243 |
float[] c = {0}; |
|
244 |
mCuts = new float[][] { c,c,c }; |
|
245 |
} |
|
246 |
|
|
247 |
return mCuts; |
|
248 |
} |
|
249 |
|
|
250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
|
|
252 |
public boolean[][] getLayerRotatable() |
|
253 |
{ |
|
254 |
boolean[] r = new boolean[] {true,true}; |
|
255 |
return new boolean[][] { r,r,r }; |
|
256 |
} |
|
257 |
|
|
258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
259 |
|
|
260 |
public int getTouchControlType() |
|
261 |
{ |
|
262 |
return TC_CHANGING_SHAPEMOD; |
|
263 |
} |
|
264 |
|
|
265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
266 |
|
|
267 |
public int getTouchControlSplit() |
|
268 |
{ |
|
269 |
return TYPE_NOT_SPLIT; |
|
270 |
} |
|
271 |
|
|
272 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
273 |
|
|
274 |
public int[][][] getEnabled() |
|
275 |
{ |
|
276 |
return null; |
|
277 |
} |
|
278 |
|
|
279 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
280 |
|
|
281 |
public float[] getDist3D() |
|
282 |
{ |
|
283 |
int[] numLayers = getNumLayers(); |
|
284 |
float x = numLayers[0]; |
|
285 |
float y = numLayers[1]; |
|
286 |
float z = numLayers[2]; |
|
287 |
float a = (x+y+z)/1.5f; |
|
288 |
|
|
289 |
return new float[] {x/a,x/a,y/a,y/a,z/a,z/a}; |
|
290 |
} |
|
291 |
|
|
292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
293 |
|
|
294 |
public Static3D[] getFaceAxis() |
|
295 |
{ |
|
296 |
return TouchControlCuboids.FACE_AXIS; |
|
297 |
} |
|
298 |
|
|
299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
300 |
|
|
301 |
public float getStickerRadius() |
|
302 |
{ |
|
303 |
return 0.10f; |
|
304 |
} |
|
305 |
|
|
306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
307 |
|
|
308 |
public float getStickerStroke() |
|
309 |
{ |
|
310 |
return isInIconMode() ? 0.16f : 0.08f ; |
|
311 |
} |
|
312 |
|
|
313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
314 |
|
|
315 |
public float[][][] getStickerAngles() |
|
316 |
{ |
|
317 |
return null; |
|
318 |
} |
|
319 |
|
|
320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
321 |
// PUBLIC API |
|
322 |
|
|
323 |
public Static3D[] getRotationAxis() |
|
324 |
{ |
|
325 |
return ROT_AXIS; |
|
326 |
} |
|
327 |
|
|
328 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
329 |
|
|
330 |
public String getShortName() |
|
331 |
{ |
|
332 |
return "GHOST2"; |
|
333 |
} |
|
334 |
|
|
335 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
336 |
|
|
337 |
public int[][] getBasicAngles() |
|
338 |
{ |
|
339 |
if( mBasicAngle==null ) |
|
340 |
{ |
|
341 |
int[] a = {4,4}; |
|
342 |
mBasicAngle = new int[][] { a,a,a }; |
|
343 |
} |
|
344 |
return mBasicAngle; |
|
345 |
} |
|
346 |
|
|
347 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
348 |
|
|
349 |
public String[][] getTutorials() |
|
350 |
{ |
|
351 |
return null; |
|
352 |
} |
|
353 |
} |
Also available in: Unified diff
unify test ghost classes into one