1 |
826d293e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2022 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Magic Cube. //
|
5 |
|
|
// //
|
6 |
|
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7 |
|
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9 |
|
|
|
10 |
|
|
package org.distorted.objectlib.effects.present;
|
11 |
|
|
|
12 |
|
|
import org.distorted.library.effect.Effect;
|
13 |
8801b933
|
Leszek Koltunski
|
import org.distorted.library.effect.MatrixEffectRotate;
|
14 |
826d293e
|
Leszek Koltunski
|
import org.distorted.library.type.Dynamic;
|
15 |
8801b933
|
Leszek Koltunski
|
import org.distorted.library.type.Dynamic1D;
|
16 |
|
|
import org.distorted.library.type.Static1D;
|
17 |
826d293e
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
18 |
|
|
import org.distorted.library.type.Static4D;
|
19 |
|
|
|
20 |
8801b933
|
Leszek Koltunski
|
import static org.distorted.library.main.QuatHelper.rotateVectorByInvertedQuat;
|
21 |
|
|
|
22 |
826d293e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
|
24 |
|
|
public class PresentEffectSpin extends PresentEffect
|
25 |
|
|
{
|
26 |
|
|
public void createEffects(int duration, int numScrambles)
|
27 |
|
|
{
|
28 |
|
|
mCubeEffectNumber = 1;
|
29 |
|
|
mNodeEffectNumber = 0;
|
30 |
8801b933
|
Leszek Koltunski
|
mCubeEffectPosition = new int[] {0};
|
31 |
826d293e
|
Leszek Koltunski
|
mCubeEffects = new Effect[mCubeEffectPosition.length];
|
32 |
|
|
|
33 |
8801b933
|
Leszek Koltunski
|
Static4D quaternion = mObject.getRotationQuat(); // always rotate around
|
34 |
|
|
Static4D tmpAxis = new Static4D(0,-1,0,0); // vert axis no matter
|
35 |
|
|
Static4D rotated = rotateVectorByInvertedQuat(tmpAxis,quaternion); // how cube is rotated
|
36 |
826d293e
|
Leszek Koltunski
|
|
37 |
8801b933
|
Leszek Koltunski
|
Static3D axis = new Static3D(rotated.get0(), rotated.get1(), rotated.get2());
|
38 |
|
|
Static3D center= new Static3D(0,0,0);
|
39 |
826d293e
|
Leszek Koltunski
|
|
40 |
8801b933
|
Leszek Koltunski
|
Dynamic1D d = new Dynamic1D(duration, 0.0f);
|
41 |
|
|
d.setMode(Dynamic.MODE_JUMP);
|
42 |
|
|
d.setConvexity(0.0f); // otherwise speed of the rotation would be strangely uneven
|
43 |
|
|
d.add( new Static1D( 0));
|
44 |
|
|
d.add( new Static1D(360));
|
45 |
826d293e
|
Leszek Koltunski
|
|
46 |
8801b933
|
Leszek Koltunski
|
mCubeEffects[0] = new MatrixEffectRotate(d,axis,center);
|
47 |
826d293e
|
Leszek Koltunski
|
}
|
48 |
|
|
|
49 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
// Enable all effects used in this Effect. Called by reflection from the parent class.
|
51 |
|
|
|
52 |
|
|
@SuppressWarnings("unused")
|
53 |
|
|
static void enable()
|
54 |
|
|
{
|
55 |
|
|
|
56 |
|
|
}
|
57 |
|
|
}
|