| 1 |
e844c116
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2019 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 |
1f9772f3
|
Leszek Koltunski
|
package org.distorted.objects;
|
| 21 |
e844c116
|
Leszek Koltunski
|
|
| 22 |
|
|
import android.graphics.Canvas;
|
| 23 |
|
|
import android.graphics.Paint;
|
| 24 |
|
|
|
| 25 |
40ab026e
|
Leszek Koltunski
|
import org.distorted.library.effect.VertexEffectDeform;
|
| 26 |
|
|
import org.distorted.library.effect.VertexEffectMove;
|
| 27 |
|
|
import org.distorted.library.effect.VertexEffectRotate;
|
| 28 |
|
|
import org.distorted.library.effect.VertexEffectScale;
|
| 29 |
f0fa83ae
|
Leszek Koltunski
|
import org.distorted.library.effect.VertexEffectSink;
|
| 30 |
e844c116
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
| 31 |
|
|
import org.distorted.library.main.DistortedTexture;
|
| 32 |
|
|
import org.distorted.library.mesh.MeshBase;
|
| 33 |
988f434e
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshJoined;
|
| 34 |
e844c116
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshRectangles;
|
| 35 |
988f434e
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshTriangles;
|
| 36 |
|
|
import org.distorted.library.type.Static1D;
|
| 37 |
e844c116
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
| 38 |
|
|
import org.distorted.library.type.Static4D;
|
| 39 |
|
|
|
| 40 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 41 |
|
|
|
| 42 |
|
|
public class RubikPyraminx extends RubikObject
|
| 43 |
|
|
{
|
| 44 |
9f4c44fe
|
Leszek Koltunski
|
private static final float SQ2 = (float)Math.sqrt(2);
|
| 45 |
|
|
private static final float SQ3 = (float)Math.sqrt(3);
|
| 46 |
10585385
|
Leszek Koltunski
|
private static final float SQ6 = (float)Math.sqrt(6);
|
| 47 |
9f4c44fe
|
Leszek Koltunski
|
|
| 48 |
37a25788
|
Leszek Koltunski
|
static final Static3D[] AXIS = new Static3D[]
|
| 49 |
e844c116
|
Leszek Koltunski
|
{
|
| 50 |
9f4c44fe
|
Leszek Koltunski
|
new Static3D( 0, 1, 0 ),
|
| 51 |
49f67f9b
|
Leszek Koltunski
|
new Static3D( 0, -1.0f/3, 2*SQ2/3 ),
|
| 52 |
9f4c44fe
|
Leszek Koltunski
|
new Static3D(-SQ2*SQ3/3, -1.0f/3, -SQ2/3 ),
|
| 53 |
49f67f9b
|
Leszek Koltunski
|
new Static3D( SQ2*SQ3/3, -1.0f/3, -SQ2/3 )
|
| 54 |
e844c116
|
Leszek Koltunski
|
};
|
| 55 |
|
|
|
| 56 |
|
|
private static final int[] FACE_COLORS = new int[]
|
| 57 |
|
|
{
|
| 58 |
906cc928
|
Leszek Koltunski
|
0xff00ff00, 0xffffff00, // AXIS[0]right (GREEN ) AXIS[1]right (YELLOW )
|
| 59 |
|
|
0xff0000ff, 0xffff0000 // AXIS[2]right (BLUE ) AXIS[3]right (RED )
|
| 60 |
e844c116
|
Leszek Koltunski
|
};
|
| 61 |
|
|
|
| 62 |
9f4c44fe
|
Leszek Koltunski
|
// computed with res/raw/compute_quats.c
|
| 63 |
10585385
|
Leszek Koltunski
|
private static final Static4D[] QUATS = new Static4D[]
|
| 64 |
e844c116
|
Leszek Koltunski
|
{
|
| 65 |
10585385
|
Leszek Koltunski
|
new Static4D( 0.0f, 0.0f, 0.0f, 1.0f),
|
| 66 |
|
|
new Static4D( 0.0f, SQ3/2, 0.0f, 0.5f),
|
| 67 |
|
|
new Static4D( SQ2/2, -SQ3/6, -SQ6/6, 0.5f),
|
| 68 |
|
|
new Static4D(-SQ2/2, -SQ3/6, -SQ6/6, 0.5f),
|
| 69 |
|
|
new Static4D( 0.0f, -SQ3/6, SQ6/3, 0.5f),
|
| 70 |
|
|
new Static4D( 0.0f, SQ3/2, 0.0f, -0.5f),
|
| 71 |
|
|
new Static4D( SQ2/2, -SQ3/6, -SQ6/6, -0.5f),
|
| 72 |
|
|
new Static4D(-SQ2/2, -SQ3/6, -SQ6/6, -0.5f),
|
| 73 |
|
|
new Static4D( 0.0f, -SQ3/6, SQ6/3, -0.5f),
|
| 74 |
|
|
new Static4D( SQ2/2, -SQ3/3, SQ6/6, 0.0f),
|
| 75 |
|
|
new Static4D( 0.0f, -SQ3/3, -SQ6/3, 0.0f),
|
| 76 |
|
|
new Static4D(-SQ2/2, -SQ3/3, SQ6/6, 0.0f)
|
| 77 |
e844c116
|
Leszek Koltunski
|
};
|
| 78 |
|
|
|
| 79 |
89a11f7b
|
Leszek Koltunski
|
private int[] mRotArray;
|
| 80 |
40ab026e
|
Leszek Koltunski
|
private static VertexEffectRotate[] ROTATION;
|
| 81 |
|
|
|
| 82 |
|
|
private static MeshBase mMesh =null;
|
| 83 |
|
|
private static MeshBase[] mMeshRotated = new MeshBase[AXIS.length];
|
| 84 |
89a11f7b
|
Leszek Koltunski
|
|
| 85 |
|
|
static
|
| 86 |
|
|
{
|
| 87 |
|
|
Static3D center = new Static3D(0,0,0);
|
| 88 |
|
|
Static1D angle = new Static1D(180.0f);
|
| 89 |
|
|
|
| 90 |
40ab026e
|
Leszek Koltunski
|
ROTATION = new VertexEffectRotate[AXIS.length];
|
| 91 |
89a11f7b
|
Leszek Koltunski
|
|
| 92 |
|
|
for(int i=0; i<AXIS.length; i++)
|
| 93 |
|
|
{
|
| 94 |
40ab026e
|
Leszek Koltunski
|
ROTATION[i] = new VertexEffectRotate( angle, AXIS[i], center);
|
| 95 |
|
|
mMeshRotated[i] = null;
|
| 96 |
89a11f7b
|
Leszek Koltunski
|
}
|
| 97 |
|
|
}
|
| 98 |
49f67f9b
|
Leszek Koltunski
|
|
| 99 |
e844c116
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 100 |
|
|
|
| 101 |
a31d25de
|
Leszek Koltunski
|
RubikPyraminx(int size, Static4D quatCur, Static4D quatAcc, DistortedTexture texture, MeshRectangles mesh, DistortedEffects effects, int[][] moves)
|
| 102 |
e844c116
|
Leszek Koltunski
|
{
|
| 103 |
aa171dee
|
Leszek Koltunski
|
super(size, 30, quatCur,quatAcc,texture,mesh,effects,moves, RubikObjectList.PYRA);
|
| 104 |
e844c116
|
Leszek Koltunski
|
}
|
| 105 |
|
|
|
| 106 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 107 |
|
|
|
| 108 |
89a11f7b
|
Leszek Koltunski
|
private void emitRow(float x, float y, float z, float dx, float dy, float dz, int n, int rot, Static3D[] array, int index)
|
| 109 |
49f67f9b
|
Leszek Koltunski
|
{
|
| 110 |
|
|
for(int i=0; i<n; i++)
|
| 111 |
|
|
{
|
| 112 |
|
|
mRotArray[i+index] = rot;
|
| 113 |
|
|
array[i+index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6);
|
| 114 |
|
|
x += dx;
|
| 115 |
|
|
y += dy;
|
| 116 |
|
|
z += dz;
|
| 117 |
|
|
}
|
| 118 |
|
|
}
|
| 119 |
|
|
|
| 120 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 121 |
|
|
|
| 122 |
|
|
private int emitLowermost(float x, float y, float z, int n, Static3D[] array)
|
| 123 |
|
|
{
|
| 124 |
|
|
int added = 0;
|
| 125 |
|
|
|
| 126 |
769409d2
|
Leszek Koltunski
|
emitRow( x +0.5f, y+SQ3*SQ2/9, z+ SQ3/18, 1.0f, 0, 0, n-1, 1, array, added);
|
| 127 |
|
|
added += (n-1);
|
| 128 |
|
|
emitRow( x +1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, 0.5f, 0, SQ3/2, n-1, 3, array, added);
|
| 129 |
|
|
added += (n-1);
|
| 130 |
|
|
emitRow( x+n-1-1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, -0.5f, 0, SQ3/2, n-1, 2, array, added);
|
| 131 |
|
|
added += (n-1);
|
| 132 |
|
|
|
| 133 |
49f67f9b
|
Leszek Koltunski
|
for(int i=n; i>=1; i--)
|
| 134 |
|
|
{
|
| 135 |
769409d2
|
Leszek Koltunski
|
emitRow(x , y, z , 1,0,0, i , -1, array, added);
|
| 136 |
49f67f9b
|
Leszek Koltunski
|
added += i;
|
| 137 |
769409d2
|
Leszek Koltunski
|
emitRow(x+0.5f, y, z+SQ3/6, 1,0,0, i-1, 0, array, added);
|
| 138 |
|
|
added += (i-1);
|
| 139 |
49f67f9b
|
Leszek Koltunski
|
x += 0.5f;
|
| 140 |
|
|
y += 0.0f;
|
| 141 |
|
|
z += SQ3/2;
|
| 142 |
|
|
}
|
| 143 |
|
|
|
| 144 |
|
|
return added;
|
| 145 |
|
|
}
|
| 146 |
|
|
|
| 147 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 148 |
|
|
|
| 149 |
|
|
private int emitUpper(float x, float y, float z, int n, Static3D[] array, int index)
|
| 150 |
|
|
{
|
| 151 |
|
|
if( n>1 )
|
| 152 |
|
|
{
|
| 153 |
769409d2
|
Leszek Koltunski
|
emitRow( x , y , z , 1.0f, 0, 0, n-1, -1, array, index);
|
| 154 |
|
|
index += (n-1);
|
| 155 |
|
|
emitRow( x+0.5f , y+SQ3*SQ2/9, z+SQ3/18 , 1.0f, 0, 0, n-1, 1, array, index);
|
| 156 |
|
|
index += (n-1);
|
| 157 |
|
|
emitRow( x+0.5f , y , z+SQ3/2 , 0.5f, 0, SQ3/2, n-1, -1, array, index);
|
| 158 |
|
|
index += (n-1);
|
| 159 |
|
|
emitRow( x +1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, 0.5f, 0, SQ3/2, n-1, 3, array, index);
|
| 160 |
49f67f9b
|
Leszek Koltunski
|
index += (n-1);
|
| 161 |
769409d2
|
Leszek Koltunski
|
emitRow( x+n-1 , y , z , -0.5f, 0, SQ3/2, n-1, -1, array, index);
|
| 162 |
49f67f9b
|
Leszek Koltunski
|
index += (n-1);
|
| 163 |
769409d2
|
Leszek Koltunski
|
emitRow( x+n-1-1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, -0.5f, 0, SQ3/2, n-1, 2, array, index);
|
| 164 |
49f67f9b
|
Leszek Koltunski
|
index += (n-1);
|
| 165 |
|
|
}
|
| 166 |
|
|
else
|
| 167 |
|
|
{
|
| 168 |
89a11f7b
|
Leszek Koltunski
|
mRotArray[index] = -1;
|
| 169 |
49f67f9b
|
Leszek Koltunski
|
array[index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6);
|
| 170 |
|
|
index++;
|
| 171 |
|
|
}
|
| 172 |
|
|
|
| 173 |
|
|
return index;
|
| 174 |
|
|
}
|
| 175 |
|
|
|
| 176 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 177 |
|
|
// size^2 + 3*(size-1) in the lowermost layer, then 6*(size-2) in the next, 6*(size-3) in the next,
|
| 178 |
|
|
// ... 6 in the forelast, 1 in the last = 4size^2 - 6size +4 (if size>1)
|
| 179 |
|
|
|
| 180 |
e844c116
|
Leszek Koltunski
|
Static3D[] getCubitPositions(int size)
|
| 181 |
|
|
{
|
| 182 |
769409d2
|
Leszek Koltunski
|
int numCubits = size>1 ? 4*size*size - 6*size +4 : 1;
|
| 183 |
c2cb520d
|
Leszek Koltunski
|
Static3D[] tmp = new Static3D[numCubits];
|
| 184 |
89a11f7b
|
Leszek Koltunski
|
mRotArray = new int[numCubits];
|
| 185 |
49f67f9b
|
Leszek Koltunski
|
|
| 186 |
|
|
int currentIndex = emitLowermost( -0.5f*size, -(SQ2*SQ3/12)*size, -(SQ3/6)*size, size, tmp);
|
| 187 |
c2cb520d
|
Leszek Koltunski
|
|
| 188 |
49f67f9b
|
Leszek Koltunski
|
for(int i=size-1; i>=1; i--)
|
| 189 |
cc7dc72a
|
Leszek Koltunski
|
{
|
| 190 |
49f67f9b
|
Leszek Koltunski
|
currentIndex = emitUpper( -0.5f*i, ((SQ2*SQ3)/12)*(3*size-4*i), -(SQ3/6)*i, i, tmp, currentIndex);
|
| 191 |
cc7dc72a
|
Leszek Koltunski
|
}
|
| 192 |
49f67f9b
|
Leszek Koltunski
|
|
| 193 |
c2cb520d
|
Leszek Koltunski
|
return tmp;
|
| 194 |
e844c116
|
Leszek Koltunski
|
}
|
| 195 |
|
|
|
| 196 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 197 |
|
|
|
| 198 |
10585385
|
Leszek Koltunski
|
Static4D[] getQuats()
|
| 199 |
e844c116
|
Leszek Koltunski
|
{
|
| 200 |
10585385
|
Leszek Koltunski
|
return QUATS;
|
| 201 |
e844c116
|
Leszek Koltunski
|
}
|
| 202 |
|
|
|
| 203 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 204 |
|
|
|
| 205 |
|
|
int getNumFaces()
|
| 206 |
|
|
{
|
| 207 |
|
|
return FACE_COLORS.length;
|
| 208 |
|
|
}
|
| 209 |
|
|
|
| 210 |
f0fa83ae
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 211 |
|
|
|
| 212 |
|
|
float getScreenRatio()
|
| 213 |
|
|
{
|
| 214 |
7381193e
|
Leszek Koltunski
|
return 0.82f;
|
| 215 |
f0fa83ae
|
Leszek Koltunski
|
}
|
| 216 |
|
|
|
| 217 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 218 |
|
|
|
| 219 |
14bd7976
|
Leszek Koltunski
|
private MeshBase createStaticMesh(int cubit)
|
| 220 |
e844c116
|
Leszek Koltunski
|
{
|
| 221 |
40ab026e
|
Leszek Koltunski
|
final float SQ2 = (float)Math.sqrt(2);
|
| 222 |
|
|
final float SQ3 = (float)Math.sqrt(3);
|
| 223 |
988f434e
|
Leszek Koltunski
|
final float angleFaces = (float)((180/Math.PI)*(2*Math.asin(SQ3/3))); // angle between two faces of a tetrahedron
|
| 224 |
|
|
final int MESHES=4;
|
| 225 |
|
|
|
| 226 |
40ab026e
|
Leszek Koltunski
|
int association = 1;
|
| 227 |
988f434e
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshTriangles[MESHES];
|
| 228 |
|
|
|
| 229 |
40ab026e
|
Leszek Koltunski
|
meshes[0] = new MeshTriangles(5);
|
| 230 |
e82f3f9c
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0,association,0);
|
| 231 |
988f434e
|
Leszek Koltunski
|
|
| 232 |
40ab026e
|
Leszek Koltunski
|
for(int i=1; i<MESHES; i++)
|
| 233 |
|
|
{
|
| 234 |
|
|
association <<= 1;
|
| 235 |
|
|
meshes[i] = meshes[0].copy(true);
|
| 236 |
e82f3f9c
|
Leszek Koltunski
|
meshes[i].setEffectAssociation(0,association,0);
|
| 237 |
40ab026e
|
Leszek Koltunski
|
}
|
| 238 |
988f434e
|
Leszek Koltunski
|
|
| 239 |
40ab026e
|
Leszek Koltunski
|
MeshBase result = new MeshJoined(meshes);
|
| 240 |
|
|
|
| 241 |
|
|
Static3D a0 = new Static3D( 0, 1, 0 );
|
| 242 |
|
|
Static3D a1 = new Static3D( 0, -1.0f/3, 2*SQ2/3 );
|
| 243 |
|
|
Static3D a2 = new Static3D(-SQ2*SQ3/3, -1.0f/3, -SQ2/3 );
|
| 244 |
|
|
Static3D a3 = new Static3D( SQ2*SQ3/3, -1.0f/3, -SQ2/3 );
|
| 245 |
|
|
|
| 246 |
|
|
float tetraHeight = SQ2*SQ3/3;
|
| 247 |
|
|
float d1 = 0.75f*tetraHeight;
|
| 248 |
|
|
float d2 =-0.10f*tetraHeight;
|
| 249 |
|
|
float d3 = 0.20f*tetraHeight;
|
| 250 |
|
|
|
| 251 |
|
|
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
| 252 |
|
|
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
| 253 |
|
|
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
| 254 |
|
|
Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
|
| 255 |
|
|
|
| 256 |
|
|
Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
|
| 257 |
|
|
Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
|
| 258 |
|
|
Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
|
| 259 |
|
|
Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
|
| 260 |
|
|
|
| 261 |
|
|
Static4D dReg = new Static4D(0,0,0,d3);
|
| 262 |
|
|
Static1D dRad = new Static1D(1);
|
| 263 |
|
|
|
| 264 |
|
|
Static1D angle = new Static1D(angleFaces);
|
| 265 |
|
|
Static3D axis1 = new Static3D( -1, 0, 0);
|
| 266 |
|
|
Static3D axis2 = new Static3D(0.5f, 0, -SQ3/2);
|
| 267 |
|
|
Static3D axis3 = new Static3D(0.5f, 0, +SQ3/2);
|
| 268 |
|
|
Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
|
| 269 |
|
|
Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
|
| 270 |
|
|
|
| 271 |
14bd7976
|
Leszek Koltunski
|
Static3D center = new Static3D(0,0,0);
|
| 272 |
|
|
Static4D region = new Static4D(0,0,0,0.6f);
|
| 273 |
|
|
|
| 274 |
e82f3f9c
|
Leszek Koltunski
|
VertexEffectScale effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
|
| 275 |
40ab026e
|
Leszek Koltunski
|
VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
|
| 276 |
e82f3f9c
|
Leszek Koltunski
|
VertexEffectMove effect3 = new VertexEffectMove ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
|
| 277 |
40ab026e
|
Leszek Koltunski
|
VertexEffectRotate effect4 = new VertexEffectRotate( new Static1D(180), new Static3D(0,0,1), center1 );
|
| 278 |
|
|
VertexEffectRotate effect5 = new VertexEffectRotate( angle, axis1, center1 );
|
| 279 |
|
|
VertexEffectRotate effect6 = new VertexEffectRotate( angle, axis2, center2 );
|
| 280 |
|
|
VertexEffectRotate effect7 = new VertexEffectRotate( angle, axis3, center2 );
|
| 281 |
|
|
|
| 282 |
e82f3f9c
|
Leszek Koltunski
|
VertexEffectDeform effect8 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
| 283 |
|
|
VertexEffectDeform effect9 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
| 284 |
|
|
VertexEffectDeform effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
| 285 |
|
|
VertexEffectDeform effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
| 286 |
40ab026e
|
Leszek Koltunski
|
|
| 287 |
e82f3f9c
|
Leszek Koltunski
|
VertexEffectSink effect12= new VertexEffectSink( new Static1D(1.3f), center, region );
|
| 288 |
14bd7976
|
Leszek Koltunski
|
|
| 289 |
e82f3f9c
|
Leszek Koltunski
|
effect4.setMeshAssociation(14,-1); // apply to mesh[1], [2] and [3]
|
| 290 |
|
|
effect5.setMeshAssociation( 2,-1); // apply only to mesh[1]
|
| 291 |
|
|
effect6.setMeshAssociation( 4,-1); // apply only to mesh[2]
|
| 292 |
|
|
effect7.setMeshAssociation( 8,-1); // apply only to mesh[3]
|
| 293 |
40ab026e
|
Leszek Koltunski
|
|
| 294 |
|
|
result.apply(effect1);
|
| 295 |
|
|
result.apply(effect2);
|
| 296 |
|
|
result.apply(effect3);
|
| 297 |
|
|
result.apply(effect4);
|
| 298 |
|
|
result.apply(effect5);
|
| 299 |
|
|
result.apply(effect6);
|
| 300 |
|
|
result.apply(effect7);
|
| 301 |
|
|
result.apply(effect8);
|
| 302 |
|
|
result.apply(effect9);
|
| 303 |
|
|
result.apply(effect10);
|
| 304 |
|
|
result.apply(effect11);
|
| 305 |
14bd7976
|
Leszek Koltunski
|
result.apply(effect12);
|
| 306 |
89a11f7b
|
Leszek Koltunski
|
|
| 307 |
|
|
if( mRotArray[cubit]>=0 )
|
| 308 |
|
|
{
|
| 309 |
|
|
result.apply( ROTATION[mRotArray[cubit]] );
|
| 310 |
|
|
}
|
| 311 |
|
|
|
| 312 |
470820a7
|
Leszek Koltunski
|
result.mergeEffComponents();
|
| 313 |
|
|
|
| 314 |
89a11f7b
|
Leszek Koltunski
|
return result;
|
| 315 |
e844c116
|
Leszek Koltunski
|
}
|
| 316 |
|
|
|
| 317 |
40ab026e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 318 |
|
|
|
| 319 |
14bd7976
|
Leszek Koltunski
|
MeshBase createCubitMesh(int cubit)
|
| 320 |
40ab026e
|
Leszek Koltunski
|
{
|
| 321 |
|
|
int kind = mRotArray[cubit];
|
| 322 |
|
|
|
| 323 |
|
|
if( kind>=0 )
|
| 324 |
|
|
{
|
| 325 |
14bd7976
|
Leszek Koltunski
|
if( mMeshRotated[kind]==null ) mMeshRotated[kind] = createStaticMesh(cubit);
|
| 326 |
470820a7
|
Leszek Koltunski
|
return mMeshRotated[kind].copy(true);
|
| 327 |
40ab026e
|
Leszek Koltunski
|
}
|
| 328 |
|
|
else
|
| 329 |
|
|
{
|
| 330 |
14bd7976
|
Leszek Koltunski
|
if( mMesh==null ) mMesh = createStaticMesh(cubit);
|
| 331 |
470820a7
|
Leszek Koltunski
|
return mMesh.copy(true);
|
| 332 |
40ab026e
|
Leszek Koltunski
|
}
|
| 333 |
|
|
}
|
| 334 |
|
|
|
| 335 |
7289fd6c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 336 |
|
|
|
| 337 |
|
|
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side)
|
| 338 |
|
|
{
|
| 339 |
|
|
float STROKE = 0.06f*side;
|
| 340 |
|
|
float OFF = STROKE/2 -1;
|
| 341 |
|
|
float OFF2 = 0.5f*side + OFF;
|
| 342 |
|
|
float HEIGHT = side - OFF;
|
| 343 |
|
|
float RADIUS = side/12.0f;
|
| 344 |
|
|
float ARC1_H = 0.2f*side;
|
| 345 |
|
|
float ARC1_W = side*0.5f;
|
| 346 |
|
|
float ARC2_W = 0.153f*side;
|
| 347 |
|
|
float ARC2_H = 0.905f*side;
|
| 348 |
|
|
float ARC3_W = side-ARC2_W;
|
| 349 |
|
|
|
| 350 |
|
|
paint.setAntiAlias(true);
|
| 351 |
|
|
paint.setStrokeWidth(STROKE);
|
| 352 |
|
|
paint.setColor(FACE_COLORS[face]);
|
| 353 |
|
|
paint.setStyle(Paint.Style.FILL);
|
| 354 |
|
|
|
| 355 |
|
|
canvas.drawRect(left,top,left+side,top+side,paint);
|
| 356 |
|
|
|
| 357 |
14bd7976
|
Leszek Koltunski
|
paint.setColor(INTERIOR_COLOR);
|
| 358 |
7289fd6c
|
Leszek Koltunski
|
paint.setStyle(Paint.Style.STROKE);
|
| 359 |
|
|
|
| 360 |
|
|
canvas.drawLine( left, HEIGHT, side +left, HEIGHT, paint);
|
| 361 |
|
|
canvas.drawLine( OFF +left, side , OFF2 +left, 0, paint);
|
| 362 |
|
|
canvas.drawLine((side-OFF)+left, side , (side-OFF2) +left, 0, paint);
|
| 363 |
|
|
|
| 364 |
|
|
canvas.drawArc( ARC1_W-RADIUS+left, ARC1_H-RADIUS, ARC1_W+RADIUS+left, ARC1_H+RADIUS, 225, 90, false, paint);
|
| 365 |
|
|
canvas.drawArc( ARC2_W-RADIUS+left, ARC2_H-RADIUS, ARC2_W+RADIUS+left, ARC2_H+RADIUS, 105, 90, false, paint);
|
| 366 |
|
|
canvas.drawArc( ARC3_W-RADIUS+left, ARC2_H-RADIUS, ARC3_W+RADIUS+left, ARC2_H+RADIUS, 345, 90, false, paint);
|
| 367 |
|
|
}
|
| 368 |
|
|
|
| 369 |
e844c116
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 370 |
|
|
// PUBLIC API
|
| 371 |
|
|
|
| 372 |
12ad3fca
|
Leszek Koltunski
|
public Static3D[] getRotationAxis()
|
| 373 |
|
|
{
|
| 374 |
|
|
return AXIS;
|
| 375 |
|
|
}
|
| 376 |
|
|
|
| 377 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 378 |
|
|
|
| 379 |
e844c116
|
Leszek Koltunski
|
public int getBasicAngle()
|
| 380 |
|
|
{
|
| 381 |
|
|
return 3;
|
| 382 |
|
|
}
|
| 383 |
39e74052
|
Leszek Koltunski
|
|
| 384 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 385 |
|
|
|
| 386 |
9621255f
|
Leszek Koltunski
|
public float returnMultiplier()
|
| 387 |
39e74052
|
Leszek Koltunski
|
{
|
| 388 |
9621255f
|
Leszek Koltunski
|
return getSize()/(SQ3/2);
|
| 389 |
39e74052
|
Leszek Koltunski
|
}
|
| 390 |
e46e17fb
|
Leszek Koltunski
|
|
| 391 |
5cf34c5f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 392 |
|
|
|
| 393 |
|
|
public float[] getRowChances()
|
| 394 |
|
|
{
|
| 395 |
|
|
int size = getSize();
|
| 396 |
|
|
int total = size*(size+1)/2;
|
| 397 |
|
|
float running=0.0f;
|
| 398 |
|
|
float[] chances = new float[size];
|
| 399 |
|
|
|
| 400 |
|
|
for(int i=0; i<size; i++)
|
| 401 |
|
|
{
|
| 402 |
|
|
running += (size-i);
|
| 403 |
|
|
chances[i] = running / total;
|
| 404 |
|
|
}
|
| 405 |
|
|
|
| 406 |
|
|
return chances;
|
| 407 |
|
|
}
|
| 408 |
|
|
|
| 409 |
e46e17fb
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 410 |
|
|
|
| 411 |
|
|
public float returnRotationFactor(float offset)
|
| 412 |
|
|
{
|
| 413 |
|
|
int size = getSize();
|
| 414 |
|
|
int row = (int)(size*offset/(SQ3/2));
|
| 415 |
|
|
|
| 416 |
|
|
return ((float)size)/(size-row);
|
| 417 |
|
|
}
|
| 418 |
f0336037
|
Leszek Koltunski
|
|
| 419 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 420 |
|
|
// TODO
|
| 421 |
|
|
|
| 422 |
20931cf6
|
Leszek Koltunski
|
public String retObjectString()
|
| 423 |
f0336037
|
Leszek Koltunski
|
{
|
| 424 |
|
|
return "";
|
| 425 |
|
|
}
|
| 426 |
e844c116
|
Leszek Koltunski
|
}
|