Revision 7589635e
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.EffectTypes; |
31 |
import org.distorted.library.type.Interpolator2D;
|
|
31 |
import org.distorted.library.type.Dynamic2D;
|
|
32 | 32 |
import org.distorted.library.Distorted; |
33 | 33 |
import org.distorted.library.DistortedBitmap; |
34 |
import org.distorted.library.type.Float2D; |
|
35 |
import org.distorted.library.type.Float4D; |
|
34 |
import org.distorted.library.type.Static2D; |
|
35 |
import org.distorted.library.type.Static3D; |
|
36 |
import org.distorted.library.type.Static4D; |
|
36 | 37 |
|
37 | 38 |
import android.graphics.Bitmap; |
38 | 39 |
import android.graphics.BitmapFactory; |
... | ... | |
45 | 46 |
{ |
46 | 47 |
private GLSurfaceView mView; |
47 | 48 |
private DistortedBitmap mBean; |
48 |
private Float2D pLeft, pRight;
|
|
49 |
private Interpolator2D iLeft, iRight;
|
|
50 |
private Float4D rLeft, rRight;
|
|
49 |
private Static2D pLeft, pRight;
|
|
50 |
private Dynamic2D iLeft, iRight;
|
|
51 |
private Static4D rLeft, rRight;
|
|
51 | 52 |
private int bmpHeight, bmpWidth; |
52 | 53 |
|
53 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
56 | 57 |
{ |
57 | 58 |
mView = v; |
58 | 59 |
|
59 |
pLeft = new Float2D(100, 199);
|
|
60 |
pRight= new Float2D(230, 150);
|
|
60 |
pLeft = new Static2D(100, 199);
|
|
61 |
pRight= new Static2D(230, 150);
|
|
61 | 62 |
|
62 |
rLeft = new Float4D(-9,-31,35,35);
|
|
63 |
rRight= new Float4D(-9,-31,35,35);
|
|
63 |
rLeft = new Static4D(-9,-31,35,35);
|
|
64 |
rRight= new Static4D(-9,-31,35,35);
|
|
64 | 65 |
|
65 |
iLeft = new Interpolator2D();
|
|
66 |
iRight= new Interpolator2D();
|
|
66 |
iLeft = new Dynamic2D();
|
|
67 |
iRight= new Dynamic2D();
|
|
67 | 68 |
|
68 | 69 |
iLeft.setCount(0.0f); |
69 | 70 |
iRight.setCount(0.0f); |
70 | 71 |
iLeft.setDuration(1500); |
71 | 72 |
iRight.setDuration(1500); |
72 | 73 |
|
73 |
Float2D p1 = new Float2D(0,0);
|
|
74 |
Float2D p2 = new Float2D(-10,-34);
|
|
74 |
Static2D p1 = new Static2D(0,0);
|
|
75 |
Static2D p2 = new Static2D(-10,-34);
|
|
75 | 76 |
|
76 | 77 |
iLeft.add(p1); |
77 | 78 |
iLeft.add(p1); |
... | ... | |
107 | 108 |
if( bmpHeight/bmpWidth > height/width ) |
108 | 109 |
{ |
109 | 110 |
int w = (height*bmpWidth)/bmpHeight; |
110 |
mBean.move((width-w)/2 ,0, 0); |
|
111 |
mBean.scale((float)height/bmpHeight); |
|
111 |
float factor = (float)height/bmpHeight; |
|
112 |
|
|
113 |
mBean.move( new Static3D((width-w)/2,0,0) ); |
|
114 |
mBean.scale( new Static3D(factor,factor,factor) ); |
|
112 | 115 |
} |
113 | 116 |
else |
114 | 117 |
{ |
115 | 118 |
int h = (width*bmpHeight)/bmpWidth; |
116 |
mBean.move(0 ,(height-h)/2, 0); |
|
117 |
mBean.scale((float)width/bmpWidth); |
|
119 |
float factor = (float)width/bmpWidth; |
|
120 |
|
|
121 |
mBean.move( new Static3D(0,(height-h)/2,0) ); |
|
122 |
mBean.scale( new Static3D(factor,factor,factor) ); |
|
118 | 123 |
} |
119 | 124 |
|
120 | 125 |
Distorted.onSurfaceChanged(width, height); |
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.DistortedBitmap; |
32 | 32 |
import org.distorted.library.EffectTypes; |
33 |
import org.distorted.library.type.Float1D;
|
|
34 |
import org.distorted.library.type.Float2D;
|
|
35 |
import org.distorted.library.type.Float3D;
|
|
36 |
import org.distorted.library.type.Float4D;
|
|
37 |
import org.distorted.library.type.Interpolator1D;
|
|
38 |
import org.distorted.library.type.Interpolator2D;
|
|
33 |
import org.distorted.library.type.Static1D;
|
|
34 |
import org.distorted.library.type.Static2D;
|
|
35 |
import org.distorted.library.type.Static3D;
|
|
36 |
import org.distorted.library.type.Static4D;
|
|
37 |
import org.distorted.library.type.Dynamic1D;
|
|
38 |
import org.distorted.library.type.Dynamic2D;
|
|
39 | 39 |
|
40 | 40 |
import android.app.AlertDialog; |
41 | 41 |
import android.content.Context; |
... | ... | |
85 | 85 |
if( bmpHeight/bmpWidth > height/width ) |
86 | 86 |
{ |
87 | 87 |
int w = (height*bmpWidth)/bmpHeight; |
88 |
mSuccess.move((width-w)/2 ,0, 0); |
|
89 |
mSuccess.scale((float)height/bmpHeight); |
|
88 |
float factor = (float)height/bmpHeight; |
|
89 |
|
|
90 |
mSuccess.move( new Static3D((width-w)/2,0,0) ); |
|
91 |
mSuccess.scale( new Static3D(factor,factor,factor) ); |
|
90 | 92 |
} |
91 | 93 |
else |
92 | 94 |
{ |
93 | 95 |
int h = (width*bmpHeight)/bmpWidth; |
94 |
mSuccess.move(0 ,(height-h)/2, 0); |
|
95 |
mSuccess.scale((float)width/bmpWidth); |
|
96 |
float factor = (float)width/bmpWidth; |
|
97 |
|
|
98 |
mSuccess.move( new Static3D(0,(height-h)/2,0) ); |
|
99 |
mSuccess.scale( new Static3D(factor,factor,factor) ); |
|
96 | 100 |
} |
97 | 101 |
|
98 | 102 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
128 | 132 |
// |
129 | 133 |
// Even if adding some of the Effects fails, the App will still start - you just won't see |
130 | 134 |
// the effects that failed to add. |
131 |
Float2D pDown = new Float2D(bmpWidth/2, 0);
|
|
132 |
Float3D vDown = new Float3D( 0,-bmpHeight,0);
|
|
133 |
Float4D mRegion = new Float4D( 0, 0, 40 ,40 );
|
|
135 |
Static2D pDown = new Static2D(bmpWidth/2, 0);
|
|
136 |
Static3D vDown = new Static3D( 0,-bmpHeight,0);
|
|
137 |
Static4D mRegion = new Static4D( 0, 0, 40 ,40 );
|
|
134 | 138 |
|
135 |
Interpolator2D mPoint = new Interpolator2D();
|
|
139 |
Dynamic2D mPoint = new Dynamic2D();
|
|
136 | 140 |
mPoint.setCount(0.0f); |
137 | 141 |
mPoint.setDuration(2000); |
138 |
mPoint.add(new Float2D( 0, bmpHeight/2));
|
|
139 |
mPoint.add(new Float2D( bmpWidth, bmpHeight/2));
|
|
142 |
mPoint.add(new Static2D( 0, bmpHeight/2));
|
|
143 |
mPoint.add(new Static2D( bmpWidth, bmpHeight/2));
|
|
140 | 144 |
|
141 | 145 |
mSuccess.swirl( 30, mRegion, mPoint ); |
142 | 146 |
mSuccess.deform(vDown, pDown, 2000, 0.0f); |
143 | 147 |
|
144 | 148 |
// Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1. |
145 |
Float3D color = new Float3D(1,0,0);
|
|
146 |
Interpolator1D inter = new Interpolator1D();
|
|
149 |
Static3D color = new Static3D(1,0,0);
|
|
150 |
Dynamic1D inter = new Dynamic1D();
|
|
147 | 151 |
inter.setCount(0.0f); |
148 | 152 |
inter.setDuration(2000); |
149 |
inter.add(new Float1D(0));
|
|
150 |
inter.add(new Float1D(1));
|
|
153 |
inter.add(new Static1D(0));
|
|
154 |
inter.add(new Static1D(1));
|
|
151 | 155 |
|
152 |
mSuccess.chroma(inter, color, null, new Float2D(0,0) );
|
|
156 |
mSuccess.chroma(inter, color, null, new Static2D(0,0) );
|
|
153 | 157 |
|
154 | 158 |
try |
155 | 159 |
{ |
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.EffectTypes; |
31 |
import org.distorted.library.type.InterpolatorQuat;
|
|
31 |
import org.distorted.library.type.DynamicQuat;
|
|
32 | 32 |
import org.distorted.library.DistortedCubes; |
33 |
import org.distorted.library.type.Float4D;
|
|
34 |
import org.distorted.library.type.Float3D;
|
|
33 |
import org.distorted.library.type.Static4D;
|
|
34 |
import org.distorted.library.type.Static3D;
|
|
35 | 35 |
import org.distorted.library.Distorted; |
36 | 36 |
|
37 | 37 |
import android.graphics.Bitmap; |
... | ... | |
49 | 49 |
|
50 | 50 |
private GLSurfaceView mView; |
51 | 51 |
private DistortedCubes mCubes; |
52 |
private InterpolatorQuat mQuatInt1, mQuatInt2;
|
|
52 |
private DynamicQuat mQuatInt1, mQuatInt2;
|
|
53 | 53 |
|
54 |
Float4D mQuat1, mQuat2;
|
|
54 |
Static4D mQuat1, mQuat2;
|
|
55 | 55 |
int mScreenMin; |
56 | 56 |
|
57 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
67 | 67 |
|
68 | 68 |
mCubes = new DistortedCubes( mCols, shape, SIZE); |
69 | 69 |
|
70 |
mQuat1 = new Float4D(0,0,0,1); // unity
|
|
71 |
mQuat2 = new Float4D(0,0,0,1); // quaternions
|
|
70 |
mQuat1 = new Static4D(0,0,0,1); // unity
|
|
71 |
mQuat2 = new Static4D(0,0,0,1); // quaternions
|
|
72 | 72 |
|
73 |
mQuatInt1 = new InterpolatorQuat();
|
|
74 |
mQuatInt2 = new InterpolatorQuat();
|
|
73 |
mQuatInt1 = new DynamicQuat();
|
|
74 |
mQuatInt2 = new DynamicQuat();
|
|
75 | 75 |
mQuatInt1.setDuration(0); |
76 | 76 |
mQuatInt2.setDuration(0); |
77 | 77 |
mQuatInt1.setCount(0.5f); |
... | ... | |
102 | 102 |
if( mRows/mCols > height/width ) |
103 | 103 |
{ |
104 | 104 |
int w = (height*mRows)/mCols; |
105 |
mCubes.move((width-w)/2 ,0, 0); |
|
106 |
mCubes.scale((float)height/(mRows*SIZE)); |
|
105 |
float factor = (float)height/(mRows*SIZE); |
|
106 |
|
|
107 |
mCubes.move( new Static3D((width-w)/2,0,0) ); |
|
108 |
mCubes.scale( new Static3D(factor,factor,factor) ); |
|
107 | 109 |
} |
108 | 110 |
else |
109 | 111 |
{ |
110 | 112 |
int h = (width*mRows)/mCols; |
111 |
mCubes.move(0 ,(height-h)/2, 0); |
|
112 |
mCubes.scale((float)width/(mCols*SIZE)); |
|
113 |
float factor = (float)width/(mCols*SIZE); |
|
114 |
|
|
115 |
mCubes.move( new Static3D(0,(height-h)/2,0) ); |
|
116 |
mCubes.scale( new Static3D(factor,factor,factor) ); |
|
113 | 117 |
} |
114 | 118 |
|
115 |
Float3D center = new Float3D(mCols*SIZE/2,mRows*SIZE/2, 0);
|
|
119 |
Static3D center = new Static3D(mCols*SIZE/2,mRows*SIZE/2, 0);
|
|
116 | 120 |
|
117 | 121 |
mCubes.quaternion(center, mQuatInt1); |
118 | 122 |
mCubes.quaternion(center, mQuatInt2); |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.Distorted; |
26 | 26 |
import org.distorted.library.DistortedBitmap; |
27 | 27 |
import org.distorted.library.EffectTypes; |
28 |
import org.distorted.library.type.Interpolator2D;
|
|
29 |
import org.distorted.library.type.Float3D;
|
|
30 |
import org.distorted.library.type.Float4D;
|
|
28 |
import org.distorted.library.type.Dynamic3D;
|
|
29 |
import org.distorted.library.type.Static3D;
|
|
30 |
import org.distorted.library.type.Static4D;
|
|
31 | 31 |
|
32 | 32 |
import android.graphics.Bitmap; |
33 | 33 |
import android.graphics.Canvas; |
... | ... | |
51 | 51 |
private GLSurfaceView mView; |
52 | 52 |
private DistortedBitmap fps; |
53 | 53 |
private DistortedBitmap stretch; |
54 |
private Float3D touchPoint; |
|
55 |
private static Interpolator2D di; |
|
56 |
private static Float3D[] v; |
|
57 |
private static Float4D dr; |
|
54 |
private Static3D touchPoint; |
|
55 |
private static Dynamic3D mReleasedDynamic; |
|
56 |
private static Dynamic3D mMovingDynamic; |
|
57 |
private static Static3D[] v; |
|
58 |
private static Static4D dr; |
|
58 | 59 |
private Canvas fpsCanvas; |
59 | 60 |
private Bitmap fpsBitmap, stretchBitmap; |
60 | 61 |
private int scrHeight, scrWidth; |
... | ... | |
75 | 76 |
{ |
76 | 77 |
mView = view; |
77 | 78 |
|
78 |
dr = new Float4D(0,0,0,0);
|
|
79 |
dr = new Static4D(0,0,0,0);
|
|
79 | 80 |
|
80 |
di = new Interpolator2D(); |
|
81 |
di.setMode(Interpolator2D.MODE_PATH); |
|
82 |
di.setCount(0.5f); |
|
83 |
di.setDuration(NUM_VECTORS*500); |
|
84 |
|
|
85 |
v = new Float3D[NUM_VECTORS]; |
|
86 |
|
|
81 |
mReleasedDynamic = new Dynamic3D(); |
|
82 |
mReleasedDynamic.setMode(Dynamic3D.MODE_PATH); |
|
83 |
mReleasedDynamic.setCount(0.5f); |
|
84 |
mReleasedDynamic.setDuration(NUM_VECTORS*500); |
|
85 |
|
|
86 |
mMovingDynamic = new Dynamic3D(); |
|
87 |
mMovingDynamic.setMode(Dynamic3D.MODE_PATH); |
|
88 |
mMovingDynamic.setCount(0.5f); |
|
89 |
mMovingDynamic.setDuration(0); |
|
90 |
|
|
91 |
v = new Static3D[NUM_VECTORS]; |
|
92 |
|
|
87 | 93 |
for(int i=0; i<NUM_VECTORS; i++) |
88 | 94 |
{ |
89 |
v[i] = new Float3D(0,0,0);
|
|
90 |
di.add(v[i]);
|
|
95 |
v[i] = new Static3D(0,0,0);
|
|
96 |
mReleasedDynamic.add(v[i]);
|
|
91 | 97 |
} |
92 |
|
|
98 |
|
|
99 |
mMovingDynamic.add(v[0]); |
|
100 |
|
|
93 | 101 |
durations = new long[NUMFRAMES+1]; |
94 | 102 |
currDuration = 0; |
95 | 103 |
|
... | ... | |
154 | 162 |
if( bitmapCreated==false ) |
155 | 163 |
{ |
156 | 164 |
createBitmap(scrWidth/2,scrHeight/2); |
157 |
stretch.move(scrWidth/4,scrHeight/4,0);
|
|
158 |
fps.move(5,5,0);
|
|
165 |
stretch.move( new Static3D(scrWidth/4,scrHeight/4,0) );
|
|
166 |
fps.move( new Static3D(5,5,0) );
|
|
159 | 167 |
bitmapCreated=true; |
160 | 168 |
} |
161 | 169 |
else |
... | ... | |
208 | 216 |
stretchCanvas.drawRect( 0, h *i/NUMLINES -1, w , h*i/NUMLINES + 1, mPaint); |
209 | 217 |
} |
210 | 218 |
|
211 |
touchPoint= new Float3D(0,0,0);
|
|
219 |
touchPoint= new Static3D(0,0,0);
|
|
212 | 220 |
|
213 | 221 |
fps = new DistortedBitmap( fpsW, fpsH, 2); |
214 | 222 |
fpsBitmap = Bitmap.createBitmap(fpsW,fpsH, Bitmap.Config.ARGB_8888); |
... | ... | |
244 | 252 |
break; |
245 | 253 |
case MODE_DEFORM : stretch.deform( v[0], touchPoint); |
246 | 254 |
break; |
247 |
case MODE_SHEAR : shearID = stretch.shear(touchPoint,v[0]);
|
|
255 |
case MODE_SHEAR : shearID = stretch.shear(touchPoint, mMovingDynamic);
|
|
248 | 256 |
break; |
249 | 257 |
} |
250 | 258 |
} |
... | ... | |
283 | 291 |
|
284 | 292 |
switch(mMode) |
285 | 293 |
{ |
286 |
case MODE_DISTORT: stretch.distort(di, dr, touchPoint);
|
|
294 |
case MODE_DISTORT: stretch.distort( mReleasedDynamic, dr, touchPoint);
|
|
287 | 295 |
break; |
288 |
case MODE_DEFORM : stretch.deform( di, touchPoint);
|
|
296 |
case MODE_DEFORM : stretch.deform( mReleasedDynamic, touchPoint);
|
|
289 | 297 |
break; |
290 |
case MODE_SHEAR : shearID = stretch.shear(touchPoint,di);
|
|
298 |
case MODE_SHEAR : shearID = stretch.shear(touchPoint,mReleasedDynamic);
|
|
291 | 299 |
break; |
292 | 300 |
} |
293 | 301 |
} |
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.DistortedBitmap; |
32 | 32 |
import org.distorted.library.EffectTypes; |
33 |
import org.distorted.library.type.Float2D; |
|
34 |
import org.distorted.library.type.Float4D; |
|
35 |
import org.distorted.library.type.Interpolator2D; |
|
33 |
import org.distorted.library.type.Dynamic2D; |
|
34 |
import org.distorted.library.type.Static2D; |
|
35 |
import org.distorted.library.type.Static3D; |
|
36 |
import org.distorted.library.type.Static4D; |
|
36 | 37 |
|
37 | 38 |
import android.graphics.Bitmap; |
38 | 39 |
import android.graphics.BitmapFactory; |
... | ... | |
47 | 48 |
|
48 | 49 |
private GLSurfaceView mView; |
49 | 50 |
private DistortedBitmap[] bmp; |
50 |
private Float2D point;
|
|
51 |
private Interpolator2D di;
|
|
52 |
private Float2D[] vec;
|
|
51 |
private Static2D point;
|
|
52 |
private Dynamic2D di;
|
|
53 |
private Static2D[] vec;
|
|
53 | 54 |
private int bmpHeight, bmpWidth; |
54 | 55 |
|
55 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
59 | 60 |
mView = v; |
60 | 61 |
|
61 | 62 |
// create shared effects - enlarge the nose and keep moving the whole bitmap left and right. |
62 |
di = new Interpolator2D();
|
|
63 |
di = new Dynamic2D();
|
|
63 | 64 |
di.setCount(0.0f); |
64 | 65 |
di.setDuration(3000); |
65 |
vec = new Float2D[2];
|
|
66 |
vec[0] = new Float2D( 25,0);
|
|
67 |
vec[1] = new Float2D(-25,0);
|
|
66 |
vec = new Static2D[2];
|
|
67 |
vec[0] = new Static2D( 25,0);
|
|
68 |
vec[1] = new Static2D(-25,0);
|
|
68 | 69 |
di.add(vec[0]); |
69 | 70 |
di.add(vec[1]); |
70 |
point = new Float2D(305, 380);
|
|
71 |
point = new Static2D(305, 380);
|
|
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
117 | 118 |
if( bmpHeight/(NUM*bmpWidth) > height/width ) |
118 | 119 |
{ |
119 | 120 |
int w = (height*bmpWidth)/bmpHeight; |
120 |
|
|
121 |
float factor = (float)height/bmpHeight; |
|
122 |
Static3D scale = new Static3D(factor,factor,factor); |
|
123 |
|
|
121 | 124 |
for(int i=NUM-1; i>=0; i--) |
122 | 125 |
{ |
123 |
bmp[i].move( (width-NUM*w)/2 +i*w ,0,0);
|
|
124 |
bmp[i].scale((float)height/bmpHeight);
|
|
126 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
|
|
127 |
bmp[i].scale(scale);
|
|
125 | 128 |
} |
126 | 129 |
} |
127 | 130 |
else |
128 | 131 |
{ |
129 | 132 |
int w = width/NUM; |
130 | 133 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
131 |
|
|
134 |
float factor = (float)width/(bmpWidth*NUM); |
|
135 |
Static3D scale = new Static3D(factor,factor,factor); |
|
136 |
|
|
132 | 137 |
for(int i=NUM-1; i>=0; i--) |
133 | 138 |
{ |
134 |
bmp[i].move(i*w, (height-h)/2, 0);
|
|
135 |
bmp[i].scale((float)width/(bmpWidth*NUM));
|
|
139 |
bmp[i].move( new Static3D(i*w,(height-h)/2,0) );
|
|
140 |
bmp[i].scale(scale);
|
|
136 | 141 |
} |
137 | 142 |
} |
138 | 143 |
|
... | ... | |
160 | 165 |
bmp[1].setBitmap(bitmap1); |
161 | 166 |
bmp[2].setBitmap(bitmap2); |
162 | 167 |
|
163 |
bmp[0].sink(8.0f, new Float4D(0,0,80,80), point, 0, 0.5f);
|
|
168 |
bmp[0].sink(8.0f, new Static4D(0,0,80,80), point, 0, 0.5f);
|
|
164 | 169 |
bmp[0].distort(di,point); |
165 | 170 |
|
166 | 171 |
try |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.DistortedBitmap; |
32 | 32 |
import org.distorted.library.EffectTypes; |
33 |
import org.distorted.library.type.Float2D;
|
|
34 |
import org.distorted.library.type.Float3D;
|
|
35 |
import org.distorted.library.type.Float4D;
|
|
36 |
import org.distorted.library.type.Interpolator3D;
|
|
33 |
import org.distorted.library.type.Dynamic3D;
|
|
34 |
import org.distorted.library.type.Static2D;
|
|
35 |
import org.distorted.library.type.Static3D;
|
|
36 |
import org.distorted.library.type.Static4D;
|
|
37 | 37 |
|
38 | 38 |
import android.graphics.Bitmap; |
39 | 39 |
import android.graphics.BitmapFactory; |
... | ... | |
48 | 48 |
|
49 | 49 |
private GLSurfaceView mView; |
50 | 50 |
private DistortedBitmap[] bmp; |
51 |
private Float2D pLeft, pRight, pNose1;
|
|
52 |
private Float4D RegionEye;
|
|
53 |
private Interpolator3D mDI;
|
|
54 |
private Float3D[] vec;
|
|
51 |
private Static2D pLeft, pRight, pNose1;
|
|
52 |
private Static4D RegionEye;
|
|
53 |
private Dynamic3D mDI;
|
|
54 |
private Static3D[] vec;
|
|
55 | 55 |
private int bmpHeight, bmpWidth; |
56 | 56 |
|
57 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
61 | 61 |
mView = v; |
62 | 62 |
|
63 | 63 |
// bmp[0] effects |
64 |
pLeft = new Float2D(214, 206);
|
|
65 |
pRight= new Float2D(390, 212);
|
|
66 |
RegionEye = new Float4D(0,0,60,60);
|
|
64 |
pLeft = new Static2D(214, 206);
|
|
65 |
pRight= new Static2D(390, 212);
|
|
66 |
RegionEye = new Static4D(0,0,60,60);
|
|
67 | 67 |
|
68 | 68 |
// bmp[1] effects |
69 |
mDI = new Interpolator3D();
|
|
69 |
mDI = new Dynamic3D();
|
|
70 | 70 |
mDI.setCount(0.0f); |
71 | 71 |
mDI.setDuration(1000); |
72 |
vec = new Float3D[2];
|
|
73 |
vec[0] = new Float3D( 50,0,0);
|
|
74 |
vec[1] = new Float3D(-50,0,0);
|
|
72 |
vec = new Static3D[2];
|
|
73 |
vec[0] = new Static3D( 50,0,0);
|
|
74 |
vec[1] = new Static3D(-50,0,0);
|
|
75 | 75 |
mDI.add(vec[0]); |
76 | 76 |
mDI.add(vec[1]); |
77 |
pNose1 = new Float2D(305, 340);
|
|
77 |
pNose1 = new Static2D(305, 340);
|
|
78 | 78 |
|
79 | 79 |
// we don't need to prepare anything for bmp[2] effects |
80 | 80 |
} |
... | ... | |
103 | 103 |
if( bmpHeight/(NUM*bmpWidth) > height/width ) |
104 | 104 |
{ |
105 | 105 |
int w = (height*bmpWidth)/bmpHeight; |
106 |
|
|
106 |
float factor = (float)height/bmpHeight; |
|
107 |
Static3D scaleFactor = new Static3D(factor,factor,factor); |
|
108 |
|
|
107 | 109 |
for(int i=NUM-1; i>=0; i--) |
108 | 110 |
{ |
109 |
bmp[i].move( (width-NUM*w)/2 +i*w ,0, 0);
|
|
110 |
bmp[i].scale((float)height/bmpHeight);
|
|
111 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
|
|
112 |
bmp[i].scale(scaleFactor);
|
|
111 | 113 |
} |
112 | 114 |
} |
113 | 115 |
else |
114 | 116 |
{ |
115 | 117 |
int w = width/NUM; |
116 | 118 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
117 |
|
|
119 |
float factor = (float)width/(bmpWidth*NUM); |
|
120 |
Static3D scaleFactor = new Static3D(factor,factor,factor); |
|
121 |
|
|
118 | 122 |
for(int i=NUM-1; i>=0; i--) |
119 | 123 |
{ |
120 |
bmp[i].move(i*w, (height-h)/2, 0);
|
|
121 |
bmp[i].scale((float)width/(bmpWidth*NUM));
|
|
124 |
bmp[i].move( new Static3D(i*w, (height-h)/2, 0) );
|
|
125 |
bmp[i].scale(scaleFactor);
|
|
122 | 126 |
} |
123 | 127 |
} |
124 | 128 |
|
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import org.distorted.library.DistortedCubes; |
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Float3D; |
|
33 |
import org.distorted.library.type.Float4D; |
|
34 |
import org.distorted.library.type.Interpolator3D; |
|
35 |
import org.distorted.library.type.Interpolator4D; |
|
32 |
import org.distorted.library.type.Dynamic1D; |
|
33 |
import org.distorted.library.type.Dynamic3D; |
|
34 |
import org.distorted.library.type.Static1D; |
|
35 |
import org.distorted.library.type.Static3D; |
|
36 |
import org.distorted.library.type.Static4D; |
|
37 |
import org.distorted.library.type.Dynamic4D; |
|
36 | 38 |
import org.distorted.library.Distorted; |
37 | 39 |
|
38 | 40 |
import android.graphics.Bitmap; |
... | ... | |
51 | 53 |
|
52 | 54 |
private static int[] order; |
53 | 55 |
|
54 |
private static Interpolator3D mMoveInter, mScaleInter, mShearInter;
|
|
55 |
private static Interpolator4D mRotateInter;
|
|
56 |
|
|
57 |
private static Float3D mZeroPoint, mMovePoint, mScalePoint, mShearPoint;
|
|
58 |
private static Float4D mRotatePoint;
|
|
59 |
|
|
56 |
private static Dynamic3D mMoveInter, mScaleInter, mShearInter;
|
|
57 |
private static Dynamic4D mDynamicRotate;
|
|
58 |
|
|
59 |
private static Static3D mZeroPoint, mMovePoint, mScalePoint, mShearPoint;
|
|
60 |
private static Static4D mRotatePoint;
|
|
61 |
|
|
60 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | 63 |
|
62 | 64 |
public static void setMove(float x, float y, float z) |
... | ... | |
75 | 77 |
|
76 | 78 |
public static void setRotate(float a, float x, float y, float z) |
77 | 79 |
{ |
78 |
mRotatePoint.set(a, x, y, z);
|
|
80 |
mRotatePoint.set(a,x,y,z);
|
|
79 | 81 |
} |
80 | 82 |
|
81 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
103 | 105 |
{ |
104 | 106 |
switch(order[i]) |
105 | 107 |
{ |
106 |
case Effects3DActivity.MOVE : mCube.move(mMoveInter) ; break;
|
|
107 |
case Effects3DActivity.SCALE : mCube.scale(mScaleInter) ; break; |
|
108 |
case Effects3DActivity.ROTATE: mCube.rotate(mZeroPoint,mRotateInter); break;
|
|
109 |
case Effects3DActivity.SHEAR : mCube.shear(mZeroPoint,mShearInter) ; break; |
|
108 |
case Effects3DActivity.MOVE : mCube.move(mMoveInter) ; break;
|
|
109 |
case Effects3DActivity.SCALE : mCube.scale(mScaleInter) ; break;
|
|
110 |
case Effects3DActivity.ROTATE: mCube.rotate(mZeroPoint,mDynamicRotate); break;
|
|
111 |
case Effects3DActivity.SHEAR : mCube.shear(mZeroPoint,mShearInter) ; break;
|
|
110 | 112 |
} |
111 | 113 |
} |
112 | 114 |
} |
... | ... | |
118 | 120 |
mView = v; |
119 | 121 |
mCube = new DistortedCubes( 1, "1", SIZE); |
120 | 122 |
|
121 |
mZeroPoint = new Float3D(0,0,0);
|
|
122 |
mMovePoint = new Float3D(0,0,0);
|
|
123 |
mScalePoint = new Float3D(1,1,1);
|
|
124 |
mShearPoint = new Float3D(0,0,0);
|
|
125 |
mRotatePoint= new Float4D(1,0,0,0);
|
|
126 |
|
|
127 |
mMoveInter = new Interpolator3D();
|
|
128 |
mScaleInter = new Interpolator3D();
|
|
129 |
mShearInter = new Interpolator3D();
|
|
130 |
mRotateInter= new Interpolator4D();
|
|
131 |
|
|
123 |
mZeroPoint = new Static3D(0,0,0);
|
|
124 |
mMovePoint = new Static3D(0,0,0);
|
|
125 |
mScalePoint = new Static3D(1,1,1);
|
|
126 |
mShearPoint = new Static3D(0,0,0);
|
|
127 |
mRotatePoint = new Static4D(0,1,0,0);
|
|
128 |
|
|
129 |
mMoveInter = new Dynamic3D();
|
|
130 |
mScaleInter = new Dynamic3D();
|
|
131 |
mShearInter = new Dynamic3D();
|
|
132 |
mDynamicRotate= new Dynamic4D();
|
|
133 |
|
|
132 | 134 |
mMoveInter.add(mMovePoint); |
133 | 135 |
mScaleInter.add(mScalePoint); |
134 | 136 |
mShearInter.add(mShearPoint); |
135 |
mRotateInter.add(mRotatePoint);
|
|
137 |
mDynamicRotate.add(mRotatePoint);
|
|
136 | 138 |
} |
137 | 139 |
|
138 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.Distorted; |
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.EffectTypes; |
34 |
import org.distorted.library.type.Float2D; |
|
34 |
import org.distorted.library.type.Static2D; |
|
35 |
import org.distorted.library.type.Static3D; |
|
35 | 36 |
|
36 | 37 |
import android.graphics.Bitmap; |
37 | 38 |
import android.graphics.BitmapFactory; |
... | ... | |
74 | 75 |
if( lisaHeight/lisaWidth > height/width ) |
75 | 76 |
{ |
76 | 77 |
int w = (height*lisaWidth)/lisaHeight; |
77 |
mLisa.move((width-w)/2 ,0, 0); |
|
78 |
mLisa.scale((float)height/lisaHeight); |
|
78 |
float factor = (float)height/lisaHeight; |
|
79 |
|
|
80 |
mLisa.move( new Static3D((width-w)/2,0,0) ); |
|
81 |
mLisa.scale( new Static3D(factor,factor,factor)); |
|
79 | 82 |
} |
80 | 83 |
else |
81 | 84 |
{ |
82 | 85 |
int h = (width*lisaHeight)/lisaWidth; |
83 |
mLisa.move(0 ,(height-h)/2, 0); |
|
84 |
mLisa.scale((float)width/lisaWidth); |
|
86 |
float factor = (float)width/lisaWidth; |
|
87 |
|
|
88 |
mLisa.move( new Static3D(0,(height-h)/2,0) ); |
|
89 |
mLisa.scale( new Static3D(factor,factor,factor) ); |
|
85 | 90 |
} |
86 | 91 |
|
87 | 92 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
122 | 127 |
|
123 | 128 |
int textWidth = mText.getWidth(); |
124 | 129 |
int textHeight = mText.getHeight(); |
125 |
|
|
126 |
mText.move(lisaWidth/6 , lisaHeight/3, 0); |
|
127 |
mText.scale(lisaWidth/(1.5f*textWidth)); |
|
128 |
mText.sink(0.5f, new Float2D( textWidth/2, textHeight/2), 5000, 0.0f); |
|
130 |
|
|
131 |
float factor = lisaWidth/(1.5f*textWidth); |
|
132 |
|
|
133 |
mText.move( new Static3D(lisaWidth/6,lisaHeight/3,0) ); |
|
134 |
mText.scale( new Static3D(factor,factor,factor) ); |
|
135 |
mText.sink(0.5f, new Static2D( textWidth/2, textHeight/2), 5000, 0.0f); |
|
129 | 136 |
mLisa.macroblock(4, 10000, 0.0f); |
130 | 137 |
|
131 | 138 |
try |
src/main/java/org/distorted/examples/fov/FOVRenderer.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import org.distorted.library.Distorted; |
26 | 26 |
import org.distorted.library.DistortedBitmap; |
27 |
import org.distorted.library.type.Float2D;
|
|
28 |
import org.distorted.library.type.Float3D;
|
|
29 |
import org.distorted.library.type.Float4D;
|
|
27 |
import org.distorted.library.type.Static2D;
|
|
28 |
import org.distorted.library.type.Static3D;
|
|
29 |
import org.distorted.library.type.Static4D;
|
|
30 | 30 |
|
31 | 31 |
import android.graphics.Bitmap; |
32 | 32 |
import android.graphics.Canvas; |
... | ... | |
115 | 115 |
|
116 | 116 |
int min = w<h ? w:h; |
117 | 117 |
|
118 |
Float3D dp3D = new Float3D(0,0,min/5);
|
|
119 |
Float4D dr = new Float4D(0,0,min/5,min/5);
|
|
118 |
Static3D dp3D = new Static3D(0,0,min/5);
|
|
119 |
Static4D dr = new Static4D(0,0,min/5,min/5);
|
|
120 | 120 |
|
121 |
Float2D point1 = new Float2D( w/4, h/4);
|
|
122 |
Float2D point2 = new Float2D(3*w/4, h/4);
|
|
123 |
Float2D point3 = new Float2D( w/4, 3*h/4);
|
|
124 |
Float2D point4 = new Float2D(3*w/4, 3*h/4);
|
|
121 |
Static2D point1 = new Static2D( w/4, h/4);
|
|
122 |
Static2D point2 = new Static2D(3*w/4, h/4);
|
|
123 |
Static2D point3 = new Static2D( w/4, 3*h/4);
|
|
124 |
Static2D point4 = new Static2D(3*w/4, 3*h/4);
|
|
125 | 125 |
|
126 | 126 |
fov.distort(dp3D, dr, point1, 0, 0.5f); |
127 | 127 |
fov.distort(dp3D, dr, point2, 0, 0.5f); |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.DistortedBitmap; |
32 | 32 |
import org.distorted.library.EffectTypes; |
33 |
import org.distorted.library.type.Float1D;
|
|
34 |
import org.distorted.library.type.Float2D;
|
|
35 |
import org.distorted.library.type.Float3D;
|
|
36 |
import org.distorted.library.type.Float4D;
|
|
37 |
import org.distorted.library.type.Interpolator3D;
|
|
38 |
import org.distorted.library.type.Interpolator1D;
|
|
33 |
import org.distorted.library.type.Dynamic1D;
|
|
34 |
import org.distorted.library.type.Dynamic3D;
|
|
35 |
import org.distorted.library.type.Static1D;
|
|
36 |
import org.distorted.library.type.Static2D;
|
|
37 |
import org.distorted.library.type.Static3D;
|
|
38 |
import org.distorted.library.type.Static4D;
|
|
39 | 39 |
|
40 | 40 |
import android.graphics.Bitmap; |
41 | 41 |
import android.graphics.BitmapFactory; |
... | ... | |
48 | 48 |
{ |
49 | 49 |
private GLSurfaceView mView; |
50 | 50 |
private DistortedBitmap mGirl; |
51 |
private Float2D pLeft, pRight, pHips;
|
|
52 |
private Float4D Region, sinkRegion, HipsRegion;
|
|
53 |
private static Interpolator3D diL, diR;
|
|
54 |
private static Interpolator1D diHips, diSink;
|
|
55 |
private static Float3D v0,v1,v2,v3;
|
|
56 |
private static Float1D d0, d1, s0;
|
|
51 |
private Static2D pLeft, pRight, pHips;
|
|
52 |
private Static4D Region, sinkRegion, HipsRegion;
|
|
53 |
private static Dynamic3D diL, diR;
|
|
54 |
private static Dynamic1D diHips, diSink;
|
|
55 |
private static Static3D v0,v1,v2,v3;
|
|
56 |
private static Static1D d0, d1, s0;
|
|
57 | 57 |
|
58 | 58 |
private int bmpHeight, bmpWidth; |
59 | 59 |
|
... | ... | |
71 | 71 |
hipsSwirl = 0; |
72 | 72 |
boobsSink = 1.0f; |
73 | 73 |
|
74 |
pLeft = new Float2D(132, 264);
|
|
75 |
pRight= new Float2D(247, 264);
|
|
74 |
pLeft = new Static2D(132, 264);
|
|
75 |
pRight= new Static2D(247, 264);
|
|
76 | 76 |
|
77 | 77 |
// Make the boobs bigger |
78 |
sinkRegion = new Float4D(0,0,60,60);
|
|
78 |
sinkRegion = new Static4D(0,0,60,60);
|
|
79 | 79 |
|
80 |
s0 = new Float1D(boobsSink);
|
|
80 |
s0 = new Static1D(boobsSink);
|
|
81 | 81 |
|
82 |
diSink = new Interpolator1D();
|
|
82 |
diSink = new Dynamic1D();
|
|
83 | 83 |
diSink.setCount(0.5f); |
84 | 84 |
diSink.setDuration(0); |
85 | 85 |
diSink.add(s0); |
86 | 86 |
|
87 | 87 |
// Boobs Movement |
88 |
Region = new Float4D(0,0,45,45);
|
|
88 |
Region = new Static4D(0,0,45,45);
|
|
89 | 89 |
|
90 |
diL = new Interpolator3D();
|
|
91 |
diR = new Interpolator3D();
|
|
90 |
diL = new Dynamic3D();
|
|
91 |
diR = new Dynamic3D();
|
|
92 | 92 |
|
93 | 93 |
diL.setCount(0.0f); |
94 | 94 |
diR.setCount(0.0f); |
95 | 95 |
diL.setDuration(1000); |
96 | 96 |
diR.setDuration(1000); |
97 | 97 |
|
98 |
v0 = new Float3D( 0,-boobsSwing, 0);
|
|
99 |
v1 = new Float3D( boobsSwing, 0, 0);
|
|
100 |
v2 = new Float3D( 0, boobsSwing, 0);
|
|
101 |
v3 = new Float3D(-boobsSwing, 0, 0);
|
|
98 |
v0 = new Static3D( 0,-boobsSwing, 0);
|
|
99 |
v1 = new Static3D( boobsSwing, 0, 0);
|
|
100 |
v2 = new Static3D( 0, boobsSwing, 0);
|
|
101 |
v3 = new Static3D(-boobsSwing, 0, 0);
|
|
102 | 102 |
|
103 | 103 |
diL.add(v0); |
104 | 104 |
diL.add(v1); |
... | ... | |
111 | 111 |
diR.add(v1); |
112 | 112 |
|
113 | 113 |
// Movement of the hips |
114 |
pHips = new Float2D(216,505);
|
|
115 |
HipsRegion = new Float4D(0,0,120,120);
|
|
116 |
diHips = new Interpolator1D();
|
|
114 |
pHips = new Static2D(216,505);
|
|
115 |
HipsRegion = new Static4D(0,0,120,120);
|
|
116 |
diHips = new Dynamic1D();
|
|
117 | 117 |
|
118 |
d0 = new Float1D(-hipsSwirl);
|
|
119 |
d1 = new Float1D(+hipsSwirl);
|
|
118 |
d0 = new Static1D(-hipsSwirl);
|
|
119 |
d1 = new Static1D(+hipsSwirl);
|
|
120 | 120 |
|
121 | 121 |
diHips.add(d0); |
122 | 122 |
diHips.add(d1); |
... | ... | |
172 | 172 |
if( bmpHeight/bmpWidth > height/width ) |
173 | 173 |
{ |
174 | 174 |
int w = (height*bmpWidth)/bmpHeight; |
175 |
mGirl.move((width-w)/2 ,0, 0); |
|
176 |
mGirl.scale((float)height/bmpHeight); |
|
175 |
float factor = (float)height/bmpHeight; |
|
176 |
|
|
177 |
mGirl.move( new Static3D((width-w)/2,0,0) ); |
|
178 |
mGirl.scale( new Static3D(factor,factor,factor) ); |
|
177 | 179 |
} |
178 | 180 |
else |
179 | 181 |
{ |
180 | 182 |
int h = (width*bmpHeight)/bmpWidth; |
181 |
mGirl.move(0 ,(height-h)/2, 0); |
|
182 |
mGirl.scale((float)width/bmpWidth); |
|
183 |
float factor = (float)width/bmpWidth; |
|
184 |
|
|
185 |
mGirl.move( new Static3D(0,(height-h)/2,0) ); |
|
186 |
mGirl.scale( new Static3D(factor,factor,factor) ); |
|
183 | 187 |
} |
184 | 188 |
|
185 | 189 |
Distorted.onSurfaceChanged(width, height); |
src/main/java/org/distorted/examples/interpolator/InterpolatorActivity.java | ||
---|---|---|
20 | 20 |
package org.distorted.examples.interpolator; |
21 | 21 |
|
22 | 22 |
import org.distorted.library.Distorted; |
23 |
import org.distorted.library.type.Interpolator1D;
|
|
23 |
import org.distorted.library.type.Dynamic1D;
|
|
24 | 24 |
import org.distorted.examples.R; |
25 | 25 |
|
26 | 26 |
import android.app.Activity; |
... | ... | |
99 | 99 |
|
100 | 100 |
public void Loop(View v) |
101 | 101 |
{ |
102 |
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_LOOP);
|
|
102 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_LOOP);
|
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
/////////////////////////////////////////////////////////////////// |
106 | 106 |
|
107 | 107 |
public void Path(View v) |
108 | 108 |
{ |
109 |
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_PATH);
|
|
109 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_PATH);
|
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
/////////////////////////////////////////////////////////////////// |
113 | 113 |
|
114 | 114 |
public void Jump(View v) |
115 | 115 |
{ |
116 |
InterpolatorSurfaceView.setMode(Interpolator1D.MODE_JUMP);
|
|
116 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_JUMP);
|
|
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
/////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/interpolator/InterpolatorRenderer.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.Distorted; |
34 | 34 |
import org.distorted.library.EffectTypes; |
35 |
import org.distorted.library.type.Static3D; |
|
35 | 36 |
|
36 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 38 |
|
... | ... | |
86 | 87 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
87 | 88 |
{ |
88 | 89 |
mBackground.abortEffects(EffectTypes.MATRIX); |
89 |
mBackground.scale((float)width/texWidth,(float)height/texHeight,1);
|
|
90 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
90 | 91 |
Distorted.onSurfaceChanged(width, height); |
91 | 92 |
InterpolatorSurfaceView.setScreenSize(width,height); |
92 | 93 |
} |
src/main/java/org/distorted/examples/interpolator/InterpolatorSurfaceView.java | ||
---|---|---|
28 | 28 |
import android.graphics.Paint.Style; |
29 | 29 |
import android.graphics.Paint; |
30 | 30 |
|
31 |
import org.distorted.library.type.Interpolator1D;
|
|
32 |
import org.distorted.library.type.Interpolator2D;
|
|
33 |
import org.distorted.library.type.Interpolator3D;
|
|
34 |
import org.distorted.library.type.Float1D;
|
|
35 |
import org.distorted.library.type.Float2D;
|
|
36 |
import org.distorted.library.type.Float3D;
|
|
31 |
import org.distorted.library.type.Dynamic1D;
|
|
32 |
import org.distorted.library.type.Dynamic2D;
|
|
33 |
import org.distorted.library.type.Dynamic3D;
|
|
34 |
import org.distorted.library.type.Static1D;
|
|
35 |
import org.distorted.library.type.Static2D;
|
|
36 |
import org.distorted.library.type.Static3D;
|
|
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////// |
39 | 39 |
|
... | ... | |
51 | 51 |
private static int xDown,yDown; |
52 | 52 |
private static int mScrW, mScrH; |
53 | 53 |
|
54 |
private static Interpolator1D di1D;
|
|
55 |
private static Interpolator2D di2D;
|
|
56 |
private static Interpolator3D di3D;
|
|
54 |
private static Dynamic1D di1D;
|
|
55 |
private static Dynamic2D di2D;
|
|
56 |
private static Dynamic3D di3D;
|
|
57 | 57 |
|
58 | 58 |
private static Paint mPaint; |
59 | 59 |
private static int moving; |
... | ... | |
65 | 65 |
|
66 | 66 |
private static int currentDim = DIM_2D; |
67 | 67 |
|
68 |
private static Float1D p1D;
|
|
69 |
private static Float2D p2D;
|
|
70 |
private static Float3D p3D;
|
|
68 |
private static Static1D p1D;
|
|
69 |
private static Static2D p2D;
|
|
70 |
private static Static3D p3D;
|
|
71 | 71 |
|
72 | 72 |
private static float[] mDrawCoord = new float[3]; |
73 | 73 |
|
... | ... | |
86 | 86 |
mPosition = 0; |
87 | 87 |
mNoise = 0.0f; |
88 | 88 |
|
89 |
di1D = new Interpolator1D();
|
|
89 |
di1D = new Dynamic1D();
|
|
90 | 90 |
di1D.setDuration(mDuration); |
91 | 91 |
di1D.setNoise(mNoise); |
92 | 92 |
|
93 |
di2D = new Interpolator2D();
|
|
93 |
di2D = new Dynamic2D();
|
|
94 | 94 |
di2D.setDuration(mDuration); |
95 | 95 |
di2D.setNoise(mNoise); |
96 | 96 |
|
97 |
di3D = new Interpolator3D();
|
|
97 |
di3D = new Dynamic3D();
|
|
98 | 98 |
di3D.setDuration(mDuration); |
99 | 99 |
di3D.setNoise(mNoise); |
100 | 100 |
|
... | ... | |
325 | 325 |
synchronized(lock) |
326 | 326 |
{ |
327 | 327 |
if( len>=MAX_VECTORS ) di1D.removeAll(); |
328 |
di1D.add(new Float1D(xDown));
|
|
328 |
di1D.add(new Static1D(xDown));
|
|
329 | 329 |
} |
330 | 330 |
} |
331 | 331 |
break; |
... | ... | |
348 | 348 |
synchronized(lock) |
349 | 349 |
{ |
350 | 350 |
if( len>=MAX_VECTORS ) di2D.removeAll(); |
351 |
di2D.add(new Float2D(xDown,yDown));
|
|
351 |
di2D.add(new Static2D(xDown,yDown));
|
|
352 | 352 |
} |
353 | 353 |
} |
354 | 354 |
break; |
... | ... | |
386 | 386 |
|
387 | 387 |
if( currentDim==DIM_3DXY ) |
388 | 388 |
{ |
389 |
di3D.add(new Float3D(xDown,yDown,InterpolatorRenderer.BHEI/2));
|
|
389 |
di3D.add(new Static3D(xDown,yDown,InterpolatorRenderer.BHEI/2));
|
|
390 | 390 |
} |
391 | 391 |
if( currentDim==DIM_3DXZ ) |
392 | 392 |
{ |
393 |
di3D.add(new Float3D(xDown,InterpolatorRenderer.BHEI/2,yDown));
|
|
393 |
di3D.add(new Static3D(xDown,InterpolatorRenderer.BHEI/2,yDown));
|
|
394 | 394 |
} |
395 | 395 |
} |
396 | 396 |
} |
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.Distorted; |
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.EffectTypes; |
34 |
import org.distorted.library.type.Float2D;
|
|
35 |
import org.distorted.library.type.Float3D;
|
|
36 |
import org.distorted.library.type.Float4D;
|
|
34 |
import org.distorted.library.type.Static2D;
|
|
35 |
import org.distorted.library.type.Static3D;
|
|
36 |
import org.distorted.library.type.Static4D;
|
|
37 | 37 |
import org.distorted.library.message.EffectListener; |
38 | 38 |
import org.distorted.library.message.EffectMessage; |
39 | 39 |
|
... | ... | |
71 | 71 |
int pointy = mRnd.nextInt( (int)(0.8f*bmpHeight))+ (int)(0.1f*bmpHeight); // |
72 | 72 |
int duration = 1000 + mRnd.nextInt(3000); // for anytime from 3 to 4 seconds |
73 | 73 |
|
74 |
Float3D dp3d = new Float3D(0,0,height);
|
|
75 |
Float2D dp2d = new Float2D(pointx,pointy);
|
|
76 |
Float4D dr = new Float4D(0,0,radius,radius);
|
|
74 |
Static3D dp3d = new Static3D(0,0,height);
|
|
75 |
Static2D dp2d = new Static2D(pointx,pointy);
|
|
76 |
Static4D dr = new Static4D(0,0,radius,radius);
|
|
77 | 77 |
|
78 | 78 |
return water.distort(dp3d, dr, dp2d, duration, 1.0f); |
79 | 79 |
} |
... | ... | |
109 | 109 |
if( bmpHeight/bmpWidth > height/width ) |
110 | 110 |
{ |
111 | 111 |
int w = (height*bmpWidth)/bmpHeight; |
112 |
water.move((width-w)/2 ,0, 0); |
|
113 |
water.scale((float)height/bmpHeight); |
|
112 |
float factor = (float)height/bmpHeight; |
|
113 |
|
|
114 |
water.move( new Static3D((width-w)/2,0,0) ); |
|
115 |
water.scale( new Static3D(factor,factor,factor) ); |
|
114 | 116 |
} |
115 | 117 |
else |
116 | 118 |
{ |
117 | 119 |
int h = (width*bmpHeight)/bmpWidth; |
118 |
water.move(0 ,(height-h)/2, 0); |
|
119 |
water.scale((float)width/bmpWidth); |
|
120 |
float factor = (float)width/bmpWidth; |
|
121 |
|
|
122 |
water.move( new Static3D(0,(height-h)/2,0) ); |
|
123 |
water.scale( new Static3D(factor,factor,factor) ); |
|
120 | 124 |
} |
121 | 125 |
|
122 | 126 |
Distorted.onSurfaceChanged(width, height); |
src/main/java/org/distorted/examples/macroblock/MacroblockRenderer.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.Distorted; |
30 | 30 |
import org.distorted.library.DistortedBitmap; |
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Interpolator1D;
|
|
33 |
import org.distorted.library.type.Interpolator3D;
|
|
34 |
import org.distorted.library.type.Float1D;
|
|
35 |
import org.distorted.library.type.Float2D;
|
|
36 |
import org.distorted.library.type.Float3D;
|
|
37 |
import org.distorted.library.type.Float4D;
|
|
32 |
import org.distorted.library.type.Dynamic1D;
|
|
33 |
import org.distorted.library.type.Dynamic3D;
|
|
34 |
import org.distorted.library.type.Static1D;
|
|
35 |
import org.distorted.library.type.Static2D;
|
|
36 |
import org.distorted.library.type.Static3D;
|
|
37 |
import org.distorted.library.type.Static4D;
|
|
38 | 38 |
|
39 | 39 |
import android.graphics.Bitmap; |
40 | 40 |
import android.graphics.BitmapFactory; |
... | ... | |
47 | 47 |
{ |
48 | 48 |
private GLSurfaceView mView; |
49 | 49 |
private DistortedBitmap macroblock; |
50 |
private Float4D Region;
|
|
50 |
private Static4D Region;
|
|
51 | 51 |
private int bmpHeight, bmpWidth; |
52 |
private Float2D traP, macP;
|
|
52 |
private Static2D traP, macP;
|
|
53 | 53 |
|
54 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 55 |
|
... | ... | |
57 | 57 |
{ |
58 | 58 |
mView = v; |
59 | 59 |
|
60 |
Region = new Float4D(0,0,100,100);
|
|
61 |
macP = new Float2D(530,200);
|
|
62 |
traP = new Float2D(230,200);
|
|
60 |
Region = new Static4D(0,0,100,100);
|
|
61 |
macP = new Static2D(530,200);
|
|
62 |
traP = new Static2D(230,200);
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
115 | 115 |
{ |
116 | 116 |
int duration = 10000; |
117 | 117 |
|
118 |
Interpolator3D diMove = new Interpolator3D();
|
|
118 |
Dynamic3D diMove = new Dynamic3D();
|
|
119 | 119 |
diMove.setCount(0.0f); |
120 | 120 |
diMove.setDuration(duration); |
121 |
diMove.add(new Float3D(width-bmpWidth,height-bmpHeight,0));
|
|
122 |
diMove.add(new Float3D(0,0,0));
|
|
121 |
diMove.add(new Static3D(width-bmpWidth,height-bmpHeight,0));
|
|
122 |
diMove.add(new Static3D(0,0,0));
|
|
123 | 123 |
|
124 |
Interpolator3D diScale = new Interpolator3D();
|
|
124 |
Dynamic3D diScale = new Dynamic3D();
|
|
125 | 125 |
diScale.setCount(0.0f); |
126 | 126 |
diScale.setDuration(duration); |
127 |
diScale.add(new Float3D(1,1,1));
|
|
128 |
diScale.add(new Float3D(0.33f,0.33f,1));
|
|
127 |
diScale.add(new Static3D(1,1,1));
|
|
128 |
diScale.add(new Static3D(0.33f,0.33f,1));
|
|
129 | 129 |
|
130 |
Interpolator1D diRotate = new Interpolator1D();
|
|
130 |
Dynamic1D diRotate = new Dynamic1D();
|
|
131 | 131 |
diRotate.setCount(0.0f); |
132 | 132 |
diRotate.setDuration(duration); |
133 |
diRotate.add(new Float1D( 0));
|
|
134 |
diRotate.add(new Float1D(360));
|
|
133 |
diRotate.add(new Static1D( 0));
|
|
134 |
diRotate.add(new Static1D(360));
|
|
135 | 135 |
|
136 | 136 |
macroblock.abortEffects(EffectTypes.MATRIX); |
137 | 137 |
|
138 | 138 |
macroblock.move(diMove); |
139 | 139 |
macroblock.scale(diScale); |
140 |
macroblock.rotate( new Float3D(bmpWidth/2,bmpHeight/2,0), diRotate, 0.0f, 0.0f, 1.0f);
|
|
141 |
|
|
140 |
macroblock.rotate( new Static3D(bmpWidth/2,bmpHeight/2,0), diRotate, new Static3D(0,0,1) );
|
|
141 |
|
|
142 | 142 |
Distorted.onSurfaceChanged(width, height); |
143 | 143 |
} |
144 | 144 |
} |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.Distorted; |
30 | 30 |
import org.distorted.library.DistortedBitmap; |
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Float2D;
|
|
33 |
import org.distorted.library.type.Float3D;
|
|
34 |
import org.distorted.library.type.Float4D;
|
|
32 |
import org.distorted.library.type.Static2D;
|
|
33 |
import org.distorted.library.type.Static3D;
|
|
34 |
import org.distorted.library.type.Static4D;
|
|
35 | 35 |
|
36 | 36 |
import android.graphics.Bitmap; |
37 | 37 |
import android.graphics.BitmapFactory; |
... | ... | |
44 | 44 |
{ |
45 | 45 |
private GLSurfaceView mView; |
46 | 46 |
private DistortedBitmap monaLisa; |
47 |
private Float2D pLeft, pRight;
|
|
48 |
private Float4D rLeft, rRight;
|
|
49 |
private Float3D vLeft, vRight;
|
|
47 |
private Static2D pLeft, pRight;
|
|
48 |
private Static4D rLeft, rRight;
|
|
49 |
private Static3D vLeft, vRight;
|
|
50 | 50 |
private int bmpHeight, bmpWidth; |
51 | 51 |
|
52 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
55 | 55 |
{ |
56 | 56 |
mView = v; |
57 | 57 |
|
58 |
pLeft = new Float2D( 90, 258);
|
|
59 |
pRight= new Float2D(176, 255);
|
|
58 |
pLeft = new Static2D( 90, 258);
|
|
59 |
pRight= new Static2D(176, 255);
|
|
60 | 60 |
|
61 |
rLeft = new Float4D(-10,-10,25,25);
|
|
62 |
rRight= new Float4D( 10, -5,25,25);
|
|
61 |
rLeft = new Static4D(-10,-10,25,25);
|
|
62 |
rRight= new Static4D( 10, -5,25,25);
|
|
63 | 63 |
|
64 |
vLeft = new Float3D(-20,-20,0);
|
|
65 |
vRight= new Float3D( 20,-10,0);
|
|
64 |
vLeft = new Static3D(-20,-20,0);
|
|
65 |
vRight= new Static3D( 20,-10,0);
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
84 | 84 |
if( bmpHeight/bmpWidth > height/width ) |
85 | 85 |
{ |
86 | 86 |
int w = (height*bmpWidth)/bmpHeight; |
87 |
monaLisa.move((width-w)/2 ,0, 0); |
|
88 |
monaLisa.scale((float)height/bmpHeight); |
|
87 |
float factor = (float)height/bmpHeight; |
|
88 |
|
|
89 |
monaLisa.move( new Static3D((width-w)/2,0,0) ); |
|
90 |
monaLisa.scale( new Static3D(factor,factor,factor) ); |
|
89 | 91 |
} |
90 | 92 |
else |
91 | 93 |
{ |
92 | 94 |
int h = (width*bmpHeight)/bmpWidth; |
93 |
monaLisa.move(0 ,(height-h)/2, 0); |
|
94 |
monaLisa.scale((float)width/bmpWidth); |
|
95 |
float factor = (float)width/bmpWidth; |
|
96 |
|
|
97 |
monaLisa.move( new Static3D(0,(height-h)/2,0) ); |
|
98 |
monaLisa.scale( new Static3D(factor,factor,factor) ); |
|
95 | 99 |
} |
96 | 100 |
|
97 | 101 |
Distorted.onSurfaceChanged(width, height); |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.Distorted; |
34 | 34 |
import org.distorted.library.EffectTypes; |
35 |
import org.distorted.library.type.Static3D; |
|
35 | 36 |
|
36 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 38 |
|
... | ... | |
101 | 102 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
102 | 103 |
{ |
103 | 104 |
mBackground.abortEffects(EffectTypes.MATRIX); |
104 |
mBackground.scale((float)width/texWidth,(float)height/texHeight,1);
|
|
105 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) );
|
|
105 | 106 |
|
106 | 107 |
Distorted.onSurfaceChanged(width, height); |
107 | 108 |
MovingEffectsSurfaceView.setScreenSize(width, height); |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
29 | 29 |
import android.util.AttributeSet; |
30 | 30 |
|
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Float2D;
|
|
33 |
import org.distorted.library.type.Float3D;
|
|
34 |
import org.distorted.library.type.Float4D;
|
|
35 |
import org.distorted.library.type.Interpolator2D;
|
|
36 |
import org.distorted.library.type.Interpolator3D;
|
|
32 |
import org.distorted.library.type.Dynamic2D;
|
|
33 |
import org.distorted.library.type.Dynamic3D;
|
|
34 |
import org.distorted.library.type.Static2D;
|
|
35 |
import org.distorted.library.type.Static3D;
|
|
36 |
import org.distorted.library.type.Static4D;
|
|
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////// |
39 | 39 |
|
... | ... | |
54 | 54 |
private static int xDown,yDown; |
55 | 55 |
private static int mScrW, mScrH; |
56 | 56 |
|
57 |
private static Interpolator2D di2D;
|
|
58 |
private static Interpolator3D di3D;
|
|
59 |
private static Float4D dr;
|
|
57 |
private static Dynamic2D di2D;
|
|
58 |
private static Dynamic3D di3D;
|
|
59 |
private static Static4D dr;
|
|
60 | 60 |
|
61 | 61 |
private static Paint mPaint; |
62 | 62 |
private static int moving; |
... | ... | |
76 | 76 |
mPaint.setStyle(Style.FILL); |
77 | 77 |
moving = -1; |
78 | 78 |
|
79 |
di2D = new Interpolator2D();
|
|
79 |
di2D = new Dynamic2D();
|
|
80 | 80 |
di2D.setCount(0.0f); |
81 | 81 |
di2D.setDuration(LOOP_TIME); |
82 | 82 |
|
83 |
di3D = new Interpolator3D();
|
|
84 |
di3D.add(new Float3D(0,0, 0));
|
|
85 |
di3D.add(new Float3D(0,0,30));
|
|
83 |
di3D = new Dynamic3D();
|
|
84 |
di3D.add(new Static3D(0,0, 0));
|
|
85 |
di3D.add(new Static3D(0,0,30));
|
|
86 | 86 |
|
87 |
dr = new Float4D(0,0,60,60);
|
|
87 |
dr = new Static4D(0,0,60,60);
|
|
88 | 88 |
|
89 | 89 |
if(!isInEditMode()) |
90 | 90 |
{ |
... | ... | |
214 | 214 |
{ |
215 | 215 |
int len = di2D.getNumPoints(); |
216 | 216 |
float[] drawCoord = new float[2]; |
217 |
Float2D cu;
|
|
217 |
Static2D cu;
|
|
218 | 218 |
int lit = mTime> 0 ? (int)((float)(time-mTime)*NUM_INTERPOLATIONS/LOOP_TIME) : 0; |
219 | 219 |
|
220 | 220 |
if( len>=2 ) |
... | ... | |
254 | 254 |
yDown = (int)event.getY()*MovingEffectsRenderer.BHEI/mScrH; |
255 | 255 |
|
256 | 256 |
float gx, gy; |
257 |
Float2D dv;
|
|
257 |
Static2D dv;
|
|
258 | 258 |
int len = di2D.getNumPoints(); |
259 | 259 |
|
260 | 260 |
for(int g=0; g<len; g++) |
... | ... | |
273 | 273 |
{ |
274 | 274 |
synchronized(lock) |
275 | 275 |
{ |
276 |
di2D.add(new Float2D(xDown,yDown));
|
|
276 |
di2D.add(new Static2D(xDown,yDown));
|
|
277 | 277 |
} |
278 | 278 |
} |
279 | 279 |
break; |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.EffectTypes; |
31 |
import org.distorted.library.type.Interpolator1D;
|
|
31 |
import org.distorted.library.type.Dynamic1D;
|
|
32 | 32 |
import org.distorted.library.DistortedNode; |
33 |
import org.distorted.library.type.Float3D;
|
|
34 |
import org.distorted.library.type.Float1D;
|
|
33 |
import org.distorted.library.type.Static3D;
|
|
34 |
import org.distorted.library.type.Static1D;
|
|
35 | 35 |
import org.distorted.library.Distorted; |
36 | 36 |
import org.distorted.library.DistortedBitmap; |
37 | 37 |
|
... | ... | |
52 | 52 |
private DistortedNode[] mCircleNode; |
53 | 53 |
private DistortedNode mScreen; |
54 | 54 |
private DistortedBitmap mLeaf; |
55 |
private Interpolator1D mRot;
|
|
55 |
private Dynamic1D mRot;
|
|
56 | 56 |
|
57 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
58 | 58 |
|
... | ... | |
64 | 64 |
|
65 | 65 |
mScreen = new DistortedNode(new DistortedBitmap(9*LEAF_SIZE,9*LEAF_SIZE,1)); |
66 | 66 |
|
67 |
mRot = new Interpolator1D();
|
|
68 |
mRot.setMode(Interpolator1D.MODE_JUMP);
|
|
67 |
mRot = new Dynamic1D();
|
|
68 |
mRot.setMode(Dynamic1D.MODE_JUMP);
|
|
69 | 69 |
mRot.setCount(0.0f); |
70 | 70 |
mRot.setDuration(5000); |
71 |
mRot.add(new Float1D( 0));
|
|
72 |
mRot.add(new Float1D(360));
|
|
71 |
mRot.add(new Static1D( 0));
|
|
72 |
mRot.add(new Static1D(360));
|
|
73 | 73 |
|
74 | 74 |
mCircleNode = new DistortedNode[NUM_CIRCLES]; |
75 | 75 |
|
... | ... | |
77 | 77 |
int[] positions = new int[] {0*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE,2*LEAF_SIZE, 6*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE/2,9*LEAF_SIZE/2, 9*LEAF_SIZE/2,9*LEAF_SIZE/2}; |
78 | 78 |
|
79 | 79 |
DistortedBitmap tmp; |
80 |
Float3D center = new Float3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
|
81 |
|
|
80 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
|
81 |
Static3D axis = new Static3D(0,0,1); |
|
82 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0); |
|
83 |
|
|
82 | 84 |
for(int i=0; i<NUM_CIRCLES; i++) |
83 | 85 |
{ |
84 | 86 |
if( i==0 ) |
... | ... | |
89 | 91 |
{ |
90 | 92 |
tmp = new DistortedBitmap(mLeaf, Distorted.CLONE_BITMAP); |
91 | 93 |
mCircleNode[i].attach(tmp); |
92 |
tmp.rotate(center, j*(360/NUM_LEAVES));
|
|
93 |
tmp.move(0,LEAF_SIZE,0);
|
|
94 |
tmp.rotate(center, new Static1D(j*(360/NUM_LEAVES)), axis);
|
|
95 |
tmp.move(moveVector);
|
|
94 | 96 |
} |
95 | 97 |
} |
96 | 98 |
else |
... | ... | |
100 | 102 |
|
101 | 103 |
mScreen.attach(mCircleNode[i]); |
102 | 104 |
tmp = (DistortedBitmap)mCircleNode[i].getObject(); |
103 |
tmp.move(positions[2*i], positions[2*i+1], 0);
|
|
104 |
tmp.rotate( center, mRot, 0.0f, 0.0f, 1.0f);
|
|
105 |
tmp.chroma(0.8f, new Float3D(colors[3*i],colors[3*i+1], colors[3*i+2]));
|
|
105 |
tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
|
|
106 |
tmp.rotate( center, mRot, axis );
|
|
107 |
tmp.chroma(0.8f, new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]));
|
|
106 | 108 |
} |
107 | 109 |
} |
108 | 110 |
|
... | ... | |
129 | 131 |
if( bmpHeight/bmpWidth > height/width ) |
130 | 132 |
{ |
131 | 133 |
int w = (height*bmpWidth)/bmpHeight; |
132 |
bmp.move((width-w)/2 ,0, 0); |
|
133 |
bmp.scale((float)height/bmpHeight); |
|
134 |
float factor = (float)height/bmpHeight; |
|
135 |
|
|
136 |
bmp.move( new Static3D((width-w)/2 ,0, 0) ); |
|
137 |
bmp.scale( new Static3D(factor,factor,factor) ); |
|
134 | 138 |
} |
135 | 139 |
else |
136 | 140 |
{ |
137 | 141 |
int h = (width*bmpHeight)/bmpWidth; |
138 |
bmp.move(0 ,(height-h)/2, 0); |
|
139 |
bmp.scale((float)width/bmpWidth); |
|
142 |
float factor = (float)width/bmpWidth; |
|
143 |
|
|
144 |
bmp.move( new Static3D(0,(height-h)/2,0) ); |
|
145 |
bmp.scale( new Static3D(factor,factor,factor) ); |
|
140 | 146 |
} |
141 | 147 |
|
142 | 148 |
Distorted.onSurfaceChanged(width, height); |
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.Distorted; |
35 | 35 |
import org.distorted.library.DistortedBitmap; |
36 | 36 |
import org.distorted.library.EffectTypes; |
37 |
import org.distorted.library.type.Float2D;
|
|
38 |
import org.distorted.library.type.Float3D;
|
|
39 |
import org.distorted.library.type.Float4D;
|
|
37 |
import org.distorted.library.type.Static2D;
|
|
38 |
import org.distorted.library.type.Static3D;
|
|
39 |
import org.distorted.library.type.Static4D;
|
|
40 | 40 |
import org.distorted.examples.R; |
41 | 41 |
|
42 | 42 |
import java.io.IOException; |
... | ... | |
63 | 63 |
private DistortedBitmap monaLisa; |
64 | 64 |
private int bmpHeight, bmpWidth; |
65 | 65 |
|
66 |
private Float2D pLeft, pRight;
|
|
67 |
private Float4D rLeft, rRight;
|
|
68 |
private Float3D vLeft, vRight;
|
|
66 |
private Static2D pLeft, pRight;
|
|
67 |
private Static4D rLeft, rRight;
|
|
68 |
private Static3D vLeft, vRight;
|
|
69 | 69 |
|
70 | 70 |
SurfaceView mView; |
71 | 71 |
|
... | ... | |
76 | 76 |
mSurfaceHolder = holder; |
77 | 77 |
mView = view; |
78 | 78 |
|
79 |
pLeft = new Float2D( 90, 258);
|
|
80 |
pRight= new Float2D(176, 255);
|
|
79 |
pLeft = new Static2D( 90, 258);
|
|
80 |
pRight= new Static2D(176, 255);
|
|
81 | 81 |
|
Also available in: Unified diff
Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.