Revision e844c116
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/object/Cubit.java | ||
---|---|---|
47 | 47 |
private Static3D mRotationAxis; |
48 | 48 |
private MatrixEffectRotate mRotateEffect; |
49 | 49 |
private Static3D mCurrentPosition; |
50 |
private int mNumAxis; |
|
50 | 51 |
|
51 | 52 |
Dynamic1D mRotationAngle; |
52 | 53 |
DistortedNode mNode; |
... | ... | |
155 | 156 |
|
156 | 157 |
|
157 | 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
158 |
// TODO: this is only right in case of RubikCube
|
|
159 |
// cast current position on axis; use mStart and mStep to compute the rotation row for each axis.
|
|
159 | 160 |
|
160 | 161 |
private void computeRotationRow() |
161 | 162 |
{ |
162 |
mRotationRow[0] = (int)mCurrentPosition.get0(); |
|
163 |
mRotationRow[1] = (int)mCurrentPosition.get1(); |
|
164 |
mRotationRow[2] = (int)mCurrentPosition.get2(); |
|
163 |
float tmp; |
|
164 |
Static3D axis; |
|
165 |
float x = mCurrentPosition.get0(); |
|
166 |
float y = mCurrentPosition.get1(); |
|
167 |
float z = mCurrentPosition.get2(); |
|
168 |
|
|
169 |
for(int i=0; i<mNumAxis; i++) |
|
170 |
{ |
|
171 |
axis = mParent.ROTATION_AXIS[i]; |
|
172 |
tmp = x*axis.get0() + y*axis.get1() + z*axis.get2(); |
|
173 |
mRotationRow[i] = (int)( (tmp-mParent.mStart)/mParent.mStep + 0.5f ); |
|
174 |
} |
|
165 | 175 |
} |
166 | 176 |
|
167 | 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
184 | 194 |
mCurrentPosition = position; |
185 | 195 |
mRotateEffect = new MatrixEffectRotate(mRotationAngle, mRotationAxis, matrCenter); |
186 | 196 |
|
187 |
mRotationRow = new int[mParent.ROTATION_AXIS.length]; |
|
197 |
mNumAxis = mParent.ROTATION_AXIS.length; |
|
198 |
mRotationRow = new int[mNumAxis]; |
|
188 | 199 |
computeRotationRow(); |
189 | 200 |
|
190 | 201 |
mEffect = new DistortedEffects(); |
Also available in: Unified diff
Beginnings of Pyraminx.