Revision a4d59c0b
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
81 | 81 |
mView = view; |
82 | 82 |
|
83 | 83 |
stretchEffects = new DistortedEffects(); |
84 |
mRegion = new Static4D(0,0,0,0); |
|
85 |
mMove = new Static3D(0,0,0); |
|
86 |
mTouchPoint= new Static3D(0,0,0); |
|
84 |
mRegion = new Static4D(0,0,0,0);
|
|
85 |
mMove = new Static3D(0,0,0);
|
|
86 |
mTouchPoint = new Static3D(0,0,0);
|
|
87 | 87 |
|
88 | 88 |
// DISTORT |
89 | 89 |
Dynamic3D releasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f); |
... | ... | |
136 | 136 |
mScreen = new DistortedScreen(); |
137 | 137 |
mScreen.showFPS(); |
138 | 138 |
|
139 |
mMovingDistort = new VertexEffectDistort(movingDistortDynamic, mTouchPoint, mRegion);
|
|
140 |
mMovingDeform = new VertexEffectDeform(movingDeformDynamic, mTouchPoint, mRegion);
|
|
141 |
mMovingShear = new MatrixEffectShear(movingShearDynamic, mTouchPoint);
|
|
142 |
mReleasedDistort = new VertexEffectDistort(releasedDistortDynamic, mTouchPoint, mRegion); |
|
143 |
mReleasedDeform = new VertexEffectDeform(releasedDeformDynamic, mTouchPoint, mRegion);
|
|
144 |
mReleasedShear = new MatrixEffectShear(releasedShearDynamic, mTouchPoint);
|
|
139 |
mMovingDistort = new VertexEffectDistort( movingDistortDynamic , mTouchPoint, mRegion);
|
|
140 |
mMovingDeform = new VertexEffectDeform ( movingDeformDynamic , mTouchPoint, mRegion);
|
|
141 |
mMovingShear = new MatrixEffectShear ( movingShearDynamic , mTouchPoint );
|
|
142 |
mReleasedDistort = new VertexEffectDistort( releasedDistortDynamic, mTouchPoint, mRegion);
|
|
143 |
mReleasedDeform = new VertexEffectDeform ( releasedDeformDynamic , mTouchPoint, mRegion);
|
|
144 |
mReleasedShear = new MatrixEffectShear ( releasedShearDynamic , mTouchPoint );
|
|
145 | 145 |
|
146 | 146 |
stretchEffects.apply(new MatrixEffectMove(mMove)); |
147 | 147 |
} |
... | ... | |
195 | 195 |
|
196 | 196 |
for(int i=0; i<=NUM_LINES ; i++ ) |
197 | 197 |
{ |
198 |
stretchCanvas.drawRect(w*i/NUM_LINES - 1, 0, w*i/NUM_LINES + 1, h , paint);
|
|
199 |
stretchCanvas.drawRect( 0, h *i/NUM_LINES -1, w , h*i/NUM_LINES + 1, paint);
|
|
198 |
stretchCanvas.drawRect(w*i/NUM_LINES-1, 0, w*i/NUM_LINES+1, h , paint);
|
|
199 |
stretchCanvas.drawRect( 0, h*i/NUM_LINES-1, w , h*i/NUM_LINES+1, paint);
|
|
200 | 200 |
} |
201 | 201 |
|
202 | 202 |
if( stretchTexture==null ) stretchTexture = new DistortedTexture(w,h); |
... | ... | |
231 | 231 |
|
232 | 232 |
void down(int x, int y) |
233 | 233 |
{ |
234 |
int xt = x-scrWidth/4; |
|
234 |
int xt = x-scrWidth /4;
|
|
235 | 235 |
int yt = y-scrHeight/4; |
236 | 236 |
|
237 | 237 |
if( xt<0 ) xt=0; |
238 |
if( xt>scrWidth/2 ) xt=scrWidth/2; |
|
238 |
if( xt>scrWidth /2 ) xt=scrWidth/2;
|
|
239 | 239 |
if( yt<0 ) yt=0; |
240 | 240 |
if( yt>scrHeight/2 ) yt=scrHeight/2; |
241 | 241 |
|
242 |
mTouchPoint.set(xt,yt,0);
|
|
242 |
mTouchPoint.set(xt, scrHeight/2-yt,0); // OpenGL coord system and 2D coords have inverted Y axis
|
|
243 | 243 |
|
244 | 244 |
switch(mMode) |
245 | 245 |
{ |
... | ... | |
264 | 264 |
{ |
265 | 265 |
switch(mMode) |
266 | 266 |
{ |
267 |
case DISTORT: vDistort[0].set(x,y,0); |
|
267 |
case DISTORT: vDistort[0].set(x,-y,0);
|
|
268 | 268 |
break; |
269 |
case DEFORM: vDeform[0].set(x,y,0); |
|
269 |
case DEFORM: vDeform[0].set(x,-y,0);
|
|
270 | 270 |
break; |
271 |
case SHEAR: vShear[0].set( (float)x/(scrWidth/2), (float)y/(scrHeight/2), 0);
|
|
271 |
case SHEAR: vShear[0].set( (float)x/(scrWidth/2), (float)(-y)/(scrHeight/2), 0);
|
|
272 | 272 |
break; |
273 | 273 |
} |
274 | 274 |
} |
Also available in: Unified diff
Massive: make the coordinate system agree with that of OpenGL (i.e. invert the Y axis).