1 |
4c2c0f44
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 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.resticker;
|
11 |
|
|
|
12 |
|
|
import static org.distorted.library.main.QuatHelper.rotateVectorByInvertedQuat;
|
13 |
|
|
|
14 |
|
|
import org.distorted.library.effect.Effect;
|
15 |
|
|
import org.distorted.library.effect.MatrixEffectRotate;
|
16 |
|
|
import org.distorted.library.type.Dynamic;
|
17 |
|
|
import org.distorted.library.type.Dynamic1D;
|
18 |
|
|
import org.distorted.library.type.Static1D;
|
19 |
|
|
import org.distorted.library.type.Static3D;
|
20 |
|
|
import org.distorted.library.type.Static4D;
|
21 |
|
|
|
22 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
|
24 |
|
|
public class RestickerEffectSpin extends RestickerEffect
|
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 |
|
|
}
|