| 1 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
| 3 |
|
|
// //
|
| 4 |
|
|
// This file is part of Magic Cube. //
|
| 5 |
|
|
// //
|
| 6 |
4c87f159
|
Leszek Koltunski
|
// 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 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 9 |
|
|
|
| 10 |
|
|
package org.distorted.objectlib.main;
|
| 11 |
|
|
|
| 12 |
3a1efb32
|
Leszek Koltunski
|
import java.io.DataInputStream;
|
| 13 |
|
|
import java.io.IOException;
|
| 14 |
|
|
import java.io.InputStream;
|
| 15 |
|
|
import java.util.Random;
|
| 16 |
|
|
|
| 17 |
29b82486
|
Leszek Koltunski
|
import android.graphics.Bitmap;
|
| 18 |
|
|
import android.graphics.Canvas;
|
| 19 |
|
|
import android.graphics.Paint;
|
| 20 |
|
|
|
| 21 |
|
|
import org.distorted.library.effect.Effect;
|
| 22 |
|
|
import org.distorted.library.effect.MatrixEffectMove;
|
| 23 |
|
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
| 24 |
|
|
import org.distorted.library.effect.MatrixEffectScale;
|
| 25 |
|
|
import org.distorted.library.effect.VertexEffectQuaternion;
|
| 26 |
a0b0795b
|
Leszek Koltunski
|
import org.distorted.library.effect.VertexEffectSink;
|
| 27 |
29b82486
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedEffects;
|
| 28 |
|
|
import org.distorted.library.main.DistortedLibrary;
|
| 29 |
|
|
import org.distorted.library.main.DistortedNode;
|
| 30 |
|
|
import org.distorted.library.main.DistortedTexture;
|
| 31 |
aacf5e27
|
Leszek Koltunski
|
import org.distorted.library.helpers.QuatHelper;
|
| 32 |
29b82486
|
Leszek Koltunski
|
import org.distorted.library.mesh.MeshBase;
|
| 33 |
|
|
import org.distorted.library.mesh.MeshFile;
|
| 34 |
|
|
import org.distorted.library.mesh.MeshJoined;
|
| 35 |
|
|
import org.distorted.library.message.EffectListener;
|
| 36 |
|
|
import org.distorted.library.type.Static1D;
|
| 37 |
|
|
import org.distorted.library.type.Static3D;
|
| 38 |
|
|
import org.distorted.library.type.Static4D;
|
| 39 |
a57e6870
|
Leszek Koltunski
|
|
| 40 |
198c5bf0
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.FactoryCubit;
|
| 41 |
|
|
import org.distorted.objectlib.helpers.FactorySticker;
|
| 42 |
3ee1d662
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectFaceShape;
|
| 43 |
d887aa16
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectLibInterface;
|
| 44 |
198c5bf0
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectShape;
|
| 45 |
ae9d9227
|
leszek
|
import org.distorted.objectlib.metadata.Metadata;
|
| 46 |
97a75106
|
leszek
|
import org.distorted.objectlib.signature.ObjectSignature;
|
| 47 |
198c5bf0
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectSticker;
|
| 48 |
3a0a23bf
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectStickerOverride;
|
| 49 |
84a17011
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.ObjectVertexEffects;
|
| 50 |
3103c3c8
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.OperatingSystemInterface;
|
| 51 |
802fe251
|
Leszek Koltunski
|
import org.distorted.objectlib.helpers.QuatGroupGenerator;
|
| 52 |
10b7e306
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ObjectScrambler;
|
| 53 |
82eb152a
|
Leszek Koltunski
|
import org.distorted.objectlib.json.JsonReader;
|
| 54 |
731280f7
|
Leszek Koltunski
|
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator;
|
| 55 |
c0266cb1
|
Leszek Koltunski
|
import org.distorted.objectlib.tablebases.ImplementedTablebasesList;
|
| 56 |
|
|
import org.distorted.objectlib.tablebases.TablebasesAbstract;
|
| 57 |
3a1efb32
|
Leszek Koltunski
|
import org.distorted.objectlib.touchcontrol.*;
|
| 58 |
29b82486
|
Leszek Koltunski
|
|
| 59 |
3a1efb32
|
Leszek Koltunski
|
import static org.distorted.objectlib.touchcontrol.TouchControl.*;
|
| 60 |
59c20632
|
Leszek Koltunski
|
|
| 61 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 62 |
|
|
|
| 63 |
7ba38dd4
|
Leszek Koltunski
|
public abstract class TwistyObject
|
| 64 |
29b82486
|
Leszek Koltunski
|
{
|
| 65 |
3bf19410
|
Leszek Koltunski
|
public static final int MODE_ICON = 0;
|
| 66 |
|
|
public static final int MODE_NORM = 1;
|
| 67 |
|
|
|
| 68 |
7ec32155
|
Leszek Koltunski
|
public static final int COLOR_YELLOW = 0xffffff00;
|
| 69 |
|
|
public static final int COLOR_WHITE = 0xffffffff;
|
| 70 |
|
|
public static final int COLOR_BLUE = 0xff0000ff;
|
| 71 |
|
|
public static final int COLOR_GREEN = 0xff00bb00;
|
| 72 |
|
|
public static final int COLOR_RED = 0xff990000;
|
| 73 |
|
|
public static final int COLOR_ORANGE = 0xffff6200;
|
| 74 |
|
|
public static final int COLOR_GREY = 0xff727c7b;
|
| 75 |
|
|
public static final int COLOR_VIOLET = 0xff7700bb;
|
| 76 |
|
|
public static final int COLOR_STROKE = 0xff000000;
|
| 77 |
c60d98c4
|
Leszek Koltunski
|
public static final int COLOR_INTERNAL = 0xff000000;
|
| 78 |
29b82486
|
Leszek Koltunski
|
|
| 79 |
f351be7d
|
leszek
|
public static final int COLOR_RED_TET = 0xffff1111;
|
| 80 |
|
|
public static final int COLOR_BLUE_TET = 0xff4444ff;
|
| 81 |
|
|
|
| 82 |
cce2b48c
|
leszek
|
private static final int DEFAULT_TEXTURE_HEIGHT = 256;
|
| 83 |
d1025da5
|
leszek
|
private static final int DEFAULT_TEXTURE_ROWS = 8;
|
| 84 |
29b82486
|
Leszek Koltunski
|
|
| 85 |
|
|
public static final float SQ2 = (float)Math.sqrt(2);
|
| 86 |
|
|
public static final float SQ3 = (float)Math.sqrt(3);
|
| 87 |
|
|
public static final float SQ5 = (float)Math.sqrt(5);
|
| 88 |
|
|
public static final float SQ6 = (float)Math.sqrt(6);
|
| 89 |
|
|
|
| 90 |
|
|
private static final float MAX_SIZE_CHANGE = 1.35f;
|
| 91 |
|
|
private static final float MIN_SIZE_CHANGE = 0.75f;
|
| 92 |
|
|
|
| 93 |
|
|
private static final Static3D CENTER = new Static3D(0,0,0);
|
| 94 |
|
|
|
| 95 |
ebe8c08e
|
leszek
|
protected float[][][][] mStickerCoords;
|
| 96 |
802fe251
|
Leszek Koltunski
|
protected Static4D[] mObjectQuats;
|
| 97 |
82eb152a
|
Leszek Koltunski
|
|
| 98 |
a05b6e06
|
Leszek Koltunski
|
private int[][] mStickerVariants;
|
| 99 |
|
|
private float[] mStickerScales;
|
| 100 |
5618c5a9
|
Leszek Koltunski
|
private TwistyObjectCubit[] mCubits;
|
| 101 |
|
|
private TwistyObjectSolved mSolved;
|
| 102 |
a05b6e06
|
Leszek Koltunski
|
private MeshBase[] mMeshes;
|
| 103 |
3a0a23bf
|
Leszek Koltunski
|
private int mNumCubits, mNumQuats, mNumFaceColors, mNumTextures, mNumOverrides;
|
| 104 |
7af68038
|
Leszek Koltunski
|
private int mNumCubitFaces, mNumStickerTypes;
|
| 105 |
82eb152a
|
Leszek Koltunski
|
private Static3D[] mAxis;
|
| 106 |
|
|
private float[][] mCuts;
|
| 107 |
63bfcdd1
|
leszek
|
private int[][] mMinimalCubiesInRow;
|
| 108 |
82eb152a
|
Leszek Koltunski
|
private int[] mNumCuts;
|
| 109 |
|
|
private float[][] mOrigPos;
|
| 110 |
5931ae4d
|
Leszek Koltunski
|
private Static4D[] mOrigQuat;
|
| 111 |
00a28d71
|
Leszek Koltunski
|
private Static4D[] mMixupModeQuats;
|
| 112 |
|
|
private boolean mIsInMixupMode;
|
| 113 |
82eb152a
|
Leszek Koltunski
|
private Static4D mQuat;
|
| 114 |
3ce95490
|
Leszek Koltunski
|
private int[] mNumLayers;
|
| 115 |
|
|
private float mSize;
|
| 116 |
82eb152a
|
Leszek Koltunski
|
private DistortedEffects mEffects;
|
| 117 |
|
|
private Static3D mObjectScale;
|
| 118 |
|
|
private int[] mQuatDebug;
|
| 119 |
|
|
private DistortedTexture mTexture;
|
| 120 |
|
|
private float mInitScreenRatio;
|
| 121 |
|
|
private boolean mIsBandaged;
|
| 122 |
29b82486
|
Leszek Koltunski
|
private float mObjectScreenRatio;
|
| 123 |
f3eab97f
|
leszek
|
private int mNumTexRows, mNumTexCols, mTexHeight;
|
| 124 |
29b82486
|
Leszek Koltunski
|
private MeshBase mMesh;
|
| 125 |
10b7e306
|
Leszek Koltunski
|
private ObjectScrambler mScrambler;
|
| 126 |
c9c71c3f
|
Leszek Koltunski
|
private TouchControl mTouchControl;
|
| 127 |
7ba38dd4
|
Leszek Koltunski
|
private DistortedNode mNode;
|
| 128 |
d887aa16
|
Leszek Koltunski
|
private ObjectLibInterface mInterface;
|
| 129 |
d5c71d02
|
Leszek Koltunski
|
private Bitmap mBitmap;
|
| 130 |
d53fb890
|
Leszek Koltunski
|
private ObjectSticker[] mStickers;
|
| 131 |
b968d359
|
Leszek Koltunski
|
private ObjectShape[] mShapes;
|
| 132 |
|
|
private int mNumCubitVariants;
|
| 133 |
9b1fe915
|
Leszek Koltunski
|
private int[][] mCubitFaceColors;
|
| 134 |
59a971c1
|
Leszek Koltunski
|
private int[][] mVariantFaceIsOuter;
|
| 135 |
beee90ab
|
Leszek Koltunski
|
private int[][] mBasicAngles;
|
| 136 |
3bf19410
|
Leszek Koltunski
|
private int mIconMode;
|
| 137 |
ae9d9227
|
leszek
|
private Metadata mMetadata;
|
| 138 |
fbd18fc7
|
Leszek Koltunski
|
private float[][] mRowOffsets;
|
| 139 |
|
|
private boolean[] mBelongs;
|
| 140 |
|
|
private float[] mTmp;
|
| 141 |
5a20f7a1
|
Leszek Koltunski
|
private int mNumPuzzleFaces;
|
| 142 |
3a0a23bf
|
Leszek Koltunski
|
private ObjectStickerOverride[] mStickerOverrides;
|
| 143 |
3ce95490
|
Leszek Koltunski
|
private boolean mError;
|
| 144 |
|
|
private String mErrorString;
|
| 145 |
d85de775
|
Leszek Koltunski
|
private int mMaxNumLayers;
|
| 146 |
|
|
private int mNumAxis;
|
| 147 |
3788d0cd
|
Leszek Koltunski
|
private boolean mThereAreDeciders;
|
| 148 |
e3169794
|
leszek
|
private TwistyLayerRotations mRotation;
|
| 149 |
962b8ff6
|
leszek
|
private int[] mColorTable;
|
| 150 |
5ce579d2
|
leszek
|
private int[] mOriginalColorTable;
|
| 151 |
6f5eb9b3
|
leszek
|
private float mTextureBorderMultiplier, mTextureCornerMultiplier;
|
| 152 |
29b82486
|
Leszek Koltunski
|
|
| 153 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 154 |
|
|
|
| 155 |
1fda81c4
|
leszek
|
TwistyObject(int iconMode, Static4D quat, Static3D move, float scale, InitAssets asset)
|
| 156 |
82eb152a
|
Leszek Koltunski
|
{
|
| 157 |
3ce95490
|
Leszek Koltunski
|
try
|
| 158 |
|
|
{
|
| 159 |
c0266cb1
|
Leszek Koltunski
|
InputStream jsonStream = asset!=null ? asset.getJsonStream(): null;
|
| 160 |
958a6e81
|
Leszek Koltunski
|
JsonReader reader = new JsonReader();
|
| 161 |
3ce95490
|
Leszek Koltunski
|
reader.parseJsonFile(jsonStream);
|
| 162 |
|
|
setReader(reader);
|
| 163 |
|
|
mNumLayers = reader.getNumLayers();
|
| 164 |
|
|
mSize = reader.getSize();
|
| 165 |
ae9d9227
|
leszek
|
mMetadata = null;
|
| 166 |
1fda81c4
|
leszek
|
initialize(iconMode,quat,move,scale,asset,true);
|
| 167 |
c0266cb1
|
Leszek Koltunski
|
if( asset!=null ) asset.close();
|
| 168 |
3ce95490
|
Leszek Koltunski
|
mError = false;
|
| 169 |
|
|
mErrorString=null;
|
| 170 |
|
|
}
|
| 171 |
|
|
catch(Exception ex)
|
| 172 |
|
|
{
|
| 173 |
|
|
mError = true;
|
| 174 |
|
|
mErrorString = ex.getMessage();
|
| 175 |
|
|
}
|
| 176 |
82eb152a
|
Leszek Koltunski
|
}
|
| 177 |
|
|
|
| 178 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 179 |
|
|
|
| 180 |
ae9d9227
|
leszek
|
public TwistyObject(int iconMode, float size, Static4D quat, Static3D move, float scale, Metadata meta, InitAssets asset)
|
| 181 |
29b82486
|
Leszek Koltunski
|
{
|
| 182 |
ae9d9227
|
leszek
|
mNumLayers = meta.getNumLayers();
|
| 183 |
82eb152a
|
Leszek Koltunski
|
mSize = size;
|
| 184 |
ae9d9227
|
leszek
|
mMetadata = meta;
|
| 185 |
1fda81c4
|
leszek
|
initialize(iconMode,quat,move,scale,asset,false);
|
| 186 |
c0266cb1
|
Leszek Koltunski
|
if( asset!=null ) asset.close();
|
| 187 |
3ce95490
|
Leszek Koltunski
|
mError = false;
|
| 188 |
|
|
mErrorString = null;
|
| 189 |
82eb152a
|
Leszek Koltunski
|
}
|
| 190 |
|
|
|
| 191 |
1f329dcc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 192 |
|
|
|
| 193 |
|
|
private void debugQuat(Static4D quat, int cubitIndex, float axisX, float axisY, float axisZ, float angle, int place)
|
| 194 |
|
|
{
|
| 195 |
|
|
float[] tracking = mCubits[cubitIndex].getTrackingPoint();
|
| 196 |
|
|
|
| 197 |
e61a7687
|
leszek
|
if( tracking!=null )
|
| 198 |
|
|
{
|
| 199 |
|
|
String problem = (getShortName()+" "+cubitIndex+" "+quat.get0()+" "+quat.get1()+" "+quat.get2()+" "+quat.get3());
|
| 200 |
|
|
problem += (" "+angle+" "+place+" "+tracking[0]+" "+tracking[1]+" "+tracking[2]);
|
| 201 |
e3169794
|
leszek
|
problem += (" "+axisX+" "+axisY+" "+axisZ);
|
| 202 |
1f329dcc
|
Leszek Koltunski
|
|
| 203 |
e61a7687
|
leszek
|
mInterface.reportProblem(problem, true);
|
| 204 |
|
|
}
|
| 205 |
1f329dcc
|
Leszek Koltunski
|
}
|
| 206 |
|
|
|
| 207 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 208 |
|
|
|
| 209 |
1fda81c4
|
leszek
|
private void initialize(int iconMode, Static4D quat, Static3D move, float scale, InitAssets asset, boolean fromJSON)
|
| 210 |
82eb152a
|
Leszek Koltunski
|
{
|
| 211 |
3bf19410
|
Leszek Koltunski
|
mIconMode = iconMode;
|
| 212 |
82eb152a
|
Leszek Koltunski
|
mQuat = quat;
|
| 213 |
29b82486
|
Leszek Koltunski
|
mAxis = getRotationAxis();
|
| 214 |
|
|
mInitScreenRatio = getScreenRatio();
|
| 215 |
802fe251
|
Leszek Koltunski
|
mBasicAngles = getBasicAngles();
|
| 216 |
89a00832
|
Leszek Koltunski
|
mObjectQuats = getQuats();
|
| 217 |
|
|
mNumQuats = mObjectQuats.length;
|
| 218 |
|
|
mOrigPos = getCubitPositions(mNumLayers);
|
| 219 |
5a20f7a1
|
Leszek Koltunski
|
mNumPuzzleFaces = getNumFaces();
|
| 220 |
|
|
mRowOffsets = new float[mNumPuzzleFaces][3];
|
| 221 |
fbd18fc7
|
Leszek Koltunski
|
mTmp = new float[4];
|
| 222 |
d85de775
|
Leszek Koltunski
|
mNumAxis = mAxis.length;
|
| 223 |
29b82486
|
Leszek Koltunski
|
mCuts = getCuts(mNumLayers);
|
| 224 |
d85de775
|
Leszek Koltunski
|
mNumCuts = new int[mNumAxis];
|
| 225 |
|
|
mMaxNumLayers = -1;
|
| 226 |
|
|
for(int i=0; i<mNumAxis; i++)
|
| 227 |
dfdb26a9
|
Leszek Koltunski
|
{
|
| 228 |
d55d2c6a
|
Leszek Koltunski
|
if( mMaxNumLayers<mNumLayers[i] ) mMaxNumLayers = mNumLayers[i];
|
| 229 |
dfdb26a9
|
Leszek Koltunski
|
mNumCuts[i] = (mCuts==null || mCuts[i]==null ? 0 : mCuts[i].length);
|
| 230 |
|
|
}
|
| 231 |
29b82486
|
Leszek Koltunski
|
|
| 232 |
5ce579d2
|
leszek
|
mOriginalColorTable = getColorTable();
|
| 233 |
|
|
mNumFaceColors = mOriginalColorTable.length;
|
| 234 |
|
|
mColorTable = new int[mNumFaceColors];
|
| 235 |
962b8ff6
|
leszek
|
recreateFaceColors();
|
| 236 |
6f5eb9b3
|
leszek
|
mTextureBorderMultiplier = 1.0f;
|
| 237 |
|
|
mTextureCornerMultiplier = 1.0f;
|
| 238 |
|
|
|
| 239 |
63bfcdd1
|
leszek
|
mMinimalCubiesInRow = getMinimalCubiesInRow();
|
| 240 |
a05b6e06
|
Leszek Koltunski
|
mNumCubits = mOrigPos.length;
|
| 241 |
962b8ff6
|
leszek
|
|
| 242 |
fbd18fc7
|
Leszek Koltunski
|
mBelongs = new boolean[mNumCubits];
|
| 243 |
a05b6e06
|
Leszek Koltunski
|
|
| 244 |
29b82486
|
Leszek Koltunski
|
int scramblingType = getScrambleType();
|
| 245 |
9ba7f3f6
|
Leszek Koltunski
|
int[][] edges = getScrambleEdges();
|
| 246 |
|
|
int[][] algorithms = getScrambleAlgorithms();
|
| 247 |
|
|
|
| 248 |
3103c3c8
|
Leszek Koltunski
|
OperatingSystemInterface os = asset==null ? null : asset.getOS();
|
| 249 |
|
|
TablebasesAbstract tablebase = os!=null ? getTablebase(os) : null;
|
| 250 |
c0266cb1
|
Leszek Koltunski
|
mScrambler = new ObjectScrambler(scramblingType,mNumAxis,mNumLayers,algorithms,edges,tablebase);
|
| 251 |
29b82486
|
Leszek Koltunski
|
|
| 252 |
|
|
boolean bandaged=false;
|
| 253 |
|
|
|
| 254 |
a05b6e06
|
Leszek Koltunski
|
for( int c=0; c<mNumCubits; c++)
|
| 255 |
29b82486
|
Leszek Koltunski
|
{
|
| 256 |
|
|
if( mOrigPos[c].length>3 )
|
| 257 |
|
|
{
|
| 258 |
|
|
bandaged=true;
|
| 259 |
|
|
break;
|
| 260 |
|
|
}
|
| 261 |
|
|
}
|
| 262 |
|
|
mIsBandaged = bandaged;
|
| 263 |
a05b6e06
|
Leszek Koltunski
|
mQuatDebug = new int[mNumCubits];
|
| 264 |
29b82486
|
Leszek Koltunski
|
|
| 265 |
64c209f5
|
Leszek Koltunski
|
mObjectScale = new Static3D(scale,scale,scale);
|
| 266 |
|
|
setObjectRatioNow(scale,720);
|
| 267 |
e7daa161
|
Leszek Koltunski
|
|
| 268 |
00a28d71
|
Leszek Koltunski
|
mEffects = new DistortedEffects();
|
| 269 |
|
|
createQuaternionEffects();
|
| 270 |
|
|
|
| 271 |
a0ef8a1d
|
leszek
|
mRotation = new TwistyLayerRotations(this,mAxis,mNumLayers,getGhostAngle(),mEffects);
|
| 272 |
4a014840
|
leszek
|
|
| 273 |
29b82486
|
Leszek Koltunski
|
MatrixEffectScale scaleEffect = new MatrixEffectScale(mObjectScale);
|
| 274 |
57ef6378
|
Leszek Koltunski
|
MatrixEffectQuaternion quatEffect = new MatrixEffectQuaternion(mQuat, CENTER);
|
| 275 |
b80e6524
|
Leszek Koltunski
|
MatrixEffectMove moveEffect = new MatrixEffectMove(move);
|
| 276 |
29b82486
|
Leszek Koltunski
|
|
| 277 |
c0266cb1
|
Leszek Koltunski
|
InputStream meshStream = asset!=null ? asset.getMeshStream(): null;
|
| 278 |
1fda81c4
|
leszek
|
boolean fromDMESH = (meshStream!=null);
|
| 279 |
4c9ca251
|
Leszek Koltunski
|
getQuatsAndShapes(fromDMESH,fromJSON);
|
| 280 |
1fda81c4
|
leszek
|
createMeshAndCubits(meshStream,fromDMESH);
|
| 281 |
e16fd960
|
Leszek Koltunski
|
setUpTextures(fromDMESH,fromJSON);
|
| 282 |
5618c5a9
|
Leszek Koltunski
|
|
| 283 |
|
|
int index = getSolvedFunctionIndex();
|
| 284 |
|
|
mSolved = new TwistyObjectSolved(this,mOrigPos,index);
|
| 285 |
be95dbf5
|
Leszek Koltunski
|
mSolved.setupSolvedQuats(getSolvedQuats());
|
| 286 |
29b82486
|
Leszek Koltunski
|
|
| 287 |
|
|
mEffects.apply(quatEffect);
|
| 288 |
|
|
mEffects.apply(scaleEffect);
|
| 289 |
b80e6524
|
Leszek Koltunski
|
mEffects.apply(moveEffect);
|
| 290 |
29b82486
|
Leszek Koltunski
|
|
| 291 |
7ba38dd4
|
Leszek Koltunski
|
mNode = new DistortedNode(mTexture,mEffects,mMesh);
|
| 292 |
29b82486
|
Leszek Koltunski
|
}
|
| 293 |
|
|
|
| 294 |
962b8ff6
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 295 |
|
|
|
| 296 |
|
|
public void recreateFaceColors()
|
| 297 |
|
|
{
|
| 298 |
5ce579d2
|
leszek
|
for(int i=0; i<mNumFaceColors; i++) mColorTable[i] = mOriginalColorTable[i];
|
| 299 |
962b8ff6
|
leszek
|
}
|
| 300 |
|
|
|
| 301 |
544c9224
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 302 |
|
|
// in degrees so that everything can be treated modulo 360
|
| 303 |
|
|
|
| 304 |
|
|
public int getGhostAngle()
|
| 305 |
|
|
{
|
| 306 |
|
|
return 0;
|
| 307 |
|
|
}
|
| 308 |
|
|
|
| 309 |
c0266cb1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 310 |
|
|
|
| 311 |
3103c3c8
|
Leszek Koltunski
|
private TablebasesAbstract getTablebase(OperatingSystemInterface os)
|
| 312 |
c0266cb1
|
Leszek Koltunski
|
{
|
| 313 |
1349f488
|
leszek
|
String shortName = getShortName();
|
| 314 |
|
|
return ImplementedTablebasesList.createPacked(os,shortName);
|
| 315 |
c0266cb1
|
Leszek Koltunski
|
}
|
| 316 |
|
|
|
| 317 |
00a28d71
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 318 |
|
|
|
| 319 |
|
|
private void createQuaternionEffects()
|
| 320 |
|
|
{
|
| 321 |
|
|
if( mNumQuats<=ObjectControl.MAX_QUATS )
|
| 322 |
|
|
{
|
| 323 |
|
|
mIsInMixupMode = false;
|
| 324 |
|
|
|
| 325 |
|
|
for( int q=0; q<mNumQuats; q++)
|
| 326 |
|
|
{
|
| 327 |
|
|
VertexEffectQuaternion vq = new VertexEffectQuaternion(mObjectQuats[q],CENTER);
|
| 328 |
|
|
vq.setMeshAssociation(0,q);
|
| 329 |
|
|
mEffects.apply(vq);
|
| 330 |
|
|
}
|
| 331 |
|
|
}
|
| 332 |
|
|
else if( mNumCubits<=ObjectControl.MAX_QUATS )
|
| 333 |
|
|
{
|
| 334 |
|
|
mIsInMixupMode = true;
|
| 335 |
|
|
mMixupModeQuats = new Static4D[mNumCubits];
|
| 336 |
|
|
|
| 337 |
|
|
for( int q=0; q<mNumCubits; q++)
|
| 338 |
|
|
{
|
| 339 |
|
|
mMixupModeQuats[q] = new Static4D(mObjectQuats[0]);
|
| 340 |
|
|
VertexEffectQuaternion vq = new VertexEffectQuaternion(mMixupModeQuats[q],CENTER);
|
| 341 |
|
|
vq.setMeshAssociation(0,q);
|
| 342 |
|
|
mEffects.apply(vq);
|
| 343 |
|
|
}
|
| 344 |
|
|
}
|
| 345 |
|
|
else
|
| 346 |
|
|
{
|
| 347 |
|
|
android.util.Log.e("D", "object has too many quaternions ("+mNumQuats+") or too many cubits ("+mNumCubits+")");
|
| 348 |
|
|
}
|
| 349 |
|
|
}
|
| 350 |
|
|
|
| 351 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 352 |
|
|
|
| 353 |
|
|
private Static3D getPos(float[] origPos)
|
| 354 |
|
|
{
|
| 355 |
|
|
int len = origPos.length/3;
|
| 356 |
|
|
float sumX = 0.0f;
|
| 357 |
|
|
float sumY = 0.0f;
|
| 358 |
|
|
float sumZ = 0.0f;
|
| 359 |
|
|
|
| 360 |
|
|
for(int i=0; i<len; i++)
|
| 361 |
|
|
{
|
| 362 |
|
|
sumX += origPos[3*i ];
|
| 363 |
|
|
sumY += origPos[3*i+1];
|
| 364 |
|
|
sumZ += origPos[3*i+2];
|
| 365 |
|
|
}
|
| 366 |
|
|
|
| 367 |
|
|
sumX /= len;
|
| 368 |
|
|
sumY /= len;
|
| 369 |
|
|
sumZ /= len;
|
| 370 |
|
|
|
| 371 |
|
|
return new Static3D(sumX,sumY,sumZ);
|
| 372 |
|
|
}
|
| 373 |
|
|
|
| 374 |
59a971c1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 375 |
|
|
|
| 376 |
|
|
private void createOuterFaces()
|
| 377 |
|
|
{
|
| 378 |
|
|
for(int v=0; v<mNumCubitVariants; v++)
|
| 379 |
|
|
{
|
| 380 |
89c2b479
|
Leszek Koltunski
|
int numFaces = mShapes[v].getNumFaces();
|
| 381 |
|
|
mVariantFaceIsOuter[v] = new int[numFaces];
|
| 382 |
59a971c1
|
Leszek Koltunski
|
}
|
| 383 |
|
|
|
| 384 |
a05b6e06
|
Leszek Koltunski
|
for( int cubit=0; cubit<mNumCubits; cubit++)
|
| 385 |
59a971c1
|
Leszek Koltunski
|
{
|
| 386 |
|
|
int variant = getCubitVariant(cubit,mNumLayers);
|
| 387 |
89c2b479
|
Leszek Koltunski
|
int numFaces = mShapes[variant].getNumFaces();
|
| 388 |
59a971c1
|
Leszek Koltunski
|
|
| 389 |
|
|
for(int face=0; face<numFaces; face++)
|
| 390 |
d4105efe
|
Leszek Koltunski
|
if( getCubitFaceColor(cubit,face)>=0 )
|
| 391 |
59a971c1
|
Leszek Koltunski
|
{
|
| 392 |
|
|
mVariantFaceIsOuter[variant][face] = 1;
|
| 393 |
|
|
}
|
| 394 |
|
|
}
|
| 395 |
|
|
}
|
| 396 |
|
|
|
| 397 |
4c9ca251
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 398 |
|
|
|
| 399 |
|
|
private void getQuatsAndShapes(boolean fromDMESH, boolean fromJSON)
|
| 400 |
|
|
{
|
| 401 |
|
|
mNumCubitVariants = getNumCubitVariants(mNumLayers);
|
| 402 |
|
|
|
| 403 |
|
|
if( !fromDMESH || !fromJSON )
|
| 404 |
|
|
{
|
| 405 |
|
|
FactoryCubit factory = FactoryCubit.getInstance();
|
| 406 |
|
|
factory.clear();
|
| 407 |
|
|
|
| 408 |
|
|
mShapes = new ObjectShape[mNumCubitVariants];
|
| 409 |
5e1b47f8
|
leszek
|
for(int v=0; v<mNumCubitVariants; v++) mShapes[v] = getObjectShape(v);
|
| 410 |
4c9ca251
|
Leszek Koltunski
|
mNumCubitFaces = ObjectShape.computeNumComponents(mShapes);
|
| 411 |
59a971c1
|
Leszek Koltunski
|
mVariantFaceIsOuter = new int[mNumCubitVariants][];
|
| 412 |
4c9ca251
|
Leszek Koltunski
|
|
| 413 |
716f5517
|
Leszek Koltunski
|
mOrigQuat = new Static4D[mNumCubits];
|
| 414 |
|
|
for(int i=0; i<mNumCubits; i++) mOrigQuat[i] = getCubitQuats(i,mNumLayers);
|
| 415 |
|
|
|
| 416 |
59a971c1
|
Leszek Koltunski
|
if( !fromJSON )
|
| 417 |
4c9ca251
|
Leszek Koltunski
|
{
|
| 418 |
59a971c1
|
Leszek Koltunski
|
mCubitFaceColors = ObjectShape.computeColors(mShapes,mOrigPos,mOrigQuat,this);
|
| 419 |
|
|
createOuterFaces();
|
| 420 |
4c9ca251
|
Leszek Koltunski
|
}
|
| 421 |
9b1fe915
|
Leszek Koltunski
|
|
| 422 |
59a971c1
|
Leszek Koltunski
|
if( fromDMESH )
|
| 423 |
9b1fe915
|
Leszek Koltunski
|
{
|
| 424 |
59a971c1
|
Leszek Koltunski
|
for(int i=0; i<mNumCubitVariants; i++) factory.createNewFaceTransform(mShapes[i], mVariantFaceIsOuter[i]);
|
| 425 |
9b1fe915
|
Leszek Koltunski
|
}
|
| 426 |
4c9ca251
|
Leszek Koltunski
|
}
|
| 427 |
|
|
}
|
| 428 |
|
|
|
| 429 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 430 |
|
|
|
| 431 |
1fda81c4
|
leszek
|
private void createMeshAndCubits(InputStream stream, boolean fromDMESH)
|
| 432 |
29b82486
|
Leszek Koltunski
|
{
|
| 433 |
5618c5a9
|
Leszek Koltunski
|
mCubits = new TwistyObjectCubit[mNumCubits];
|
| 434 |
4c9ca251
|
Leszek Koltunski
|
|
| 435 |
e16fd960
|
Leszek Koltunski
|
if( fromDMESH )
|
| 436 |
29b82486
|
Leszek Koltunski
|
{
|
| 437 |
82eb152a
|
Leszek Koltunski
|
DataInputStream dos = new DataInputStream(stream);
|
| 438 |
29b82486
|
Leszek Koltunski
|
mMesh = new MeshFile(dos);
|
| 439 |
|
|
|
| 440 |
|
|
try
|
| 441 |
|
|
{
|
| 442 |
82eb152a
|
Leszek Koltunski
|
stream.close();
|
| 443 |
29b82486
|
Leszek Koltunski
|
}
|
| 444 |
|
|
catch(IOException e)
|
| 445 |
|
|
{
|
| 446 |
9cb7d66f
|
Leszek Koltunski
|
android.util.Log.e("meshFile", "Error closing InputStream: "+e);
|
| 447 |
29b82486
|
Leszek Koltunski
|
}
|
| 448 |
|
|
}
|
| 449 |
|
|
else
|
| 450 |
|
|
{
|
| 451 |
a05b6e06
|
Leszek Koltunski
|
MeshBase[] cubitMesh = new MeshBase[mNumCubits];
|
| 452 |
5931ae4d
|
Leszek Koltunski
|
|
| 453 |
a05b6e06
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++)
|
| 454 |
29b82486
|
Leszek Koltunski
|
{
|
| 455 |
1fda81c4
|
leszek
|
cubitMesh[i] = createCubitMesh(i,mNumLayers,mNumCubitFaces);
|
| 456 |
29b82486
|
Leszek Koltunski
|
Static3D pos = getPos(mOrigPos[i]);
|
| 457 |
|
|
cubitMesh[i].apply(new MatrixEffectMove(pos),1,0);
|
| 458 |
|
|
}
|
| 459 |
|
|
|
| 460 |
|
|
mMesh = new MeshJoined(cubitMesh);
|
| 461 |
a0b0795b
|
Leszek Koltunski
|
|
| 462 |
|
|
float pillowCoeff = getPillowCoeff();
|
| 463 |
|
|
|
| 464 |
|
|
if( pillowCoeff!=1.0f )
|
| 465 |
|
|
{
|
| 466 |
|
|
float radius = getCircumscribedRadius();
|
| 467 |
|
|
Static1D coeff = new Static1D(pillowCoeff);
|
| 468 |
|
|
Static4D region= new Static4D(0,0,0,radius);
|
| 469 |
|
|
VertexEffectSink sink = new VertexEffectSink(coeff,CENTER,region);
|
| 470 |
|
|
mMesh.apply(sink);
|
| 471 |
|
|
}
|
| 472 |
29b82486
|
Leszek Koltunski
|
}
|
| 473 |
00a28d71
|
Leszek Koltunski
|
|
| 474 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 475 |
|
|
{
|
| 476 |
5618c5a9
|
Leszek Koltunski
|
mCubits[i] = new TwistyObjectCubit(this,mOrigPos[i],mNumAxis,mMaxNumLayers,i);
|
| 477 |
544c9224
|
leszek
|
setCubitQuat(i,0);
|
| 478 |
3788d0cd
|
Leszek Koltunski
|
|
| 479 |
|
|
if( !mThereAreDeciders && mCubits[i].getType()==TwistyObjectCubit.TYPE_DECIDER )
|
| 480 |
|
|
{
|
| 481 |
|
|
mThereAreDeciders = true;
|
| 482 |
|
|
}
|
| 483 |
00a28d71
|
Leszek Koltunski
|
}
|
| 484 |
29b82486
|
Leszek Koltunski
|
}
|
| 485 |
|
|
|
| 486 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 487 |
|
|
|
| 488 |
1fda81c4
|
leszek
|
private MeshBase createCubitMesh(int cubit, int[] numLayers, int numComponents)
|
| 489 |
29b82486
|
Leszek Koltunski
|
{
|
| 490 |
|
|
int variant = getCubitVariant(cubit,numLayers);
|
| 491 |
|
|
|
| 492 |
b968d359
|
Leszek Koltunski
|
if( mMeshes==null ) mMeshes = new MeshBase[mNumCubitVariants];
|
| 493 |
29b82486
|
Leszek Koltunski
|
|
| 494 |
|
|
if( mMeshes[variant]==null )
|
| 495 |
|
|
{
|
| 496 |
3ee1d662
|
Leszek Koltunski
|
ObjectFaceShape faceShape = getObjectFaceShape(variant);
|
| 497 |
84a17011
|
Leszek Koltunski
|
ObjectVertexEffects effects = getVertexEffects(variant);
|
| 498 |
29b82486
|
Leszek Koltunski
|
FactoryCubit factory = FactoryCubit.getInstance();
|
| 499 |
59a971c1
|
Leszek Koltunski
|
factory.createNewFaceTransform(mShapes[variant],mVariantFaceIsOuter[variant]);
|
| 500 |
1fda81c4
|
leszek
|
mMeshes[variant] = factory.createRoundedSolid(mShapes[variant],faceShape,effects,numComponents);
|
| 501 |
29b82486
|
Leszek Koltunski
|
}
|
| 502 |
|
|
|
| 503 |
|
|
MeshBase mesh = mMeshes[variant].copy(true);
|
| 504 |
5931ae4d
|
Leszek Koltunski
|
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( mOrigQuat[cubit], CENTER );
|
| 505 |
29b82486
|
Leszek Koltunski
|
mesh.apply(quat,0xffffffff,0);
|
| 506 |
|
|
|
| 507 |
|
|
return mesh;
|
| 508 |
|
|
}
|
| 509 |
|
|
|
| 510 |
f3eab97f
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 511 |
|
|
|
| 512 |
|
|
private void figureOutBitmapDimensions(int numTextures)
|
| 513 |
|
|
{
|
| 514 |
|
|
int maxSize = DistortedLibrary.getMaxTextureSize();
|
| 515 |
|
|
|
| 516 |
|
|
mTexHeight = DEFAULT_TEXTURE_HEIGHT;
|
| 517 |
|
|
|
| 518 |
|
|
while(true)
|
| 519 |
|
|
{
|
| 520 |
d1025da5
|
leszek
|
mNumTexCols = DEFAULT_TEXTURE_ROWS;
|
| 521 |
f3eab97f
|
leszek
|
mNumTexRows = numTextures/mNumTexCols + 1;
|
| 522 |
|
|
|
| 523 |
d1025da5
|
leszek
|
if( mNumTexRows*mTexHeight <= maxSize &&
|
| 524 |
|
|
mNumTexCols*mTexHeight <= maxSize ) break;
|
| 525 |
|
|
|
| 526 |
|
|
mTexHeight/=2;
|
| 527 |
f3eab97f
|
leszek
|
}
|
| 528 |
|
|
}
|
| 529 |
|
|
|
| 530 |
7994b456
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 531 |
|
|
|
| 532 |
|
|
private void setUpTextures(boolean fromDMESH, boolean fromJSON)
|
| 533 |
|
|
{
|
| 534 |
|
|
mTexture = new DistortedTexture();
|
| 535 |
|
|
|
| 536 |
|
|
if( fromJSON )
|
| 537 |
|
|
{
|
| 538 |
|
|
mNumStickerTypes = getNumStickerTypes();
|
| 539 |
|
|
mNumCubitFaces = getNumCubitFaces();
|
| 540 |
|
|
}
|
| 541 |
|
|
else
|
| 542 |
|
|
{
|
| 543 |
|
|
FactoryCubit factory = FactoryCubit.getInstance();
|
| 544 |
3d2493ea
|
Leszek Koltunski
|
mStickerCoords = factory.getStickerCoords();
|
| 545 |
7994b456
|
Leszek Koltunski
|
mStickerVariants = factory.getStickerVariants();
|
| 546 |
3d2493ea
|
Leszek Koltunski
|
mStickerScales = factory.getStickerScales();
|
| 547 |
7994b456
|
Leszek Koltunski
|
adjustStickerCoords();
|
| 548 |
325a17e0
|
Leszek Koltunski
|
mNumStickerTypes = (mStickerCoords==null ? 0 : mStickerCoords.length);
|
| 549 |
7994b456
|
Leszek Koltunski
|
}
|
| 550 |
|
|
|
| 551 |
3a0a23bf
|
Leszek Koltunski
|
mStickerOverrides = getStickerOverrides();
|
| 552 |
|
|
mNumOverrides = mStickerOverrides==null ? 0 : mStickerOverrides.length;
|
| 553 |
|
|
|
| 554 |
|
|
mNumTextures= mNumFaceColors*mNumStickerTypes + mNumOverrides;
|
| 555 |
f3eab97f
|
leszek
|
figureOutBitmapDimensions(mNumTextures);
|
| 556 |
a05b6e06
|
Leszek Koltunski
|
if( mNumTexCols*mNumTexRows < mNumTextures+1 ) mNumTexRows++;
|
| 557 |
7994b456
|
Leszek Koltunski
|
|
| 558 |
|
|
if( !fromDMESH || shouldResetTextureMaps() ) resetAllTextureMaps();
|
| 559 |
b0c97683
|
Leszek Koltunski
|
else overrideCubitFaceColor();
|
| 560 |
|
|
|
| 561 |
7994b456
|
Leszek Koltunski
|
setTexture();
|
| 562 |
|
|
}
|
| 563 |
|
|
|
| 564 |
a8295031
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 565 |
|
|
|
| 566 |
ae9d9227
|
leszek
|
public Metadata getMetadata()
|
| 567 |
a8295031
|
Leszek Koltunski
|
{
|
| 568 |
ae9d9227
|
leszek
|
return mMetadata;
|
| 569 |
a8295031
|
Leszek Koltunski
|
}
|
| 570 |
|
|
|
| 571 |
3bf19410
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 572 |
|
|
|
| 573 |
|
|
public boolean isInIconMode()
|
| 574 |
|
|
{
|
| 575 |
|
|
return mIconMode==MODE_ICON;
|
| 576 |
|
|
}
|
| 577 |
|
|
|
| 578 |
ec42a6fe
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 579 |
|
|
|
| 580 |
51262d81
|
Leszek Koltunski
|
public int getVariantStickerShape(int variant, int face)
|
| 581 |
ec42a6fe
|
Leszek Koltunski
|
{
|
| 582 |
f7f5771f
|
leszek
|
if( variant <mStickerVariants.length )
|
| 583 |
|
|
{
|
| 584 |
|
|
int[] var = mStickerVariants[variant];
|
| 585 |
|
|
return face>=var.length ? -1 : var[face];
|
| 586 |
|
|
}
|
| 587 |
|
|
return -1;
|
| 588 |
ec42a6fe
|
Leszek Koltunski
|
}
|
| 589 |
|
|
|
| 590 |
19595510
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 591 |
|
|
|
| 592 |
|
|
public boolean shouldResetTextureMaps()
|
| 593 |
|
|
{
|
| 594 |
|
|
return false;
|
| 595 |
|
|
}
|
| 596 |
|
|
|
| 597 |
9ba7f3f6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 598 |
|
|
|
| 599 |
|
|
public int[][] getScrambleAlgorithms()
|
| 600 |
|
|
{
|
| 601 |
731280f7
|
Leszek Koltunski
|
return ScrambleEdgeGenerator.getScramblingAlgorithms(mBasicAngles);
|
| 602 |
9ba7f3f6
|
Leszek Koltunski
|
}
|
| 603 |
|
|
|
| 604 |
a4af26c1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 605 |
|
|
|
| 606 |
|
|
private boolean sticksOut(Static3D[] faceAxis, float[] dist, float x, float y, float z )
|
| 607 |
|
|
{
|
| 608 |
|
|
final float MAXERR = 0.05f;
|
| 609 |
|
|
int numAxis = dist.length;
|
| 610 |
|
|
|
| 611 |
|
|
for(int i=0; i<numAxis; i++)
|
| 612 |
|
|
{
|
| 613 |
|
|
Static3D ax = faceAxis[i];
|
| 614 |
|
|
float len = ax.get0()*x + ax.get1()*y + ax.get2()*z;
|
| 615 |
dcce7b29
|
Leszek Koltunski
|
if( len>mSize*dist[i]+MAXERR ) return true;
|
| 616 |
a4af26c1
|
Leszek Koltunski
|
}
|
| 617 |
|
|
|
| 618 |
|
|
return false;
|
| 619 |
|
|
}
|
| 620 |
|
|
|
| 621 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 622 |
|
|
|
| 623 |
9554f5d4
|
Leszek Koltunski
|
private boolean doesNotStickOut(int variant, float px, float py, float pz, float[] tmp, Static4D quat)
|
| 624 |
a4af26c1
|
Leszek Koltunski
|
{
|
| 625 |
fbd18fc7
|
Leszek Koltunski
|
float[][] vertices = mShapes[variant].getVertices();
|
| 626 |
a4af26c1
|
Leszek Koltunski
|
Static3D[] axis = getFaceAxis();
|
| 627 |
|
|
float[] dist3D = getDist3D(mNumLayers);
|
| 628 |
|
|
|
| 629 |
|
|
for( float[] vertex : vertices)
|
| 630 |
|
|
{
|
| 631 |
|
|
float x = vertex[0];
|
| 632 |
|
|
float y = vertex[1];
|
| 633 |
|
|
float z = vertex[2];
|
| 634 |
|
|
|
| 635 |
|
|
QuatHelper.rotateVectorByQuat(tmp, x, y, z, 1, quat);
|
| 636 |
|
|
|
| 637 |
9554f5d4
|
Leszek Koltunski
|
float mx = tmp[0] + px;
|
| 638 |
|
|
float my = tmp[1] + py;
|
| 639 |
|
|
float mz = tmp[2] + pz;
|
| 640 |
a4af26c1
|
Leszek Koltunski
|
|
| 641 |
|
|
if( sticksOut(axis, dist3D, mx,my,mz) ) return false;
|
| 642 |
|
|
}
|
| 643 |
|
|
|
| 644 |
|
|
return true;
|
| 645 |
|
|
}
|
| 646 |
|
|
|
| 647 |
9554f5d4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 648 |
|
|
|
| 649 |
|
|
private float computeAvg(float[] pos, int offset)
|
| 650 |
|
|
{
|
| 651 |
|
|
int len = pos.length/3;
|
| 652 |
|
|
float ret=0.0f;
|
| 653 |
|
|
for(int i=0; i<len; i++) ret += pos[3*i+offset];
|
| 654 |
|
|
ret /= len;
|
| 655 |
|
|
|
| 656 |
|
|
return ret;
|
| 657 |
|
|
}
|
| 658 |
|
|
|
| 659 |
97a6aa87
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 660 |
|
|
|
| 661 |
|
|
protected void displayCubitQuats()
|
| 662 |
|
|
{
|
| 663 |
|
|
StringBuilder builder = new StringBuilder();
|
| 664 |
|
|
float[] tmp = new float[4];
|
| 665 |
a4af26c1
|
Leszek Koltunski
|
float ERR = 0.01f;
|
| 666 |
97a6aa87
|
Leszek Koltunski
|
|
| 667 |
|
|
for(int cubit=0; cubit<mNumCubits; cubit++)
|
| 668 |
|
|
{
|
| 669 |
a4af26c1
|
Leszek Koltunski
|
builder.append(cubit);
|
| 670 |
|
|
builder.append(" : ");
|
| 671 |
|
|
|
| 672 |
97a6aa87
|
Leszek Koltunski
|
int refCubit,variant = getCubitVariant(cubit,mNumLayers);
|
| 673 |
|
|
|
| 674 |
|
|
for(refCubit=0; refCubit<mNumCubits; refCubit++)
|
| 675 |
|
|
{
|
| 676 |
|
|
if( getCubitVariant(refCubit,mNumLayers)==variant ) break;
|
| 677 |
|
|
}
|
| 678 |
|
|
|
| 679 |
|
|
float[] curpos = mOrigPos[cubit];
|
| 680 |
|
|
float[] refpos = mOrigPos[refCubit];
|
| 681 |
9554f5d4
|
Leszek Koltunski
|
float refX = computeAvg(refpos,0);
|
| 682 |
|
|
float refY = computeAvg(refpos,1);
|
| 683 |
|
|
float refZ = computeAvg(refpos,2);
|
| 684 |
|
|
float curX = computeAvg(curpos,0);
|
| 685 |
|
|
float curY = computeAvg(curpos,1);
|
| 686 |
|
|
float curZ = computeAvg(curpos,2);
|
| 687 |
97a6aa87
|
Leszek Koltunski
|
|
| 688 |
|
|
for(int quat=0; quat<mNumQuats; quat++)
|
| 689 |
|
|
{
|
| 690 |
|
|
QuatHelper.rotateVectorByQuat(tmp,refX,refY,refZ,0,mObjectQuats[quat]);
|
| 691 |
|
|
|
| 692 |
|
|
float dx = tmp[0]-curX;
|
| 693 |
|
|
float dy = tmp[1]-curY;
|
| 694 |
|
|
float dz = tmp[2]-curZ;
|
| 695 |
|
|
|
| 696 |
a4af26c1
|
Leszek Koltunski
|
if( dx>-ERR && dx<ERR && dy>-ERR && dy<ERR && dz>-ERR && dz<ERR )
|
| 697 |
97a6aa87
|
Leszek Koltunski
|
{
|
| 698 |
9554f5d4
|
Leszek Koltunski
|
if( doesNotStickOut(variant,curX,curY,curZ,tmp,mObjectQuats[quat]) )
|
| 699 |
a4af26c1
|
Leszek Koltunski
|
{
|
| 700 |
|
|
builder.append(quat);
|
| 701 |
|
|
builder.append(',');
|
| 702 |
|
|
}
|
| 703 |
|
|
else
|
| 704 |
|
|
{
|
| 705 |
|
|
android.util.Log.e("D", "cubit: "+cubit+" quat: "+quat+" : center correct, but shape sticks out");
|
| 706 |
|
|
}
|
| 707 |
97a6aa87
|
Leszek Koltunski
|
}
|
| 708 |
|
|
}
|
| 709 |
|
|
|
| 710 |
|
|
builder.append('\n');
|
| 711 |
|
|
}
|
| 712 |
|
|
|
| 713 |
9cb7d66f
|
Leszek Koltunski
|
android.util.Log.e("D", "cubitQuats: \n"+builder );
|
| 714 |
97a6aa87
|
Leszek Koltunski
|
}
|
| 715 |
|
|
|
| 716 |
bc008758
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 717 |
|
|
|
| 718 |
fbd18fc7
|
Leszek Koltunski
|
public int getCubitRotationType(int cubit)
|
| 719 |
bc008758
|
Leszek Koltunski
|
{
|
| 720 |
5618c5a9
|
Leszek Koltunski
|
return TwistyObjectCubit.TYPE_NORMAL;
|
| 721 |
fbd18fc7
|
Leszek Koltunski
|
}
|
| 722 |
|
|
|
| 723 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 724 |
|
|
|
| 725 |
d844220f
|
Leszek Koltunski
|
float[] getTrackingPoint(int cubitIndex, int cubitType)
|
| 726 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 727 |
5618c5a9
|
Leszek Koltunski
|
if( cubitType!=TwistyObjectCubit.TYPE_NORMAL )
|
| 728 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 729 |
|
|
int variant = getCubitVariant(cubitIndex,mNumLayers);
|
| 730 |
40e77224
|
Leszek Koltunski
|
|
| 731 |
|
|
// object must have been created from JSON
|
| 732 |
|
|
if( mVariantFaceIsOuter==null || mVariantFaceIsOuter[variant]==null )
|
| 733 |
|
|
{
|
| 734 |
|
|
mVariantFaceIsOuter = getVariantFaceIsOuter();
|
| 735 |
|
|
}
|
| 736 |
39c6b370
|
Leszek Koltunski
|
if( mShapes==null )
|
| 737 |
|
|
{
|
| 738 |
|
|
mShapes = new ObjectShape[mNumCubitVariants];
|
| 739 |
|
|
}
|
| 740 |
|
|
if( mShapes[variant]==null )
|
| 741 |
|
|
{
|
| 742 |
|
|
mShapes[variant] = getObjectShape(variant);
|
| 743 |
|
|
}
|
| 744 |
|
|
if( mOrigQuat==null )
|
| 745 |
|
|
{
|
| 746 |
|
|
mOrigQuat = new Static4D[mNumCubits];
|
| 747 |
|
|
}
|
| 748 |
|
|
if( mOrigQuat[cubitIndex]==null )
|
| 749 |
|
|
{
|
| 750 |
|
|
mOrigQuat[cubitIndex] = getCubitQuats(cubitIndex,mNumLayers);
|
| 751 |
|
|
}
|
| 752 |
|
|
|
| 753 |
efa5bc1e
|
leszek
|
int outer=-1, faces = mShapes[variant].getNumFaces();
|
| 754 |
fbd18fc7
|
Leszek Koltunski
|
|
| 755 |
|
|
for(int i=0; i<faces; i++)
|
| 756 |
|
|
{
|
| 757 |
|
|
if( mVariantFaceIsOuter[variant][i]==1 )
|
| 758 |
|
|
{
|
| 759 |
|
|
outer=i;
|
| 760 |
|
|
break;
|
| 761 |
|
|
}
|
| 762 |
|
|
}
|
| 763 |
|
|
|
| 764 |
|
|
if( outer>=0 )
|
| 765 |
|
|
{
|
| 766 |
efa5bc1e
|
leszek
|
float[] v = mShapes[variant].getFirstVertexInFace(outer);
|
| 767 |
fbd18fc7
|
Leszek Koltunski
|
float[] ret = new float[3];
|
| 768 |
|
|
float[] curpos = mOrigPos[cubitIndex];
|
| 769 |
|
|
Static4D quat = mOrigQuat[cubitIndex];
|
| 770 |
efa5bc1e
|
leszek
|
QuatHelper.rotateVectorByQuat(mTmp, v[0], v[1], v[2], 1, quat);
|
| 771 |
fbd18fc7
|
Leszek Koltunski
|
|
| 772 |
|
|
ret[0] = mTmp[0]+computeAvg(curpos,0);
|
| 773 |
|
|
ret[1] = mTmp[1]+computeAvg(curpos,1);
|
| 774 |
|
|
ret[2] = mTmp[2]+computeAvg(curpos,2);
|
| 775 |
|
|
|
| 776 |
|
|
return ret;
|
| 777 |
|
|
}
|
| 778 |
|
|
else
|
| 779 |
|
|
{
|
| 780 |
d844220f
|
Leszek Koltunski
|
android.util.Log.e("D", "Error in getTrackingPoint: no outer face??");
|
| 781 |
fbd18fc7
|
Leszek Koltunski
|
}
|
| 782 |
|
|
}
|
| 783 |
|
|
|
| 784 |
|
|
return null;
|
| 785 |
|
|
}
|
| 786 |
|
|
|
| 787 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 788 |
|
|
|
| 789 |
1f329dcc
|
Leszek Koltunski
|
public int computeCurrentPuzzleFace(int type, float[] vertex)
|
| 790 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 791 |
5618c5a9
|
Leszek Koltunski
|
if( type!=TwistyObjectCubit.TYPE_NORMAL )
|
| 792 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 793 |
|
|
Static3D[] axis = getFaceAxis();
|
| 794 |
|
|
float[] dist3D = getDist3D(mNumLayers);
|
| 795 |
|
|
final float MAXERR = 0.98f;
|
| 796 |
|
|
int numAxis = axis.length;
|
| 797 |
|
|
float x = vertex[0];
|
| 798 |
|
|
float y = vertex[1];
|
| 799 |
|
|
float z = vertex[2];
|
| 800 |
|
|
|
| 801 |
|
|
for(int i=0; i<numAxis; i++)
|
| 802 |
|
|
{
|
| 803 |
|
|
Static3D ax = axis[i];
|
| 804 |
|
|
float len = ax.get0()*x + ax.get1()*y + ax.get2()*z;
|
| 805 |
|
|
if( len>mSize*dist3D[i]*MAXERR ) return i;
|
| 806 |
|
|
}
|
| 807 |
4e1f3a8e
|
Leszek Koltunski
|
|
| 808 |
1f329dcc
|
Leszek Koltunski
|
return -2;
|
| 809 |
fbd18fc7
|
Leszek Koltunski
|
}
|
| 810 |
|
|
|
| 811 |
|
|
return -1;
|
| 812 |
|
|
}
|
| 813 |
|
|
|
| 814 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 815 |
|
|
|
| 816 |
|
|
public float[] getCubitRowOffset(int cubitIndex)
|
| 817 |
|
|
{
|
| 818 |
|
|
return null;
|
| 819 |
|
|
}
|
| 820 |
|
|
|
| 821 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 822 |
|
|
|
| 823 |
|
|
void setRotationRowOffset(int puzzleFace, float[] offset)
|
| 824 |
|
|
{
|
| 825 |
|
|
mRowOffsets[puzzleFace][0] = offset[0];
|
| 826 |
|
|
mRowOffsets[puzzleFace][1] = offset[1];
|
| 827 |
|
|
mRowOffsets[puzzleFace][2] = offset[2];
|
| 828 |
bc008758
|
Leszek Koltunski
|
}
|
| 829 |
|
|
|
| 830 |
d85de775
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 831 |
|
|
|
| 832 |
|
|
int getNumAxis()
|
| 833 |
|
|
{
|
| 834 |
|
|
return mNumAxis;
|
| 835 |
|
|
}
|
| 836 |
|
|
|
| 837 |
f5426a4c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 838 |
|
|
|
| 839 |
19595510
|
Leszek Koltunski
|
public int[][] getSolvedQuats()
|
| 840 |
074a0284
|
leszek
|
{
|
| 841 |
|
|
return null;
|
| 842 |
|
|
}
|
| 843 |
|
|
|
| 844 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 845 |
|
|
|
| 846 |
|
|
protected int[][] getOldSolvedQuats()
|
| 847 |
f5426a4c
|
Leszek Koltunski
|
{
|
| 848 |
5618c5a9
|
Leszek Koltunski
|
return mSolved.getSolvedQuats(mNumLayers,mNumCubitFaces,mCubitFaceColors);
|
| 849 |
f5426a4c
|
Leszek Koltunski
|
}
|
| 850 |
|
|
|
| 851 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 852 |
074a0284
|
leszek
|
// 0: old, groups-of-quaternions based function.
|
| 853 |
|
|
// Still used by: Masterball, Mirror Sqewb, Mirror Jing, Mirror Pyraminx & the Penrose Cubes.
|
| 854 |
|
|
//
|
| 855 |
|
|
// 1: specific function only for the Dino4.
|
| 856 |
|
|
//
|
| 857 |
|
|
// 2: the new default; automatic way based on automatic detection of monochromatic puzzle surfaces.
|
| 858 |
f5426a4c
|
Leszek Koltunski
|
|
| 859 |
|
|
public int getSolvedFunctionIndex()
|
| 860 |
|
|
{
|
| 861 |
074a0284
|
leszek
|
return 2;
|
| 862 |
f5426a4c
|
Leszek Koltunski
|
}
|
| 863 |
|
|
|
| 864 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 865 |
|
|
|
| 866 |
fbd18fc7
|
Leszek Koltunski
|
int computeRow(float[] pos, int axisIndex, int cubitType, int puzzleFace)
|
| 867 |
29b82486
|
Leszek Koltunski
|
{
|
| 868 |
|
|
int ret=0;
|
| 869 |
|
|
int len = pos.length / 3;
|
| 870 |
|
|
Static3D axis = mAxis[axisIndex];
|
| 871 |
|
|
float axisX = axis.get0();
|
| 872 |
|
|
float axisY = axis.get1();
|
| 873 |
|
|
float axisZ = axis.get2();
|
| 874 |
fbd18fc7
|
Leszek Koltunski
|
float casted, xoff=0, yoff=0, zoff=0;
|
| 875 |
29b82486
|
Leszek Koltunski
|
|
| 876 |
5618c5a9
|
Leszek Koltunski
|
if( cubitType!=TwistyObjectCubit.TYPE_NORMAL )
|
| 877 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 878 |
|
|
xoff = mRowOffsets[puzzleFace][0];
|
| 879 |
|
|
yoff = mRowOffsets[puzzleFace][1];
|
| 880 |
|
|
zoff = mRowOffsets[puzzleFace][2];
|
| 881 |
|
|
}
|
| 882 |
bc008758
|
Leszek Koltunski
|
|
| 883 |
29b82486
|
Leszek Koltunski
|
for(int i=0; i<len; i++)
|
| 884 |
|
|
{
|
| 885 |
bc008758
|
Leszek Koltunski
|
casted = (pos[3*i]+xoff)*axisX + (pos[3*i+1]+yoff)*axisY + (pos[3*i+2]+zoff)*axisZ;
|
| 886 |
29b82486
|
Leszek Koltunski
|
ret |= computeSingleRow(axisIndex,casted);
|
| 887 |
|
|
}
|
| 888 |
|
|
|
| 889 |
|
|
return ret;
|
| 890 |
|
|
}
|
| 891 |
|
|
|
| 892 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 893 |
|
|
|
| 894 |
|
|
private int computeSingleRow(int axisIndex,float casted)
|
| 895 |
|
|
{
|
| 896 |
|
|
int num = mNumCuts[axisIndex];
|
| 897 |
b346ba5b
|
leszek
|
float[] cuts = mCuts[axisIndex];
|
| 898 |
29b82486
|
Leszek Koltunski
|
|
| 899 |
|
|
for(int i=0; i<num; i++)
|
| 900 |
|
|
{
|
| 901 |
b346ba5b
|
leszek
|
if( casted<cuts[i] ) return (1<<i);
|
| 902 |
29b82486
|
Leszek Koltunski
|
}
|
| 903 |
|
|
|
| 904 |
|
|
return (1<<num);
|
| 905 |
|
|
}
|
| 906 |
|
|
|
| 907 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 908 |
|
|
|
| 909 |
|
|
private boolean belongsToRotation( int cubit, int axis, int rowBitmap)
|
| 910 |
|
|
{
|
| 911 |
a05b6e06
|
Leszek Koltunski
|
return (mCubits[cubit].getRotRow(axis) & rowBitmap) != 0;
|
| 912 |
29b82486
|
Leszek Koltunski
|
}
|
| 913 |
|
|
|
| 914 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 915 |
|
|
// note the minus in front of the sin() - we rotate counterclockwise
|
| 916 |
|
|
// when looking towards the direction where the axis increases in values.
|
| 917 |
|
|
|
| 918 |
1f329dcc
|
Leszek Koltunski
|
private Static4D makeQuaternion(float axisX, float axisY, float axisZ, int angleInDegrees)
|
| 919 |
29b82486
|
Leszek Koltunski
|
{
|
| 920 |
|
|
while( angleInDegrees<0 ) angleInDegrees += 360;
|
| 921 |
|
|
angleInDegrees %= 360;
|
| 922 |
|
|
|
| 923 |
|
|
float cosA = (float)Math.cos(Math.PI*angleInDegrees/360);
|
| 924 |
|
|
float sinA =-(float)Math.sqrt(1-cosA*cosA);
|
| 925 |
|
|
|
| 926 |
1f329dcc
|
Leszek Koltunski
|
return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
|
| 927 |
29b82486
|
Leszek Koltunski
|
}
|
| 928 |
|
|
|
| 929 |
e3169794
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 930 |
|
|
|
| 931 |
|
|
void rotateAllCubits(int axisIndex, int rowBitmap, int angle)
|
| 932 |
|
|
{
|
| 933 |
|
|
Static3D axis = mAxis[axisIndex];
|
| 934 |
|
|
float axisX = axis.get0();
|
| 935 |
|
|
float axisY = axis.get1();
|
| 936 |
|
|
float axisZ = axis.get2();
|
| 937 |
|
|
Static4D quat = makeQuaternion(axisX,axisY,axisZ,angle);
|
| 938 |
|
|
|
| 939 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 940 |
|
|
{
|
| 941 |
|
|
mBelongs[i] = belongsToRotation(i,axisIndex,rowBitmap);
|
| 942 |
|
|
if( mBelongs[i] )
|
| 943 |
|
|
{
|
| 944 |
|
|
boolean result = mCubits[i].rotateCubit(quat,false);
|
| 945 |
|
|
if( !result ) debugQuat(quat,i,axisX,axisY,axisZ,angle,1);
|
| 946 |
|
|
}
|
| 947 |
|
|
}
|
| 948 |
|
|
|
| 949 |
|
|
recomputeFaceOffsets();
|
| 950 |
|
|
|
| 951 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 952 |
|
|
{
|
| 953 |
|
|
if( mBelongs[i] )
|
| 954 |
|
|
{
|
| 955 |
|
|
int index = mCubits[i].postRotateCubit(quat);
|
| 956 |
|
|
setCubitQuat(i,index);
|
| 957 |
|
|
}
|
| 958 |
|
|
else if( mCubits[i].getType()==TwistyObjectCubit.TYPE_FOLLOWER )
|
| 959 |
|
|
{
|
| 960 |
|
|
mCubits[i].computeRotationRow();
|
| 961 |
|
|
setCubitQuat(i,mCubits[i].mQuatIndex);
|
| 962 |
|
|
}
|
| 963 |
|
|
}
|
| 964 |
|
|
}
|
| 965 |
|
|
|
| 966 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 967 |
|
|
|
| 968 |
|
|
private synchronized void setupPosition(int[][] moves)
|
| 969 |
|
|
{
|
| 970 |
|
|
if( moves!=null )
|
| 971 |
|
|
{
|
| 972 |
e3169794
|
leszek
|
int axisIndex, row, rowBitmap, basic, angle;
|
| 973 |
29b82486
|
Leszek Koltunski
|
|
| 974 |
|
|
for(int[] move: moves)
|
| 975 |
|
|
{
|
| 976 |
1f329dcc
|
Leszek Koltunski
|
axisIndex= move[0];
|
| 977 |
e3169794
|
leszek
|
rowBitmap= computeBandagedBitmap( move[1],axisIndex);
|
| 978 |
c9e40dfc
|
Leszek Koltunski
|
row = computeRowFromBitmap( move[1] );
|
| 979 |
1f329dcc
|
Leszek Koltunski
|
basic = mBasicAngles[axisIndex][row];
|
| 980 |
40e76ea4
|
Leszek Koltunski
|
angle = move[2]*(360/basic); // this assumes that all layers from
|
| 981 |
|
|
// the bitmap have the same BasicAngle.
|
| 982 |
|
|
// at the moment this is always true as
|
| 983 |
|
|
// there are no bandaged objects with
|
| 984 |
|
|
// different per-layer BasicAngles.
|
| 985 |
29b82486
|
Leszek Koltunski
|
|
| 986 |
e3169794
|
leszek
|
rotateAllCubits(axisIndex,rowBitmap,angle);
|
| 987 |
29b82486
|
Leszek Koltunski
|
}
|
| 988 |
3788d0cd
|
Leszek Koltunski
|
|
| 989 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 990 |
|
|
{
|
| 991 |
|
|
float[] pos = mCubits[i].getCurrentPos();
|
| 992 |
|
|
int len = pos.length/3;
|
| 993 |
|
|
for(int j=0; j<len; j++) clampPos(pos,3*j);
|
| 994 |
|
|
}
|
| 995 |
29b82486
|
Leszek Koltunski
|
}
|
| 996 |
|
|
}
|
| 997 |
|
|
|
| 998 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 999 |
|
|
|
| 1000 |
f9a81f52
|
Leszek Koltunski
|
public int getScrambleType()
|
| 1001 |
29b82486
|
Leszek Koltunski
|
{
|
| 1002 |
9283a268
|
Leszek Koltunski
|
return ObjectScrambler.SCRAMBLING_ALGORITHMS;
|
| 1003 |
29b82486
|
Leszek Koltunski
|
}
|
| 1004 |
|
|
|
| 1005 |
63bfcdd1
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1006 |
|
|
|
| 1007 |
|
|
public int[][] getMinimalCubiesInRow()
|
| 1008 |
|
|
{
|
| 1009 |
|
|
return null;
|
| 1010 |
|
|
}
|
| 1011 |
|
|
|
| 1012 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1013 |
|
|
|
| 1014 |
7ca7a08f
|
leszek
|
int computeBandagedBitmap(int rowBitmap, int axisIndex)
|
| 1015 |
29b82486
|
Leszek Koltunski
|
{
|
| 1016 |
|
|
if( mIsBandaged )
|
| 1017 |
|
|
{
|
| 1018 |
|
|
int bitmap, initBitmap=0;
|
| 1019 |
|
|
|
| 1020 |
|
|
while( initBitmap!=rowBitmap )
|
| 1021 |
|
|
{
|
| 1022 |
|
|
initBitmap = rowBitmap;
|
| 1023 |
|
|
|
| 1024 |
a05b6e06
|
Leszek Koltunski
|
for(int cubit=0; cubit<mNumCubits; cubit++)
|
| 1025 |
29b82486
|
Leszek Koltunski
|
{
|
| 1026 |
7ca7a08f
|
leszek
|
bitmap = mCubits[cubit].getRotRow(axisIndex);
|
| 1027 |
29b82486
|
Leszek Koltunski
|
if( (rowBitmap & bitmap) != 0 ) rowBitmap |= bitmap;
|
| 1028 |
|
|
}
|
| 1029 |
|
|
}
|
| 1030 |
|
|
}
|
| 1031 |
|
|
|
| 1032 |
63bfcdd1
|
leszek
|
if( mMinimalCubiesInRow!=null )
|
| 1033 |
|
|
{
|
| 1034 |
7ca7a08f
|
leszek
|
int[] minC = mMinimalCubiesInRow[axisIndex];
|
| 1035 |
63bfcdd1
|
leszek
|
int numL = minC.length;
|
| 1036 |
|
|
int[] numC = new int[numL];
|
| 1037 |
|
|
|
| 1038 |
|
|
for(int cubit=0; cubit<mNumCubits; cubit++)
|
| 1039 |
|
|
{
|
| 1040 |
7ca7a08f
|
leszek
|
int bitmap = mCubits[cubit].getRotRow(axisIndex);
|
| 1041 |
63bfcdd1
|
leszek
|
|
| 1042 |
|
|
for(int i=0; i<numL; i++)
|
| 1043 |
|
|
{
|
| 1044 |
|
|
if( (bitmap&0x1)!=0 ) numC[i]++;
|
| 1045 |
|
|
bitmap>>=1;
|
| 1046 |
|
|
}
|
| 1047 |
|
|
}
|
| 1048 |
|
|
|
| 1049 |
|
|
int bitmap,initBitmap = 0;
|
| 1050 |
|
|
|
| 1051 |
|
|
while( initBitmap!=rowBitmap )
|
| 1052 |
|
|
{
|
| 1053 |
|
|
initBitmap = rowBitmap;
|
| 1054 |
|
|
bitmap = rowBitmap;
|
| 1055 |
|
|
int last = 0;
|
| 1056 |
|
|
|
| 1057 |
|
|
for(int i=0; i<numL; i++)
|
| 1058 |
|
|
{
|
| 1059 |
|
|
if( numC[i]<minC[i] && numC[i]>0 )
|
| 1060 |
|
|
{
|
| 1061 |
|
|
if( (bitmap&0x1)!=0 )
|
| 1062 |
|
|
{
|
| 1063 |
|
|
if( i>0 ) rowBitmap |= (1<<(i-1));
|
| 1064 |
|
|
if( i<numL-1) rowBitmap |= (1<<(i+1));
|
| 1065 |
|
|
}
|
| 1066 |
|
|
else if( (bitmap&0x2)!=0 || last>0 ) // we are not rotating this row, but
|
| 1067 |
|
|
// we are rotating the next or the prev
|
| 1068 |
|
|
{
|
| 1069 |
|
|
rowBitmap |= (1<<i);
|
| 1070 |
|
|
}
|
| 1071 |
|
|
}
|
| 1072 |
|
|
|
| 1073 |
|
|
last = (bitmap&0x1);
|
| 1074 |
|
|
bitmap>>=1;
|
| 1075 |
|
|
}
|
| 1076 |
|
|
}
|
| 1077 |
|
|
}
|
| 1078 |
|
|
|
| 1079 |
29b82486
|
Leszek Koltunski
|
return rowBitmap;
|
| 1080 |
|
|
}
|
| 1081 |
|
|
|
| 1082 |
c9e40dfc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1083 |
|
|
|
| 1084 |
|
|
private int computeRowFromBitmap(int rowBitmap)
|
| 1085 |
|
|
{
|
| 1086 |
|
|
int index = 0;
|
| 1087 |
|
|
|
| 1088 |
|
|
while(index<32)
|
| 1089 |
|
|
{
|
| 1090 |
|
|
if( (rowBitmap&0x1) != 0 ) return index;
|
| 1091 |
|
|
rowBitmap>>=1;
|
| 1092 |
|
|
index++;
|
| 1093 |
|
|
}
|
| 1094 |
|
|
return 0;
|
| 1095 |
|
|
}
|
| 1096 |
|
|
|
| 1097 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1098 |
|
|
// Clamp all rotated positions to one of those original ones to avoid accumulating errors.
|
| 1099 |
|
|
// Do so only if minimal Error is appropriately low (shape-shifting puzzles - Square-1)
|
| 1100 |
|
|
|
| 1101 |
fbd18fc7
|
Leszek Koltunski
|
void clampPos(float[] pos, int offset)
|
| 1102 |
29b82486
|
Leszek Koltunski
|
{
|
| 1103 |
|
|
float currError, minError = Float.MAX_VALUE;
|
| 1104 |
|
|
int minErrorIndex1 = -1;
|
| 1105 |
|
|
int minErrorIndex2 = -1;
|
| 1106 |
|
|
|
| 1107 |
|
|
float x = pos[offset ];
|
| 1108 |
|
|
float y = pos[offset+1];
|
| 1109 |
|
|
float z = pos[offset+2];
|
| 1110 |
|
|
|
| 1111 |
|
|
float xo,yo,zo;
|
| 1112 |
|
|
|
| 1113 |
a05b6e06
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++)
|
| 1114 |
29b82486
|
Leszek Koltunski
|
{
|
| 1115 |
|
|
int len = mOrigPos[i].length / 3;
|
| 1116 |
|
|
|
| 1117 |
|
|
for(int j=0; j<len; j++)
|
| 1118 |
|
|
{
|
| 1119 |
|
|
xo = mOrigPos[i][3*j ];
|
| 1120 |
|
|
yo = mOrigPos[i][3*j+1];
|
| 1121 |
|
|
zo = mOrigPos[i][3*j+2];
|
| 1122 |
|
|
|
| 1123 |
|
|
currError = (xo-x)*(xo-x) + (yo-y)*(yo-y) + (zo-z)*(zo-z);
|
| 1124 |
|
|
|
| 1125 |
|
|
if( currError<minError )
|
| 1126 |
|
|
{
|
| 1127 |
|
|
minError = currError;
|
| 1128 |
|
|
minErrorIndex1 = i;
|
| 1129 |
|
|
minErrorIndex2 = j;
|
| 1130 |
|
|
}
|
| 1131 |
|
|
}
|
| 1132 |
|
|
}
|
| 1133 |
|
|
|
| 1134 |
4bd1b3d6
|
Leszek Koltunski
|
if( minError< 0.05f ) // TODO: 0.05 ?
|
| 1135 |
29b82486
|
Leszek Koltunski
|
{
|
| 1136 |
|
|
pos[offset ] = mOrigPos[minErrorIndex1][3*minErrorIndex2 ];
|
| 1137 |
|
|
pos[offset+1] = mOrigPos[minErrorIndex1][3*minErrorIndex2+1];
|
| 1138 |
|
|
pos[offset+2] = mOrigPos[minErrorIndex1][3*minErrorIndex2+2];
|
| 1139 |
|
|
}
|
| 1140 |
|
|
}
|
| 1141 |
|
|
|
| 1142 |
d887aa16
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1143 |
|
|
|
| 1144 |
|
|
void setLibInterface(ObjectLibInterface inter)
|
| 1145 |
|
|
{
|
| 1146 |
|
|
mInterface = inter;
|
| 1147 |
c8bc83d9
|
Leszek Koltunski
|
}
|
| 1148 |
|
|
|
| 1149 |
d356eecc
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1150 |
|
|
|
| 1151 |
|
|
void applyScrambles(int[][] moves)
|
| 1152 |
|
|
{
|
| 1153 |
|
|
setupPosition(moves);
|
| 1154 |
|
|
}
|
| 1155 |
|
|
|
| 1156 |
7c111294
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1157 |
198c5bf0
|
Leszek Koltunski
|
|
| 1158 |
880beeea
|
Leszek Koltunski
|
void initializeObject(int[][] moves)
|
| 1159 |
7c111294
|
Leszek Koltunski
|
{
|
| 1160 |
|
|
solve();
|
| 1161 |
|
|
setupPosition(moves);
|
| 1162 |
|
|
}
|
| 1163 |
198c5bf0
|
Leszek Koltunski
|
|
| 1164 |
5a20f7a1
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1165 |
|
|
|
| 1166 |
|
|
private void recomputeFaceOffsets()
|
| 1167 |
|
|
{
|
| 1168 |
3788d0cd
|
Leszek Koltunski
|
if( mThereAreDeciders )
|
| 1169 |
5a20f7a1
|
Leszek Koltunski
|
{
|
| 1170 |
3788d0cd
|
Leszek Koltunski
|
for(int i=0; i<mNumPuzzleFaces; i++)
|
| 1171 |
5a20f7a1
|
Leszek Koltunski
|
{
|
| 1172 |
3788d0cd
|
Leszek Koltunski
|
mRowOffsets[i][0] =0;
|
| 1173 |
|
|
mRowOffsets[i][1] =0;
|
| 1174 |
|
|
mRowOffsets[i][2] =0;
|
| 1175 |
5a20f7a1
|
Leszek Koltunski
|
}
|
| 1176 |
3788d0cd
|
Leszek Koltunski
|
|
| 1177 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 1178 |
|
|
if( mCubits[i].getType()==TwistyObjectCubit.TYPE_DECIDER )
|
| 1179 |
|
|
{
|
| 1180 |
|
|
float[] offset = mCubits[i].getOffset();
|
| 1181 |
|
|
int face = mCubits[i].getPuzzleFace();
|
| 1182 |
|
|
mRowOffsets[face][0] = offset[0];
|
| 1183 |
|
|
mRowOffsets[face][1] = offset[1];
|
| 1184 |
|
|
mRowOffsets[face][2] = offset[2];
|
| 1185 |
|
|
}
|
| 1186 |
|
|
}
|
| 1187 |
5a20f7a1
|
Leszek Koltunski
|
}
|
| 1188 |
|
|
|
| 1189 |
c8bc83d9
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1190 |
|
|
|
| 1191 |
4a014840
|
leszek
|
synchronized float removeRotation()
|
| 1192 |
bb58b357
|
leszek
|
{
|
| 1193 |
4a014840
|
leszek
|
return mRotation.removeRotation();
|
| 1194 |
bb58b357
|
leszek
|
}
|
| 1195 |
|
|
|
| 1196 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1197 |
|
|
|
| 1198 |
a0ef8a1d
|
leszek
|
long finishRotation(ObjectPreRender pre, int finishAx, int finishRow, float finishAngle, float avgSpeed)
|
| 1199 |
c8bc83d9
|
Leszek Koltunski
|
{
|
| 1200 |
e3169794
|
leszek
|
int basicAngle = mBasicAngles[finishAx][finishRow];
|
| 1201 |
a0ef8a1d
|
leszek
|
return mRotation.finishRotation(pre,finishAx,finishRow,basicAngle,finishAngle,avgSpeed);
|
| 1202 |
c8bc83d9
|
Leszek Koltunski
|
}
|
| 1203 |
|
|
|
| 1204 |
bb58b357
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1205 |
|
|
|
| 1206 |
|
|
void continueRotation(float angleInDegrees)
|
| 1207 |
|
|
{
|
| 1208 |
e3169794
|
leszek
|
mRotation.continueRotation(angleInDegrees);
|
| 1209 |
bb58b357
|
leszek
|
}
|
| 1210 |
|
|
|
| 1211 |
c8bc83d9
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1212 |
|
|
|
| 1213 |
4a014840
|
leszek
|
synchronized long addRotation(EffectListener listener, int axis, int rowBitmap, int angle, long durationMillis )
|
| 1214 |
|
|
{
|
| 1215 |
63bfcdd1
|
leszek
|
return mRotation.addRotation(listener,axis,rowBitmap,angle,durationMillis);
|
| 1216 |
4a014840
|
leszek
|
}
|
| 1217 |
|
|
|
| 1218 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1219 |
|
|
|
| 1220 |
93dc5a55
|
leszek
|
void enableGhostAxis(int axNum, boolean enable)
|
| 1221 |
c8bc83d9
|
Leszek Koltunski
|
{
|
| 1222 |
93dc5a55
|
leszek
|
mTouchControl.enableGhostAxis(axNum,enable);
|
| 1223 |
c8bc83d9
|
Leszek Koltunski
|
}
|
| 1224 |
|
|
|
| 1225 |
880beeea
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1226 |
|
|
|
| 1227 |
4a014840
|
leszek
|
synchronized boolean beginRotation(int axis, int row )
|
| 1228 |
880beeea
|
Leszek Koltunski
|
{
|
| 1229 |
d55d2c6a
|
Leszek Koltunski
|
if( axis<0 || axis>=mNumAxis )
|
| 1230 |
880beeea
|
Leszek Koltunski
|
{
|
| 1231 |
|
|
android.util.Log.e("object", "invalid rotation axis: "+axis);
|
| 1232 |
605f319b
|
Leszek Koltunski
|
return false;
|
| 1233 |
880beeea
|
Leszek Koltunski
|
}
|
| 1234 |
|
|
|
| 1235 |
63bfcdd1
|
leszek
|
return mRotation.beginRotation(axis,row);
|
| 1236 |
880beeea
|
Leszek Koltunski
|
}
|
| 1237 |
|
|
|
| 1238 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1239 |
|
|
|
| 1240 |
51262d81
|
Leszek Koltunski
|
void setTextureMap(int cubit, int face, int color)
|
| 1241 |
29b82486
|
Leszek Koltunski
|
{
|
| 1242 |
51262d81
|
Leszek Koltunski
|
int variant = getCubitVariant(cubit,mNumLayers);
|
| 1243 |
|
|
int shape = getVariantStickerShape(variant,face);
|
| 1244 |
|
|
int texIndex = color<0 || shape<0 ? mNumTextures-mNumOverrides : shape*mNumFaceColors + color;
|
| 1245 |
|
|
int row = (mNumTexRows-1) - texIndex/mNumTexCols;
|
| 1246 |
|
|
int col = texIndex%mNumTexCols;
|
| 1247 |
|
|
|
| 1248 |
7c111294
|
Leszek Koltunski
|
final float ratioW = 1.0f/mNumTexCols;
|
| 1249 |
|
|
final float ratioH = 1.0f/mNumTexRows;
|
| 1250 |
51262d81
|
Leszek Koltunski
|
final Static4D[] maps = new Static4D[1];
|
| 1251 |
|
|
maps[0] = new Static4D(col*ratioW, row*ratioH, ratioW, ratioH);
|
| 1252 |
|
|
mMesh.setTextureMap(maps,mNumCubitFaces*cubit+face);
|
| 1253 |
29b82486
|
Leszek Koltunski
|
}
|
| 1254 |
|
|
|
| 1255 |
55acff1e
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1256 |
|
|
// figure out the whole face to which (cubit,face) belongs, repaint all (cubit,face) pairs to
|
| 1257 |
|
|
// the new color.
|
| 1258 |
|
|
|
| 1259 |
6f5eb9b3
|
leszek
|
void repaintPuzzleFace(int cubit, int face, int newColor)
|
| 1260 |
55acff1e
|
leszek
|
{
|
| 1261 |
7e8750c9
|
leszek
|
int oldColorIndex = getCubitFaceColor(cubit,face);
|
| 1262 |
5ce579d2
|
leszek
|
|
| 1263 |
|
|
if( oldColorIndex<0 || oldColorIndex>=mNumFaceColors )
|
| 1264 |
|
|
{
|
| 1265 |
|
|
android.util.Log.e("D", "error in TwistyObject.repaintPuzzleFace, index="+oldColorIndex);
|
| 1266 |
|
|
return;
|
| 1267 |
|
|
}
|
| 1268 |
|
|
|
| 1269 |
962b8ff6
|
leszek
|
int oldColor = mColorTable[oldColorIndex];
|
| 1270 |
7e8750c9
|
leszek
|
|
| 1271 |
962b8ff6
|
leszek
|
if( oldColor!=newColor )
|
| 1272 |
7e8750c9
|
leszek
|
{
|
| 1273 |
5ce579d2
|
leszek
|
oldColor = mOriginalColorTable[oldColorIndex];
|
| 1274 |
6f5eb9b3
|
leszek
|
changeColorInTexture(oldColor,newColor);
|
| 1275 |
962b8ff6
|
leszek
|
mColorTable[oldColorIndex] = newColor;
|
| 1276 |
7e8750c9
|
leszek
|
setTexture();
|
| 1277 |
|
|
}
|
| 1278 |
55acff1e
|
leszek
|
}
|
| 1279 |
|
|
|
| 1280 |
9b1fe915
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1281 |
|
|
|
| 1282 |
f80b9473
|
leszek
|
int getCubitFaceColor(int cubit, int face)
|
| 1283 |
9b1fe915
|
Leszek Koltunski
|
{
|
| 1284 |
ed0988c0
|
Leszek Koltunski
|
int puzzleFace = getCubitFaceMap(cubit,face);
|
| 1285 |
|
|
if( puzzleFace>=0 ) puzzleFace %= mNumFaceColors;
|
| 1286 |
|
|
return puzzleFace;
|
| 1287 |
1b7ece90
|
Leszek Koltunski
|
}
|
| 1288 |
|
|
|
| 1289 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1290 |
|
|
|
| 1291 |
ed0988c0
|
Leszek Koltunski
|
public int getCubitFaceMap(int cubit, int face)
|
| 1292 |
1b7ece90
|
Leszek Koltunski
|
{
|
| 1293 |
|
|
int numFaces = mCubitFaceColors[cubit].length;
|
| 1294 |
|
|
int puzzleFace = face<numFaces ? mCubitFaceColors[cubit][face] : -1;
|
| 1295 |
|
|
return puzzleFace<0 ? -1 : puzzleFace;
|
| 1296 |
|
|
}
|
| 1297 |
|
|
|
| 1298 |
f80b9473
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1299 |
|
|
// this would return the REAL value of outer; the 'getCubitFaceColor()>=0' returns if the face is
|
| 1300 |
|
|
// colored, which for example in case of Container (which has colored internal faces) is not the
|
| 1301 |
|
|
// same thing
|
| 1302 |
|
|
|
| 1303 |
|
|
boolean faceIsOuter(int cubit, int face)
|
| 1304 |
|
|
{
|
| 1305 |
d03443d4
|
leszek
|
if( mCubitFaceColors==null )
|
| 1306 |
|
|
{
|
| 1307 |
|
|
if( mShapes==null )
|
| 1308 |
|
|
{
|
| 1309 |
|
|
mShapes = new ObjectShape[mNumCubitVariants];
|
| 1310 |
|
|
}
|
| 1311 |
|
|
|
| 1312 |
|
|
if( mShapes[0]==null )
|
| 1313 |
|
|
{
|
| 1314 |
|
|
for(int v=0; v<mNumCubitVariants; v++) mShapes[v] = getObjectShape(v);
|
| 1315 |
|
|
}
|
| 1316 |
|
|
|
| 1317 |
|
|
if( mOrigQuat==null )
|
| 1318 |
|
|
{
|
| 1319 |
|
|
mOrigQuat = new Static4D[mNumCubits];
|
| 1320 |
|
|
}
|
| 1321 |
|
|
|
| 1322 |
|
|
if( mOrigQuat[0]==null )
|
| 1323 |
|
|
{
|
| 1324 |
|
|
for(int c=0; c<mNumCubits; c++) mOrigQuat[c] = getCubitQuats(c,mNumLayers);
|
| 1325 |
|
|
}
|
| 1326 |
|
|
|
| 1327 |
|
|
mCubitFaceColors = ObjectShape.computeColors(mShapes,mOrigPos,mOrigQuat,this);
|
| 1328 |
|
|
}
|
| 1329 |
|
|
|
| 1330 |
f80b9473
|
leszek
|
return mCubitFaceColors[cubit][face]>=0;
|
| 1331 |
|
|
}
|
| 1332 |
|
|
|
| 1333 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1334 |
|
|
|
| 1335 |
880beeea
|
Leszek Koltunski
|
void resetAllTextureMaps()
|
| 1336 |
29b82486
|
Leszek Koltunski
|
{
|
| 1337 |
7c111294
|
Leszek Koltunski
|
final float ratioW = 1.0f/mNumTexCols;
|
| 1338 |
|
|
final float ratioH = 1.0f/mNumTexRows;
|
| 1339 |
51262d81
|
Leszek Koltunski
|
int cubColor, stiShape, texIndex, variant, row, col;
|
| 1340 |
29b82486
|
Leszek Koltunski
|
|
| 1341 |
a05b6e06
|
Leszek Koltunski
|
for(int cubit=0; cubit<mNumCubits; cubit++)
|
| 1342 |
29b82486
|
Leszek Koltunski
|
{
|
| 1343 |
7c111294
|
Leszek Koltunski
|
final Static4D[] maps = new Static4D[mNumCubitFaces];
|
| 1344 |
a75ae1ee
|
Leszek Koltunski
|
variant = getCubitVariant(cubit,mNumLayers);
|
| 1345 |
29b82486
|
Leszek Koltunski
|
|
| 1346 |
a75ae1ee
|
Leszek Koltunski
|
for(int face=0; face<mNumCubitFaces; face++)
|
| 1347 |
7c111294
|
Leszek Koltunski
|
{
|
| 1348 |
d4105efe
|
Leszek Koltunski
|
cubColor = getCubitFaceColor(cubit,face);
|
| 1349 |
51262d81
|
Leszek Koltunski
|
stiShape = getVariantStickerShape(variant,face);
|
| 1350 |
|
|
texIndex = cubColor<0 || stiShape<0 ? mNumTextures-mNumOverrides : stiShape*mNumFaceColors + cubColor;
|
| 1351 |
|
|
row = (mNumTexRows-1) - texIndex/mNumTexCols;
|
| 1352 |
|
|
col = texIndex%mNumTexCols;
|
| 1353 |
a75ae1ee
|
Leszek Koltunski
|
|
| 1354 |
|
|
maps[face] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH);
|
| 1355 |
7c111294
|
Leszek Koltunski
|
}
|
| 1356 |
29b82486
|
Leszek Koltunski
|
|
| 1357 |
7c111294
|
Leszek Koltunski
|
mMesh.setTextureMap(maps,mNumCubitFaces*cubit);
|
| 1358 |
|
|
}
|
| 1359 |
0b050556
|
Leszek Koltunski
|
|
| 1360 |
b0c97683
|
Leszek Koltunski
|
overrideCubitFaceColor();
|
| 1361 |
|
|
}
|
| 1362 |
|
|
|
| 1363 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1364 |
|
|
|
| 1365 |
|
|
private void overrideCubitFaceColor()
|
| 1366 |
|
|
{
|
| 1367 |
|
|
final float ratioW = 1.0f/mNumTexCols;
|
| 1368 |
|
|
final float ratioH = 1.0f/mNumTexRows;
|
| 1369 |
|
|
|
| 1370 |
0b050556
|
Leszek Koltunski
|
for(int i=0; i<mNumOverrides; i++)
|
| 1371 |
|
|
{
|
| 1372 |
|
|
int[] cubitFaces = mStickerOverrides[i].getCubitFaces();
|
| 1373 |
|
|
int length = cubitFaces.length/2;
|
| 1374 |
|
|
|
| 1375 |
|
|
for(int j=0; j<length; j++)
|
| 1376 |
b0c97683
|
Leszek Koltunski
|
{
|
| 1377 |
|
|
final Static4D[] maps = new Static4D[1];
|
| 1378 |
|
|
int color = mNumTextures-mNumOverrides+1+i;
|
| 1379 |
|
|
int row = (mNumTexRows-1) - color/mNumTexCols;
|
| 1380 |
|
|
int col = color%mNumTexCols;
|
| 1381 |
|
|
int cubit = cubitFaces[2*j];
|
| 1382 |
|
|
int face = cubitFaces[2*j+1];
|
| 1383 |
|
|
maps[0] = new Static4D(col*ratioW, row*ratioH, ratioW, ratioH);
|
| 1384 |
|
|
mMesh.setTextureMap(maps,mNumCubitFaces*cubit+face);
|
| 1385 |
|
|
}
|
| 1386 |
0b050556
|
Leszek Koltunski
|
}
|
| 1387 |
|
|
}
|
| 1388 |
|
|
|
| 1389 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1390 |
|
|
|
| 1391 |
880beeea
|
Leszek Koltunski
|
void releaseResources()
|
| 1392 |
29b82486
|
Leszek Koltunski
|
{
|
| 1393 |
7c111294
|
Leszek Koltunski
|
mTexture.markForDeletion();
|
| 1394 |
|
|
mMesh.markForDeletion();
|
| 1395 |
|
|
mEffects.markForDeletion();
|
| 1396 |
|
|
|
| 1397 |
94490b34
|
leszek
|
if( mBitmap!=null )
|
| 1398 |
|
|
{
|
| 1399 |
|
|
mBitmap.recycle();
|
| 1400 |
|
|
mBitmap = null;
|
| 1401 |
|
|
}
|
| 1402 |
|
|
|
| 1403 |
a05b6e06
|
Leszek Koltunski
|
for(int j=0; j<mNumCubits; j++)
|
| 1404 |
7c111294
|
Leszek Koltunski
|
{
|
| 1405 |
a05b6e06
|
Leszek Koltunski
|
mCubits[j].releaseResources();
|
| 1406 |
7c111294
|
Leszek Koltunski
|
}
|
| 1407 |
29b82486
|
Leszek Koltunski
|
}
|
| 1408 |
|
|
|
| 1409 |
00a28d71
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1410 |
|
|
|
| 1411 |
544c9224
|
leszek
|
private void setCubitQuat(int cubit, int equAssociation)
|
| 1412 |
00a28d71
|
Leszek Koltunski
|
{
|
| 1413 |
544c9224
|
leszek
|
int andAssociation = mCubits[cubit].computeAssociation();
|
| 1414 |
|
|
|
| 1415 |
00a28d71
|
Leszek Koltunski
|
if( !mIsInMixupMode )
|
| 1416 |
|
|
{
|
| 1417 |
|
|
mMesh.setEffectAssociation(cubit,andAssociation,equAssociation);
|
| 1418 |
|
|
}
|
| 1419 |
|
|
else
|
| 1420 |
|
|
{
|
| 1421 |
|
|
mMesh.setEffectAssociation(cubit,andAssociation,cubit);
|
| 1422 |
|
|
Static4D tmp = mObjectQuats[equAssociation];
|
| 1423 |
|
|
mMixupModeQuats[cubit].set(tmp);
|
| 1424 |
|
|
}
|
| 1425 |
|
|
}
|
| 1426 |
|
|
|
| 1427 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1428 |
|
|
|
| 1429 |
79c7c950
|
Leszek Koltunski
|
synchronized void restorePreferences(OperatingSystemInterface os)
|
| 1430 |
29b82486
|
Leszek Koltunski
|
{
|
| 1431 |
|
|
boolean error = false;
|
| 1432 |
8b5894af
|
Leszek Koltunski
|
String key = getShortName();
|
| 1433 |
29b82486
|
Leszek Koltunski
|
|
| 1434 |
a05b6e06
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++)
|
| 1435 |
29b82486
|
Leszek Koltunski
|
{
|
| 1436 |
a2122d42
|
leszek
|
mQuatDebug[i] = mCubits[i].restorePreferences(key,os);
|
| 1437 |
29b82486
|
Leszek Koltunski
|
|
| 1438 |
a05b6e06
|
Leszek Koltunski
|
if( mQuatDebug[i]>=0 && mQuatDebug[i]<mNumQuats )
|
| 1439 |
29b82486
|
Leszek Koltunski
|
{
|
| 1440 |
3788d0cd
|
Leszek Koltunski
|
boolean result = mCubits[i].rotateCubit(mObjectQuats[mQuatDebug[i]],true);
|
| 1441 |
1f329dcc
|
Leszek Koltunski
|
if( !result ) debugQuat(mObjectQuats[mQuatDebug[i]],i,0,0,0,mQuatDebug[i],3);
|
| 1442 |
fbd18fc7
|
Leszek Koltunski
|
}
|
| 1443 |
7cd287b9
|
Leszek Koltunski
|
else { error = true; break; }
|
| 1444 |
fbd18fc7
|
Leszek Koltunski
|
}
|
| 1445 |
|
|
|
| 1446 |
7cd287b9
|
Leszek Koltunski
|
if( !error )
|
| 1447 |
fbd18fc7
|
Leszek Koltunski
|
{
|
| 1448 |
7cd287b9
|
Leszek Koltunski
|
recomputeFaceOffsets();
|
| 1449 |
|
|
|
| 1450 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 1451 |
29b82486
|
Leszek Koltunski
|
{
|
| 1452 |
7cd287b9
|
Leszek Koltunski
|
if( mQuatDebug[i]>=0 && mQuatDebug[i]<mNumQuats )
|
| 1453 |
|
|
{
|
| 1454 |
|
|
mCubits[i].computeRotationRow();
|
| 1455 |
544c9224
|
leszek
|
setCubitQuat(i,mQuatDebug[i]);
|
| 1456 |
7cd287b9
|
Leszek Koltunski
|
}
|
| 1457 |
|
|
else { error = true; break; }
|
| 1458 |
29b82486
|
Leszek Koltunski
|
}
|
| 1459 |
|
|
}
|
| 1460 |
|
|
|
| 1461 |
|
|
if( error )
|
| 1462 |
|
|
{
|
| 1463 |
a05b6e06
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++)
|
| 1464 |
29b82486
|
Leszek Koltunski
|
{
|
| 1465 |
a05b6e06
|
Leszek Koltunski
|
mCubits[i].solve();
|
| 1466 |
544c9224
|
leszek
|
setCubitQuat(i,0);
|
| 1467 |
29b82486
|
Leszek Koltunski
|
}
|
| 1468 |
|
|
}
|
| 1469 |
|
|
}
|
| 1470 |
|
|
|
| 1471 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1472 |
|
|
|
| 1473 |
79c7c950
|
Leszek Koltunski
|
void savePreferences(OperatingSystemInterface os)
|
| 1474 |
29b82486
|
Leszek Koltunski
|
{
|
| 1475 |
8b5894af
|
Leszek Koltunski
|
String key = getShortName();
|
| 1476 |
79c7c950
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++) mCubits[i].savePreferences(key,os);
|
| 1477 |
9c7d220a
|
leszek
|
|
| 1478 |
|
|
os.putFloat(key+"_border", mTextureBorderMultiplier);
|
| 1479 |
|
|
os.putFloat(key+"_corner", mTextureCornerMultiplier);
|
| 1480 |
|
|
os.putString(key+"_colors", createColors(mColorTable) );
|
| 1481 |
29b82486
|
Leszek Koltunski
|
}
|
| 1482 |
|
|
|
| 1483 |
ea739ec8
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1484 |
|
|
|
| 1485 |
79c7c950
|
Leszek Koltunski
|
public void removePreferences(OperatingSystemInterface os)
|
| 1486 |
ea739ec8
|
Leszek Koltunski
|
{
|
| 1487 |
|
|
String key = getShortName();
|
| 1488 |
79c7c950
|
Leszek Koltunski
|
for(int i=0; i<mNumCubits; i++) mCubits[i].removePreferences(key,os);
|
| 1489 |
9c7d220a
|
leszek
|
|
| 1490 |
|
|
os.remove(key+"_border");
|
| 1491 |
|
|
os.remove(key+"_corner");
|
| 1492 |
|
|
os.remove(key+"_colors");
|
| 1493 |
|
|
}
|
| 1494 |
|
|
|
| 1495 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1496 |
|
|
|
| 1497 |
|
|
private String createColors(int[] table)
|
| 1498 |
|
|
{
|
| 1499 |
|
|
StringBuilder sb = new StringBuilder();
|
| 1500 |
|
|
int len = table!=null ? table.length : 0;
|
| 1501 |
|
|
|
| 1502 |
|
|
for(int i=0; i<len; i++)
|
| 1503 |
|
|
{
|
| 1504 |
|
|
sb.append(table[i]);
|
| 1505 |
|
|
sb.append(',');
|
| 1506 |
|
|
}
|
| 1507 |
|
|
|
| 1508 |
|
|
return sb.toString();
|
| 1509 |
ea739ec8
|
Leszek Koltunski
|
}
|
| 1510 |
|
|
|
| 1511 |
00f4980d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1512 |
|
|
|
| 1513 |
7e9a35eb
|
leszek
|
private float computeRadiusCorrection(float[][] sticker, int curr, int len)
|
| 1514 |
00f4980d
|
Leszek Koltunski
|
{
|
| 1515 |
|
|
final float A = 0.8f; // 0<A<1
|
| 1516 |
|
|
|
| 1517 |
|
|
int prev = curr>0 ? curr-1 : len-1;
|
| 1518 |
|
|
int next = curr<len-1 ? curr+1 : 0;
|
| 1519 |
|
|
|
| 1520 |
7e9a35eb
|
leszek
|
float v1x = sticker[prev][0]-sticker[curr][0];
|
| 1521 |
|
|
float v1y = sticker[prev][1]-sticker[curr][1];
|
| 1522 |
|
|
float v2x = sticker[next][0]-sticker[curr][0];
|
| 1523 |
|
|
float v2y = sticker[next][1]-sticker[curr][1];
|
| 1524 |
00f4980d
|
Leszek Koltunski
|
|
| 1525 |
|
|
float len1= v1x*v1x+v1y*v1y;
|
| 1526 |
|
|
float len2= v2x*v2x+v2y*v2y;
|
| 1527 |
|
|
|
| 1528 |
|
|
float cos = (v1x*v2x+v1y*v2y) / ( (float)Math.sqrt(len1*len2) );
|
| 1529 |
|
|
|
| 1530 |
|
|
return 1-A*cos;
|
| 1531 |
|
|
}
|
| 1532 |
|
|
|
| 1533 |
b9c861cf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1534 |
|
|
// Radius of the sphere circumscribed on the puzzle. Needed for pillowing.
|
| 1535 |
|
|
//
|
| 1536 |
|
|
// This won't work correctly for pillowing off-center puzzles (e.g. mirrors) - for those we'd need
|
| 1537 |
|
|
// to introduce the concept of a 'sink center' as well.
|
| 1538 |
|
|
//
|
| 1539 |
|
|
// public because needed in TouchControlShapemod
|
| 1540 |
|
|
|
| 1541 |
|
|
public float getCircumscribedRadius()
|
| 1542 |
|
|
{
|
| 1543 |
|
|
switch(mNumPuzzleFaces)
|
| 1544 |
|
|
{
|
| 1545 |
|
|
case 4: return (SQ6/4)*mSize;
|
| 1546 |
|
|
case 6: return (SQ3/2)*mSize;
|
| 1547 |
|
|
case 8: return (SQ2/2)*mSize;
|
| 1548 |
|
|
case 12: return (SQ3/2)*((SQ5+1)/2)*mSize;
|
| 1549 |
c1452814
|
Leszek Koltunski
|
case 16: return 0.50f*mSize;
|
| 1550 |
b9c861cf
|
Leszek Koltunski
|
}
|
| 1551 |
|
|
|
| 1552 |
|
|
return 0.0f;
|
| 1553 |
|
|
}
|
| 1554 |
|
|
|
| 1555 |
e61a158a
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1556 |
|
|
// might be overridden in subclasses which want per-edge radii
|
| 1557 |
|
|
|
| 1558 |
|
|
protected float[][][] getStickerRadii()
|
| 1559 |
|
|
{
|
| 1560 |
|
|
float radius = getStickerRadius();
|
| 1561 |
|
|
int numStickers = mStickerCoords.length;
|
| 1562 |
|
|
float[][][] ret = new float[numStickers][][];
|
| 1563 |
|
|
|
| 1564 |
|
|
for(int s=0; s<numStickers; s++)
|
| 1565 |
|
|
{
|
| 1566 |
|
|
int numLoops = mStickerCoords[s].length;
|
| 1567 |
|
|
ret[s] = new float[numLoops][];
|
| 1568 |
|
|
|
| 1569 |
|
|
for(int l=0; l<numLoops; l++)
|
| 1570 |
|
|
{
|
| 1571 |
|
|
int numVertices = mStickerCoords[s][l].length;
|
| 1572 |
|
|
ret[s][l] = new float[numVertices];
|
| 1573 |
|
|
for(int v=0; v<numVertices; v++) ret[s][l][v] = radius;
|
| 1574 |
|
|
}
|
| 1575 |
|
|
}
|
| 1576 |
|
|
|
| 1577 |
|
|
return ret;
|
| 1578 |
|
|
}
|
| 1579 |
|
|
|
| 1580 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1581 |
|
|
// might be overridden in subclasses which want per-edge strokes
|
| 1582 |
|
|
|
| 1583 |
|
|
protected float[][][] getStickerStrokes()
|
| 1584 |
|
|
{
|
| 1585 |
|
|
float stroke = getStickerStroke();
|
| 1586 |
|
|
int numStickers = mStickerCoords.length;
|
| 1587 |
|
|
float[][][] ret = new float[numStickers][][];
|
| 1588 |
|
|
|
| 1589 |
|
|
for(int s=0; s<numStickers; s++)
|
| 1590 |
|
|
{
|
| 1591 |
|
|
int numLoops = mStickerCoords[s].length;
|
| 1592 |
|
|
ret[s] = new float[numLoops][];
|
| 1593 |
|
|
|
| 1594 |
|
|
for(int l=0; l<numLoops; l++)
|
| 1595 |
|
|
{
|
| 1596 |
|
|
int numVertices = mStickerCoords[s][l].length;
|
| 1597 |
|
|
ret[s][l] = new float[numVertices];
|
| 1598 |
|
|
for(int v=0; v<numVertices; v++) ret[s][l][v] = stroke;
|
| 1599 |
|
|
}
|
| 1600 |
|
|
}
|
| 1601 |
|
|
|
| 1602 |
|
|
return ret;
|
| 1603 |
|
|
}
|
| 1604 |
|
|
|
| 1605 |
d53fb890
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1606 |
|
|
|
| 1607 |
|
|
public ObjectSticker retSticker(int sticker)
|
| 1608 |
|
|
{
|
| 1609 |
|
|
if( mStickers==null )
|
| 1610 |
|
|
{
|
| 1611 |
e61a158a
|
leszek
|
float[][][] radii = getStickerRadii();
|
| 1612 |
|
|
float[][][] strokes = getStickerStrokes();
|
| 1613 |
|
|
float[][][] angles = getStickerAngles();
|
| 1614 |
d53fb890
|
Leszek Koltunski
|
int numStickers = mStickerCoords.length;
|
| 1615 |
|
|
mStickers = new ObjectSticker[numStickers];
|
| 1616 |
|
|
|
| 1617 |
|
|
for(int s=0; s<numStickers; s++)
|
| 1618 |
|
|
{
|
| 1619 |
bc008758
|
Leszek Koltunski
|
float scale = mStickerScales.length>s ? mStickerScales[s] : 1.0f;
|
| 1620 |
ebe8c08e
|
leszek
|
int numLoops = mStickerCoords[s].length;
|
| 1621 |
e61a158a
|
leszek
|
float[][] rad = new float[numLoops][];
|
| 1622 |
|
|
float[][] str = new float[numLoops][];
|
| 1623 |
ebe8c08e
|
leszek
|
|
| 1624 |
|
|
for(int l=0; l<numLoops; l++)
|
| 1625 |
|
|
{
|
| 1626 |
|
|
int numVerts = mStickerCoords[s][l].length;
|
| 1627 |
e61a158a
|
leszek
|
rad[l] = new float[numVerts];
|
| 1628 |
|
|
str[l] = new float[numVerts];
|
| 1629 |
|
|
float[] st = strokes[s][l];
|
| 1630 |
|
|
float[] ra = radii[s][l];
|
| 1631 |
ebe8c08e
|
leszek
|
|
| 1632 |
|
|
for(int v=0; v<numVerts; v++)
|
| 1633 |
e61a158a
|
leszek
|
{
|
| 1634 |
|
|
rad[l][v] = ra[v] * computeRadiusCorrection(mStickerCoords[s][l],v,numVerts) / scale;
|
| 1635 |
|
|
str[l][v] = st[v] / scale;
|
| 1636 |
|
|
}
|
| 1637 |
ebe8c08e
|
leszek
|
}
|
| 1638 |
|
|
|
| 1639 |
e61a158a
|
leszek
|
mStickers[s] = new ObjectSticker(mStickerCoords[s], (angles==null ? null : angles[s]) ,rad, str);
|
| 1640 |
d53fb890
|
Leszek Koltunski
|
}
|
| 1641 |
|
|
}
|
| 1642 |
|
|
|
| 1643 |
|
|
return mStickers[sticker];
|
| 1644 |
|
|
}
|
| 1645 |
|
|
|
| 1646 |
3d766df3
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1647 |
e3937019
|
Leszek Koltunski
|
// some objects (currently Kilominx,Ivy,Rex) might want to change the stickers.
|
| 1648 |
3d766df3
|
Leszek Koltunski
|
|
| 1649 |
|
|
public void adjustStickerCoords()
|
| 1650 |
|
|
{
|
| 1651 |
|
|
|
| 1652 |
|
|
}
|
| 1653 |
|
|
|
| 1654 |
802fe251
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1655 |
|
|
|
| 1656 |
|
|
public Static4D[] getQuats()
|
| 1657 |
|
|
{
|
| 1658 |
|
|
if( mObjectQuats==null )
|
| 1659 |
|
|
{
|
| 1660 |
|
|
mObjectQuats = QuatGroupGenerator.computeGroup(mAxis,mBasicAngles);
|
| 1661 |
|
|
}
|
| 1662 |
|
|
|
| 1663 |
|
|
return mObjectQuats;
|
| 1664 |
|
|
}
|
| 1665 |
|
|
|
| 1666 |
40e77224
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1667 |
|
|
|
| 1668 |
|
|
public int[][] getVariantFaceIsOuter()
|
| 1669 |
|
|
{
|
| 1670 |
|
|
return mVariantFaceIsOuter;
|
| 1671 |
|
|
}
|
| 1672 |
|
|
|
| 1673 |
253e440f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1674 |
|
|
|
| 1675 |
|
|
public int getInternalColor()
|
| 1676 |
|
|
{
|
| 1677 |
|
|
return COLOR_INTERNAL;
|
| 1678 |
|
|
}
|
| 1679 |
|
|
|
| 1680 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1681 |
3a0a23bf
|
Leszek Koltunski
|
// the getFaceColors + final INTERNAL_COLOR in a grid (so that we do not exceed the maximum texture size)
|
| 1682 |
29b82486
|
Leszek Koltunski
|
|
| 1683 |
352bd362
|
leszek
|
void createTexture(float borders, float corners)
|
| 1684 |
29b82486
|
Leszek Koltunski
|
{
|
| 1685 |
7c111294
|
Leszek Koltunski
|
Paint paint = new Paint();
|
| 1686 |
d5c71d02
|
Leszek Koltunski
|
Canvas canvas = new Canvas(mBitmap);
|
| 1687 |
29b82486
|
Leszek Koltunski
|
|
| 1688 |
7c111294
|
Leszek Koltunski
|
paint.setAntiAlias(true);
|
| 1689 |
|
|
paint.setTextAlign(Paint.Align.CENTER);
|
| 1690 |
|
|
paint.setStyle(Paint.Style.FILL);
|
| 1691 |
253e440f
|
Leszek Koltunski
|
paint.setColor(getInternalColor());
|
| 1692 |
f3eab97f
|
leszek
|
canvas.drawRect(0, 0, mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, paint);
|
| 1693 |
7c111294
|
Leszek Koltunski
|
|
| 1694 |
6f5eb9b3
|
leszek
|
mTextureBorderMultiplier = borders;
|
| 1695 |
|
|
mTextureCornerMultiplier = corners;
|
| 1696 |
|
|
|
| 1697 |
43a4ccff
|
Leszek Koltunski
|
int texture = 0;
|
| 1698 |
7c111294
|
Leszek Koltunski
|
FactorySticker factory = FactorySticker.getInstance();
|
| 1699 |
|
|
|
| 1700 |
|
|
for(int row=0; row<mNumTexRows; row++)
|
| 1701 |
|
|
for(int col=0; col<mNumTexCols; col++)
|
| 1702 |
29b82486
|
Leszek Koltunski
|
{
|
| 1703 |
3a0a23bf
|
Leszek Koltunski
|
if( texture<mNumTextures-mNumOverrides )
|
| 1704 |
|
|
{
|
| 1705 |
|
|
ObjectSticker sticker = retSticker(texture/mNumFaceColors);
|
| 1706 |
962b8ff6
|
leszek
|
int color = mColorTable[texture%mNumFaceColors];
|
| 1707 |
6f5eb9b3
|
leszek
|
factory.drawRoundedPolygons( canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, color,
|
| 1708 |
|
|
mTexHeight, sticker,mTextureBorderMultiplier,mTextureCornerMultiplier);
|
| 1709 |
3a0a23bf
|
Leszek Koltunski
|
}
|
| 1710 |
ff60e713
|
Leszek Koltunski
|
else if( texture>mNumTextures-mNumOverrides && texture<=mNumTextures )
|
| 1711 |
3a0a23bf
|
Leszek Koltunski
|
{
|
| 1712 |
ff60e713
|
Leszek Koltunski
|
int color = mStickerOverrides[mNumTextures-texture].getColor();
|
| 1713 |
f3eab97f
|
leszek
|
factory.drawSolidColor(canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, color, mTexHeight);
|
| 1714 |
3a0a23bf
|
Leszek Koltunski
|
}
|
| 1715 |
ff60e713
|
Leszek Koltunski
|
|
| 1716 |
|
|
texture++;
|
| 1717 |
7e8750c9
|
leszek
|
}
|
| 1718 |
|
|
}
|
| 1719 |
|
|
|
| 1720 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1721 |
|
|
|
| 1722 |
6f5eb9b3
|
leszek
|
private void changeColorInTexture(int oldColor, int newColor)
|
| 1723 |
7e8750c9
|
leszek
|
{
|
| 1724 |
|
|
Paint paint = new Paint();
|
| 1725 |
|
|
Canvas canvas = new Canvas(mBitmap);
|
| 1726 |
|
|
paint.setAntiAlias(true);
|
| 1727 |
|
|
int texture = 0;
|
| 1728 |
|
|
FactorySticker factory = FactorySticker.getInstance();
|
| 1729 |
|
|
|
| 1730 |
|
|
for(int row=0; row<mNumTexRows; row++)
|
| 1731 |
|
|
for(int col=0; col<mNumTexCols; col++)
|
| 1732 |
|
|
{
|
| 1733 |
|
|
if( texture<mNumTextures-mNumOverrides )
|
| 1734 |
|
|
{
|
| 1735 |
5ce579d2
|
leszek
|
int color = mOriginalColorTable[texture%mNumFaceColors];
|
| 1736 |
7e8750c9
|
leszek
|
|
| 1737 |
|
|
if( color==oldColor )
|
| 1738 |
|
|
{
|
| 1739 |
|
|
ObjectSticker sticker = retSticker(texture/mNumFaceColors);
|
| 1740 |
6f5eb9b3
|
leszek
|
factory.drawRoundedPolygons( canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight,
|
| 1741 |
|
|
newColor, mTexHeight, sticker,mTextureBorderMultiplier,mTextureCornerMultiplier);
|
| 1742 |
7e8750c9
|
leszek
|
}
|
| 1743 |
|
|
}
|
| 1744 |
|
|
|
| 1745 |
|
|
texture++;
|
| 1746 |
29b82486
|
Leszek Koltunski
|
}
|
| 1747 |
d5c71d02
|
Leszek Koltunski
|
}
|
| 1748 |
|
|
|
| 1749 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1750 |
|
|
|
| 1751 |
|
|
void setTexture()
|
| 1752 |
|
|
{
|
| 1753 |
352bd362
|
leszek
|
if( mBitmap==null )
|
| 1754 |
|
|
{
|
| 1755 |
|
|
mBitmap = Bitmap.createBitmap( mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, Bitmap.Config.ARGB_4444);
|
| 1756 |
|
|
createTexture(1.0f,1.0f);
|
| 1757 |
|
|
}
|
| 1758 |
29b82486
|
Leszek Koltunski
|
|
| 1759 |
a0ccffb4
|
Leszek Koltunski
|
if( !mTexture.setTextureAlreadyInverted(mBitmap) )
|
| 1760 |
7c111294
|
Leszek Koltunski
|
{
|
| 1761 |
|
|
int max = DistortedLibrary.getMaxTextureSize();
|
| 1762 |
32c1697e
|
Leszek Koltunski
|
mInterface.reportProblem("failed to set texture of size "+mBitmap.getWidth()+"x"+mBitmap.getHeight()+" max is "+max, true);
|
| 1763 |
29b82486
|
Leszek Koltunski
|
}
|
| 1764 |
|
|
}
|
| 1765 |
|
|
|
| 1766 |
ee6bb8d7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1767 |
|
|
|
| 1768 |
45e0065d
|
Leszek Koltunski
|
void setObjectRatioNow(float sc, int nodeSize)
|
| 1769 |
ee6bb8d7
|
Leszek Koltunski
|
{
|
| 1770 |
64c209f5
|
Leszek Koltunski
|
mObjectScreenRatio = sc;
|
| 1771 |
45e0065d
|
Leszek Koltunski
|
float scale = mObjectScreenRatio*mInitScreenRatio*nodeSize/mSize;
|
| 1772 |
ee6bb8d7
|
Leszek Koltunski
|
mObjectScale.set(scale,scale,scale);
|
| 1773 |
23afe4c4
|
Leszek Koltunski
|
|
| 1774 |
11fa413d
|
Leszek Koltunski
|
if( mTouchControl ==null ) mTouchControl = getTouchControl();
|
| 1775 |
c9c71c3f
|
Leszek Koltunski
|
mTouchControl.setObjectRatio(mObjectScreenRatio*mInitScreenRatio);
|
| 1776 |
ee6bb8d7
|
Leszek Koltunski
|
}
|
| 1777 |
|
|
|
| 1778 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1779 |
|
|
|
| 1780 |
45e0065d
|
Leszek Koltunski
|
void setObjectRatio(float sizeChange, int nodeSize)
|
| 1781 |
29b82486
|
Leszek Koltunski
|
{
|
| 1782 |
7c111294
|
Leszek Koltunski
|
mObjectScreenRatio *= (1.0f+sizeChange)/2;
|
| 1783 |
29b82486
|
Leszek Koltunski
|
|
| 1784 |
7c111294
|
Leszek Koltunski
|
if( mObjectScreenRatio>MAX_SIZE_CHANGE) mObjectScreenRatio = MAX_SIZE_CHANGE;
|
| 1785 |
|
|
if( mObjectScreenRatio<MIN_SIZE_CHANGE) mObjectScreenRatio = MIN_SIZE_CHANGE;
|
| 1786 |
|
|
|
| 1787 |
45e0065d
|
Leszek Koltunski
|
setObjectRatioNow(mObjectScreenRatio, nodeSize);
|
| 1788 |
|
|
}
|
| 1789 |
|
|
|
| 1790 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1791 |
|
|
|
| 1792 |
|
|
void setNodeSize(int nodeSize)
|
| 1793 |
|
|
{
|
| 1794 |
|
|
setObjectRatioNow(mObjectScreenRatio, nodeSize);
|
| 1795 |
29b82486
|
Leszek Koltunski
|
}
|
| 1796 |
|
|
|
| 1797 |
02d80fe6
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1798 |
|
|
|
| 1799 |
|
|
public float getRatio()
|
| 1800 |
|
|
{
|
| 1801 |
|
|
return mObjectScreenRatio;
|
| 1802 |
|
|
}
|
| 1803 |
|
|
|
| 1804 |
11fa413d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1805 |
|
|
|
| 1806 |
|
|
public float getObjectRatio()
|
| 1807 |
|
|
{
|
| 1808 |
|
|
return mObjectScreenRatio*mInitScreenRatio;
|
| 1809 |
|
|
}
|
| 1810 |
|
|
|
| 1811 |
7c111294
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1812 |
29b82486
|
Leszek Koltunski
|
|
| 1813 |
880beeea
|
Leszek Koltunski
|
boolean isSolved()
|
| 1814 |
7c111294
|
Leszek Koltunski
|
{
|
| 1815 |
5df97ecb
|
leszek
|
boolean solved = mSolved.isSolved(mCubits);
|
| 1816 |
|
|
return mRotation.isSolved(solved);
|
| 1817 |
29b82486
|
Leszek Koltunski
|
}
|
| 1818 |
|
|
|
| 1819 |
880beeea
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1820 |
|
|
// INTERNAL API - those are called from 'effects' package
|
| 1821 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1822 |
|
|
|
| 1823 |
880beeea
|
Leszek Koltunski
|
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total)
|
| 1824 |
29b82486
|
Leszek Koltunski
|
{
|
| 1825 |
a72a4b6a
|
Leszek Koltunski
|
mScrambler.randomizeNewScramble(scramble,rnd,curr,total, getSignature() );
|
| 1826 |
7c111294
|
Leszek Koltunski
|
}
|
| 1827 |
29b82486
|
Leszek Koltunski
|
|
| 1828 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1829 |
|
|
|
| 1830 |
880beeea
|
Leszek Koltunski
|
public Static4D getRotationQuat()
|
| 1831 |
59c20632
|
Leszek Koltunski
|
{
|
| 1832 |
|
|
return mQuat;
|
| 1833 |
|
|
}
|
| 1834 |
|
|
|
| 1835 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1836 |
|
|
|
| 1837 |
|
|
public float getSize()
|
| 1838 |
|
|
{
|
| 1839 |
|
|
return mSize;
|
| 1840 |
|
|
}
|
| 1841 |
7c111294
|
Leszek Koltunski
|
|
| 1842 |
2df35810
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1843 |
|
|
|
| 1844 |
826d293e
|
Leszek Koltunski
|
public void applyEffect(Effect effect, int position)
|
| 1845 |
2df35810
|
Leszek Koltunski
|
{
|
| 1846 |
|
|
mEffects.apply(effect, position);
|
| 1847 |
|
|
}
|
| 1848 |
|
|
|
| 1849 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1850 |
|
|
|
| 1851 |
826d293e
|
Leszek Koltunski
|
public void removeEffect(long effectID)
|
| 1852 |
2df35810
|
Leszek Koltunski
|
{
|
| 1853 |
|
|
mEffects.abortById(effectID);
|
| 1854 |
|
|
}
|
| 1855 |
|
|
|
| 1856 |
3e9df6aa
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1857 |
|
|
|
| 1858 |
758b028d
|
Leszek Koltunski
|
public MeshBase getObjectMesh()
|
| 1859 |
3e9df6aa
|
Leszek Koltunski
|
{
|
| 1860 |
|
|
return mMesh;
|
| 1861 |
|
|
}
|
| 1862 |
|
|
|
| 1863 |
758b028d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1864 |
|
|
|
| 1865 |
|
|
public DistortedEffects getObjectEffects()
|
| 1866 |
|
|
{
|
| 1867 |
|
|
return mEffects;
|
| 1868 |
|
|
}
|
| 1869 |
|
|
|
| 1870 |
7aae846c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1871 |
|
|
|
| 1872 |
|
|
public int getCubitType(int cubit)
|
| 1873 |
|
|
{
|
| 1874 |
|
|
return mCubits[cubit].getType();
|
| 1875 |
|
|
}
|
| 1876 |
|
|
|
| 1877 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1878 |
|
|
|
| 1879 |
|
|
public float[] getCubitOffset(int cubit)
|
| 1880 |
|
|
{
|
| 1881 |
|
|
return mCubits[cubit].getOffset();
|
| 1882 |
|
|
}
|
| 1883 |
|
|
|
| 1884 |
3a0a23bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1885 |
|
|
|
| 1886 |
|
|
public ObjectStickerOverride[] getStickerOverrides()
|
| 1887 |
|
|
{
|
| 1888 |
|
|
return null;
|
| 1889 |
|
|
}
|
| 1890 |
|
|
|
| 1891 |
3ce95490
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1892 |
|
|
|
| 1893 |
|
|
public boolean getError()
|
| 1894 |
|
|
{
|
| 1895 |
|
|
return mError;
|
| 1896 |
|
|
}
|
| 1897 |
|
|
|
| 1898 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1899 |
|
|
|
| 1900 |
|
|
public String getErrorString()
|
| 1901 |
|
|
{
|
| 1902 |
|
|
return mErrorString;
|
| 1903 |
|
|
}
|
| 1904 |
|
|
|
| 1905 |
880beeea
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1906 |
|
|
// PUBLIC API
|
| 1907 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1908 |
|
|
|
| 1909 |
a1f8dc90
|
Leszek Koltunski
|
public int getCubitFaceStickerIndex(int cubit, int face)
|
| 1910 |
29b82486
|
Leszek Koltunski
|
{
|
| 1911 |
a1f8dc90
|
Leszek Koltunski
|
Static4D texMap = mMesh.getTextureMap(mNumCubitFaces*cubit + face);
|
| 1912 |
29b82486
|
Leszek Koltunski
|
|
| 1913 |
880beeea
|
Leszek Koltunski
|
int x = (int)(texMap.get0()/texMap.get2());
|
| 1914 |
|
|
int y = (int)(texMap.get1()/texMap.get3());
|
| 1915 |
29b82486
|
Leszek Koltunski
|
|
| 1916 |
f3eab97f
|
leszek
|
return (mNumTexRows-1-y)*mNumTexCols + x;
|
| 1917 |
29b82486
|
Leszek Koltunski
|
}
|
| 1918 |
|
|
|
| 1919 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1920 |
|
|
|
| 1921 |
a57e6870
|
Leszek Koltunski
|
public int[] getNumLayers()
|
| 1922 |
29b82486
|
Leszek Koltunski
|
{
|
| 1923 |
880beeea
|
Leszek Koltunski
|
return mNumLayers;
|
| 1924 |
|
|
}
|
| 1925 |
29b82486
|
Leszek Koltunski
|
|
| 1926 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1927 |
|
|
|
| 1928 |
880beeea
|
Leszek Koltunski
|
public synchronized void solve()
|
| 1929 |
29b82486
|
Leszek Koltunski
|
{
|
| 1930 |
f557ecc4
|
leszek
|
for(int i=0; i<mNumCubits; i++) mCubits[i].solve();
|
| 1931 |
7d2fe403
|
Leszek Koltunski
|
|
| 1932 |
|
|
recomputeFaceOffsets();
|
| 1933 |
|
|
|
| 1934 |
|
|
for(int i=0; i<mNumCubits; i++)
|
| 1935 |
|
|
{
|
| 1936 |
|
|
mCubits[i].computeRotationRow();
|
| 1937 |
544c9224
|
leszek
|
setCubitQuat(i,0);
|
| 1938 |
880beeea
|
Leszek Koltunski
|
}
|
| 1939 |
29b82486
|
Leszek Koltunski
|
}
|
| 1940 |
|
|
|
| 1941 |
57ef6378
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1942 |
|
|
|
| 1943 |
|
|
public int getCubitQuatIndex(int cubit)
|
| 1944 |
|
|
{
|
| 1945 |
05b0a7dd
|
Leszek Koltunski
|
return (cubit>=0 && cubit<mNumCubits) ? mCubits[cubit].mQuatIndex : 0;
|
| 1946 |
57ef6378
|
Leszek Koltunski
|
}
|
| 1947 |
|
|
|
| 1948 |
92a6fc8b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1949 |
|
|
|
| 1950 |
|
|
public int getCubitRotRow(int cubit, int axis)
|
| 1951 |
|
|
{
|
| 1952 |
a05b6e06
|
Leszek Koltunski
|
return mCubits[cubit].getRotRow(axis);
|
| 1953 |
92a6fc8b
|
Leszek Koltunski
|
}
|
| 1954 |
|
|
|
| 1955 |
d5c71d02
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1956 |
|
|
|
| 1957 |
|
|
public Bitmap getStickerBitmap()
|
| 1958 |
|
|
{
|
| 1959 |
|
|
return mBitmap;
|
| 1960 |
|
|
}
|
| 1961 |
|
|
|
| 1962 |
7ba38dd4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1963 |
|
|
|
| 1964 |
|
|
public DistortedNode getNode()
|
| 1965 |
|
|
{
|
| 1966 |
|
|
return mNode;
|
| 1967 |
|
|
}
|
| 1968 |
|
|
|
| 1969 |
7af68038
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1970 |
|
|
|
| 1971 |
|
|
public int getNumStickerTypes()
|
| 1972 |
|
|
{
|
| 1973 |
|
|
return mNumStickerTypes;
|
| 1974 |
|
|
}
|
| 1975 |
|
|
|
| 1976 |
93743a22
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1977 |
|
|
|
| 1978 |
|
|
public String reportState()
|
| 1979 |
|
|
{
|
| 1980 |
|
|
StringBuilder builder = new StringBuilder();
|
| 1981 |
|
|
|
| 1982 |
|
|
for(int i=0; i<mNumCubits; i++ )
|
| 1983 |
|
|
{
|
| 1984 |
|
|
if( i>0 ) builder.append('.');
|
| 1985 |
|
|
builder.append(mCubits[i].mQuatIndex);
|
| 1986 |
|
|
}
|
| 1987 |
|
|
|
| 1988 |
|
|
return builder.toString();
|
| 1989 |
|
|
}
|
| 1990 |
|
|
|
| 1991 |
d66e98d7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 1992 |
a0b0795b
|
Leszek Koltunski
|
// this is here only so it can be overridden in TwistyJSON so that we can get this from JSON.
|
| 1993 |
d66e98d7
|
Leszek Koltunski
|
|
| 1994 |
|
|
public int getNumCubitFaces()
|
| 1995 |
|
|
{
|
| 1996 |
|
|
return 0;
|
| 1997 |
|
|
}
|
| 1998 |
|
|
|
| 1999 |
a0b0795b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2000 |
|
|
// 1.0 - i.e. no pillowing - by default.
|
| 2001 |
|
|
// The coeff is really param of the 'sink' vertex effect - if it is not equal to 1.0, we apply the
|
| 2002 |
|
|
// sink effect [centered at (0,0,0)] to the whole mesh as the last step of composing it.
|
| 2003 |
|
|
|
| 2004 |
|
|
public float getPillowCoeff()
|
| 2005 |
|
|
{
|
| 2006 |
|
|
return 1.0f;
|
| 2007 |
|
|
}
|
| 2008 |
|
|
|
| 2009 |
59c20632
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2010 |
|
|
|
| 2011 |
11fa413d
|
Leszek Koltunski
|
public TouchControl getTouchControl()
|
| 2012 |
59c20632
|
Leszek Koltunski
|
{
|
| 2013 |
57ef6378
|
Leszek Koltunski
|
if( mTouchControl==null )
|
| 2014 |
59c20632
|
Leszek Koltunski
|
{
|
| 2015 |
11fa413d
|
Leszek Koltunski
|
switch(getTouchControlType())
|
| 2016 |
59c20632
|
Leszek Koltunski
|
{
|
| 2017 |
cd2e8d4c
|
Leszek Koltunski
|
case TC_TETRAHEDRON : mTouchControl = new TouchControlTetrahedron(this);
|
| 2018 |
|
|
break;
|
| 2019 |
|
|
case TC_HEXAHEDRON : mTouchControl = new TouchControlHexahedron(this);
|
| 2020 |
|
|
break;
|
| 2021 |
|
|
case TC_OCTAHEDRON : mTouchControl = new TouchControlOctahedron(this);
|
| 2022 |
|
|
break;
|
| 2023 |
|
|
case TC_DODECAHEDRON : mTouchControl = new TouchControlDodecahedron(this);
|
| 2024 |
|
|
break;
|
| 2025 |
5caf2641
|
Leszek Koltunski
|
case TC_ICOSAHEDRON : mTouchControl = new TouchControlIcosahedron(this);
|
| 2026 |
|
|
break;
|
| 2027 |
cd2e8d4c
|
Leszek Koltunski
|
case TC_CUBOID : int[] numLayers = getNumLayers();
|
| 2028 |
|
|
mTouchControl = new TouchControlCuboids(this,getDist3D(numLayers));
|
| 2029 |
|
|
break;
|
| 2030 |
5caf2641
|
Leszek Koltunski
|
case TC_BALL : mTouchControl = new TouchControlBall(this);
|
| 2031 |
|
|
break;
|
| 2032 |
cd2e8d4c
|
Leszek Koltunski
|
case TC_CHANGING_MIRROR : mTouchControl = new TouchControlMirror(this);
|
| 2033 |
|
|
break;
|
| 2034 |
|
|
case TC_CHANGING_SQUARE : mTouchControl = new TouchControlSquare(this);
|
| 2035 |
|
|
break;
|
| 2036 |
|
|
case TC_CHANGING_SHAPEMOD: mTouchControl = new TouchControlShapemod(this);
|
| 2037 |
|
|
break;
|
| 2038 |
59c20632
|
Leszek Koltunski
|
}
|
| 2039 |
|
|
}
|
| 2040 |
c9c71c3f
|
Leszek Koltunski
|
return mTouchControl;
|
| 2041 |
59c20632
|
Leszek Koltunski
|
}
|
| 2042 |
|
|
|
| 2043 |
fb1e9a31
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2044 |
|
|
|
| 2045 |
|
|
public float[][] returnRotationFactor()
|
| 2046 |
|
|
{
|
| 2047 |
|
|
float[][] factor = new float[mNumAxis][];
|
| 2048 |
|
|
|
| 2049 |
|
|
for(int ax=0; ax<mNumAxis; ax++)
|
| 2050 |
|
|
{
|
| 2051 |
|
|
int numL = mNumLayers[ax];
|
| 2052 |
|
|
factor[ax] = new float[numL];
|
| 2053 |
|
|
for(int la=0; la<numL; la++) factor[ax][la] = 1.0f;
|
| 2054 |
|
|
}
|
| 2055 |
|
|
|
| 2056 |
|
|
return factor;
|
| 2057 |
|
|
}
|
| 2058 |
|
|
|
| 2059 |
29b82486
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2060 |
|
|
|
| 2061 |
82eb152a
|
Leszek Koltunski
|
protected void setReader(JsonReader reader)
|
| 2062 |
|
|
{
|
| 2063 |
|
|
// empty
|
| 2064 |
|
|
}
|
| 2065 |
|
|
|
| 2066 |
743cdab7
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2067 |
|
|
|
| 2068 |
|
|
public String getInventor()
|
| 2069 |
|
|
{
|
| 2070 |
71df2bd4
|
leszek
|
return mMetadata.getAuthor();
|
| 2071 |
743cdab7
|
leszek
|
}
|
| 2072 |
|
|
|
| 2073 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2074 |
|
|
|
| 2075 |
|
|
public int getYearOfInvention()
|
| 2076 |
|
|
{
|
| 2077 |
|
|
return mMetadata.getYearOfInvention();
|
| 2078 |
|
|
}
|
| 2079 |
|
|
|
| 2080 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2081 |
|
|
|
| 2082 |
|
|
public float getComplexity()
|
| 2083 |
|
|
{
|
| 2084 |
71df2bd4
|
leszek
|
return mMetadata.getDifficulty();
|
| 2085 |
743cdab7
|
leszek
|
}
|
| 2086 |
|
|
|
| 2087 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2088 |
|
|
|
| 2089 |
|
|
public String getObjectName()
|
| 2090 |
|
|
{
|
| 2091 |
|
|
return mMetadata.getObjectName();
|
| 2092 |
|
|
}
|
| 2093 |
|
|
|
| 2094 |
baa031e2
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2095 |
|
|
|
| 2096 |
|
|
public ObjectSignature getSignature()
|
| 2097 |
|
|
{
|
| 2098 |
|
|
return mMetadata.getSignature();
|
| 2099 |
|
|
}
|
| 2100 |
|
|
|
| 2101 |
82eb152a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2102 |
59c20632
|
Leszek Koltunski
|
// for JSON only
|
| 2103 |
11fa413d
|
Leszek Koltunski
|
public abstract int getTouchControlType();
|
| 2104 |
|
|
public abstract int getTouchControlSplit();
|
| 2105 |
59c20632
|
Leszek Koltunski
|
public abstract boolean[][] getLayerRotatable(int[] numLayers);
|
| 2106 |
|
|
public abstract int[][][] getEnabled();
|
| 2107 |
|
|
public abstract float[] getDist3D(int[] numLayers);
|
| 2108 |
4c9ca251
|
Leszek Koltunski
|
public abstract Static3D[] getFaceAxis();
|
| 2109 |
9ba7f3f6
|
Leszek Koltunski
|
public abstract int[][] getScrambleEdges();
|
| 2110 |
7bbfc84f
|
Leszek Koltunski
|
public abstract float[][] getCuts(int[] numLayers);
|
| 2111 |
d53fb890
|
Leszek Koltunski
|
public abstract float getStickerRadius();
|
| 2112 |
|
|
public abstract float getStickerStroke();
|
| 2113 |
ebe8c08e
|
leszek
|
public abstract float[][][] getStickerAngles();
|
| 2114 |
e30c522a
|
Leszek Koltunski
|
public abstract int getCubitVariant(int cubit, int[] numLayers);
|
| 2115 |
|
|
public abstract ObjectShape getObjectShape(int variant);
|
| 2116 |
3ee1d662
|
Leszek Koltunski
|
public abstract ObjectFaceShape getObjectFaceShape(int variant);
|
| 2117 |
84a17011
|
Leszek Koltunski
|
public abstract ObjectVertexEffects getVertexEffects(int variant);
|
| 2118 |
e30c522a
|
Leszek Koltunski
|
public abstract int getNumCubitVariants(int[] numLayers);
|
| 2119 |
7b832206
|
Leszek Koltunski
|
public abstract float[][] getCubitPositions(int[] numLayers);
|
| 2120 |
d0e6cf7f
|
Leszek Koltunski
|
public abstract Static4D getCubitQuats(int cubit, int[] numLayers);
|
| 2121 |
82eb152a
|
Leszek Koltunski
|
public abstract float getScreenRatio();
|
| 2122 |
962b8ff6
|
leszek
|
public abstract int[] getColorTable();
|
| 2123 |
5f54927b
|
Leszek Koltunski
|
public abstract String getShortName();
|
| 2124 |
7b832206
|
Leszek Koltunski
|
|
| 2125 |
a75ae1ee
|
Leszek Koltunski
|
// not only for JSON
|
| 2126 |
29b82486
|
Leszek Koltunski
|
public abstract Static3D[] getRotationAxis();
|
| 2127 |
beee90ab
|
Leszek Koltunski
|
public abstract int[][] getBasicAngles();
|
| 2128 |
2289cab1
|
Leszek Koltunski
|
public abstract int getNumFaces();
|
| 2129 |
7ba38dd4
|
Leszek Koltunski
|
public abstract int getFOV();
|
| 2130 |
052e0362
|
Leszek Koltunski
|
public abstract String[][] getTutorials();
|
| 2131 |
29b82486
|
Leszek Koltunski
|
}
|