Revision e8b6aa95
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.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.DistortedObject; |
|
32 |
import org.distorted.library.DistortedBitmapGrid; |
|
32 | 33 |
import org.distorted.library.EffectTypes; |
33 | 34 |
import org.distorted.library.type.Dynamic3D; |
34 | 35 |
import org.distorted.library.type.Static1D; |
35 |
import org.distorted.library.type.Static2D; |
|
36 | 36 |
import org.distorted.library.type.Static3D; |
37 | 37 |
import org.distorted.library.type.Static4D; |
38 | 38 |
|
... | ... | |
48 | 48 |
private static final int NUM = 3; |
49 | 49 |
|
50 | 50 |
private GLSurfaceView mView; |
51 |
private DistortedBitmap[] bmp; |
|
51 |
private DistortedObject[] mObj; |
|
52 |
private DistortedBitmapGrid mGrid; |
|
52 | 53 |
private Static3D mPoint; |
53 | 54 |
private Dynamic3D dDistort; |
54 | 55 |
private int bmpHeight, bmpWidth; |
... | ... | |
97 | 98 |
|
98 | 99 |
long time = System.currentTimeMillis(); |
99 | 100 |
|
100 |
for(int i=NUM-1; i>=0; i--) bmp[i].draw(time);
|
|
101 |
for(int i=NUM-1; i>=0; i--) mObj[i].draw(time, mGrid);
|
|
101 | 102 |
} |
102 | 103 |
|
103 | 104 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
106 | 107 |
{ |
107 | 108 |
for(int i=NUM-1; i>=0; i--) |
108 | 109 |
{ |
109 |
bmp[i].abortEffects(EffectTypes.MATRIX);
|
|
110 |
mObj[i].abortEffects(EffectTypes.MATRIX);
|
|
110 | 111 |
} |
111 | 112 |
|
112 | 113 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
... | ... | |
116 | 117 |
|
117 | 118 |
for(int i=NUM-1; i>=0; i--) |
118 | 119 |
{ |
119 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
120 |
bmp[i].scale(factor);
|
|
120 |
mObj[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
121 |
mObj[i].scale(factor);
|
|
121 | 122 |
} |
122 | 123 |
} |
123 | 124 |
else |
... | ... | |
128 | 129 |
|
129 | 130 |
for(int i=NUM-1; i>=0; i--) |
130 | 131 |
{ |
131 |
bmp[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
132 |
bmp[i].scale(factor);
|
|
132 |
mObj[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
133 |
mObj[i].scale(factor);
|
|
133 | 134 |
} |
134 | 135 |
} |
135 | 136 |
|
... | ... | |
150 | 151 |
bmpWidth = bitmap0.getWidth(); |
151 | 152 |
|
152 | 153 |
// create NUM DistortedBitmaps with shared effects |
153 |
bmp = new DistortedBitmap[NUM];
|
|
154 |
bmp[0] = new DistortedBitmap(bmpWidth, bmpHeight, 30);
|
|
154 |
mObj = new DistortedObject[NUM];
|
|
155 |
mObj[0] = new DistortedObject(bmpWidth, bmpHeight, 1);
|
|
155 | 156 |
for(int i=1; i<NUM; i++) |
156 |
bmp[i] = new DistortedBitmap(bmp[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
157 |
mObj[i] = new DistortedObject(mObj[0], Distorted.CLONE_VERTEX|Distorted.CLONE_FRAGMENT);
|
|
157 | 158 |
|
158 |
bmp[0].setBitmap(bitmap0);
|
|
159 |
bmp[1].setBitmap(bitmap1);
|
|
160 |
bmp[2].setBitmap(bitmap2);
|
|
159 |
mObj[0].setTexture(bitmap0);
|
|
160 |
mObj[1].setTexture(bitmap1);
|
|
161 |
mObj[2].setTexture(bitmap2);
|
|
161 | 162 |
|
162 |
bmp[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); |
|
163 |
bmp[0].distort(dDistort,mPoint); |
|
164 |
|
|
163 |
mObj[0].sink( new Static1D(8), mPoint, new Static4D(0,0,80,80)); |
|
164 |
mObj[0].distort(dDistort,mPoint); |
|
165 |
|
|
166 |
mGrid = new DistortedBitmapGrid(30,30*bmpHeight/bmpWidth); |
|
167 |
|
|
165 | 168 |
try |
166 | 169 |
{ |
167 | 170 |
Distorted.onSurfaceCreated(mView.getContext()); |
Also available in: Unified diff
Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.