Revision c6526577
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
26 | 26 |
import javax.microedition.khronos.opengles.GL10; |
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 |
import org.distorted.library.effect.EffectName; |
|
30 |
import org.distorted.library.effect.MatrixEffectMove; |
|
31 |
import org.distorted.library.effect.MatrixEffectScale; |
|
32 |
import org.distorted.library.effect.VertexEffectDistort; |
|
29 | 33 |
import org.distorted.library.main.Distorted; |
30 | 34 |
import org.distorted.library.main.DistortedEffects; |
31 | 35 |
import org.distorted.library.main.DistortedScreen; |
32 | 36 |
import org.distorted.library.main.DistortedTexture; |
33 |
import org.distorted.library.EffectNames; |
|
34 | 37 |
import org.distorted.library.main.MeshFlat; |
35 |
import org.distorted.library.EffectTypes; |
|
36 | 38 |
import org.distorted.library.type.Dynamic3D; |
37 | 39 |
import org.distorted.library.type.Static3D; |
38 | 40 |
import org.distorted.library.type.Static4D; |
... | ... | |
51 | 53 |
private MeshFlat mMesh; |
52 | 54 |
private DistortedScreen mScreen; |
53 | 55 |
private int bmpHeight, bmpWidth; |
56 |
private Static3D mMove, mScale; |
|
54 | 57 |
|
55 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 59 |
|
... | ... | |
71 | 74 |
dRight.add( new Static3D( 20,-10,0) ); |
72 | 75 |
|
73 | 76 |
mEffects = new DistortedEffects(); |
74 |
mEffects.distort( dLeft, pLeft , rLeft ); |
|
75 |
mEffects.distort(dRight, pRight, rRight); |
|
77 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
|
78 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
|
79 |
|
|
80 |
mMove = new Static3D(0,0,0); |
|
81 |
mScale= new Static3D(1,1,1); |
|
82 |
mEffects.apply(new MatrixEffectMove(mMove)); |
|
83 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
76 | 84 |
|
77 | 85 |
mScreen = new DistortedScreen(mView); |
78 | 86 |
} |
... | ... | |
88 | 96 |
|
89 | 97 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
90 | 98 |
{ |
91 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
92 |
|
|
93 | 99 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
94 | 100 |
{ |
95 | 101 |
int w = (height*bmpWidth)/bmpHeight; |
96 | 102 |
float factor = (float)height/bmpHeight; |
97 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
98 |
mEffects.scale(factor); |
|
103 |
|
|
104 |
mMove.set((width-w)/2,0,0); |
|
105 |
mScale.set( factor,factor,factor ); |
|
99 | 106 |
} |
100 | 107 |
else |
101 | 108 |
{ |
102 | 109 |
int h = (width*bmpHeight)/bmpWidth; |
103 | 110 |
float factor = (float)width/bmpWidth; |
104 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
105 |
mEffects.scale(factor); |
|
111 |
|
|
112 |
mMove.set(0,(height-h)/2,0); |
|
113 |
mScale.set( factor,factor,factor ); |
|
106 | 114 |
} |
107 | 115 |
|
108 | 116 |
mScreen.resize(width, height); |
... | ... | |
148 | 156 |
mScreen.detachAll(); |
149 | 157 |
mScreen.attach(mTexture,mEffects,mMesh); |
150 | 158 |
|
151 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
159 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
152 | 160 |
|
153 | 161 |
try |
154 | 162 |
{ |
Also available in: Unified diff
Further progress with Apps: 18 (out of 30) compile now.