Revision 49f67f9b
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/object/RubikObject.java | ||
---|---|---|
54 | 54 |
private final int NUM_CUBITS; |
55 | 55 |
private int mRotRow; |
56 | 56 |
private int mRotAxis; |
57 |
private Static3D[] mOrigPos; |
|
57 | 58 |
private Static3D mScale, mNodeScale; |
58 | 59 |
private Static4D mQuatAccumulated; |
59 | 60 |
private Cubit[] mCubits; |
61 |
private int mSize; |
|
60 | 62 |
|
61 | 63 |
float mStart, mStep; |
62 |
int mSize; |
|
63 | 64 |
|
64 | 65 |
Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal; |
65 | 66 |
DistortedTexture mTexture; |
... | ... | |
77 | 78 |
|
78 | 79 |
resizeFBO(NODE_FBO_SIZE, NODE_FBO_SIZE); |
79 | 80 |
|
80 |
Static3D[] positions = getCubitPositions(size);
|
|
81 |
mOrigPos = getCubitPositions(size);
|
|
81 | 82 |
|
82 | 83 |
LEGAL_QUATS = getLegalQuats(); |
83 |
NUM_CUBITS = positions.length;
|
|
84 |
NUM_CUBITS = mOrigPos.length;
|
|
84 | 85 |
ROTATION_AXIS = getRotationAxis(); |
85 | 86 |
|
86 | 87 |
mSize = size; |
87 |
|
|
88 |
computeStartAndStep(positions); |
|
88 |
computeStartAndStep(mOrigPos); |
|
89 | 89 |
|
90 | 90 |
mRotationAngleStatic = new Static1D(0); |
91 | 91 |
mRotationAngleMiddle = new Static1D(0); |
... | ... | |
115 | 115 |
for(int i=0; i<NUM_CUBITS; i++) |
116 | 116 |
{ |
117 | 117 |
MeshBase cubitMesh = createCubitMesh(vertices); |
118 |
mCubits[i] = new Cubit(this,cubitMesh,positions[i]);
|
|
118 |
mCubits[i] = new Cubit(this,cubitMesh,mOrigPos[i]);
|
|
119 | 119 |
textureCubitMesh(cubitMesh,i); |
120 | 120 |
|
121 | 121 |
attach(mCubits[i].mNode); |
... | ... | |
143 | 143 |
{ |
144 | 144 |
for(int i=0; i<numFaces; i++) |
145 | 145 |
{ |
146 |
belongs = belongsToRotation(cubit, i, mSize-1 );
|
|
146 |
belongs = belongsToRotation(cubit, i, 0 );
|
|
147 | 147 |
maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f); |
148 | 148 |
} |
149 | 149 |
} |
... | ... | |
213 | 213 |
} |
214 | 214 |
} |
215 | 215 |
|
216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
217 |
// Clamp all rotated positions to one of those original ones to avoid accumulating errors. |
|
218 |
|
|
219 |
void clampPos(Static3D pos) |
|
220 |
{ |
|
221 |
float currError, minError = Float.MAX_VALUE; |
|
222 |
int minErrorIndex= -1; |
|
223 |
float x = pos.get0(); |
|
224 |
float y = pos.get1(); |
|
225 |
float z = pos.get2(); |
|
226 |
float xo,yo,zo; |
|
227 |
|
|
228 |
for(int i=0; i<NUM_CUBITS; i++) |
|
229 |
{ |
|
230 |
xo = mOrigPos[i].get0(); |
|
231 |
yo = mOrigPos[i].get1(); |
|
232 |
zo = mOrigPos[i].get2(); |
|
233 |
|
|
234 |
currError = (xo-x)*(xo-x) + (yo-y)*(yo-y) + (zo-z)*(zo-z); |
|
235 |
|
|
236 |
if( currError<minError ) |
|
237 |
{ |
|
238 |
minError = currError; |
|
239 |
minErrorIndex = i; |
|
240 |
} |
|
241 |
} |
|
242 |
|
|
243 |
pos.set( mOrigPos[minErrorIndex] ); |
|
244 |
} |
|
245 |
|
|
216 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
217 | 247 |
// the getFaceColors + final black in a horizontal strip. |
218 | 248 |
|
Also available in: Unified diff
Progress with Pyraminx.