Revision 51262d81
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/json/JsonReader.java | ||
---|---|---|
59 | 59 |
private Static4D[] mCubitQuats; |
60 | 60 |
private int mNumCubitVariants; |
61 | 61 |
private int[] mCubitVariant; |
62 |
private int[][] mVariantFaceColor, mVariantFaceIsOuter, mCubitFaceColor;
|
|
62 |
private int[][] mVariantStickerShape, mVariantFaceIsOuter, mCubitFaceColor;
|
|
63 | 63 |
private ObjectSticker[] mObjectSticker; |
64 | 64 |
private Static3D[] mAxis; |
65 | 65 |
private int[][] mBasicAngle; |
... | ... | |
168 | 168 |
private void parseShapes(JSONArray object) throws JSONException |
169 | 169 |
{ |
170 | 170 |
mNumCubitVariants = object.length(); |
171 |
mVariantFaceColor = new int[mNumCubitVariants][];
|
|
171 |
mVariantStickerShape = new int[mNumCubitVariants][];
|
|
172 | 172 |
mVariantFaceIsOuter = new int[mNumCubitVariants][]; |
173 | 173 |
mShapes = new ObjectShape[mNumCubitVariants]; |
174 | 174 |
mFaceShapes = new ObjectFaceShape[mNumCubitVariants]; |
... | ... | |
201 | 201 |
////// faces //////////////////////////////////////////////////// |
202 | 202 |
JSONArray jsonFaces= jsonShape.getJSONArray("faces"); |
203 | 203 |
int numFaces = jsonFaces.length(); |
204 |
mVariantFaceColor[i] = new int[numFaces];
|
|
204 |
mVariantStickerShape[i]= new int[numFaces];
|
|
205 | 205 |
mVariantFaceIsOuter[i] = new int[numFaces]; |
206 | 206 |
bandIndices[i] = new int[numFaces]; |
207 | 207 |
vertIndices[i] = new int[numFaces][]; |
... | ... | |
211 | 211 |
for(int j=0; j<numFaces; j++) |
212 | 212 |
{ |
213 | 213 |
JSONObject jsonFace = jsonFaces.getJSONObject(j); |
214 |
mVariantFaceColor[i][j] = jsonFace.getInt("sticker");
|
|
214 |
mVariantStickerShape[i][j]= jsonFace.getInt("sticker");
|
|
215 | 215 |
mVariantFaceIsOuter[i][j] = jsonFace.optInt("isOuter",0); |
216 | 216 |
bandIndices[i][j] = jsonFace.getInt("bandIndex"); |
217 | 217 |
JSONArray vertices = jsonFace.getJSONArray("vertexIndices"); |
... | ... | |
827 | 827 |
|
828 | 828 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
829 | 829 |
|
830 |
public int getVariantFaceColor(int variant, int face)
|
|
830 |
public int getVariantStickerShape(int variant, int face)
|
|
831 | 831 |
{ |
832 |
int[] colors = mVariantFaceColor[variant];
|
|
833 |
return colors.length>face ? colors[face] : -1;
|
|
832 |
int[] shapes = mVariantStickerShape[variant];
|
|
833 |
return shapes.length>face ? shapes[face] : -1;
|
|
834 | 834 |
} |
835 | 835 |
|
836 | 836 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/json/JsonWriter.java | ||
---|---|---|
135 | 135 |
JSONObject face = new JSONObject(); |
136 | 136 |
face.put("bandIndex", bandIndices[i]); |
137 | 137 |
|
138 |
int sticker = object.getVariantFaceColor(variant,i);
|
|
139 |
face.put("sticker", sticker);
|
|
138 |
int stiShape = object.getVariantStickerShape(variant,i);
|
|
139 |
face.put("sticker", stiShape);
|
|
140 | 140 |
face.put("isOuter", faceOuter[i]); |
141 | 141 |
|
142 | 142 |
JSONArray vertArr = new JSONArray(); |
src/main/java/org/distorted/objectlib/main/TwistyJson.java | ||
---|---|---|
106 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 107 |
|
108 | 108 |
@Override |
109 |
public int getVariantFaceColor(int variant, int face)
|
|
109 |
public int getVariantStickerShape(int variant, int face)
|
|
110 | 110 |
{ |
111 |
return mReader.getVariantFaceColor(variant,face);
|
|
111 |
return mReader.getVariantStickerShape(variant,face);
|
|
112 | 112 |
} |
113 | 113 |
|
114 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
549 | 549 |
|
550 | 550 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
551 | 551 |
|
552 |
public int getVariantFaceColor(int variant, int face)
|
|
552 |
public int getVariantStickerShape(int variant, int face)
|
|
553 | 553 |
{ |
554 | 554 |
return face>=mStickerVariants[variant].length ? -1 : mStickerVariants[variant][face]; |
555 | 555 |
} |
... | ... | |
579 | 579 |
|
580 | 580 |
protected int retCubitSolvedStatus(int cubit) |
581 | 581 |
{ |
582 |
int numNonBlack=0, nonBlackIndex=-1, varColor, cubColor;
|
|
582 |
int numNonBlack=0, nonBlackIndex=-1, stiShape, cubColor;
|
|
583 | 583 |
int variant = getCubitVariant(cubit,mNumLayers); |
584 | 584 |
|
585 | 585 |
for(int face=0; face<mNumCubitFaces; face++) |
586 | 586 |
{ |
587 |
varColor = getVariantFaceColor(variant,face);
|
|
587 |
stiShape = getVariantStickerShape(variant,face);
|
|
588 | 588 |
int numFaces = mCubitFaceColors[cubit].length; |
589 | 589 |
cubColor = face<numFaces ? mCubitFaceColors[cubit][face] : -1; |
590 | 590 |
|
591 |
if( varColor>=0 && cubColor>=0 )
|
|
591 |
if( stiShape>=0 && cubColor>=0 )
|
|
592 | 592 |
{ |
593 | 593 |
numNonBlack++; |
594 | 594 |
nonBlackIndex = cubColor; |
... | ... | |
1540 | 1540 |
|
1541 | 1541 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1542 | 1542 |
|
1543 |
void setTextureMap(int cubit, int face, int newColor)
|
|
1543 |
void setTextureMap(int cubit, int face, int color)
|
|
1544 | 1544 |
{ |
1545 |
int variant = getCubitVariant(cubit,mNumLayers); |
|
1546 |
int shape = getVariantStickerShape(variant,face); |
|
1547 |
int texIndex = color<0 || shape<0 ? mNumTextures-mNumOverrides : shape*mNumFaceColors + color; |
|
1548 |
int row = (mNumTexRows-1) - texIndex/mNumTexCols; |
|
1549 |
int col = texIndex%mNumTexCols; |
|
1550 |
|
|
1545 | 1551 |
final float ratioW = 1.0f/mNumTexCols; |
1546 | 1552 |
final float ratioH = 1.0f/mNumTexRows; |
1547 |
final Static4D[] maps = new Static4D[mNumCubitFaces]; |
|
1548 |
int row = (mNumTexRows-1) - newColor/mNumTexCols; |
|
1549 |
int col = newColor%mNumTexCols; |
|
1550 |
|
|
1551 |
maps[face] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH); |
|
1552 |
mMesh.setTextureMap(maps,mNumCubitFaces*cubit); |
|
1553 |
final Static4D[] maps = new Static4D[1]; |
|
1554 |
maps[0] = new Static4D(col*ratioW, row*ratioH, ratioW, ratioH); |
|
1555 |
mMesh.setTextureMap(maps,mNumCubitFaces*cubit+face); |
|
1553 | 1556 |
} |
1554 | 1557 |
|
1555 | 1558 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1576 | 1579 |
{ |
1577 | 1580 |
final float ratioW = 1.0f/mNumTexCols; |
1578 | 1581 |
final float ratioH = 1.0f/mNumTexRows; |
1579 |
int cubColor, varColor, color, variant, row, col;
|
|
1582 |
int cubColor, stiShape, texIndex, variant, row, col;
|
|
1580 | 1583 |
|
1581 | 1584 |
for(int cubit=0; cubit<mNumCubits; cubit++) |
1582 | 1585 |
{ |
... | ... | |
1586 | 1589 |
for(int face=0; face<mNumCubitFaces; face++) |
1587 | 1590 |
{ |
1588 | 1591 |
cubColor = getCubitFaceColor(cubit,face); |
1589 |
varColor = getVariantFaceColor(variant,face);
|
|
1590 |
color = cubColor<0 || varColor<0 ? mNumTextures-mNumOverrides : varColor*mNumFaceColors + cubColor;
|
|
1591 |
row = (mNumTexRows-1) - color/mNumTexCols;
|
|
1592 |
col = color%mNumTexCols;
|
|
1592 |
stiShape = getVariantStickerShape(variant,face);
|
|
1593 |
texIndex = cubColor<0 || stiShape<0 ? mNumTextures-mNumOverrides : stiShape*mNumFaceColors + cubColor;
|
|
1594 |
row = (mNumTexRows-1) - texIndex/mNumTexCols;
|
|
1595 |
col = texIndex%mNumTexCols;
|
|
1593 | 1596 |
|
1594 | 1597 |
maps[face] = new Static4D( col*ratioW, row*ratioH, ratioW, ratioH); |
1595 | 1598 |
} |
src/main/java/org/distorted/objectlib/touchcontrol/TouchControlMirror.java | ||
---|---|---|
32 | 32 |
private int correctTouchedFace(int cubit, int face, float[] quat) |
33 | 33 |
{ |
34 | 34 |
int[] numLayers = mObject.getNumLayers(); |
35 |
int variant = mObject.getCubitVariant(cubit,numLayers); |
|
36 |
int color = mObject.getVariantFaceColor(variant,face);
|
|
35 |
int variant = mObject.getCubitVariant(cubit,numLayers);
|
|
36 |
int stiShape = mObject.getVariantStickerShape(variant,face);
|
|
37 | 37 |
|
38 |
if( color>=0 ) return face;
|
|
38 |
if( stiShape>=0 ) return face;
|
|
39 | 39 |
|
40 | 40 |
float cx = mCamera[0]; |
41 | 41 |
float cy = mCamera[1]; |
... | ... | |
56 | 56 |
for(int i=0; i<6; i++) |
57 | 57 |
if( i!=face ) |
58 | 58 |
{ |
59 |
color = mObject.getVariantFaceColor(variant,i);
|
|
59 |
stiShape = mObject.getVariantStickerShape(variant,i);
|
|
60 | 60 |
|
61 |
if( color>=0 )
|
|
61 |
if( stiShape>=0 )
|
|
62 | 62 |
{ |
63 | 63 |
normal = mInfos[mTouchedCubit][i].getNormal(); |
64 | 64 |
QuatHelper.rotateVectorByQuat(mTmp,normal,quat); |
Also available in: Unified diff
Fix touch-replacing colors of the stickers. Now correctly takes into account the shape of the sticker.