Project

General

Profile

« Previous | Next » 

Revision 8b7c0ab3

Added by Leszek Koltunski over 7 years ago

Improve the Dynamics app (multi-dimensional noise)

View differences:

src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java
43 43
    public static final int DIM_2D   = 1; 
44 44
    public static final int DIM_3DXY = 2; 
45 45
    public static final int DIM_3DXZ = 3; 
46
   
46

  
47 47
    private static final int NUM_INTERPOLATIONS= 100;
48 48
    private static final int MAX_VECTORS       =   6;
49
   
50
    private DynamicRenderer mRenderer;
49

  
50
    private static final Object lock = new Object();
51

  
51 52
    private static int xDown,yDown;
52 53
    private static int mScrW, mScrH;
53 54
   
......
57 58
    
58 59
    private static Paint mPaint;
59 60
    private static int moving;
60
    private static Object lock = new Object();
61 61
    private static long mTime = 0;
62 62
    private static int mDuration;
63 63
    private static float mPosition;
64
    private static float mNoise;
64
    private static float mNoise0, mNoise1, mNoise2;
65 65
    
66 66
    private static int currentDim = DIM_2D;
67 67
    
......
88 88
      moving    = -1;
89 89
      mDuration = 10000;
90 90
      mPosition = 0;
91
      mNoise    = 0.0f;
92
      
91
      mNoise0   = 0.0f;
92
      mNoise1   = 0.0f;
93
      mNoise2   = 0.0f;
94

  
93 95
      di1D = new Dynamic1D(mDuration,0.5f);
94
      p1N = new Static1D(mNoise);
96
      p1N = new Static1D(mNoise0);
95 97
      di1D.setNoise(p1N);
96 98
      
97 99
      di2D = new Dynamic2D(mDuration,0.5f);
98
      p2N = new Static2D(mNoise,mNoise);
100
      p2N = new Static2D(mNoise0,mNoise1);
99 101
      di2D.setNoise(p2N);
100 102
      
101 103
      di3D = new Dynamic3D(mDuration,0.5f);
102
      p3N = new Static3D(mNoise,mNoise,mNoise);
104
      p3N = new Static3D(mNoise0,mNoise1,mNoise2);
103 105
      di3D.setNoise(p3N);
104 106
        
105 107
      if(!isInEditMode())
......
114 116
          setEGLConfigChooser(8, 8, 8, 8, 16, 0);   
115 117
          }
116 118
        
117
        mRenderer = new DynamicRenderer(this);
119
        DynamicRenderer mRenderer = new DynamicRenderer(this);
118 120
        setRenderer(mRenderer);
119 121
        }
120 122
      }
......
149 151

  
150 152
///////////////////////////////////////////////////////////////////
151 153

  
152
    public static void setNoise(float noise)
154
    public static void setNoise(float noise0, float noise1, float noise2)
153 155
      {
154
      mNoise = noise;
156
      mNoise0 = noise0;
157
      mNoise1 = noise1;
158
      mNoise2 = noise2;
155 159

  
156
      p1N.set(mNoise);
157
      p2N.set(mNoise,mNoise);
158
      p3N.set(mNoise,mNoise,mNoise);
160
      p1N.set(mNoise0);
161
      p2N.set(mNoise0,mNoise1);
162
      p3N.set(mNoise0,mNoise1,mNoise2);
159 163

  
160 164
      di1D.setNoise(p1N);
161 165
      di2D.setNoise(p2N);

Also available in: Unified diff