1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.fastscramble;
|
11
|
|
12
|
import org.distorted.library.effect.Effect;
|
13
|
import org.distorted.library.effect.MatrixEffectRotate;
|
14
|
import org.distorted.library.type.Dynamic;
|
15
|
import org.distorted.library.type.Dynamic1D;
|
16
|
import org.distorted.library.type.Static1D;
|
17
|
import org.distorted.library.type.Static3D;
|
18
|
import org.distorted.library.type.Static4D;
|
19
|
|
20
|
import static org.distorted.library.main.QuatHelper.rotateVectorByInvertedQuat;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
|
24
|
public class FastScrambleEffectSpin extends FastScrambleEffect
|
25
|
{
|
26
|
private void createEffects(int phase, int duration, int[] points)
|
27
|
{
|
28
|
mCubeEffectPosition[phase] = new int[] {0};
|
29
|
mCubeEffects[phase] = new Effect[mCubeEffectPosition[0].length];
|
30
|
|
31
|
Static4D quaternion = mObject.getRotationQuat(); // always rotate around
|
32
|
Static4D tmpAxis = new Static4D(0,1,0,0); // vert axis no matter
|
33
|
Static4D rotated = rotateVectorByInvertedQuat(tmpAxis,quaternion); // how cube is rotated
|
34
|
|
35
|
Static3D axis = new Static3D(rotated.get0(), rotated.get1(), rotated.get2());
|
36
|
Static3D center= new Static3D(0,0,0);
|
37
|
|
38
|
Dynamic1D d = new Dynamic1D(duration/2, 1.0f);
|
39
|
d.setMode(Dynamic.MODE_JUMP);
|
40
|
d.setConvexity(0.0f); // otherwise speed of the rotation would be strangely uneven
|
41
|
|
42
|
d.add( new Static1D(36*points[0]) );
|
43
|
d.add( new Static1D(36*points[1]) );
|
44
|
d.add( new Static1D(36*points[2]) );
|
45
|
d.add( new Static1D(36*points[3]) );
|
46
|
d.add( new Static1D(36*points[4]) );
|
47
|
|
48
|
mCubeEffects[phase][0] = new MatrixEffectRotate(d,axis,center);
|
49
|
}
|
50
|
|
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52
|
// PUBLIC API
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public void createEffectsPhase0(int duration)
|
56
|
{
|
57
|
createEffects(0,duration,new int[] {0,1,3,6,10});
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
public void createEffectsPhase1(int duration)
|
63
|
{
|
64
|
createEffects(1,duration,new int[] {0,4,7,9,10});
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
// Enable all effects used in this Effect. Called by reflection from the parent class.
|
69
|
|
70
|
@SuppressWarnings("unused")
|
71
|
static void enable()
|
72
|
{
|
73
|
|
74
|
}
|
75
|
}
|