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

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

  
28
/**
29
 * Pull all points around the center of the Effect towards a line passing through the center
30
 * (that's if degree>=1) or push them away from the line (degree<=1).
31
 */
29 32
public class VertexEffectPinch extends VertexEffect
30 33
  {
31 34
  private Data2D mPinch;
......
34 37

  
35 38
///////////////////////////////////////////////////////////////////////////////////////////////////
36 39
/**
37
 * Pull all points around the center of the Effect towards a line passing through the center
38
 * (that's if degree>=1) or push them away from the line (degree<=1)
40
 * Only for use by the library itself.
39 41
 *
40
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
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.
42
 * @y.exclude
43 43
 */
44
  public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
45
    {
46
    super(EffectName.PINCH);
47
    mPinch  = pinch;
48
    mCenter = center;
49
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
/**
54
 * Pull all points around the center of the Effect towards a line passing through the center
55
 * (that's if degree>=1) or push them away from the line (degree<=1)
56
 *
57
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
58
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
59
 */
60
  public VertexEffectPinch(Data2D pinch, Data3D center)
61
    {
62
    super(EffectName.PINCH);
63
    mPinch  = pinch;
64
    mCenter = center;
65
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
66
    }
67

  
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

  
70 44
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
71 45
    {
72 46
    mCenter.get(uniforms,index+5,currentDuration,step);
......
79 53
    return ret;
80 54
    }
81 55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
// PUBLIC API
82 58
///////////////////////////////////////////////////////////////////////////////////////////////////
83 59
// Pull P=(v.x,v.y) towards the line that
84 60
// a) passes through the center of the effect
85 61
// b) forms angle defined in the 2nd interpolated value with the X-axis
86 62
// with P' = P + (1-h)*dist(line to P)
87 63
// when h>1 we are pushing points away from S: P' = P + (1/h-1)*dist(line to P)
88

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
/**
66
 * Have to call this before the shaders get compiled (i.e before Distorted.onCreate()) for the Effect to work.
67
 */
89 68
  public static void enable()
90 69
    {
91 70
    addEffect(EffectName.PINCH,
......
99 78
      + "v.xy += t*dot(ps,dir)*dir;"
100 79
      );
101 80
    }
81

  
82
///////////////////////////////////////////////////////////////////////////////////////////////////
83
/**
84
 * Pull all points around the center of the Effect towards a line passing through the center
85
 * (that's if degree>=1) or push them away from the line (degree<=1)
86
 *
87
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
88
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
89
 * @param region Region that masks the Effect.
90
 */
91
  public VertexEffectPinch(Data2D pinch, Data3D center, Data4D region)
92
    {
93
    super(EffectName.PINCH);
94
    mPinch  = pinch;
95
    mCenter = center;
96
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
97
    }
98

  
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
/**
101
 * Pull all points around the center of the Effect towards a line passing through the center
102
 * (that's if degree>=1) or push them away from the line (degree<=1)
103
 *
104
 * @param pinch  The current degree of the Effect + angle the line forms with X-axis
105
 * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
106
 */
107
  public VertexEffectPinch(Data2D pinch, Data3D center)
108
    {
109
    super(EffectName.PINCH);
110
    mPinch  = pinch;
111
    mCenter = center;
112
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
113
    }
102 114
  }

Also available in: Unified diff