Revision f6d884d5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import org.distorted.library.Distorted; |
31 | 31 |
import org.distorted.library.GridFlat; |
32 |
import org.distorted.library.DistortedObject; |
|
32 |
import org.distorted.library.DistortedTexture; |
|
33 |
import org.distorted.library.DistortedEffectQueues; |
|
33 | 34 |
import org.distorted.library.EffectTypes; |
34 | 35 |
import org.distorted.library.type.Dynamic1D; |
35 | 36 |
import org.distorted.library.type.Dynamic3D; |
... | ... | |
47 | 48 |
class GirlRenderer implements GLSurfaceView.Renderer |
48 | 49 |
{ |
49 | 50 |
private GLSurfaceView mView; |
50 |
private DistortedObject mGirl; |
|
51 |
private DistortedTexture mTexture; |
|
52 |
private DistortedEffectQueues mQueues; |
|
51 | 53 |
private GridFlat mGrid; |
52 |
private Static3D pLeft, pRight, pHips; |
|
53 |
private Static4D Region, sinkRegion, HipsRegion; |
|
54 |
private Dynamic3D diL, diR; |
|
55 |
private Dynamic1D diHips, diSink; |
|
56 | 54 |
private Static3D v0,v1,v2,v3; |
57 | 55 |
private Static1D dBegin, dMiddle, dEnd, s0; |
58 | 56 |
private int bmpHeight, bmpWidth; |
59 |
private int boobsSwing; |
|
60 |
private int hipsSwirl; |
|
61 |
private float boobsSink; |
|
62 |
|
|
57 |
|
|
63 | 58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 59 |
|
65 | 60 |
GirlRenderer(GLSurfaceView v) |
66 | 61 |
{ |
67 | 62 |
mView = v; |
68 |
|
|
69 |
boobsSwing = 0; |
|
70 |
hipsSwirl = 0; |
|
71 |
boobsSink = 1.0f; |
|
72 |
|
|
73 |
pLeft = new Static3D(132, 264, 0); |
|
74 |
pRight= new Static3D(247, 264, 0); |
|
63 |
|
|
64 |
Static3D pLeft = new Static3D(132, 264, 0); |
|
65 |
Static3D pRight= new Static3D(247, 264, 0); |
|
75 | 66 |
|
76 | 67 |
// Size |
77 |
sinkRegion = new Static4D(0,0,60,60); |
|
68 |
Static4D sinkRegion = new Static4D(0,0,60,60);
|
|
78 | 69 |
|
79 |
s0 = new Static1D(boobsSink);
|
|
70 |
s0 = new Static1D(1.0f);
|
|
80 | 71 |
|
81 |
diSink = new Dynamic1D(0,0.5f); |
|
72 |
Dynamic1D diSink = new Dynamic1D(0,0.5f);
|
|
82 | 73 |
diSink.add(s0); |
83 | 74 |
|
84 | 75 |
// Upper Movement |
85 |
Region = new Static4D(0,0,45,45); |
|
76 |
Static4D Region = new Static4D(0,0,45,45);
|
|
86 | 77 |
|
87 |
diL = new Dynamic3D(1000,0.0f); |
|
88 |
diR = new Dynamic3D(1000,0.0f); |
|
78 |
Dynamic3D diL = new Dynamic3D(1000,0.0f);
|
|
79 |
Dynamic3D diR = new Dynamic3D(1000,0.0f);
|
|
89 | 80 |
|
90 |
v0 = new Static3D( 0,-boobsSwing, 0);
|
|
91 |
v1 = new Static3D( boobsSwing, 0, 0);
|
|
92 |
v2 = new Static3D( 0, boobsSwing, 0);
|
|
93 |
v3 = new Static3D(-boobsSwing, 0, 0);
|
|
81 |
v0 = new Static3D(0,0,0);
|
|
82 |
v1 = new Static3D(0,0,0);
|
|
83 |
v2 = new Static3D(0,0,0);
|
|
84 |
v3 = new Static3D(0,0,0);
|
|
94 | 85 |
|
95 | 86 |
diL.add(v0); |
96 | 87 |
diL.add(v1); |
... | ... | |
103 | 94 |
diR.add(v1); |
104 | 95 |
|
105 | 96 |
// Lower Movement |
106 |
pHips = new Static3D(216,505,0); |
|
107 |
HipsRegion = new Static4D(0,0,120,120); |
|
108 |
diHips = new Dynamic1D(1500,0.0f); |
|
97 |
Static3D pHips = new Static3D(216,505,0);
|
|
98 |
Static4D HipsRegion = new Static4D(0,0,120,120);
|
|
99 |
Dynamic1D diHips = new Dynamic1D(1500,0.0f);
|
|
109 | 100 |
|
110 |
dBegin = new Static1D(-hipsSwirl);
|
|
101 |
dBegin = new Static1D(0);
|
|
111 | 102 |
dMiddle= new Static1D(0); |
112 |
dEnd = new Static1D(+hipsSwirl);
|
|
103 |
dEnd = new Static1D(0);
|
|
113 | 104 |
|
114 | 105 |
diHips.add(dBegin); |
115 | 106 |
diHips.add(dMiddle); |
... | ... | |
117 | 108 |
diHips.add(dEnd); |
118 | 109 |
diHips.add(dMiddle); |
119 | 110 |
diHips.add(dBegin); |
111 |
|
|
112 |
mQueues = new DistortedEffectQueues(); |
|
113 |
|
|
114 |
mQueues.sink( diSink, pLeft, sinkRegion ); |
|
115 |
mQueues.sink( diSink, pRight,sinkRegion ); |
|
116 |
|
|
117 |
mQueues.distort(diL, pLeft , Region); |
|
118 |
mQueues.distort(diR, pRight, Region); |
|
119 |
|
|
120 |
mQueues.swirl(diHips, pHips, HipsRegion ); |
|
120 | 121 |
} |
121 | 122 |
|
122 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
123 | 124 |
|
124 |
void setHips(int s) |
|
125 |
void setHips(int swirl)
|
|
125 | 126 |
{ |
126 |
hipsSwirl = s; |
|
127 |
dBegin.set(-hipsSwirl); |
|
128 |
dEnd.set(+hipsSwirl); |
|
127 |
dBegin.set(-swirl); |
|
128 |
dEnd.set(+swirl); |
|
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
132 | 132 |
|
133 |
void setSize(float s) |
|
133 |
void setSize(float size)
|
|
134 | 134 |
{ |
135 |
boobsSink = s; |
|
136 |
s0.set(boobsSink); |
|
135 |
s0.set(size); |
|
137 | 136 |
} |
138 | 137 |
|
139 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
140 | 139 |
|
141 |
void setSwing(int s) |
|
140 |
void setSwing(int swing)
|
|
142 | 141 |
{ |
143 |
boobsSwing = s; |
|
144 |
|
|
145 |
v0.set( 0,-boobsSwing, 0); |
|
146 |
v1.set( boobsSwing, 0, 0); |
|
147 |
v2.set( 0, boobsSwing, 0); |
|
148 |
v3.set(-boobsSwing, 0, 0); |
|
142 |
v0.set( 0,-swing, 0); |
|
143 |
v1.set( swing, 0, 0); |
|
144 |
v2.set( 0, swing, 0); |
|
145 |
v3.set(-swing, 0, 0); |
|
149 | 146 |
} |
150 | 147 |
|
151 | 148 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
153 | 150 |
public void onDrawFrame(GL10 glUnused) |
154 | 151 |
{ |
155 | 152 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
156 |
mGirl.draw(System.currentTimeMillis(),mGrid);
|
|
153 |
mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
|
|
157 | 154 |
} |
158 | 155 |
|
159 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
160 | 157 |
|
161 | 158 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
162 | 159 |
{ |
163 |
mGirl.abortEffects(EffectTypes.MATRIX);
|
|
160 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
164 | 161 |
|
165 | 162 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
166 | 163 |
{ |
167 | 164 |
int w = (height*bmpWidth)/bmpHeight; |
168 | 165 |
float factor = (float)height/bmpHeight; |
169 | 166 |
|
170 |
mGirl.move( new Static3D((width-w)/2,0,0) );
|
|
171 |
mGirl.scale(factor);
|
|
167 |
mQueues.move( new Static3D((width-w)/2,0,0) );
|
|
168 |
mQueues.scale(factor);
|
|
172 | 169 |
} |
173 | 170 |
else |
174 | 171 |
{ |
175 | 172 |
int h = (width*bmpHeight)/bmpWidth; |
176 | 173 |
float factor = (float)width/bmpWidth; |
177 | 174 |
|
178 |
mGirl.move( new Static3D(0,(height-h)/2,0) );
|
|
179 |
mGirl.scale(factor);
|
|
175 |
mQueues.move( new Static3D(0,(height-h)/2,0) );
|
|
176 |
mQueues.scale(factor);
|
|
180 | 177 |
} |
181 | 178 |
|
182 | 179 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
208 | 205 |
bmpWidth = bitmap.getWidth(); |
209 | 206 |
|
210 | 207 |
mGrid = new GridFlat(30,30*bmpHeight/bmpWidth); |
211 |
mGirl = new DistortedObject(bmpWidth,bmpHeight,1);
|
|
212 |
mGirl.setTexture(bitmap);
|
|
208 |
mTexture = new DistortedTexture(bmpWidth,bmpHeight,0);
|
|
209 |
mTexture.setTexture(bitmap);
|
|
213 | 210 |
|
214 |
mGirl.sink( diSink, pLeft, sinkRegion ); |
|
215 |
mGirl.sink( diSink, pRight,sinkRegion ); |
|
216 |
|
|
217 |
mGirl.distort(diL, pLeft , Region); |
|
218 |
mGirl.distort(diR, pRight, Region); |
|
219 |
|
|
220 |
mGirl.swirl(diHips, pHips, HipsRegion ); |
|
221 |
|
|
222 | 211 |
try |
223 | 212 |
{ |
224 | 213 |
Distorted.onSurfaceCreated(mView.getContext()); |
Also available in: Unified diff
Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)