1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2017 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.library.effect;
|
21
|
|
22
|
import org.distorted.library.type.Data1D;
|
23
|
import org.distorted.library.type.Data3D;
|
24
|
import org.distorted.library.type.Data4D;
|
25
|
import org.distorted.library.type.Static4D;
|
26
|
|
27
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28
|
|
29
|
public class VertexEffectSink extends VertexEffect
|
30
|
{
|
31
|
private Data1D mSink;
|
32
|
private Data3D mCenter;
|
33
|
private Data4D mRegion;
|
34
|
|
35
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36
|
/**
|
37
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
38
|
* away from the center (degree<=1)
|
39
|
*
|
40
|
* @param sink The current degree of the Effect.
|
41
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
42
|
* @param region Region that masks the Effect.
|
43
|
*/
|
44
|
public VertexEffectSink(Data1D sink, Data3D center, Data4D region)
|
45
|
{
|
46
|
super(EffectName.SINK);
|
47
|
mSink = sink;
|
48
|
mCenter = center;
|
49
|
mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
/**
|
54
|
* Pull all points around the center of the Effect towards the center (if degree>=1) or push them
|
55
|
* away from the center (degree<=1)
|
56
|
*
|
57
|
* @param sink The current degree of the Effect.
|
58
|
* @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
|
59
|
*/
|
60
|
public VertexEffectSink(Data1D sink, Data3D center)
|
61
|
{
|
62
|
super(EffectName.SINK);
|
63
|
mSink = sink;
|
64
|
mCenter = center;
|
65
|
mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
|
66
|
}
|
67
|
|
68
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69
|
|
70
|
public boolean compute(float[] uniforms, int index, long currentDuration, long step )
|
71
|
{
|
72
|
mCenter.get(uniforms,index+5,currentDuration,step);
|
73
|
mRegion.get(uniforms,index+8,currentDuration,step);
|
74
|
boolean ret = mSink.get(uniforms,index,currentDuration,step);
|
75
|
|
76
|
uniforms[index+9] =-uniforms[index+9];
|
77
|
|
78
|
return ret;
|
79
|
}
|
80
|
}
|