| 30 |
30 |
|
| 31 |
31 |
import org.distorted.examples.R;
|
| 32 |
32 |
|
| 33 |
|
import org.distorted.library.effect.Effect;
|
|
33 |
import org.distorted.library.effect.EffectName;
|
|
34 |
import org.distorted.library.effect.MatrixEffectMove;
|
|
35 |
import org.distorted.library.effect.MatrixEffectScale;
|
| 34 |
36 |
import org.distorted.library.effect.VertexEffectSink;
|
| 35 |
37 |
import org.distorted.library.main.Distorted;
|
| 36 |
38 |
import org.distorted.library.main.DistortedEffects;
|
| ... | ... | |
| 39 |
41 |
import org.distorted.library.main.MeshFlat;
|
| 40 |
42 |
import org.distorted.library.main.DistortedFramebuffer;
|
| 41 |
43 |
import org.distorted.library.type.Dynamic1D;
|
| 42 |
|
import org.distorted.library.type.Dynamic3D;
|
| 43 |
44 |
import org.distorted.library.type.Static1D;
|
| 44 |
45 |
import org.distorted.library.type.Static3D;
|
| 45 |
46 |
import org.distorted.library.type.Static4D;
|
| ... | ... | |
| 61 |
62 |
private MeshFlat mMesh;
|
| 62 |
63 |
private DistortedScreen mScreen;
|
| 63 |
64 |
private Static1D s0;
|
| 64 |
|
private Dynamic3D mScaleDyn;
|
| 65 |
|
private Static3D mScaleFactor;
|
|
65 |
private Static3D mScaleFactor, mScaleMain, mMove;
|
| 66 |
66 |
|
| 67 |
67 |
private float mScale;
|
| 68 |
68 |
private int bmpHeight, bmpWidth;
|
| ... | ... | |
| 90 |
90 |
diSink.add(s0);
|
| 91 |
91 |
|
| 92 |
92 |
mScale = 1.0f;
|
| 93 |
|
mScaleDyn = new Dynamic3D();
|
| 94 |
93 |
mScaleFactor = new Static3D(mScale,mScale,1.0f);
|
| 95 |
|
mScaleDyn.add(mScaleFactor);
|
|
94 |
mMove = new Static3D(0,0,0);
|
|
95 |
mScaleMain = new Static3D(1,1,1);
|
| 96 |
96 |
|
| 97 |
97 |
mEffects = new DistortedEffects();
|
| 98 |
|
mEffects.sink( diSink, pLeft , sinkRegion);
|
| 99 |
|
mEffects.sink( diSink, pRight, sinkRegion);
|
|
98 |
mEffects.apply( new VertexEffectSink(diSink, pLeft , sinkRegion) );
|
|
99 |
mEffects.apply( new VertexEffectSink(diSink, pRight, sinkRegion) );
|
|
100 |
mEffects.apply( new MatrixEffectMove(mMove));
|
|
101 |
mEffects.apply( new MatrixEffectScale(mScaleMain));
|
|
102 |
mEffects.apply( new MatrixEffectScale(mScaleFactor));
|
| 100 |
103 |
|
| 101 |
104 |
mScreen = new DistortedScreen(mView);
|
| 102 |
105 |
}
|
| ... | ... | |
| 155 |
158 |
|
| 156 |
159 |
if( isSaving ) // render to an offscreen buffer and read pixels
|
| 157 |
160 |
{
|
| 158 |
|
mEffects.abortByType(Effect.MATRIX);
|
| 159 |
|
mEffects.scale(mScaleFactor);
|
|
161 |
mMove.set(0,0,0);
|
|
162 |
mScaleMain.set(1,1,1);
|
| 160 |
163 |
mOffscreen.render(time);
|
| 161 |
164 |
applyMatrixEffects(scrWidth,scrHeight);
|
| 162 |
165 |
|
| ... | ... | |
| 188 |
191 |
|
| 189 |
192 |
private void applyMatrixEffects(int width, int height)
|
| 190 |
193 |
{
|
| 191 |
|
mEffects.abortByType(Effect.MATRIX);
|
| 192 |
|
|
| 193 |
194 |
if( (float)bmpHeight/bmpWidth > (float)height/width )
|
| 194 |
195 |
{
|
| 195 |
196 |
int w = (height*bmpWidth)/bmpHeight;
|
| 196 |
197 |
float factor = (float)height/bmpHeight;
|
| 197 |
198 |
|
| 198 |
|
mEffects.move( new Static3D((width-w)/2,0,0) );
|
| 199 |
|
mEffects.scale(factor);
|
|
199 |
mMove.set((width-w)/2,0,0);
|
|
200 |
mScaleMain.set(factor,factor,factor);
|
| 200 |
201 |
}
|
| 201 |
202 |
else
|
| 202 |
203 |
{
|
| 203 |
204 |
int h = (width*bmpHeight)/bmpWidth;
|
| 204 |
205 |
float factor = (float)width/bmpWidth;
|
| 205 |
206 |
|
| 206 |
|
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
| 207 |
|
mEffects.scale(factor);
|
|
207 |
mMove.set(0,(height-h)/2,0);
|
|
208 |
mScaleMain.set(factor,factor,factor);
|
| 208 |
209 |
}
|
| 209 |
|
|
| 210 |
|
mEffects.scale(mScaleDyn);
|
| 211 |
210 |
}
|
| 212 |
211 |
|
| 213 |
212 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 254 |
253 |
mScreen.detachAll();
|
| 255 |
254 |
mScreen.attach(mTexture,mEffects,mMesh);
|
| 256 |
255 |
|
| 257 |
|
DistortedEffects.enableEffect(org.distorted.library.effect.VertexEffectSink.class);
|
|
256 |
DistortedEffects.enableEffect(EffectName.SINK);
|
| 258 |
257 |
|
| 259 |
258 |
try
|
| 260 |
259 |
{
|
Further progress with Apps: 25 (out of 31) compile now.