Project

General

Profile

« Previous | Next » 

Revision faa3ff56

Added by Leszek Koltunski almost 7 years ago

Javadoc.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectDistort.java
24 24
import org.distorted.library.type.Static4D;
25 25

  
26 26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

  
27
/**
28
 * Distort the Mesh by applying a 3D vector of force.
29
 */
28 30
public class VertexEffectDistort extends VertexEffect
29 31
  {
30 32
  private Data3D mVector, mCenter;
......
32 34

  
33 35
///////////////////////////////////////////////////////////////////////////////////////////////////
34 36
/**
35
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
36
 *
37
 * @param vector vector of force the Center of the Effect is currently being dragged with.
38
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
39
 * @param region Region that masks the Effect.
40
 */
41
  public VertexEffectDistort(Data3D vector, Data3D center, Data4D region)
42
    {
43
    super(EffectName.DISTORT);
44
    mVector = vector;
45
    mCenter = center;
46
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
/**
51
 * Distort the whole Object by a (possibly changing in time) vector of force.
37
 * Only for use by the library itself.
52 38
 *
53
 * @param vector vector of force the Center of the Effect is currently being dragged with.
54
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
39
 * @y.exclude
55 40
 */
56
  public VertexEffectDistort(Data3D vector, Data3D center)
57
    {
58
    super(EffectName.DISTORT);
59
    mVector = vector;
60
    mCenter = center;
61
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66 41
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
67 42
    {
68 43
    mCenter.get(uniforms,index+5,currentDuration,step);
......
75 50
    return ret;
76 51
    }
77 52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
// PUBLIC API
78 55
///////////////////////////////////////////////////////////////////////////////////////////////////
79 56
// Point (Px,Py) gets moved by vector (Wx,Wy,Wz) where Wx/Wy = Vx/Vy i.e. Wx=aVx and Wy=aVy where
80 57
// a=Py/Sy (N --> when (Px,Py) is above (Sx,Sy)) or a=Px/Sx (W) or a=(w-Px)/(w-Sx) (E) or a=(h-Py)/(h-Sy) (S)
......
127 104
//
128 105
// Thus we actually want to compute N(v.x,v.y) = a*(-(dx/|PS|)*f'(|PX|), -(dy/|PS|)*f'(|PX|), 1) and keep adding
129 106
// the first two components. (a is the horizontal part)
130

  
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108
/**
109
 * Have to call this before the shaders get compiled (i.e before Distorted.onCreate()) for the Effect to work.
110
 */
131 111
  public static void enable()
132 112
    {
133 113
    addEffect(EffectName.DISTORT,
......
152 132
      + "n.xy += n.z*b*ps;"
153 133
      );
154 134
    }
135

  
136
///////////////////////////////////////////////////////////////////////////////////////////////////
137
/**
138
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
139
 *
140
 * @param vector vector of force the Center of the Effect is currently being dragged with.
141
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
142
 * @param region Region that masks the Effect.
143
 */
144
  public VertexEffectDistort(Data3D vector, Data3D center, Data4D region)
145
    {
146
    super(EffectName.DISTORT);
147
    mVector = vector;
148
    mCenter = center;
149
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
150
    }
151

  
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153
/**
154
 * Distort the whole Object by a (possibly changing in time) vector of force.
155
 *
156
 * @param vector vector of force the Center of the Effect is currently being dragged with.
157
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
158
 */
159
  public VertexEffectDistort(Data3D vector, Data3D center)
160
    {
161
    super(EffectName.DISTORT);
162
    mVector = vector;
163
    mCenter = center;
164
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
165
    }
155 166
  }
156 167

  
157 168

  

Also available in: Unified diff