Revision 849e0034
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
51 | 51 |
private DistortedScreen mScreen; |
52 | 52 |
private DistortedTexture mTexture; |
53 | 53 |
private MeshRectangles mMesh; |
54 |
private Static3D mScale, mBrowL, mBrowR;
|
|
54 |
private Static3D mScale; |
|
55 | 55 |
|
56 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 57 |
|
... | ... | |
59 | 59 |
{ |
60 | 60 |
mView = v; |
61 | 61 |
|
62 |
|
|
62 |
Static3D pointLeft = new Static3D(-85, 57, 0); |
|
63 |
Static3D pointRight = new Static3D( 50, 100, 0); |
|
63 | 64 |
Static4D regionLeft = new Static4D( -3, 33, 0, 47); |
64 | 65 |
Static4D regionRight= new Static4D(-14, 33, 0, 47); |
65 | 66 |
Dynamic3D dynLeft = new Dynamic3D(2000,0.0f); |
... | ... | |
83 | 84 |
dynRight.add(vect1); |
84 | 85 |
|
85 | 86 |
mScale= new Static3D(1,1,1); |
86 |
mBrowL= new Static3D(0,0,0); |
|
87 |
mBrowR= new Static3D(0,0,0); |
|
88 | 87 |
|
89 | 88 |
mEffects = new DistortedEffects(); |
90 |
mEffects.apply( new VertexEffectDistort(dynLeft , mBrowL, regionLeft) );
|
|
91 |
mEffects.apply( new VertexEffectDistort(dynRight, mBrowR, regionRight));
|
|
89 |
mEffects.apply( new VertexEffectDistort(dynLeft , pointLeft , regionLeft) );
|
|
90 |
mEffects.apply( new VertexEffectDistort(dynRight, pointRight, regionRight));
|
|
92 | 91 |
mEffects.apply( new MatrixEffectScale(mScale) ); |
93 | 92 |
|
94 | 93 |
mScreen = new DistortedScreen(); |
... | ... | |
136 | 135 |
int bmpHeight = bitmap.getHeight(); |
137 | 136 |
int bmpWidth = bitmap.getWidth(); |
138 | 137 |
|
139 |
mBrowL.set( 98 - bmpWidth/2, 297 - bmpHeight/2, 0); |
|
140 |
mBrowR.set(233 - bmpWidth/2, 340 - bmpHeight/2, 0); |
|
141 |
|
|
142 | 138 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
143 | 139 |
mTexture.setTexture(bitmap); |
144 | 140 |
|
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
77 | 77 |
moveDyn.add(mMoveStartingPoint); |
78 | 78 |
moveDyn.add(mMoveEndPoint); |
79 | 79 |
|
80 |
Static3D chromaCenter= new Static3D( 530, 300, 0 );
|
|
80 |
Static3D chromaCenter= new Static3D( 130, 50, 0 );
|
|
81 | 81 |
Static3D chromaRegion= new Static3D( 100, 100, 100 ); |
82 |
Static3D alphaCenter = new Static3D( 230, 300, 0 );
|
|
82 |
Static3D alphaCenter = new Static3D(-170, 50, 0 );
|
|
83 | 83 |
Static3D alphaRegion = new Static3D( 100, 100, 100 ); |
84 | 84 |
|
85 | 85 |
Dynamic1D chromaDyn = new Dynamic1D(DURATION_CHROMA_ALPHA,0.0f); |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
236 | 236 |
|
237 | 237 |
void down(int x, int y) |
238 | 238 |
{ |
239 |
int xt = x-(scrWidth -textureWidth )/2; |
|
240 |
int yt = y-(scrHeight-textureHeight)/2; |
|
241 |
|
|
242 |
yt = textureHeight - yt; // OpenGL coord system and 2D coords have inverted Y axis |
|
239 |
int xt = x-(scrWidth/2); |
|
240 |
int yt = (scrHeight/2)-y; |
|
243 | 241 |
|
244 | 242 |
switch(mMode) |
245 | 243 |
{ |
... | ... | |
256 | 254 |
case SHEAR : vShear[0].set(0,0,0); |
257 | 255 |
mEffects.apply(mMovingShear); |
258 | 256 |
mLastEffect = mMovingShear.getID(); |
259 |
mTouchPoint.set(xt-textureWidth/2,yt-textureHeight/2,0);
|
|
257 |
mTouchPoint.set(xt,yt,0);
|
|
260 | 258 |
break; |
261 | 259 |
} |
262 | 260 |
} |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
65 | 65 |
{ |
66 | 66 |
mView = v; |
67 | 67 |
|
68 |
Static3D pLeft = new Static3D(132, 336, 0);
|
|
69 |
Static3D pRight= new Static3D(247, 336, 0);
|
|
70 |
|
|
68 |
Static3D pLeft = new Static3D(-68, 36, 0);
|
|
69 |
Static3D pRight= new Static3D( 47, 36, 0);
|
|
70 |
|
|
71 | 71 |
// Size |
72 | 72 |
Static4D sinkRegion = new Static4D(0,0,0,60); |
73 | 73 |
|
... | ... | |
98 | 98 |
diR.add(v1); |
99 | 99 |
|
100 | 100 |
// Lower Movement |
101 |
Static3D pHips = new Static3D(216,95,0);
|
|
101 |
Static3D pHips = new Static3D( 16,-205,0);
|
|
102 | 102 |
Static4D HipsRegion = new Static4D(0,0,0,120); |
103 | 103 |
Dynamic1D diHips = new Dynamic1D(1500,0.0f); |
104 | 104 |
|
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
75 | 75 |
|
76 | 76 |
private boolean addNewBubble() |
77 | 77 |
{ |
78 |
int radius = (int)(( 0.10f + 0.70f*mRnd.nextFloat())*bmpWidth); // pop up a bubble of size (radius,height)
|
|
79 |
int height = (int)((-0.10f + 0.20f*mRnd.nextFloat())*bmpWidth); //
|
|
80 |
int pointx = mRnd.nextInt( (int)(0.8f*bmpWidth ))+ (int)(0.1f*bmpWidth ); // at a random place on the bitmap (but not near the edge)
|
|
81 |
int pointy = mRnd.nextInt( (int)(0.8f*bmpHeight))+ (int)(0.1f*bmpHeight); //
|
|
82 |
int duration = 1000 + mRnd.nextInt(3000); // for anytime from 1 to 4 seconds
|
|
78 |
int radius = (int)(( 0.10f + 0.70f*mRnd.nextFloat())*bmpWidth); // pop up a bubble of size (radius,height) |
|
79 |
int height = (int)((-0.10f + 0.20f*mRnd.nextFloat())*bmpWidth); //
|
|
80 |
int pointx = (int)(0.8f * bmpWidth * (mRnd.nextFloat()-0.5f)); // at a random place on the bitmap (but not near the edge)
|
|
81 |
int pointy = (int)(0.8f * bmpHeight* (mRnd.nextFloat()-0.5f)); //
|
|
82 |
int duration = 1000 + mRnd.nextInt(3000); // for anytime from 1 to 4 seconds |
|
83 | 83 |
|
84 | 84 |
Dynamic3D dDistort = new Dynamic3D(duration,1.0f); |
85 | 85 |
dDistort.add(new Static3D(0,0, 0)); |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
51 | 51 |
private MeshRectangles mMesh; |
52 | 52 |
private DistortedScreen mScreen; |
53 | 53 |
private Static3D mScale; |
54 |
private Static3D mCenterLeft, mCenterRight; |
|
55 | 54 |
|
56 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 56 |
|
... | ... | |
59 | 58 |
{ |
60 | 59 |
mView = v; |
61 | 60 |
|
62 |
// two points, centers of the Distort effect |
|
63 |
// the left and right tip of the mouth |
|
64 |
// (0,0,0) for now because we don't know the size of the bitmap yet. |
|
65 |
mCenterLeft = new Static3D(0,0,0); |
|
66 |
mCenterRight = new Static3D(0,0,0); |
|
61 |
// MonaLisa bitmap is 320x366, this is thus (90,108) pixels from the lower-left corner |
|
62 |
Static3D centerLeft = new Static3D( 90-320/2, 108-366/2,0); |
|
63 |
// (176,111) from the lower left |
|
64 |
Static3D centerRight = new Static3D(176-320/2, 111-366/2,0); |
|
67 | 65 |
|
68 | 66 |
// two regions defining the areas affected by the Distort effect |
69 | 67 |
Static4D rLeft = new Static4D(-10, 10, 0, 25); |
... | ... | |
85 | 83 |
dRight.add( new Static3D( 20, 10, 0) ); |
86 | 84 |
|
87 | 85 |
mEffects = new DistortedEffects(); |
88 |
mEffects.apply( new VertexEffectDistort(dLeft , mCenterLeft , rLeft ) );
|
|
89 |
mEffects.apply( new VertexEffectDistort(dRight, mCenterRight, rRight) );
|
|
86 |
mEffects.apply( new VertexEffectDistort(dLeft , centerLeft , rLeft ) );
|
|
87 |
mEffects.apply( new VertexEffectDistort(dRight, centerRight, rRight) );
|
|
90 | 88 |
|
91 | 89 |
mScale= new Static3D(1,1,1); |
92 | 90 |
mEffects.apply(new MatrixEffectScale(mScale)); |
... | ... | |
136 | 134 |
int bmpHeight = bitmap.getHeight(); |
137 | 135 |
int bmpWidth = bitmap.getWidth(); |
138 | 136 |
|
139 |
// Now we know the size of the bitmap, we can set the centers of effects |
|
140 |
// to (90,108) from the lower-left corner (CenterLeft) and (176,111) from the corner. |
|
141 |
mCenterLeft .set( 90 - bmpWidth/2, 108 - bmpHeight/2, 0); |
|
142 |
mCenterRight.set(176 - bmpWidth/2, 111 - bmpHeight/2, 0); |
|
143 |
|
|
144 | 137 |
// We could have gotten here after the activity went to the background |
145 | 138 |
// for a brief amount of time; in this case mTexture is already created. |
146 | 139 |
// Do not leak memory by creating it the second time around. |
Also available in: Unified diff
Moving the Vertex and Fragment centers of effect to the center of the Mesh.