Project

General

Profile

« Previous | Next » 

Revision 8dfa45c4

Added by Leszek Koltunski almost 7 years ago

Some progress with Effect classes.

10 apps compile now.

View differences:

src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
27 27

  
28 28
import org.distorted.examples.R;
29 29

  
30
import org.distorted.library.effect.EffectName;
31
import org.distorted.library.effect.FragmentEffectChroma;
32
import org.distorted.library.effect.MatrixEffectMove;
33
import org.distorted.library.effect.MatrixEffectScale;
34
import org.distorted.library.effect.VertexEffectDistort;
35
import org.distorted.library.effect.VertexEffectSink;
30 36
import org.distorted.library.main.Distorted;
31 37
import org.distorted.library.main.DistortedEffects;
32 38
import org.distorted.library.main.DistortedScreen;
33
import org.distorted.library.EffectNames;
34 39
import org.distorted.library.main.MeshFlat;
35 40
import org.distorted.library.main.DistortedTexture;
36
import org.distorted.library.EffectTypes;
37 41
import org.distorted.library.type.Dynamic1D;
38 42
import org.distorted.library.type.Dynamic3D;
39 43
import org.distorted.library.type.Static1D;
......
56 60
   private MeshFlat mMesh;
57 61
   private DistortedScreen mScreen;
58 62
   private int bmpHeight, bmpWidth;
59
    
63
   private Static3D mScale;
64
   private Static3D[] mMove;
65

  
60 66
///////////////////////////////////////////////////////////////////////////////////////////////////
61 67

  
62 68
   DifferentEffectsRenderer(GLSurfaceView v)
......
84 90
      sink.add(new Static1D( 1));
85 91
      sink.add(new Static1D(10));
86 92

  
87
      mEffects[0].sink(sink, pLeft, RegionEye);
88
      mEffects[0].sink(sink, pRight,RegionEye);
89
      mEffects[1].distort(dyn, pNose1);
93
      VertexEffectSink sinkL = new VertexEffectSink(sink, pLeft , RegionEye);
94
      VertexEffectSink sinkR = new VertexEffectSink(sink, pRight, RegionEye);
95
      VertexEffectDistort distort = new VertexEffectDistort(dyn,pNose1);
96

  
97
      mEffects[0].apply(sinkL);
98
      mEffects[0].apply(sinkR);
99
      mEffects[1].apply(distort);
90 100

  
91 101
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
92 102
      chromaDyn.add(new Static1D(0));
93 103
      chromaDyn.add(new Static1D(1));
94 104

  
95
      mEffects[2].chroma(chromaDyn, new Static3D(0,1,0) );
105
      FragmentEffectChroma chroma = new FragmentEffectChroma(chromaDyn, new Static3D(0,1,0));
106
      mEffects[2].apply(chroma);
107

  
108
      mScale = new Static3D(1,1,1);
109
      MatrixEffectScale scaleEffect = new MatrixEffectScale(mScale);
110
      mMove  = new Static3D[NUM];
111
      MatrixEffectMove[] moveEffect = new MatrixEffectMove[NUM];
112

  
113
      for(int i=0; i<NUM; i++)
114
        {
115
        mMove[i] = new Static3D(0,0,0);
116
        moveEffect[i] = new MatrixEffectMove(mMove[i]);
117
        mEffects[i].apply(moveEffect[i]);
118
        mEffects[i].apply(scaleEffect);
119
        }
96 120

  
97 121
      mScreen = new DistortedScreen(mView);
98 122
      }
......
108 132
    
109 133
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
110 134
     {
111
     for(int i=NUM-1; i>=0; i--)
112
       {
113
       mEffects[i].abortEffects(EffectTypes.MATRIX);
114
       }
115
      
116 135
     if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
117 136
       {
118 137
       int w = (height*bmpWidth)/bmpHeight;
119 138
       float factor = (float)height/bmpHeight;
139
       mScale.set(factor,factor,factor);
120 140

  
121 141
       for(int i=NUM-1; i>=0; i--)
122 142
         {
123
         mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
124
         mEffects[i].scale(factor);
143
         mMove[i].set((width-NUM*w)/2 +i*w , 0, 0);
125 144
         }
145

  
126 146
       }
127 147
     else
128 148
       {
129 149
       int w = width/NUM;
130 150
       int h = (width*bmpHeight)/(bmpWidth*NUM);
131 151
       float factor = (float)width/(bmpWidth*NUM);
152
       mScale.set(factor,factor,factor);
132 153

  
133 154
       for(int i=NUM-1; i>=0; i--)
134 155
         {
135
         mEffects[i].move( new Static3D(i*w, (height-h)/2, 0) );
136
         mEffects[i].scale(factor);
156
         mMove[i].set(i*w, (height-h)/2, 0);
137 157
         }
138 158
       }
139 159
       
......
170 190
     mScreen.detachAll();
171 191
     for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture, mEffects[i], mMesh);
172 192

  
173
     DistortedEffects.enableEffect(EffectNames.SINK);
174
     DistortedEffects.enableEffect(EffectNames.DISTORT);
175
     DistortedEffects.enableEffect(EffectNames.CHROMA);
193
     DistortedEffects.enableEffect(EffectName.SINK);
194
     DistortedEffects.enableEffect(EffectName.DISTORT);
195
     DistortedEffects.enableEffect(EffectName.CHROMA);
176 196

  
177 197
     try
178 198
       {

Also available in: Unified diff