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.present;
|
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.helpers.QuatHelper.rotateVectorByInvertedQuat;
|
21
|
|
22
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23
|
|
24
|
public class PresentEffectSpin extends PresentEffect
|
25
|
{
|
26
|
public void createEffects(int duration, int numScrambles)
|
27
|
{
|
28
|
mCubeEffectNumber = 1;
|
29
|
mNodeEffectNumber = 0;
|
30
|
mCubeEffectPosition = new int[] {0};
|
31
|
mCubeEffects = new Effect[mCubeEffectPosition.length];
|
32
|
|
33
|
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
|
|
37
|
Static3D axis = new Static3D(rotated.get0(), rotated.get1(), rotated.get2());
|
38
|
Static3D center= new Static3D(0,0,0);
|
39
|
|
40
|
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
|
|
46
|
mCubeEffects[0] = new MatrixEffectRotate(d,axis,center);
|
47
|
}
|
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
|
}
|