1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2019 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.effect;
|
21
|
|
22
|
import org.distorted.library.effect.Effect;
|
23
|
import org.distorted.library.effect.MatrixEffectMove;
|
24
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
25
|
import org.distorted.library.type.Dynamic;
|
26
|
import org.distorted.library.type.Dynamic3D;
|
27
|
import org.distorted.library.type.DynamicQuat;
|
28
|
import org.distorted.library.type.Static3D;
|
29
|
import org.distorted.library.type.Static4D;
|
30
|
|
31
|
import java.util.Random;
|
32
|
|
33
|
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
|
34
|
|
35
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36
|
|
37
|
public class ScrambleEffectRotations extends ScrambleEffect
|
38
|
{
|
39
|
private Random mRnd = new Random(0);
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
public void createEffects(int duration)
|
44
|
{
|
45
|
mCubeEffectNumber = 2;
|
46
|
mNodeEffectNumber = 0;
|
47
|
mCubeEffectPosition = new int[] {6,7};
|
48
|
mCubeEffects = new Effect[mCubeEffectPosition.length];
|
49
|
|
50
|
mRnd.setSeed(System.currentTimeMillis());
|
51
|
|
52
|
DynamicQuat dq = new DynamicQuat(duration, 0.5f);
|
53
|
dq.setMode(Dynamic.MODE_PATH);
|
54
|
dq.add(new Static4D(0,0,0,1));
|
55
|
dq.add(generateNewRandomPoint());
|
56
|
dq.add(generateNewRandomPoint());
|
57
|
dq.add(generateNewRandomPoint());
|
58
|
dq.add(new Static4D(0,0,0,1));
|
59
|
|
60
|
mCubeEffects[0] = new MatrixEffectQuaternion(dq, new Static3D(0,0,0));
|
61
|
|
62
|
float Z = TEXTURE_SIZE/3;
|
63
|
|
64
|
Dynamic3D d0 = new Dynamic3D(duration, 0.5f);
|
65
|
d0.setMode(Dynamic.MODE_PATH);
|
66
|
d0.add(new Static3D( 0, 0, 0));
|
67
|
d0.add(new Static3D( 0, 0,-Z));
|
68
|
d0.add(new Static3D( 0, 0, 0));
|
69
|
mCubeEffects[1] = new MatrixEffectMove(d0);
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
private Static4D generateNewRandomPoint()
|
75
|
{
|
76
|
float x = mRnd.nextFloat();
|
77
|
float y = mRnd.nextFloat();
|
78
|
float z = mRnd.nextFloat();
|
79
|
float w = mRnd.nextFloat();
|
80
|
|
81
|
float len = (float)Math.sqrt(x*x + y*y + z*z + w*w);
|
82
|
|
83
|
return new Static4D( x/len, y/len, z/len, w/len);
|
84
|
}
|
85
|
|
86
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87
|
|
88
|
public void effectFinishedPlugin(final long effectID)
|
89
|
{
|
90
|
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
// Enable all effects used in this Effect. Called by reflection from the parent class.
|
95
|
|
96
|
@SuppressWarnings("unused")
|
97
|
static void enable()
|
98
|
{
|
99
|
|
100
|
}
|
101
|
}
|