Project

General

Profile

« Previous | Next » 

Revision b24e4719

Added by Leszek Koltunski over 5 years ago

Make the Fragment effects truly 3D: change their 4D 'region' into a 3D 'center' (a point in 3D) and 3D 'region' (which is now a set of 3 radii defining an ellipsoid around the center)

Also corresponding changes to the applications.

View differences:

src/main/java/org/distorted/library/effect/FragmentEffectAlpha.java
20 20
package org.distorted.library.effect;
21 21

  
22 22
import org.distorted.library.type.Data1D;
23
import org.distorted.library.type.Data4D;
24
import org.distorted.library.type.Static4D;
23
import org.distorted.library.type.Data3D;
24
import org.distorted.library.type.Static3D;
25 25

  
26 26
///////////////////////////////////////////////////////////////////////////////////////////////////
27 27
/**
......
30 30
public class FragmentEffectAlpha extends FragmentEffect
31 31
  {
32 32
  private Data1D mAlpha;
33
  private Data4D mRegion;
33
  private Data3D mCenter;
34
  private Data3D mRegion;
34 35

  
35 36
///////////////////////////////////////////////////////////////////////////////////////////////////
36 37
/**
......
40 41
 */
41 42
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
42 43
    {
43
    mRegion.get(uniforms, index+4, currentDuration, step);
44
    mCenter.get(uniforms, index+CENTER_OFFSET, currentDuration, step);
45
    mRegion.get(uniforms, index+REGION_OFFSET, currentDuration, step);
44 46
    return mAlpha.get(uniforms,index, currentDuration, step);
45 47
    }
46 48

  
......
52 54
 *
53 55
 * @param alpha  level of transparency we want to have at any given moment: pixel.a *= alpha.
54 56
 *               Valid range: <0,1>
55
 * @param region Region this Effect is limited to.
57
 * @param center center of the Effect (point in 3D).
58
 * @param region Region this Effect is limited to (3 radii defining an ellipsoid).
56 59
 * @param smooth If true, the level of 'alpha' will smoothly fade out towards the edges of the region.
57 60
 */
58
  public FragmentEffectAlpha(Data1D alpha, Data4D region, boolean smooth)
61
  public FragmentEffectAlpha(Data1D alpha, Data3D center, Data3D region, boolean smooth)
59 62
    {
60 63
    super(smooth? EffectName.SMOOTH_ALPHA:EffectName.ALPHA);
61
    mAlpha = alpha;
62
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
64
    mAlpha  = alpha;
65
    mCenter = center;
66
    mRegion = (region==null ? new Static3D(Float.MAX_VALUE,Float.MAX_VALUE, Float.MAX_VALUE) : region);
63 67
    }
64 68

  
65 69
///////////////////////////////////////////////////////////////////////////////////////////////////
......
72 76
  public FragmentEffectAlpha(Data1D alpha)
73 77
    {
74 78
    super(EffectName.ALPHA);
75
    mAlpha = alpha;
76
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
79
    mAlpha  = alpha;
80
    mCenter = new Static3D(0,0,0);
81
    mRegion = new Static3D(Float.MAX_VALUE,Float.MAX_VALUE, Float.MAX_VALUE);
77 82
    }
78 83

  
79 84
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff