24 |
24 |
import android.graphics.Paint;
|
25 |
25 |
|
26 |
26 |
import org.distorted.library.effect.MatrixEffectQuaternion;
|
|
27 |
import org.distorted.library.effect.VertexEffectDeform;
|
|
28 |
import org.distorted.library.effect.VertexEffectMove;
|
|
29 |
import org.distorted.library.effect.VertexEffectRotate;
|
|
30 |
import org.distorted.library.effect.VertexEffectScale;
|
27 |
31 |
import org.distorted.library.main.DistortedEffects;
|
28 |
32 |
import org.distorted.library.main.DistortedTexture;
|
29 |
33 |
import org.distorted.library.mesh.MeshBase;
|
|
34 |
import org.distorted.library.mesh.MeshJoined;
|
|
35 |
import org.distorted.library.mesh.MeshPolygon;
|
30 |
36 |
import org.distorted.library.mesh.MeshSquare;
|
|
37 |
import org.distorted.library.mesh.MeshTriangle;
|
|
38 |
import org.distorted.library.type.Static1D;
|
31 |
39 |
import org.distorted.library.type.Static3D;
|
32 |
40 |
import org.distorted.library.type.Static4D;
|
33 |
41 |
|
... | ... | |
71 |
79 |
COLOR_PINK , COLOR_VIOLET
|
72 |
80 |
};
|
73 |
81 |
|
74 |
|
// All legal rotation quats of a Diamond
|
|
82 |
// All legal rotation quats of a Diamond: unit + three 180 deg turns + 8 generators
|
75 |
83 |
private static final Static4D[] QUATS = new Static4D[]
|
76 |
84 |
{
|
77 |
85 |
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
|
78 |
86 |
new Static4D( 0.0f, 1.0f, 0.0f, 0.0f ),
|
|
87 |
new Static4D(+SQ2/2, 0.0f, -SQ2/2, 0.0f ),
|
|
88 |
new Static4D(-SQ2/2, 0.0f, -SQ2/2, 0.0f ),
|
|
89 |
|
79 |
90 |
new Static4D(+SQ2/2, 0.5f, 0.0f, 0.5f ),
|
80 |
91 |
new Static4D(-SQ2/2, 0.5f, 0.0f, 0.5f ),
|
81 |
92 |
new Static4D( 0.0f, 0.5f, +SQ2/2, 0.5f ),
|
... | ... | |
83 |
94 |
new Static4D(+SQ2/2, 0.5f, 0.0f, -0.5f ),
|
84 |
95 |
new Static4D(-SQ2/2, 0.5f, 0.0f, -0.5f ),
|
85 |
96 |
new Static4D( 0.0f, 0.5f, +SQ2/2, -0.5f ),
|
86 |
|
new Static4D( 0.0f, 0.5f, -SQ2/2, -0.5f ),
|
87 |
|
new Static4D(+SQ2/2, 0.0f, -SQ2/2, 0.0f ),
|
88 |
|
new Static4D(-SQ2/2, 0.0f, -SQ2/2, 0.0f )
|
|
97 |
new Static4D( 0.0f, 0.5f, -SQ2/2, -0.5f )
|
89 |
98 |
};
|
90 |
99 |
|
91 |
100 |
private static final float DIST = 0.50f;
|
... | ... | |
144 |
153 |
|
145 |
154 |
private void createOctaMesh()
|
146 |
155 |
{
|
|
156 |
int association = 1;
|
|
157 |
|
|
158 |
float C = 0.06f;
|
|
159 |
float D = 0.02f;
|
|
160 |
float E = SQ3/2;
|
|
161 |
float F = 0.5f;
|
|
162 |
|
|
163 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
|
164 |
|
|
165 |
float[] bands = new float[] { 1.0f , 0,
|
|
166 |
1.0f -C, D*0.50f,
|
|
167 |
1.0f-2*C, D*0.80f,
|
|
168 |
1.0f-4*C, D*1.00f,
|
|
169 |
0.5f , D*1.20f,
|
|
170 |
0.0f , D*1.25f };
|
147 |
171 |
|
|
172 |
MeshBase[] meshes = new MeshPolygon[FACES_PER_CUBIT];
|
|
173 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
|
174 |
meshes[0].setEffectAssociation(0,association,0);
|
|
175 |
|
|
176 |
for(int i=1; i<FACES_PER_CUBIT; i++)
|
|
177 |
{
|
|
178 |
association <<= 1;
|
|
179 |
meshes[i] = meshes[0].copy(true);
|
|
180 |
meshes[i].setEffectAssociation(0,association,0);
|
|
181 |
}
|
|
182 |
|
|
183 |
mOctaMesh = new MeshJoined(meshes);
|
|
184 |
|
|
185 |
float d1 = SQ2/2;
|
|
186 |
float d2 =-0.06f;
|
|
187 |
float d3 = 0.20f;
|
|
188 |
|
|
189 |
Static3D a0 = new Static3D( 0, 1, 0 );
|
|
190 |
Static3D a1 = new Static3D( SQ2/2, 0, SQ2/2 );
|
|
191 |
Static3D a2 = new Static3D(-SQ2/2, 0, SQ2/2 );
|
|
192 |
|
|
193 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
|
194 |
Static1D angle1= new Static1D( 90);
|
|
195 |
Static1D angle2= new Static1D(180);
|
|
196 |
Static1D angle3= new Static1D(270);
|
|
197 |
|
|
198 |
Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
|
|
199 |
|
|
200 |
Static3D axisX = new Static3D(1,0,0);
|
|
201 |
Static3D axisY = new Static3D(0,1,0);
|
|
202 |
|
|
203 |
Static3D cent0 = new Static3D(0,0,0);
|
|
204 |
Static3D cent1 = new Static3D(0,SQ2/2,0);
|
|
205 |
|
|
206 |
Static3D flipY = new Static3D( 1,-1, 1);
|
|
207 |
|
|
208 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
|
209 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
|
210 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
|
211 |
Static3D dCen3 = new Static3D(-d1*a0.get0(),-d1*a0.get1(),-d1*a0.get2() );
|
|
212 |
Static3D dCen4 = new Static3D(-d1*a1.get0(),-d1*a2.get1(),-d1*a2.get2() );
|
|
213 |
Static3D dCen5 = new Static3D(-d1*a2.get0(),-d1*a1.get1(),-d1*a1.get2() );
|
|
214 |
|
|
215 |
Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
|
|
216 |
Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
|
|
217 |
Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
|
|
218 |
Static3D dVec3 = new Static3D(-d2*a0.get0(),-d2*a0.get1(),-d2*a0.get2() );
|
|
219 |
Static3D dVec4 = new Static3D(-d2*a1.get0(),-d2*a1.get1(),-d2*a1.get2() );
|
|
220 |
Static3D dVec5 = new Static3D(-d2*a2.get0(),-d2*a2.get1(),-d2*a2.get2() );
|
|
221 |
|
|
222 |
Static4D dReg = new Static4D(0,0,0,d3);
|
|
223 |
Static1D dRad = new Static1D(1);
|
|
224 |
|
|
225 |
VertexEffectMove effect0 = new VertexEffectMove(move1);
|
|
226 |
VertexEffectRotate effect1 = new VertexEffectRotate(alpha , axisX, cent1);
|
|
227 |
VertexEffectRotate effect2 = new VertexEffectRotate(angle1, axisY, cent0);
|
|
228 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2, axisY, cent0);
|
|
229 |
VertexEffectRotate effect4 = new VertexEffectRotate(angle3, axisY, cent0);
|
|
230 |
VertexEffectScale effect5 = new VertexEffectScale(flipY);
|
|
231 |
|
|
232 |
VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
233 |
VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
234 |
VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
235 |
VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
236 |
VertexEffectDeform effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
|
|
237 |
VertexEffectDeform effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
|
|
238 |
|
|
239 |
effect0.setMeshAssociation (255,-1); // apply to all meshes
|
|
240 |
effect1.setMeshAssociation (255,-1); // apply to all meshes
|
|
241 |
effect2.setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
|
|
242 |
effect3.setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
|
|
243 |
effect4.setMeshAssociation (136,-1); // apply to meshes 3 & 7
|
|
244 |
effect5.setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
|
|
245 |
effect6.setMeshAssociation (255,-1); // apply to all meshes
|
|
246 |
effect7.setMeshAssociation (255,-1); // apply to all meshes
|
|
247 |
effect8.setMeshAssociation (255,-1); // apply to all meshes
|
|
248 |
effect9.setMeshAssociation (255,-1); // apply to all meshes
|
|
249 |
effect10.setMeshAssociation(255,-1); // apply to all meshes
|
|
250 |
effect11.setMeshAssociation(255,-1); // apply to all meshes
|
|
251 |
|
|
252 |
mOctaMesh.apply(effect0);
|
|
253 |
mOctaMesh.apply(effect1);
|
|
254 |
mOctaMesh.apply(effect2);
|
|
255 |
mOctaMesh.apply(effect3);
|
|
256 |
mOctaMesh.apply(effect4);
|
|
257 |
mOctaMesh.apply(effect5);
|
|
258 |
mOctaMesh.apply(effect6);
|
|
259 |
mOctaMesh.apply(effect7);
|
|
260 |
mOctaMesh.apply(effect8);
|
|
261 |
mOctaMesh.apply(effect9);
|
|
262 |
mOctaMesh.apply(effect10);
|
|
263 |
mOctaMesh.apply(effect11);
|
|
264 |
|
|
265 |
mOctaMesh.mergeEffComponents();
|
148 |
266 |
}
|
149 |
267 |
|
150 |
268 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
151 |
269 |
|
152 |
270 |
private void createTetraMesh()
|
153 |
271 |
{
|
|
272 |
int association = 1;
|
|
273 |
|
|
274 |
float C = 0.06f;
|
|
275 |
float D = 0.035f;
|
|
276 |
float E = SQ3/2;
|
|
277 |
float F = 0.5f;
|
|
278 |
|
|
279 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
154 |
280 |
|
|
281 |
float[] bands = new float[] { 1.0f , 0,
|
|
282 |
1.0f -C, D*0.50f,
|
|
283 |
1.0f-2*C, D*0.80f,
|
|
284 |
1.0f-4*C, D*1.00f,
|
|
285 |
0.5f , D*1.20f,
|
|
286 |
0.0f , D*1.25f };
|
|
287 |
|
|
288 |
MeshBase[] meshes = new MeshBase[FACES_PER_CUBIT];
|
|
289 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
|
290 |
meshes[0].setEffectAssociation(0,association,0);
|
|
291 |
|
|
292 |
for(int i=1; i<4; i++)
|
|
293 |
{
|
|
294 |
association <<= 1;
|
|
295 |
meshes[i] = meshes[0].copy(true);
|
|
296 |
meshes[i].setEffectAssociation(0,association,0);
|
|
297 |
}
|
|
298 |
|
|
299 |
for(int i=4; i<FACES_PER_CUBIT; i++)
|
|
300 |
{
|
|
301 |
association <<= 1;
|
|
302 |
meshes[i] = new MeshTriangle(1);
|
|
303 |
meshes[i].setEffectAssociation(0,association,0);
|
|
304 |
}
|
|
305 |
|
|
306 |
mTetraMesh = new MeshJoined(meshes);
|
|
307 |
|
|
308 |
Static3D flipZ = new Static3D( 1, 1,-1);
|
|
309 |
|
|
310 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
|
311 |
Static1D angle1= new Static1D( 90);
|
|
312 |
Static1D angle2= new Static1D(180);
|
|
313 |
Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
|
|
314 |
|
|
315 |
Static3D axisX = new Static3D(1,0,0);
|
|
316 |
Static3D axisY = new Static3D(0,1,0);
|
|
317 |
Static3D axisZ = new Static3D(0,0,1);
|
|
318 |
|
|
319 |
Static3D cent0 = new Static3D(0,0,0);
|
|
320 |
Static3D cent1 = new Static3D(0,SQ2/4,0);
|
|
321 |
|
|
322 |
float d1 =-1.00f;
|
|
323 |
float d2 = 0.10f;
|
|
324 |
float d3 = 0.15f;
|
|
325 |
|
|
326 |
float vx = 0.5f ;
|
|
327 |
float vy = (SQ2/4);
|
|
328 |
|
|
329 |
Static3D a0 = new Static3D(+vx,-vy, 0 );
|
|
330 |
Static3D a1 = new Static3D(-vx,-vy, 0 );
|
|
331 |
Static3D a2 = new Static3D( 0, vy,-vx);
|
|
332 |
Static3D a3 = new Static3D( 0, vy,+vx);
|
|
333 |
|
|
334 |
Static4D dReg = new Static4D(0,0,0,d3);
|
|
335 |
Static1D dRad = new Static1D(1);
|
|
336 |
|
|
337 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
|
338 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
|
339 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
|
340 |
Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
|
|
341 |
|
|
342 |
Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
|
|
343 |
Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
|
|
344 |
Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
|
|
345 |
Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
|
|
346 |
|
|
347 |
VertexEffectRotate effect0 = new VertexEffectRotate(angle2, axisZ, cent0);
|
|
348 |
VertexEffectMove effect1 = new VertexEffectMove(move1);
|
|
349 |
VertexEffectRotate effect2 = new VertexEffectRotate(alpha , axisX, cent1);
|
|
350 |
VertexEffectScale effect3 = new VertexEffectScale(flipZ);
|
|
351 |
VertexEffectRotate effect4 = new VertexEffectRotate(angle1, axisY, cent0);
|
|
352 |
VertexEffectRotate effect5 = new VertexEffectRotate(angle2, axisZ, cent0);
|
|
353 |
|
|
354 |
VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
355 |
VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
356 |
VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
357 |
VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
358 |
|
|
359 |
VertexEffectScale effect10 = new VertexEffectScale(0.1f);
|
|
360 |
|
|
361 |
effect0.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
362 |
effect1.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
363 |
effect2.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
364 |
effect3.setMeshAssociation(10,-1); // meshes 1 & 3
|
|
365 |
effect4.setMeshAssociation(12,-1); // meshes 2 & 3
|
|
366 |
effect5.setMeshAssociation(12,-1); // meshes 2 & 3
|
|
367 |
effect6.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
368 |
effect7.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
369 |
effect8.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
370 |
effect9.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
371 |
effect10.setMeshAssociation(240,-1); // meshes 4,5,6,7
|
|
372 |
|
|
373 |
mTetraMesh.apply(effect0);
|
|
374 |
mTetraMesh.apply(effect1);
|
|
375 |
mTetraMesh.apply(effect2);
|
|
376 |
mTetraMesh.apply(effect3);
|
|
377 |
mTetraMesh.apply(effect4);
|
|
378 |
mTetraMesh.apply(effect5);
|
|
379 |
mTetraMesh.apply(effect6);
|
|
380 |
mTetraMesh.apply(effect7);
|
|
381 |
mTetraMesh.apply(effect8);
|
|
382 |
mTetraMesh.apply(effect9);
|
|
383 |
mTetraMesh.apply(effect10);
|
|
384 |
|
|
385 |
mTetraMesh.mergeEffComponents();
|
155 |
386 |
}
|
156 |
387 |
|
157 |
388 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
158 |
389 |
|
159 |
390 |
float getScreenRatio()
|
160 |
391 |
{
|
161 |
|
return 1.0f;
|
|
392 |
return 0.65f;
|
162 |
393 |
}
|
163 |
394 |
|
164 |
395 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
223 |
454 |
case 4:
|
224 |
455 |
case 5:
|
225 |
456 |
case 6: return QUATS[0]; // unit quat
|
226 |
|
case 7: return new Static4D( SQ2/2,0,0,SQ2/2); // 90 along Y
|
|
457 |
case 7: return new Static4D(0,-SQ2/2,0,SQ2/2); // 90 along Y
|
227 |
458 |
case 8: return QUATS[1]; // 180 along Y
|
228 |
|
case 9: return new Static4D(-SQ2/2,0,0,SQ2/2); // 90 along Y
|
229 |
|
case 10: return new Static4D( 0,0,1, 0); // 180 along Z
|
230 |
|
case 11: return new Static4D(0, SQ2/2,SQ2/2,0); //
|
|
459 |
case 9: return new Static4D(0,+SQ2/2,0,SQ2/2); // 90 along Y
|
|
460 |
case 10: return new Static4D(0, 0,1, 0); // 180 along Z
|
|
461 |
case 11: return new Static4D(SQ2/2, 0,SQ2/2,0); //
|
231 |
462 |
case 12: return new Static4D( 1,0,0, 0); // 180 along X
|
232 |
|
case 13: return new Static4D(0,-SQ2/2,SQ2/2,0); //
|
|
463 |
case 13: return new Static4D(-SQ2/2,0,SQ2/2,0); //
|
233 |
464 |
}
|
234 |
465 |
|
235 |
466 |
return null;
|
... | ... | |
388 |
619 |
|
389 |
620 |
public boolean isSolved()
|
390 |
621 |
{
|
391 |
|
|
392 |
|
|
393 |
|
return false;
|
|
622 |
int q = CUBITS[0].mQuatIndex;
|
|
623 |
|
|
624 |
return ( CUBITS[ 1].mQuatIndex == q &&
|
|
625 |
CUBITS[ 2].mQuatIndex == q &&
|
|
626 |
CUBITS[ 3].mQuatIndex == q &&
|
|
627 |
CUBITS[ 4].mQuatIndex == q &&
|
|
628 |
CUBITS[ 5].mQuatIndex == q &&
|
|
629 |
CUBITS[ 6].mQuatIndex == q &&
|
|
630 |
CUBITS[ 7].mQuatIndex == q &&
|
|
631 |
CUBITS[ 8].mQuatIndex == q &&
|
|
632 |
CUBITS[ 9].mQuatIndex == q &&
|
|
633 |
CUBITS[10].mQuatIndex == q &&
|
|
634 |
CUBITS[11].mQuatIndex == q &&
|
|
635 |
CUBITS[12].mQuatIndex == q &&
|
|
636 |
CUBITS[13].mQuatIndex == q );
|
394 |
637 |
}
|
395 |
638 |
|
396 |
639 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
397 |
|
// only needed for solvers - there are no Diamond solvers ATM)
|
|
640 |
// only needed for solvers - there are no Diamond solvers ATM
|
398 |
641 |
|
399 |
642 |
public String retObjectString()
|
400 |
643 |
{
|
Progress with the Skewb Diamond - it is rendered correctly now.