43 |
43 |
new Static3D(0,0,1)
|
44 |
44 |
};
|
45 |
45 |
|
46 |
|
private static final int[] FACE_COLORS = new int[] { ShapeColors.COLOR_DYELLO };
|
47 |
|
private static final float[] GHOST_VEC = {0,0,0};//{ 0.10f, 0.25f, 0.40f };
|
48 |
|
private static final Static4D GHOST_QUAT = new Static4D(0,0,0,1);
|
|
46 |
private static final int[] FACE_COLORS = new int[] { ShapeColors.COLOR_DYELLO };
|
|
47 |
private static final float[] GHOST_VEC = { 0.10f, 0.25f, 0.40f };
|
|
48 |
private static final float[] PLANES_ROT_AXIS = { 1,0,0 };
|
|
49 |
private static final int PLANES_ROT_ANGLE= 20;
|
|
50 |
|
49 |
51 |
|
50 |
52 |
private int[][] mEdges;
|
51 |
53 |
private float[][] mCuts;
|
... | ... | |
58 |
60 |
private float[][] mCutPlanes;
|
59 |
61 |
private float[][] mPotentialVertices;
|
60 |
62 |
private Static3D[] mFaceAxis, mRotAxis;
|
|
63 |
private Static4D mPlanesRotQuat;
|
61 |
64 |
|
62 |
65 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63 |
66 |
|
... | ... | |
111 |
114 |
return new int[] { (1+numL[0])/2, (1+numL[1])/2, (1+numL[2])/2 };
|
112 |
115 |
}
|
113 |
116 |
|
|
117 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
118 |
|
|
119 |
private void makePlanesRotQuat()
|
|
120 |
{
|
|
121 |
if( mPlanesRotQuat==null )
|
|
122 |
{
|
|
123 |
double rotAngle = PLANES_ROT_ANGLE*Math.PI/180;
|
|
124 |
float cosA = (float)Math.cos(rotAngle/2);
|
|
125 |
float sinA = (float)Math.sin(rotAngle/2);
|
|
126 |
float x = PLANES_ROT_AXIS[0];
|
|
127 |
float y = PLANES_ROT_AXIS[1];
|
|
128 |
float z = PLANES_ROT_AXIS[2];
|
|
129 |
|
|
130 |
mPlanesRotQuat = new Static4D(x*sinA, y*sinA, z*sinA, cosA);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
114 |
134 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115 |
135 |
|
116 |
136 |
public float[][] getCubitPositions()
|
117 |
137 |
{
|
118 |
138 |
if( mPositions==null )
|
119 |
139 |
{
|
|
140 |
makePlanesRotQuat();
|
120 |
141 |
int[] numLayers = getNumLayers();
|
121 |
142 |
int numL = numLayers[0];
|
122 |
143 |
int numCubits = getNumCubitVariants();
|
... | ... | |
130 |
151 |
for( int z=0; z<numL; z++)
|
131 |
152 |
if( x==0 || x==numL-1 || y==0 || y==numL-1 || z==0 || z==numL-1 )
|
132 |
153 |
{
|
133 |
|
QuatHelper.rotateVectorByQuat(tmp, x-diff, y-diff, z-diff, 1, GHOST_QUAT);
|
|
154 |
QuatHelper.rotateVectorByQuat(tmp, x-diff, y-diff, z-diff, 1, mPlanesRotQuat);
|
134 |
155 |
mPositions[currPos++] = new float[] {tmp[0],tmp[1],tmp[2]};
|
135 |
156 |
}
|
136 |
157 |
}
|
... | ... | |
333 |
354 |
float[] v1 = verts[wall[1]];
|
334 |
355 |
float[] v2 = verts[wall[2]];
|
335 |
356 |
|
336 |
|
float ax = v0[0]-v1[0];
|
337 |
|
float ay = v0[1]-v1[1];
|
338 |
|
float az = v0[2]-v1[2];
|
339 |
|
|
340 |
|
float bx = v1[0]-v2[0];
|
341 |
|
float by = v1[1]-v2[1];
|
342 |
|
float bz = v1[2]-v2[2];
|
|
357 |
float ax = v1[0]-v2[0];
|
|
358 |
float ay = v1[1]-v2[1];
|
|
359 |
float az = v1[2]-v2[2];
|
343 |
360 |
|
344 |
|
float vx = ay*bz - az*by;
|
345 |
|
float vy = az*bx - ax*bz;
|
346 |
|
float vz = ax*by - ay*bx;
|
|
361 |
float bx = v0[0]-v1[0];
|
|
362 |
float by = v0[1]-v1[1];
|
|
363 |
float bz = v0[2]-v1[2];
|
347 |
364 |
|
348 |
|
return new float[] {vx,vy,vz};
|
|
365 |
return FactoryShape.crossProduct(ax,ay,az,bx,by,bz);
|
349 |
366 |
}
|
350 |
367 |
|
351 |
368 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
398 |
415 |
float[][] centers = computeVertexEffectCenter(variant);
|
399 |
416 |
float[][] pos = getCubitPositions();
|
400 |
417 |
int[] cornerIndices= FactoryShape.computeVertexEffectsIndices(vertices, pos[variant], getFaceAxis(), getDist() );
|
401 |
|
float[][] corners = { {0.05f,015f} };
|
|
418 |
float[][] corners = { {0.015f,0.12f} };
|
402 |
419 |
int[] centerIndices= new int[centers.length];
|
403 |
420 |
for(int c=0; c<centers.length; c++) centerIndices[c] = c;
|
404 |
421 |
|
... | ... | |
426 |
443 |
{
|
427 |
444 |
if( mFaceAxis==null )
|
428 |
445 |
{
|
|
446 |
makePlanesRotQuat();
|
429 |
447 |
Static3D[] axis = TouchControlHexahedron.FACE_AXIS;
|
430 |
448 |
int len = axis.length;
|
431 |
449 |
mFaceAxis = new Static3D[len];
|
... | ... | |
434 |
452 |
for(int a=0; a<len; a++)
|
435 |
453 |
{
|
436 |
454 |
Static3D ax = axis[a];
|
437 |
|
QuatHelper.rotateVectorByInvertedQuat( tmp, ax.get0(), ax.get1(), ax.get2(), 0, GHOST_QUAT);
|
|
455 |
QuatHelper.rotateVectorByInvertedQuat( tmp, ax.get0(), ax.get1(), ax.get2(), 0, mPlanesRotQuat);
|
438 |
456 |
mFaceAxis[a] = new Static3D(tmp[0],tmp[1],tmp[2]);
|
439 |
457 |
}
|
440 |
458 |
}
|
... | ... | |
478 |
496 |
{
|
479 |
497 |
if( mRotAxis==null )
|
480 |
498 |
{
|
|
499 |
makePlanesRotQuat();
|
481 |
500 |
Static3D[] axis = ROT_AXIS;
|
482 |
501 |
int len = axis.length;
|
483 |
502 |
mRotAxis = new Static3D[len];
|
... | ... | |
486 |
505 |
for(int a=0; a<len; a++)
|
487 |
506 |
{
|
488 |
507 |
Static3D ax = axis[a];
|
489 |
|
QuatHelper.rotateVectorByQuat( tmp, ax.get0(), ax.get1(), ax.get2(), 0, GHOST_QUAT);
|
|
508 |
QuatHelper.rotateVectorByQuat( tmp, ax.get0(), ax.get1(), ax.get2(), 0, mPlanesRotQuat);
|
490 |
509 |
mRotAxis[a] = new Static3D(tmp[0],tmp[1],tmp[2]);
|
491 |
510 |
}
|
492 |
511 |
}
|
progress with GhostCube