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/VertexEffectWave.java
25 25
import org.distorted.library.type.Static4D;
26 26

  
27 27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
28
/**
29
 * Directional, sinusoidal wave effect.
30
 */
29 31
public class VertexEffectWave extends VertexEffect
30 32
  {
31 33
  private Data5D mWave;
......
34 36

  
35 37
///////////////////////////////////////////////////////////////////////////////////////////////////
36 38
/**
37
 * Directional, sinusoidal wave effect.
38
 *
39
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
40
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
41
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
42
 *               describe the 'direction' of the wave.
43
 *               <p>
44
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
45
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
46
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
47
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
48
 *               <p>
49
 *               <p>
50
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
51
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
52
 *               will be sine shapes.
53
 *               <p>
54
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
55
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
56
 *               YZ-plane with be sine shapes.
57
 *               <p>
58
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
59
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
60
 *               value if sin at this point.
61
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
62
 * @param region Region that masks the Effect.
63
 */
64
  public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
65
    {
66
    super(EffectName.WAVE);
67
    mWave   = wave;
68
    mCenter = center;
69
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
70
    }
71

  
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
/**
74
 * Directional, sinusoidal wave effect.
39
 * Only for use by the library itself.
75 40
 *
76
 * @param wave   see {@link VertexEffectWave(Data5D,Data3D)}
77
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
41
 * @y.exclude
78 42
 */
79
  public VertexEffectWave(Data5D wave, Data3D center)
80
    {
81
    super(EffectName.WAVE);
82
    mWave   = wave;
83
    mCenter = center;
84
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
85
    }
86

  
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

  
89 43
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
90 44
    {
91 45
    mCenter.get(uniforms,index+5,currentDuration,step);
......
100 54
    return ret;
101 55
    }
102 56

  
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
// PUBLIC API
103 59
///////////////////////////////////////////////////////////////////////////////////////////////////
104 60
// Directional sinusoidal wave effect.
105 61
//
......
163 119
// points very dark)
164 120
//
165 121
// Generally speaking I'd keep to amplitude < length, as the opposite case has some other problems as well.
166

  
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
/**
124
 * Have to call this before the shaders get compiled (i.e before Distorted.onCreate()) for the Effect to work.
125
 */
167 126
  public static void enable()
168 127
    {
169 128
    addEffect(EffectName.WAVE,
......
226 185
      +   "}"
227 186
      );
228 187
    }
188

  
189
///////////////////////////////////////////////////////////////////////////////////////////////////
190
/**
191
 * Directional, sinusoidal wave effect.
192
 *
193
 * @param wave   A 5-dimensional data structure describing the wave: first member is the amplitude,
194
 *               second is the wave length, third is the phase (i.e. when phase = PI/2, the sine
195
 *               wave at the center does not start from sin(0), but from sin(PI/2) ) and the next two
196
 *               describe the 'direction' of the wave.
197
 *               <p>
198
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
199
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
200
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
201
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
202
 *               <p>
203
 *               <p>
204
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
205
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
206
 *               will be sine shapes.
207
 *               <p>
208
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
209
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
210
 *               YZ-plane with be sine shapes.
211
 *               <p>
212
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
213
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
214
 *               value if sin at this point.
215
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
216
 * @param region Region that masks the Effect.
217
 */
218
  public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
219
    {
220
    super(EffectName.WAVE);
221
    mWave   = wave;
222
    mCenter = center;
223
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
224
    }
225

  
226
///////////////////////////////////////////////////////////////////////////////////////////////////
227
/**
228
 * Directional, sinusoidal wave effect.
229
 *
230
 * @param wave   see {@link VertexEffectWave(Data5D,Data3D)}
231
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
232
 */
233
  public VertexEffectWave(Data5D wave, Data3D center)
234
    {
235
    super(EffectName.WAVE);
236
    mWave   = wave;
237
    mCenter = center;
238
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
239
    }
229 240
  }

Also available in: Unified diff