Revision 1f218177
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import org.distorted.examples.R; |
27 | 27 |
import org.distorted.library.main.DistortedEffects; |
28 |
import org.distorted.library.EffectNames; |
|
29 |
import org.distorted.library.EffectTypes; |
|
30 | 28 |
import org.distorted.library.type.Dynamic1D; |
31 | 29 |
import org.distorted.library.type.Dynamic2D; |
32 | 30 |
import org.distorted.library.type.Dynamic3D; |
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
30 | 30 |
import android.view.SurfaceHolder; |
31 | 31 |
import android.view.SurfaceView; |
32 | 32 |
|
33 |
import org.distorted.library.effect.EffectName; |
|
34 |
import org.distorted.library.effect.MatrixEffectMove; |
|
35 |
import org.distorted.library.effect.MatrixEffectScale; |
|
36 |
import org.distorted.library.effect.VertexEffectDistort; |
|
33 | 37 |
import org.distorted.library.main.Distorted; |
34 | 38 |
import org.distorted.library.main.DistortedEffects; |
35 | 39 |
import org.distorted.library.main.DistortedScreen; |
36 |
import org.distorted.library.EffectNames; |
|
37 | 40 |
import org.distorted.library.main.MeshFlat; |
38 | 41 |
import org.distorted.library.main.DistortedTexture; |
39 |
import org.distorted.library.EffectTypes; |
|
40 | 42 |
import org.distorted.library.type.Dynamic3D; |
41 | 43 |
import org.distorted.library.type.Static3D; |
42 | 44 |
import org.distorted.library.type.Static4D; |
... | ... | |
70 | 72 |
private int bmpHeight, bmpWidth; |
71 | 73 |
private SurfaceView mView; |
72 | 74 |
private static boolean resourcesCreated = false; |
75 |
private Static3D mMove, mScale; |
|
73 | 76 |
|
74 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 78 |
|
... | ... | |
94 | 97 |
dRight.add( new Static3D( 20,-10,0) ); |
95 | 98 |
|
96 | 99 |
mEffects = new DistortedEffects(); |
97 |
mEffects.distort( dLeft, pLeft , rLeft ); |
|
98 |
mEffects.distort(dRight, pRight, rRight); |
|
100 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
|
101 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
|
102 |
|
|
103 |
mMove = new Static3D(0,0,0); |
|
104 |
mScale= new Static3D(1,1,1); |
|
105 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
106 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
99 | 107 |
|
100 | 108 |
mScreen = new DistortedScreen(null); |
101 | 109 |
} |
... | ... | |
117 | 125 |
{ |
118 | 126 |
String msg = op + ": glError 0x" + Integer.toHexString(error); |
119 | 127 |
Log.e(TAG, msg); |
120 |
// throw new RuntimeException(msg);
|
|
128 |
// throw new RuntimeException(msg); |
|
121 | 129 |
} |
122 | 130 |
} |
123 | 131 |
|
... | ... | |
210 | 218 |
{ |
211 | 219 |
Log.d(TAG, "surfaceChanged " + width + "x" + height); |
212 | 220 |
|
213 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
214 |
|
|
215 | 221 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
216 | 222 |
{ |
217 | 223 |
int w = (height*bmpWidth)/bmpHeight; |
218 | 224 |
float factor = (float)height/bmpHeight; |
219 | 225 |
|
220 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
221 |
mEffects.scale( factor );
|
|
226 |
mMove.set((width-w)/2,0,0);
|
|
227 |
mScale.set( factor,factor,factor );
|
|
222 | 228 |
} |
223 | 229 |
else |
224 | 230 |
{ |
225 | 231 |
int h = (width*bmpHeight)/bmpWidth; |
226 | 232 |
float factor = (float)width/bmpWidth; |
227 | 233 |
|
228 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
229 |
mEffects.scale( factor );
|
|
234 |
mMove.set(0,(height-h)/2,0);
|
|
235 |
mScale.set( factor,factor,factor );
|
|
230 | 236 |
} |
231 | 237 |
|
232 | 238 |
mScreen.resize(width, height); |
... | ... | |
234 | 240 |
|
235 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
236 | 242 |
|
237 |
void createResources() |
|
243 |
private void createResources()
|
|
238 | 244 |
{ |
239 | 245 |
resourcesCreated = true; |
240 | 246 |
|
... | ... | |
265 | 271 |
mScreen.detachAll(); |
266 | 272 |
mScreen.attach(mTexture,mEffects,mMesh); |
267 | 273 |
|
268 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
274 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
269 | 275 |
|
270 | 276 |
try |
271 | 277 |
{ |
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
---|---|---|
22 | 22 |
import javax.microedition.khronos.egl.EGLConfig; |
23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
24 | 24 |
|
25 |
import org.distorted.library.effect.EffectName; |
|
26 |
import org.distorted.library.effect.VertexEffectDistort; |
|
25 | 27 |
import org.distorted.library.main.Distorted; |
26 | 28 |
import org.distorted.library.main.DistortedEffects; |
27 | 29 |
import org.distorted.library.main.DistortedScreen; |
28 |
import org.distorted.library.EffectNames; |
|
29 | 30 |
import org.distorted.library.main.MeshFlat; |
30 | 31 |
import org.distorted.library.main.DistortedTexture; |
31 | 32 |
import org.distorted.library.type.Static3D; |
... | ... | |
48 | 49 |
private DistortedTexture mTexture; |
49 | 50 |
private float mF, mNear; |
50 | 51 |
|
52 |
private Static3D mVector, mPoint1, mPoint2, mPoint3, mPoint4; |
|
53 |
private Static4D mRegion; |
|
54 |
|
|
51 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 56 |
|
53 | 57 |
ProjectionRenderer(GLSurfaceView view) |
... | ... | |
55 | 59 |
mView = view; |
56 | 60 |
mEffects= new DistortedEffects(); |
57 | 61 |
mScreen = new DistortedScreen(mView); |
62 |
|
|
63 |
mVector = new Static3D(0,0,0); |
|
64 |
mPoint1 = new Static3D(0,0,0); |
|
65 |
mPoint2 = new Static3D(0,0,0); |
|
66 |
mPoint3 = new Static3D(0,0,0); |
|
67 |
mPoint4 = new Static3D(0,0,0); |
|
68 |
mRegion = new Static4D(0,0,0,0); |
|
69 |
|
|
70 |
mEffects.apply( new VertexEffectDistort(mVector, mPoint1, mRegion) ); |
|
71 |
mEffects.apply( new VertexEffectDistort(mVector, mPoint2, mRegion) ); |
|
72 |
mEffects.apply( new VertexEffectDistort(mVector, mPoint3, mRegion) ); |
|
73 |
mEffects.apply( new VertexEffectDistort(mVector, mPoint4, mRegion) ); |
|
58 | 74 |
} |
59 | 75 |
|
60 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
108 | 124 |
|
109 | 125 |
int min = width<height ? width:height; |
110 | 126 |
|
111 |
Static3D vector = new Static3D(0,0,min/5);
|
|
112 |
Static4D region = new Static4D(0,0,min/5,min/5);
|
|
127 |
mVector.set(0,0,min/5);
|
|
128 |
mRegion.set(0,0,min/5,min/5);
|
|
113 | 129 |
|
114 |
mEffects.distort(vector, new Static3D( width/4, height/4, 0), region);
|
|
115 |
mEffects.distort(vector, new Static3D(3*width/4, height/4, 0), region);
|
|
116 |
mEffects.distort(vector, new Static3D( width/4, 3*height/4, 0), region);
|
|
117 |
mEffects.distort(vector, new Static3D(3*width/4, 3*height/4, 0), region);
|
|
130 |
mPoint1.set( width/4, height/4, 0);
|
|
131 |
mPoint2.set(3*width/4, height/4, 0);
|
|
132 |
mPoint3.set( width/4, 3*height/4, 0);
|
|
133 |
mPoint4.set(3*width/4, 3*height/4, 0);
|
|
118 | 134 |
|
119 | 135 |
// Avoid memory leaks: delete old texture if it exists (it might if we |
120 | 136 |
// got here after a brief amount of time spent in the background) |
... | ... | |
137 | 153 |
|
138 | 154 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
139 | 155 |
{ |
140 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
156 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
141 | 157 |
|
142 | 158 |
try |
143 | 159 |
{ |
Also available in: Unified diff
Further progress with Apps: 18 (out of 30) compile now.