Revision 66cbdd21
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/object/Cubit.java | ||
|---|---|---|
| 53 | 53 |
DistortedNode mNode; |
| 54 | 54 |
DistortedEffects mEffect; |
| 55 | 55 |
Static4D mQuatScramble; |
| 56 |
int[] mRotationRow;
|
|
| 56 |
float[] mRotationRow;
|
|
| 57 | 57 |
|
| 58 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 59 | 59 |
// Because of quatMultiplication, errors can accumulate - so to avoid this, we |
| ... | ... | |
| 169 | 169 |
{
|
| 170 | 170 |
axis = mParent.ROTATION_AXIS[i]; |
| 171 | 171 |
tmp = x*axis.get0() + y*axis.get1() + z*axis.get2(); |
| 172 |
mRotationRow[i] = (int)( (tmp-mParent.mStart)/mParent.mStep + 0.5f );
|
|
| 172 |
mRotationRow[i] = (tmp-mParent.mStart)/mParent.mStep;
|
|
| 173 | 173 |
} |
| 174 | 174 |
} |
| 175 | 175 |
|
| ... | ... | |
| 193 | 193 |
mRotateEffect = new MatrixEffectRotate(mRotationAngle, mRotationAxis, matrCenter); |
| 194 | 194 |
|
| 195 | 195 |
mNumAxis = mParent.ROTATION_AXIS.length; |
| 196 |
mRotationRow = new int[mNumAxis];
|
|
| 196 |
mRotationRow = new float[mNumAxis];
|
|
| 197 | 197 |
computeRotationRow(); |
| 198 | 198 |
|
| 199 | 199 |
mEffect = new DistortedEffects(); |
| src/main/java/org/distorted/object/RubikObject.java | ||
|---|---|---|
| 136 | 136 |
{
|
| 137 | 137 |
for(int i=0; i<numFaces; i++) |
| 138 | 138 |
{
|
| 139 |
belongs = belongsToRotation(cubit, i/2, i%2==0 ? mSize-1:0 );
|
|
| 139 |
belongs = isOnFace(cubit, i/2, i%2==0 ? mSize-1:0 );
|
|
| 140 | 140 |
maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f); |
| 141 | 141 |
} |
| 142 | 142 |
} |
| ... | ... | |
| 144 | 144 |
{
|
| 145 | 145 |
for(int i=0; i<numFaces; i++) |
| 146 | 146 |
{
|
| 147 |
belongs = belongsToRotation(cubit, i, 0 );
|
|
| 147 |
belongs = isOnFace(cubit, i, 0 );
|
|
| 148 | 148 |
maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f); |
| 149 | 149 |
} |
| 150 | 150 |
} |
| ... | ... | |
| 185 | 185 |
|
| 186 | 186 |
private boolean belongsToRotation( int cubit, int axis, int row) |
| 187 | 187 |
{
|
| 188 |
return mCubits[cubit].mRotationRow[axis]==row; |
|
| 188 |
return ((int)(mCubits[cubit].mRotationRow[axis]+0.5f))==row; |
|
| 189 |
} |
|
| 190 |
|
|
| 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 192 |
// we cannot use belongsToRotation for deciding if to texture a face. Counterexample: the 'rotated' |
|
| 193 |
// tetrahedrons of Pyraminx nearby the edge: they belong to rotation but their face which is rotated |
|
| 194 |
// away from the face of the Pyraminx shouldn't be textured. |
|
| 195 |
|
|
| 196 |
private boolean isOnFace( int cubit, int axis, int row) |
|
| 197 |
{
|
|
| 198 |
final float MAX_ERROR = 0.0001f; |
|
| 199 |
float diff = mCubits[cubit].mRotationRow[axis] - row; |
|
| 200 |
return diff*diff < MAX_ERROR; |
|
| 189 | 201 |
} |
| 190 | 202 |
|
| 191 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Some fixes for the Pyraminx.