Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
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); |
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.