Project

General

Profile

« Previous | Next » 

Revision a9716c0f

Added by Leszek Koltunski almost 7 years ago

Further progress with Apps: 27 (out of 31) compile now.

View differences:

src/main/java/org/distorted/examples/wind/WindEffectsManager.java
21 21

  
22 22
///////////////////////////////////////////////////////////////////////////////////////////////////
23 23

  
24
import org.distorted.library.effect.MatrixEffectScale;
25
import org.distorted.library.effect.MatrixEffectShear;
26
import org.distorted.library.effect.VertexEffectDeform;
27
import org.distorted.library.effect.VertexEffectWave;
24 28
import org.distorted.library.main.DistortedEffects;
25 29
import org.distorted.library.main.DistortedTexture;
26 30
import org.distorted.library.type.Dynamic;
27
import org.distorted.library.type.Dynamic3D;
28 31
import org.distorted.library.type.Dynamic5D;
29 32
import org.distorted.library.type.Static3D;
30 33
import org.distorted.library.type.Static4D;
......
35 38
  private int mHeight, mWidth;
36 39

  
37 40
  private Static3D  shearFactor;
38
  private Dynamic3D shearDynamic;
39 41
  private Static3D  scaleFactor;
40
  private Dynamic3D scaleDynamic;
41 42
  private Static3D  deformForce;
42 43
  private Static5D  windFactor11, windFactor12;
43 44
  private Dynamic5D windDynamic1;
......
54 55
    mWidth  = texture.getWidth();
55 56

  
56 57
    shearFactor = new Static3D(0,0,0);
57
    shearDynamic= new Dynamic3D();
58
    shearDynamic.add(shearFactor);
59

  
60 58
    scaleFactor = new Static3D(1,1,1);
61
    scaleDynamic= new Dynamic3D();
62
    scaleDynamic.add(scaleFactor);
63

  
64 59
    deformForce = new Static3D(mWidth/3,0,0);
65 60

  
66 61
    windFactor11 = new Static5D(mHeight/10,mHeight/5, 180, 0, 90);
......
90 85

  
91 86
///////////////////////////////////////////////////////////////////////////////////////////////////
92 87

  
93
  synchronized void apply(DistortedEffects effects, int wind)
88
  void apply(DistortedEffects effects, int wind)
94 89
    {
95 90
    Static3D midLeft = new Static3D(0,mHeight/2,0);
96 91
    Static3D midRight = new Static3D(mWidth,mHeight/2,0);
......
98 93

  
99 94
    setWind(wind);
100 95

  
101
    effects.shear(shearDynamic,midLeft);
102
    effects.scale(scaleDynamic);
103
    effects.deform(deformForce,midRight);
104
    effects.wave(windDynamic1, midRight, windRegion);
105
    effects.wave(windDynamic2, midRight, windRegion);
106
    effects.wave(windDynamic3, midRight, windRegion);
96
    effects.apply( new MatrixEffectShear(shearFactor,midLeft) );
97
    effects.apply( new MatrixEffectScale(scaleFactor) );
98
    effects.apply( new VertexEffectDeform(deformForce,midRight) );
99
    effects.apply( new VertexEffectWave(windDynamic1, midRight, windRegion) );
100
    effects.apply( new VertexEffectWave(windDynamic2, midRight, windRegion) );
101
    effects.apply( new VertexEffectWave(windDynamic3, midRight, windRegion) );
107 102
    }
108 103

  
109 104
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/wind/WindRenderer.java
24 24
import android.opengl.GLSurfaceView;
25 25

  
26 26
import org.distorted.examples.R;
27
import org.distorted.library.effect.EffectName;
28
import org.distorted.library.effect.MatrixEffectMove;
29
import org.distorted.library.effect.MatrixEffectRotate;
30
import org.distorted.library.effect.MatrixEffectScale;
27 31
import org.distorted.library.main.Distorted;
28 32
import org.distorted.library.main.DistortedScreen;
29
import org.distorted.library.EffectNames;
30 33
import org.distorted.library.main.MeshCubes;
31 34
import org.distorted.library.main.DistortedEffects;
32 35
import org.distorted.library.main.DistortedTexture;
......
48 51
   private DistortedTexture mTexture;
49 52
   private DistortedScreen mScreen;
50 53
   private WindEffectsManager mManager;
54
   private Static3D mMove, mScale;
51 55
   private int mObjWidth, mObjHeight;
52 56
   private int mWind;
53 57

  
......
66 70

  
67 71
      mObjWidth = mTexture.getWidth();
68 72
      mObjHeight= mTexture.getHeight();
73

  
74
      mMove = new Static3D(0,0,0);
75
      mScale= new Static3D(1,1,1);
76
      mEffects.apply( new MatrixEffectMove(mMove));
77
      mEffects.apply( new MatrixEffectScale(mScale));
78

  
79
      Static1D angle = new Static1D(-45);
80
      Static3D axis  = new Static3D(0,0,1);
81
      Static3D center= new Static3D(0,mObjHeight/2,0);
82

  
83
      mEffects.apply( new MatrixEffectRotate(angle, axis, center) );
84
      mManager.apply(mEffects,mWind);
69 85
      }
70 86

  
71 87
///////////////////////////////////////////////////////////////////////////////////////////////////
......
87 103
    
88 104
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
89 105
      {
90
      mEffects.abortAllEffects();
91

  
92 106
      float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth);
93

  
94
      mEffects.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
95
      mEffects.scale(factor);
96

  
97
      Static1D angle = new Static1D(-45);
98
      Static3D axis  = new Static3D(0,0,1);
99
      Static3D center= new Static3D(0,mObjHeight/2,0);
100

  
101
      mEffects.rotate(angle, axis, center);
102
      mManager.apply(mEffects,mWind);
107
      mMove.set( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0 );
108
      mScale.set(factor,factor,factor);
103 109
      mScreen.resize(width, height);
104 110
      }
105 111

  
......
125 131

  
126 132
      mTexture.setTexture(bitmap);
127 133

  
128
      DistortedEffects.enableEffect(EffectNames.DEFORM);
129
      DistortedEffects.enableEffect(EffectNames.WAVE);
134
      DistortedEffects.enableEffect(EffectName.DEFORM);
135
      DistortedEffects.enableEffect(EffectName.WAVE);
130 136

  
131 137
      try
132 138
        {

Also available in: Unified diff