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/Effect.java
20 20
package org.distorted.library.effect;
21 21

  
22 22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
23
/**
24
 * Abstract Effect of any type.
25
 */
24 26
public abstract class Effect
25 27
  {
26 28
  private final static int MAX_UNITY_DIM = 4;
......
47 49

  
48 50
///////////////////////////////////////////////////////////////////////////////////////////////////
49 51

  
50
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
52
  Effect(EffectName name)
53
    {
54
    mName      = name;
55
    mType      = name.getType();
56
    mDimension = name.getDimension();
57
    mSupportsC = name.supportsCenter();
58
    mSupportsR = name.supportsRegion();
51 59

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
60
    int n = name.ordinal();
61
    float[] u = name.getUnity();
62
    int l = name.getUnity().length;
53 63

  
64
    for(int i=0; i<l; i++)
65
      {
66
      mUnity[n*MAX_UNITY_DIM+i] = u[i];
67
      }
68

  
69
    mUnityDim[n] = l;
70

  
71
    mID = ((mNextID++)<<EffectType.LENGTH) + mType.ordinal();
72
    }
73

  
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
/**
76
 * Only for use by the library itself.
77
 *
78
 * @y.exclude
79
 */
54 80
  public static void onDestroy()
55 81
    {
56 82
    mNextID = 0;
......
59 85
    }
60 86

  
61 87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
/**
89
 * Only for use by the library itself.
90
 *
91
 * @y.exclude
92
 */
93
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
62 94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
// PUBLIC API
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98
/**
99
 * Do the set of Uniforms written in buffer[index], buffer[index+1], etc represent a Unity, i.e a
100
 * null Effect?
101
 */
63 102
  public boolean isUnity(float[] buffer, int index)
64 103
    {
65 104
    int name = mName.ordinal();
......
82 121
    return false;
83 122
    }
84 123
///////////////////////////////////////////////////////////////////////////////////////////////////
85

  
124
/**
125
 * Return the EffectType enum corresponding to this Effect.
126
 *
127
 * @see EffectType
128
 */
86 129
  public EffectType getType()
87 130
    {
88 131
    return mType;
89 132
    }
90 133

  
91 134
///////////////////////////////////////////////////////////////////////////////////////////////////
92

  
135
/**
136
 * Return the EffectName enum corresponding to this Effect.
137
 *
138
 * @see EffectName
139
 */
93 140
  public EffectName getName()
94 141
    {
95 142
    return mName;
96 143
    }
97 144

  
98 145
///////////////////////////////////////////////////////////////////////////////////////////////////
99

  
146
/**
147
 * Return the unique ID of this Effect.
148
 */
100 149
  public long getID()
101 150
    {
102 151
    return mID;
103 152
    }
104 153

  
105 154
///////////////////////////////////////////////////////////////////////////////////////////////////
106

  
155
/**
156
 * Return a printable name of this Effect.
157
 */
107 158
  public String getString()
108 159
    {
109 160
    return mName.name();
110 161
    }
111 162

  
112 163
///////////////////////////////////////////////////////////////////////////////////////////////////
113

  
164
/**
165
 * Does this effect have a Center?
166
 */
114 167
  public boolean supportsCenter()
115 168
    {
116 169
    return mSupportsC;
117 170
    }
118 171

  
119 172
///////////////////////////////////////////////////////////////////////////////////////////////////
120

  
173
/**
174
 * Does this effect support being masked by a Region?
175
 */
121 176
  public boolean supportsRegion()
122 177
    {
123 178
    return mSupportsR;
124 179
    }
125 180

  
126 181
///////////////////////////////////////////////////////////////////////////////////////////////////
127

  
182
/**
183
 * Return the number of Uniforms needed to describe this effect.
184
 */
128 185
  public int getDimension()
129 186
    {
130 187
    return mDimension;
131 188
    }
132

  
133
///////////////////////////////////////////////////////////////////////////////////////////////////
134

  
135
  Effect(EffectName name)
136
    {
137
    mName      = name;
138
    mType      = name.getType();
139
    mDimension = name.getDimension();
140
    mSupportsC = name.supportsCenter();
141
    mSupportsR = name.supportsRegion();
142

  
143
    int n = name.ordinal();
144
    float[] u = name.getUnity();
145
    int l = name.getUnity().length;
146

  
147
    for(int i=0; i<l; i++)
148
      {
149
      mUnity[n*MAX_UNITY_DIM+i] = u[i];
150
      }
151

  
152
    mUnityDim[n] = l;
153

  
154
    mID = ((mNextID++)<<EffectType.LENGTH) + mType.ordinal();
155
    }
156 189
  }

Also available in: Unified diff