1 |
125cee3d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
15aa7d94
|
Leszek Koltunski
|
import org.distorted.library.type.Static4D;
|
26 |
125cee3d
|
Leszek Koltunski
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
|
|
public class VertexEffectSink extends VertexEffect
|
30 |
|
|
{
|
31 |
0dd98279
|
Leszek Koltunski
|
private Data1D mSink;
|
32 |
|
|
private Data3D mCenter;
|
33 |
|
|
private Data4D mRegion;
|
34 |
|
|
|
35 |
125cee3d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
6bb59aad
|
Leszek Koltunski
|
/**
|
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 |
125cee3d
|
Leszek Koltunski
|
public VertexEffectSink(Data1D sink, Data3D center, Data4D region)
|
45 |
|
|
{
|
46 |
9d0d8530
|
leszek
|
super(EffectName.SINK);
|
47 |
0dd98279
|
Leszek Koltunski
|
mSink = sink;
|
48 |
|
|
mCenter = center;
|
49 |
|
|
mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
|
50 |
125cee3d
|
Leszek Koltunski
|
}
|
51 |
|
|
|
52 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53 |
6bb59aad
|
Leszek Koltunski
|
/**
|
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 |
125cee3d
|
Leszek Koltunski
|
public VertexEffectSink(Data1D sink, Data3D center)
|
61 |
|
|
{
|
62 |
9d0d8530
|
leszek
|
super(EffectName.SINK);
|
63 |
0dd98279
|
Leszek Koltunski
|
mSink = sink;
|
64 |
|
|
mCenter = center;
|
65 |
|
|
mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
|
66 |
15aa7d94
|
Leszek Koltunski
|
}
|
67 |
|
|
|
68 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
|
70 |
|
|
public boolean compute(float[] uniforms, int index, long currentDuration, long step )
|
71 |
|
|
{
|
72 |
0dd98279
|
Leszek Koltunski
|
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 |
15aa7d94
|
Leszek Koltunski
|
|
76 |
82d6f93a
|
Leszek Koltunski
|
uniforms[index+9] =-uniforms[index+9];
|
77 |
|
|
|
78 |
15aa7d94
|
Leszek Koltunski
|
return ret;
|
79 |
125cee3d
|
Leszek Koltunski
|
}
|
80 |
|
|
}
|