Project

General

Profile

« Previous | Next » 

Revision 318dd77b

Added by Leszek Koltunski over 5 years ago

Some improvements to the Wind app - still does not look very realistic though :(

View differences:

src/main/java/org/distorted/examples/wind/WindRenderer.java
51 51
   private DistortedTexture mTexture;
52 52
   private DistortedScreen mScreen;
53 53
   private WindEffectsManager mManager;
54
   private WindGust mGust;
54 55
   private Static3D mMove, mScale;
55 56
   private int mObjWidth, mObjHeight;
56
   private int mWind;
57 57

  
58 58
///////////////////////////////////////////////////////////////////////////////////////////////////
59 59

  
......
63 63

  
64 64
      mTexture = new DistortedTexture(50,30);
65 65
      mManager = new WindEffectsManager(mTexture);
66
      mGust    = new WindGust();
66 67
      mScreen  = new DistortedScreen();
67 68

  
68 69
      DistortedEffects effects = new DistortedEffects();
......
82 83
      Static3D center= new Static3D(0,mObjHeight/2,0);
83 84

  
84 85
      effects.apply( new MatrixEffectRotate(angle, axis, center) );
85
      mManager.apply(effects,mWind);
86
      mManager.apply(effects);
86 87
      }
87 88

  
88 89
///////////////////////////////////////////////////////////////////////////////////////////////////
89 90

  
90 91
   void setWind(int wind)
91 92
      {
92
      mWind = wind;
93
      mManager.setWind(mWind);
93
      mGust.setAverageWind(wind);
94 94
      }
95 95
   
96 96
///////////////////////////////////////////////////////////////////////////////////////////////////
97 97
   
98 98
   public void onDrawFrame(GL10 glUnused) 
99 99
      {
100
      mScreen.render( System.currentTimeMillis() );
100
      long time = System.currentTimeMillis();
101

  
102
      if( mGust.isWindBlowingNow(time) ) mManager.increaseWind(time);
103
      else                               mManager.decreaseWind(time);
104

  
105
      mScreen.render(time);
101 106
      }
102 107

  
103 108
///////////////////////////////////////////////////////////////////////////////////////////////////
104 109
    
105 110
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
106 111
      {
107
      float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth);
108
      mMove.set( factor*mObjHeight*0.58f , height - factor*mObjHeight*1.08f , 0 );
112
      int min = width<height? width:height;
113

  
114
      float factor = ((float)min)/(mObjHeight + 1.4f*mObjWidth);
115
      mMove.set( factor*mObjHeight*0.58f +(width-min)/2, height - factor*mObjHeight*1.08f -(height-min)/2, 0 );
109 116
      mScale.set(factor,factor,factor);
110 117
      mScreen.resize(width, height);
111 118
      }

Also available in: Unified diff