Project

General

Profile

« Previous | Next » 

Revision e8b6aa95

Added by Leszek Koltunski over 7 years ago

Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.

View differences:

src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
28 28
import org.distorted.examples.R;
29 29

  
30 30
import org.distorted.library.Distorted;
31
import org.distorted.library.DistortedBitmap;
31
import org.distorted.library.DistortedBitmapGrid;
32
import org.distorted.library.DistortedObject;
32 33
import org.distorted.library.EffectTypes;
33 34
import org.distorted.library.type.Dynamic1D;
34 35
import org.distorted.library.type.Dynamic3D;
35 36
import org.distorted.library.type.Static1D;
36
import org.distorted.library.type.Static2D;
37 37
import org.distorted.library.type.Static3D;
38 38
import org.distorted.library.type.Static4D;
39 39

  
......
49 49
   private static final int NUM = 3;
50 50
   
51 51
   private GLSurfaceView mView;
52
   private DistortedBitmap[] bmp;
52
   private DistortedObject[] mObj;
53
   private DistortedBitmapGrid mGrid;
53 54
   private Static3D pLeft, pRight, pNose1;
54 55
   private Static4D RegionEye;
55 56
   private Dynamic3D mDI;
......
61 62
      {     
62 63
      mView = v;
63 64
      
64
      // bmp[0] effects
65
      // mObj[0] effects
65 66
      pLeft = new Static3D(214, 206, 0);
66 67
      pRight= new Static3D(390, 212, 0);
67 68
      RegionEye = new Static4D(0,0,60,60);
68 69
      
69
      // bmp[1] effects
70
      // mObj[1] effects
70 71
      mDI = new Dynamic3D(1000,0.0f);
71 72
      mDI.add(new Static3D( 50,0,0));
72 73
      mDI.add(new Static3D(-50,0,0));
......
83 84
      
84 85
     long time = System.currentTimeMillis();
85 86
   
86
     for(int i=NUM-1; i>=0; i--) bmp[i].draw(time);
87
     for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
87 88
     }
88 89

  
89 90
///////////////////////////////////////////////////////////////////////////////////////////////////
......
92 93
     {
93 94
     for(int i=NUM-1; i>=0; i--)
94 95
       {
95
       bmp[i].abortEffects(EffectTypes.MATRIX);
96
       mObj[i].abortEffects(EffectTypes.MATRIX);
96 97
       }
97 98
      
98 99
     if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
......
102 103

  
103 104
       for(int i=NUM-1; i>=0; i--)
104 105
         {
105
         bmp[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
106
         bmp[i].scale(factor);
106
         mObj[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
107
         mObj[i].scale(factor);
107 108
         }
108 109
       }
109 110
     else
......
114 115

  
115 116
       for(int i=NUM-1; i>=0; i--)
116 117
         {
117
         bmp[i].move( new Static3D(i*w, (height-h)/2, 0) );
118
         bmp[i].scale(factor);
118
         mObj[i].move( new Static3D(i*w, (height-h)/2, 0) );
119
         mObj[i].scale(factor);
119 120
         }
120 121
       }
121 122
       
......
146 147
      
147 148
     bmpHeight = bitmap.getHeight();
148 149
     bmpWidth  = bitmap.getWidth();
150

  
151
     mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth);
152

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

  
158 161
     Dynamic1D sink = new Dynamic1D(2000,0.0f);
159 162
     sink.add(new Static1D( 1));
160 163
     sink.add(new Static1D(10));
161 164

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

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

  
170
     bmp[2].chroma(chromaDyn, new Static3D(0,1,0) );
173
     mObj[2].chroma(chromaDyn, new Static3D(0,1,0) );
171 174
      
172 175
     try
173 176
       {

Also available in: Unified diff