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/FragmentEffectSaturation.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 FragmentEffectSaturation extends FragmentEffect
31 31
  {
32 32
  private Data1D mSaturation;
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 mSaturation.get(uniforms,index,currentDuration,step);
45 47
    }
46 48

  
......
51 53
 * Makes a certain sub-region of the Object smoothly change its saturation level.
52 54
 *
53 55
 * @param saturation level of saturation we want to have at any given moment. Valid range: <0,infinity)
54
 * @param region     Region this Effect is limited to.
56
 * @param center center of the Effect (point in 3D).
57
 * @param region Region this Effect is limited to (3 radii defining an ellipsoid).
55 58
 * @param smooth     If true, the level of 'saturation' will smoothly fade out towards the edges of the region.
56 59
 */
57
  public FragmentEffectSaturation(Data1D saturation, Data4D region, boolean smooth)
60
  public FragmentEffectSaturation(Data1D saturation, Data3D center, Data3D region, boolean smooth)
58 61
    {
59 62
    super(smooth?EffectName.SMOOTH_SATURATION:EffectName.SATURATION);
60 63

  
61 64
    mSaturation = saturation;
62
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
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
///////////////////////////////////////////////////////////////////////////////////////////////////
......
73 77
    super(EffectName.SATURATION);
74 78

  
75 79
    mSaturation = saturation;
76
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
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