Project

General

Profile

« Previous | Next » 

Revision 40eef4b9

Added by Leszek Koltunski over 7 years ago

Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.

Still does not compile, but pushing already.

View differences:

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

  
30 30
import org.distorted.library.Distorted;
31 31
import org.distorted.library.GridFlat;
32
import org.distorted.library.DistortedObject;
32
import org.distorted.library.DistortedTexture;
33
import org.distorted.library.DistortedEffectQueues;
33 34
import org.distorted.library.EffectTypes;
34 35
import org.distorted.library.type.Dynamic1D;
35 36
import org.distorted.library.type.Dynamic3D;
......
49 50
   private static final int NUM = 3;
50 51
   
51 52
   private GLSurfaceView mView;
52
   private DistortedObject[] mObj;
53
   private DistortedEffectQueues[] mQueue;
54
   private DistortedTexture mTexture;
53 55
   private GridFlat mGrid;
54
   private Static3D pLeft, pRight, pNose1;
55
   private Static4D RegionEye;
56
   private Dynamic3D mDI;
57 56
   private int bmpHeight, bmpWidth;
58 57
    
59 58
///////////////////////////////////////////////////////////////////////////////////////////////////
......
62 61
      {     
63 62
      mView = v;
64 63
      
65
      // mObj[0] effects
66
      pLeft = new Static3D(214, 206, 0);
67
      pRight= new Static3D(390, 212, 0);
68
      RegionEye = new Static4D(0,0,60,60);
64
      // mQueue[0] effects
65
      Static3D pLeft = new Static3D(214, 206, 0);
66
      Static3D pRight= new Static3D(390, 212, 0);
67
      Static4D RegionEye = new Static4D(0,0,60,60);
69 68
      
70
      // mObj[1] effects
71
      mDI = new Dynamic3D(1000,0.0f);
72
      mDI.add(new Static3D( 50,0,0));
73
      mDI.add(new Static3D(-50,0,0));
74
      pNose1 = new Static3D(305, 340, 0);
69
      // mQueue[1] effects
70
      Dynamic3D dyn = new Dynamic3D(1000,0.0f);
71
      dyn.add(new Static3D( 50,0,0));
72
      dyn.add(new Static3D(-50,0,0));
73
      Static3D pNose1 = new Static3D(305, 340, 0);
75 74
      
76
      // we don't need to prepare anything for bmp[2] effects
75
      // we don't need to prepare anything for mQueue[2] effects
76

  
77
      mQueue= new DistortedEffectQueues[NUM];
78

  
79
      for(int i=0; i<NUM; i++) mQueue[i] = new DistortedEffectQueues();
80

  
81
      Dynamic1D sink = new Dynamic1D(2000,0.0f);
82
      sink.add(new Static1D( 1));
83
      sink.add(new Static1D(10));
84

  
85
      mQueue[0].sink(sink, pLeft, RegionEye);
86
      mQueue[0].sink(sink, pRight,RegionEye);
87
      mQueue[1].distort(dyn, pNose1);
88

  
89
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
90
      chromaDyn.add(new Static1D(0));
91
      chromaDyn.add(new Static1D(1));
92

  
93
      mQueue[2].chroma(chromaDyn, new Static3D(0,1,0) );
77 94
      }
78 95

  
79 96
///////////////////////////////////////////////////////////////////////////////////////////////////
......
84 101
      
85 102
     long time = System.currentTimeMillis();
86 103
   
87
     for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
104
     for(int i=NUM-1; i>=0; i--) mQueue[i].draw(time, mTexture, mGrid);
88 105
     }
89 106

  
90 107
///////////////////////////////////////////////////////////////////////////////////////////////////
......
93 110
     {
94 111
     for(int i=NUM-1; i>=0; i--)
95 112
       {
96
       mObj[i].abortEffects(EffectTypes.MATRIX);
113
       mQueue[i].abortEffects(EffectTypes.MATRIX);
97 114
       }
98 115
      
99 116
     if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
......
103 120

  
104 121
       for(int i=NUM-1; i>=0; i--)
105 122
         {
106
         mObj[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
107
         mObj[i].scale(factor);
123
         mQueue[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
124
         mQueue[i].scale(factor);
108 125
         }
109 126
       }
110 127
     else
......
115 132

  
116 133
       for(int i=NUM-1; i>=0; i--)
117 134
         {
118
         mObj[i].move( new Static3D(i*w, (height-h)/2, 0) );
119
         mObj[i].scale(factor);
135
         mQueue[i].move( new Static3D(i*w, (height-h)/2, 0) );
136
         mQueue[i].scale(factor);
120 137
         }
121 138
       }
122 139
       
......
148 165
     bmpHeight = bitmap.getHeight();
149 166
     bmpWidth  = bitmap.getWidth();
150 167

  
151
     mGrid = new GridFlat(30,30*bmpHeight/bmpWidth);
168
     mGrid     = new GridFlat(30,30*bmpHeight/bmpWidth);
169
     mTexture  = new DistortedTexture(bmpWidth, bmpHeight, 1);
152 170

  
153
     mObj = new DistortedObject[NUM];
154
     mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1);
155
      
156
     for(int i=1; i<NUM; i++) mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_BITMAP);
157
      
158
     // setting the bitmap once is enough; others are cloned!
159
     mObj[0].setTexture(bitmap);
160

  
161
     Dynamic1D sink = new Dynamic1D(2000,0.0f);
162
     sink.add(new Static1D( 1));
163
     sink.add(new Static1D(10));
171
     mTexture.setTexture(bitmap);
164 172

  
165
     mObj[0].sink(sink, pLeft, RegionEye);
166
     mObj[0].sink(sink, pRight,RegionEye);
167
     mObj[1].distort(mDI, pNose1);
168

  
169
     Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
170
     chromaDyn.add(new Static1D(0));
171
     chromaDyn.add(new Static1D(1));
172

  
173
     mObj[2].chroma(chromaDyn, new Static3D(0,1,0) );
174
      
175 173
     try
176 174
       {
177 175
       Distorted.onSurfaceCreated(mView.getContext());

Also available in: Unified diff