Project

General

Profile

« Previous | Next » 

Revision e50e7ba7

Added by Leszek Koltunski almost 4 years ago

1) rename DistortedTexture's setColor to setColorARGB
2) fix the Wiind app to take into account paused time
3) fix the Dynamic so that if a single Dynamic is used more than once (in more than one effect) than it doesn't get adjusted for paused time multiple times.

View differences:

src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java
85 85
      Static3D center     = new Static3D(0,0,0);
86 86
      Static3D axis       = new Static3D(0,0,1);
87 87

  
88
      Dynamic1D rot = new Dynamic1D(5000,0.0f);
88
      Dynamic1D rot = new Dynamic1D(50000,0.0f);
89 89
      rot.setMode(Dynamic1D.MODE_JUMP);
90 90
      rot.add(new Static1D(  0));
91 91
      rot.add(new Static1D(360));
src/main/java/org/distorted/examples/stencil/StencilRenderer.java
222 222
        }
223 223

  
224 224
      mCubeTex.setTexture(bitmap);
225
      mFloorTex.setColor(0xff000000);  // ARGB
225
      mFloorTex.setColorARGB(0xff000000);
226 226

  
227 227
      VertexEffectScale.enable();
228 228
      FragmentEffectBrightness.enable();
src/main/java/org/distorted/examples/transparency/TransparencyRenderer.java
209 209
      {
210 210
      for(int i=0; i<NUM_OBJECTS; i++)
211 211
        {
212
        mTex[i].setColor(OBJECTS[NUM * i + 3]);
212
        mTex[i].setColorARGB(OBJECTS[NUM * i + 3]);
213 213
        }
214 214

  
215 215
      VertexEffectScale.enable();
src/main/java/org/distorted/examples/wind/WindActivity.java
56 56
    @Override
57 57
    protected void onPause() 
58 58
      {
59
      GLSurfaceView view = findViewById(R.id.windSurfaceView);
59
      WindSurfaceView view = findViewById(R.id.windSurfaceView);
60 60
      view.onPause();
61
      view.getRenderer().pauseWind();
61 62
      DistortedLibrary.onPause();
62 63
      super.onPause();
63 64
      }
......
68 69
    protected void onResume() 
69 70
      {
70 71
      super.onResume();
71
      GLSurfaceView view = findViewById(R.id.windSurfaceView);
72
      WindSurfaceView view = findViewById(R.id.windSurfaceView);
72 73
      view.onResume();
74
      view.getRenderer().resumeWind();
73 75
      }
74 76
 
75 77
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/wind/WindEffectsManager.java
39 39
                                                     // make the flag horizontal (milliseconds)
40 40
  private static final long TIME_TO_FALL_DOWN =2000; // time it takes for the flag to
41 41
                                                     // fall back down if no wind (milliseconds)
42
  private long lastTime;
42
  private long mLastTime, mPausedTime;
43 43
  private float mWind;
44 44
  private int mHeight, mWidth;
45 45

  
......
59 59

  
60 60
  WindEffectsManager(int width, int height)
61 61
    {
62
    lastTime = 0;
62
    mLastTime = 0;
63 63

  
64 64
    mWidth = width;
65 65
    mHeight= height;
......
149 149
    windFactor42.set0(wave4);
150 150
    }
151 151

  
152
///////////////////////////////////////////////////////////////////////////////////////////////////
153

  
154
  void pauseWind()
155
    {
156
    mPausedTime = System.currentTimeMillis();
157
    }
158

  
159
///////////////////////////////////////////////////////////////////////////////////////////////////
160

  
161
  void resumeWind()
162
    {
163
    long gap = System.currentTimeMillis() - mPausedTime;
164
    mLastTime += gap;
165
    }
166

  
152 167
///////////////////////////////////////////////////////////////////////////////////////////////////
153 168

  
154 169
  synchronized void increaseWind(long currTime)
155 170
    {
156
    if( lastTime>0 )
171
    if( mLastTime>0 )
157 172
      {
158
      long diff = currTime-lastTime;
173
      long diff = currTime-mLastTime;
159 174
      float diffWind = (100.0f*diff/TIME_TO_GET_UP);
160 175

  
161 176
      mWind += diffWind;
......
164 179
      setWind( (int)mWind );
165 180
      }
166 181

  
167
    lastTime = currTime;
182
    mLastTime = currTime;
168 183
    }
169 184

  
170 185
///////////////////////////////////////////////////////////////////////////////////////////////////
171 186

  
172 187
  synchronized void decreaseWind(long currTime)
173 188
    {
174
    if( lastTime>0 )
189
    if( mLastTime>0 )
175 190
      {
176
      long diff = currTime-lastTime;
191
      long diff = currTime-mLastTime;
177 192
      float diffWind = (100.0f*diff/TIME_TO_FALL_DOWN);
178 193

  
179 194
      mWind -= diffWind;
......
182 197
      setWind( (int)mWind );
183 198
      }
184 199

  
185
    lastTime = currTime;
200
    mLastTime = currTime;
186 201
    }
187 202

  
188 203
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/wind/WindGust.java
28 28
  private static final long TIME_PERIOD = 1000;
29 29
  private int mAvgWind;
30 30
  private boolean mBlowingNow;
31
  private long mLastTime;
31
  private long mLastTime, mPausedTime;
32 32
  private static Random mRnd = new Random();
33 33

  
34 34
  WindGust()
......
45 45
    mAvgWind = wind;
46 46
    }
47 47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  void pauseWind()
51
    {
52
    mPausedTime = System.currentTimeMillis();
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  void resumeWind()
58
    {
59
    long gap = System.currentTimeMillis() - mPausedTime;
60
    mLastTime += gap;
61
    }
62

  
48 63
///////////////////////////////////////////////////////////////////////////////////////////////////
49 64

  
50 65
  boolean isWindBlowingNow(long currTime)
src/main/java/org/distorted/examples/wind/WindRenderer.java
102 102
      }
103 103
   
104 104
///////////////////////////////////////////////////////////////////////////////////////////////////
105
   
105

  
106
   void pauseWind()
107
      {
108
      if( mGust   !=null ) mGust.pauseWind();
109
      if( mManager!=null ) mManager.pauseWind();
110
      }
111

  
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113

  
114
   void resumeWind()
115
      {
116
      if( mGust   !=null ) mGust.resumeWind();
117
      if( mManager!=null ) mManager.resumeWind();
118
      }
119

  
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

  
106 122
   public void onDrawFrame(GL10 glUnused) 
107 123
      {
108 124
      long time = System.currentTimeMillis();

Also available in: Unified diff