Revision 9930cd43
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.effect.FragmentEffectChroma; |
32 | 32 |
import org.distorted.library.effect.MatrixEffectScale; |
33 | 33 |
import org.distorted.library.effect.VertexEffectDeform; |
34 |
import org.distorted.library.effect.VertexEffectScale; |
|
34 | 35 |
import org.distorted.library.effect.VertexEffectSwirl; |
35 | 36 |
import org.distorted.library.main.DistortedLibrary; |
36 | 37 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
65 | 66 |
private MeshRectangles mMesh; |
66 | 67 |
private DistortedScreen mScreen; |
67 | 68 |
private int mObjHeight, mObjWidth; |
68 |
private Static3D mScale, mSwirl1, mSwirl2, mDeform1, mDeform2; |
|
69 |
private Static3D mScaleMatrix, mScaleVertex, mSwirl1, mSwirl2, mDeform1, mDeform2;
|
|
69 | 70 |
private Static1D mRadius; |
70 | 71 |
|
71 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
79 | 80 |
DistortedLibrary.setMax(EffectType.VERTEX ,act.getMaxV()); |
80 | 81 |
DistortedLibrary.setMax(EffectType.FRAGMENT,act.getMaxF()); |
81 | 82 |
|
83 |
VertexEffectScale.enable(); |
|
82 | 84 |
VertexEffectSwirl.enable(); |
83 | 85 |
VertexEffectDeform.enable(); |
84 | 86 |
FragmentEffectChroma.enable(); |
85 | 87 |
|
86 |
mSwirl1 = new Static3D(0,0,0); |
|
87 |
mSwirl2 = new Static3D(0,0,0); |
|
88 |
mDeform1= new Static3D(0,0,0); |
|
89 |
mDeform2= new Static3D(0,0,0); |
|
90 |
mScale = new Static3D(1,1,1); |
|
88 |
mSwirl1 = new Static3D(0,0,0); |
|
89 |
mSwirl2 = new Static3D(0,0,0); |
|
90 |
mDeform1 = new Static3D(0,0,0); |
|
91 |
mDeform2 = new Static3D(0,0,0); |
|
92 |
mScaleMatrix= new Static3D(1,1,1); |
|
93 |
mScaleVertex= new Static3D(1,1,1); |
|
91 | 94 |
|
92 | 95 |
mRadius = new Static1D(0); |
93 | 96 |
|
94 | 97 |
mEffects = new DistortedEffects(); |
95 |
mEffects.apply(new MatrixEffectScale(mScale)); |
|
98 |
mEffects.apply(new MatrixEffectScale(mScaleMatrix));
|
|
96 | 99 |
|
97 |
// Try adding 2 Vertex Effects to the Bitmap.
|
|
98 |
// This will fail if we have set maxVertexEffects to something < 2.
|
|
100 |
// Try adding 3 Vertex Effects to the Bitmap.
|
|
101 |
// This will fail if we have set maxVertexEffects to something < 3.
|
|
99 | 102 |
// |
100 | 103 |
// Even if adding some of the Effects fails, the App will still start - you just won't see |
101 | 104 |
// the effects that failed to add. |
102 | 105 |
|
106 |
if( !mEffects.apply( new VertexEffectScale(mScaleVertex) ) ) |
|
107 |
{ |
|
108 |
Log.e("Check", "Failed to add Scale effect!"); |
|
109 |
} |
|
110 |
|
|
103 | 111 |
Dynamic3D dSwirl = new Dynamic3D(2000,0.0f); |
104 | 112 |
dSwirl.add(mSwirl1); |
105 | 113 |
dSwirl.add(mSwirl2); |
... | ... | |
150 | 158 |
|
151 | 159 |
float factor = xW>xH ? SCALE*xH : SCALE*xW; |
152 | 160 |
|
153 |
mScale.set(factor,factor,factor); |
|
161 |
mScaleMatrix.set(factor,factor,factor);
|
|
154 | 162 |
|
155 | 163 |
mScreen.resize(width,height); |
156 | 164 |
} |
... | ... | |
178 | 186 |
mObjHeight = bitmap.getHeight(); |
179 | 187 |
mObjWidth = bitmap.getWidth(); |
180 | 188 |
|
181 |
mRadius.set(mObjWidth/2); |
|
189 |
mRadius.set(mObjWidth*0.5f); |
|
190 |
mScaleVertex.set(mObjWidth,mObjHeight,0); |
|
182 | 191 |
|
192 |
if( mMesh ==null ) mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
183 | 193 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
184 | 194 |
mTexture.setTexture(bitmap); |
185 | 195 |
|
186 |
if( mMesh==null ) |
|
187 |
{ |
|
188 |
mMesh = new MeshRectangles(30,30*mObjHeight/mObjWidth); |
|
189 |
mMesh.setStretch(mObjWidth,mObjHeight,0); |
|
190 |
} |
|
191 |
|
|
192 | 196 |
mScreen.detachAll(); |
193 | 197 |
mScreen.attach(mTexture,mEffects,mMesh); |
194 | 198 |
|
Also available in: Unified diff
Convert Check to stretchless API.