Project

General

Profile

« Previous | Next » 

Revision d0c902b8

Added by Leszek Koltunski almost 10 years ago

swap the 2nd and the 3rd parameters in the WAVE effect and improve comments for the WAVE user API.

View differences:

src/main/java/org/distorted/library/DistortedObject.java
816 816
/**
817 817
 * Directional, sinusoidal wave effect.
818 818
 *
819
 * @param wave   A 3-dimensional data structure describing the wave: first member is the amplitude,
820
 *               second is the angle (in degrees, as always) the direction of the wave forms with
821
 *               the X-axis, and the third is the wave length.
819
 * @param wave   A 4-dimensional data structure describing the wave: first member is the amplitude,
820
 *               second is the wave length, and the next two describe the 'direction' of the wave.
821
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
822
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
823
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
824
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
825
 *
826
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
827
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
828
 *               will be sine shapes.
829
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
830
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
831
 *               YZ-plane with be sine shapes.
832
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
833
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V.
822 834
 * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
823 835
 * @return       ID of the effect added, or -1 if we failed to add one.
824 836
 */
......
831 843
/**
832 844
 * Directional, sinusoidal wave effect.
833 845
 *
834
 * @param wave   A 3-dimensional data structure describing the wave: first member is the amplitude,
835
 *               second is the angle (in degrees, as always) the direction of the wave forms with
836
 *               the X-axis, and the third is the wave length.
846
 * @param wave   A 4-dimensional data structure describing the wave: first member is the amplitude,
847
 *               second is the wave length, and the next two describe the 'direction' of the wave.
848
 *               Wave direction is defined to be a 3D vector of length 1. To define such vectors, we
849
 *               need 2 floats: thus the third member is the angle Alpha (in degrees) which the vector
850
 *               forms with the XY-plane, and the fourth is the angle Beta (again in degrees) which
851
 *               the projection of the vector to the XY-plane forms with the Y-axis (counterclockwise).
852
 *
853
 *               Example1: if Alpha = 90, Beta = 90, (then V=(0,0,1) ) and the wave acts 'vertically'
854
 *               in the X-direction, i.e. cross-sections of the resulting surface with the XZ-plane
855
 *               will be sine shapes.
856
 *               Example2: if Alpha = 90, Beta = 0, the again V=(0,0,1) and the wave is 'vertical',
857
 *               but this time it waves in the Y-direction, i.e. cross sections of the surface and the
858
 *               YZ-plane with be sine shapes.
859
 *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
860
 *               is entirely 'horizontal' and moves point (x,y,0) in direction V.
837 861
 * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
838 862
 * @param region Region that masks the Effect.
839 863
 * @return       ID of the effect added, or -1 if we failed to add one.
src/main/java/org/distorted/library/EffectQueueVertex.java
169 169
      }
170 170
    if( mName[effect]==EffectNames.WAVE.ordinal() )
171 171
      {
172
      mUniforms[NUM_UNIFORMS*effect+1] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180);
172
      mUniforms[NUM_UNIFORMS*effect+2] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+2]/180);
173 173
      mUniforms[NUM_UNIFORMS*effect+3] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+3]/180);
174 174
      }
175 175
    if( mName[effect]==EffectNames.DISTORT.ordinal() )
src/main/res/raw/main_vertex_shader.glsl
418 418
  {
419 419
  vec2 center     = vUniforms[effect+1].zw;
420 420
  float amplitude = vUniforms[effect  ].x;
421
  float length    = vUniforms[effect  ].z;
421
  float length    = vUniforms[effect  ].y;
422 422

  
423 423
  vec2 ps = center - v.xy;
424 424
  float deg = amplitude*degree_region(vUniforms[effect+2],ps);
425 425

  
426 426
  if( deg != 0.0 && length != 0.0 )
427 427
    {
428
    float alpha = vUniforms[effect].y;
428
    float alpha = vUniforms[effect].z;
429 429
    float beta  = vUniforms[effect].w;
430 430

  
431 431
    float sinA = sin(alpha);

Also available in: Unified diff