Revision 46a961fd
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.type.Static4D; |
32 | 32 |
import org.distorted.objects.RubikObject; |
33 | 33 |
import org.distorted.objects.RubikObjectMovement; |
34 |
import org.distorted.solvers.SolverMain; |
|
34 | 35 |
import org.distorted.states.RubikState; |
35 | 36 |
import org.distorted.states.RubikStateSolver; |
36 | 37 |
import org.distorted.states.RubikStateSolving; |
... | ... | |
72 | 73 |
private float mStartRotX, mStartRotY; |
73 | 74 |
private float mAxisX, mAxisY; |
74 | 75 |
private float mRotationFactor; |
76 |
private int mLastCubitColor, mLastCubitFace, mLastCubit; |
|
75 | 77 |
|
76 | 78 |
private static Static4D mQuatCurrent = new Static4D(0,0,0,1); |
77 | 79 |
private static Static4D mQuatAccumulated= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
... | ... | |
205 | 207 |
if( down ) |
206 | 208 |
{ |
207 | 209 |
RubikStateSolver solver = (RubikStateSolver) RubikState.SVER.getStateClass(); |
208 |
int face = mMovement.getTouchedFace();
|
|
210 |
mLastCubitFace = mMovement.getTouchedFace();
|
|
209 | 211 |
float[] point = mMovement.getTouchedPoint3D(); |
210 | 212 |
int color = solver.getCurrentColor(); |
211 | 213 |
RubikObject object = mPostRender.getObject(); |
212 |
int cubit = object.getCubit(point);
|
|
213 |
|
|
214 |
mPostRender.setTextureMap( cubit, face, color );
|
|
214 |
mLastCubit = object.getCubit(point);
|
|
215 |
mPostRender.setTextureMap( mLastCubit, mLastCubitFace, color ); |
|
216 |
mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getSize(), mLastCubit);
|
|
215 | 217 |
} |
216 | 218 |
} |
217 | 219 |
} |
... | ... | |
413 | 415 |
{ |
414 | 416 |
mPostRender.finishRotation(); |
415 | 417 |
} |
418 |
if( mLastCubitColor>=0 ) |
|
419 |
{ |
|
420 |
mPostRender.setTextureMap( mLastCubit, mLastCubitFace, mLastCubitColor ); |
|
421 |
} |
|
416 | 422 |
break; |
417 | 423 |
} |
418 | 424 |
|
src/main/java/org/distorted/solvers/SolverMain.java | ||
---|---|---|
45 | 45 |
mObjectPosition = position; |
46 | 46 |
} |
47 | 47 |
|
48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
// certain objects have certain cubits locked - for example, the Cube3's centers of |
|
50 |
// sides always have the same color. |
|
51 |
// If a certain cubit is locked, return the color (index into it's FACE_COLORS array) it |
|
52 |
// must have. Otherwise return -1. |
|
53 |
|
|
54 |
public static int cubitIsLocked(RubikObjectList object, int size, int cubit) |
|
55 |
{ |
|
56 |
if( object == RubikObjectList.CUBE && size == 3) |
|
57 |
{ |
|
58 |
if( cubit==21 ) return 0; // center of the right face |
|
59 |
if( cubit== 4 ) return 1; // center of the left face |
|
60 |
if( cubit==15 ) return 2; // center of the up face |
|
61 |
if( cubit==10 ) return 3; // center of the bottom face |
|
62 |
if( cubit==13 ) return 4; // center of the front face |
|
63 |
if( cubit==12 ) return 5; // center of the back face |
|
64 |
} |
|
65 |
|
|
66 |
return -1; |
|
67 |
} |
|
68 |
|
|
48 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 70 |
|
50 | 71 |
private void solveCube3(RubikStateSolver solver) |
Also available in: Unified diff
The 3x3x3 Solver finished - here the last piece of work, locking the centers of the 3x3x3 cube in place so that RubikStateSolver's color picker cannot change them ( the CUBE3 solver assumes this )