Revision 40eef4b9
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.examples.R; |
32 | 32 |
|
33 | 33 |
import org.distorted.library.Distorted; |
34 |
import org.distorted.library.DistortedObject; |
|
34 |
import org.distorted.library.DistortedEffectQueues; |
|
35 |
import org.distorted.library.DistortedTexture; |
|
35 | 36 |
import org.distorted.library.GridFlat; |
36 | 37 |
import org.distorted.library.DistortedFramebuffer; |
37 | 38 |
import org.distorted.library.EffectTypes; |
... | ... | |
52 | 53 |
class SaveRenderer implements GLSurfaceView.Renderer |
53 | 54 |
{ |
54 | 55 |
private GLSurfaceView mView; |
55 |
private DistortedObject mGirl; |
|
56 |
private DistortedTexture mGirl; |
|
57 |
private DistortedEffectQueues mQueues; |
|
56 | 58 |
private GridFlat mGrid; |
57 | 59 |
private DistortedFramebuffer mOffscreen; |
58 |
private Static3D pLeft, pRight; |
|
59 |
private Static4D sinkRegion; |
|
60 |
private Dynamic1D diSink; |
|
61 | 60 |
private Static1D s0; |
62 | 61 |
private Dynamic3D mScaleDyn; |
63 | 62 |
private Static3D mScaleFactor; |
... | ... | |
77 | 76 |
|
78 | 77 |
boobsSink = 1.0f; |
79 | 78 |
|
80 |
pLeft = new Static3D(132, 264, 0); |
|
81 |
pRight= new Static3D(247, 264, 0); |
|
79 |
Static3D pLeft = new Static3D(132, 264, 0);
|
|
80 |
Static3D pRight= new Static3D(247, 264, 0);
|
|
82 | 81 |
|
83 |
sinkRegion = new Static4D(0,0,60,60); |
|
82 |
Static4D sinkRegion = new Static4D(0,0,60,60);
|
|
84 | 83 |
|
85 | 84 |
s0 = new Static1D(boobsSink); |
86 | 85 |
|
87 |
diSink = new Dynamic1D(); |
|
86 |
Dynamic1D diSink = new Dynamic1D();
|
|
88 | 87 |
diSink.add(s0); |
89 | 88 |
|
90 | 89 |
mScale = 1.0f; |
91 | 90 |
mScaleDyn = new Dynamic3D(); |
92 | 91 |
mScaleFactor = new Static3D(mScale,mScale,1.0f); |
93 | 92 |
mScaleDyn.add(mScaleFactor); |
93 |
|
|
94 |
mQueues = new DistortedEffectQueues(); |
|
95 |
mQueues.sink( diSink, pLeft , sinkRegion); |
|
96 |
mQueues.sink( diSink, pRight, sinkRegion); |
|
94 | 97 |
} |
95 | 98 |
|
96 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
145 | 148 |
{ |
146 | 149 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
147 | 150 |
|
151 |
long time = System.currentTimeMillis(); |
|
152 |
|
|
148 | 153 |
if( isSaving ) // render to an offscreen buffer and read pixels |
149 | 154 |
{ |
150 |
mGirl.abortEffects(EffectTypes.MATRIX);
|
|
151 |
mGirl.scale(mScaleFactor);
|
|
152 |
mGirl.draw(System.currentTimeMillis(), mGrid, mOffscreen);
|
|
155 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
156 |
mQueues.scale(mScaleFactor);
|
|
157 |
mQueues.draw(time, mGirl, mGrid, mOffscreen);
|
|
153 | 158 |
applyMatrixEffects(scrWidth,scrHeight); |
154 | 159 |
|
155 | 160 |
int fW =(int)(mScale*bmpWidth); |
... | ... | |
164 | 169 |
isSaving = false; |
165 | 170 |
} |
166 | 171 |
|
167 |
mGirl.draw(System.currentTimeMillis(), mGrid);
|
|
172 |
mQueues.draw(time, mGirl, mGrid);
|
|
168 | 173 |
} |
169 | 174 |
|
170 | 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
171 | 176 |
|
172 | 177 |
private void applyMatrixEffects(int width, int height) |
173 | 178 |
{ |
174 |
mGirl.abortEffects(EffectTypes.MATRIX);
|
|
179 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
175 | 180 |
|
176 | 181 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
177 | 182 |
{ |
178 | 183 |
int w = (height*bmpWidth)/bmpHeight; |
179 | 184 |
float factor = (float)height/bmpHeight; |
180 | 185 |
|
181 |
mGirl.move( new Static3D((width-w)/2,0,0) );
|
|
182 |
mGirl.scale(factor);
|
|
186 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
187 |
mQueues.scale(factor);
|
|
183 | 188 |
} |
184 | 189 |
else |
185 | 190 |
{ |
186 | 191 |
int h = (width*bmpHeight)/bmpWidth; |
187 | 192 |
float factor = (float)width/bmpWidth; |
188 | 193 |
|
189 |
mGirl.move( new Static3D(0,(height-h)/2,0) );
|
|
190 |
mGirl.scale(factor);
|
|
194 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
195 |
mQueues.scale(factor);
|
|
191 | 196 |
} |
192 | 197 |
|
193 |
mGirl.scale(mScaleDyn);
|
|
198 |
mQueues.scale(mScaleDyn);
|
|
194 | 199 |
} |
195 | 200 |
|
196 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
229 | 234 |
bmpWidth = bitmap.getWidth(); |
230 | 235 |
|
231 | 236 |
mGrid = new GridFlat(30,30*bmpHeight/bmpWidth); |
232 |
mGirl = new DistortedObject(bmpWidth,bmpHeight,1);
|
|
237 |
mGirl = new DistortedTexture(bmpWidth,bmpHeight,0);
|
|
233 | 238 |
mGirl.setTexture(bitmap); |
234 | 239 |
|
235 |
mGirl.sink( diSink, pLeft , sinkRegion); |
|
236 |
mGirl.sink( diSink, pRight, sinkRegion); |
|
237 |
|
|
238 | 240 |
mOffscreen = new DistortedFramebuffer(bmpWidth,bmpHeight); |
239 | 241 |
|
240 | 242 |
try |
Also available in: Unified diff
Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.
Still does not compile, but pushing already.