Project

General

Profile

« Previous | Next » 

Revision 6bb59aad

Added by Leszek Koltunski almost 7 years ago

Progress with support for Effect classes.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectWave.java
33 33

  
34 34
public class VertexEffectWave extends VertexEffect
35 35
  {
36
  private static final String NAME = "WAVE";
36 37
  private static final float[] UNITIES = new float[] {0.0f};
37 38
  private static final int DIMENSION = 5;
38 39
  private static final boolean SUPPORTS_CENTER = true;
39 40
  private static final boolean SUPPORTS_REGION = true;
40 41

  
41 42
///////////////////////////////////////////////////////////////////////////////////////////////////
42

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

  
47 74
    if( wave instanceof Dynamic5D)
48 75
      {
......
57 84
      {
58 85
      mStaticCenter = (Static3D)center;
59 86
      }
60
    else if( center instanceof Dynamic3D)
87
    else if( center instanceof Dynamic3D )
61 88
      {
62 89
      mDynamicCenter = (Dynamic3D)center;
63 90
      }
64 91

  
65
    if( region instanceof Static4D)
66
      {
67
      mStaticRegion = (Static4D)region;
68
      }
69
    else if( region instanceof Dynamic4D)
70
      {
71
      mDynamicRegion = (Dynamic4D)region;
72
      }
92
    mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
73 93
    }
74 94

  
75 95
///////////////////////////////////////////////////////////////////////////////////////////////////
76

  
77
  public VertexEffectWave(Data5D wave, Data3D center)
96
/**
97
 * Directional, sinusoidal wave effect.
98
 *
99
 * @param wave   see {@link VertexEffectWave(Data5D,Data3D)}
100
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
101
 * @param region Region that masks the Effect.
102
 */
103
  public VertexEffectWave(Data5D wave, Data3D center, Data4D region)
78 104
    {
79
    super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION);
105
    super(WAVE,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
80 106

  
81 107
    if( wave instanceof Dynamic5D)
82 108
      {
......
91 117
      {
92 118
      mStaticCenter = (Static3D)center;
93 119
      }
94
    else if( center instanceof Dynamic3D )
120
    else if( center instanceof Dynamic3D)
95 121
      {
96 122
      mDynamicCenter = (Dynamic3D)center;
97 123
      }
98 124

  
99
    mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
125
    if( region instanceof Static4D)
126
      {
127
      mStaticRegion = (Static4D)region;
128
      }
129
    else if( region instanceof Dynamic4D)
130
      {
131
      mDynamicRegion = (Dynamic4D)region;
132
      }
100 133
    }
101 134

  
102 135
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff