55 |
55 |
private GLSurfaceView mView;
|
56 |
56 |
private DistortedObject mObject;
|
57 |
57 |
private DistortedBitmap mCenter;
|
|
58 |
private DistortedBitmap mBackground;
|
58 |
59 |
private float mFactorCen, mFactorObj;
|
59 |
60 |
|
60 |
61 |
private int mObjWidth, mObjHeight;
|
... | ... | |
83 |
84 |
{
|
84 |
85 |
mView = v;
|
85 |
86 |
|
86 |
|
mObject = ((Fragment3DActivity)v.getContext()).getObject();
|
87 |
|
mCenter = new DistortedBitmap(SIZE, SIZE, 1);
|
|
87 |
mObject = ((Fragment3DActivity)v.getContext()).getObject();
|
|
88 |
mCenter = new DistortedBitmap(SIZE, SIZE, 1);
|
|
89 |
mBackground = new DistortedBitmap(SIZE, SIZE, 1);
|
88 |
90 |
|
89 |
91 |
mObjWidth = mObject.getWidth();
|
90 |
92 |
mObjHeight= mObject.getHeight();
|
... | ... | |
112 |
114 |
|
113 |
115 |
long time = System.currentTimeMillis();
|
114 |
116 |
|
|
117 |
mBackground.draw(time);
|
115 |
118 |
mObject.draw(time);
|
116 |
119 |
mCenter.draw(time);
|
117 |
120 |
}
|
... | ... | |
124 |
127 |
|
125 |
128 |
mObject.abortEffects(EffectTypes.MATRIX);
|
126 |
129 |
mCenter.abortEffects(EffectTypes.MATRIX);
|
|
130 |
mBackground.abortEffects(EffectTypes.MATRIX);
|
127 |
131 |
|
128 |
132 |
int centerSize = mCenter.getWidth();
|
129 |
133 |
|
... | ... | |
163 |
167 |
mCenter.move(mMoveInter);
|
164 |
168 |
mCenter.scale(mFactorCen);
|
165 |
169 |
|
|
170 |
int backgroundSize = mBackground.getWidth();
|
|
171 |
float factorBackX = ((float)width)/backgroundSize;
|
|
172 |
float factorBackY = ((float)height)/backgroundSize;
|
|
173 |
|
|
174 |
mBackground.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
|
|
175 |
mBackground.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
|
|
176 |
|
166 |
177 |
Distorted.onSurfaceChanged(width, height);
|
167 |
178 |
}
|
168 |
179 |
|
... | ... | |
174 |
185 |
|
175 |
186 |
InputStream is1 = act.getResources().openRawResource(act.getBitmap());
|
176 |
187 |
InputStream is2 = act.getResources().openRawResource(R.raw.center);
|
|
188 |
InputStream is3 = act.getResources().openRawResource(R.raw.water);
|
177 |
189 |
|
178 |
|
Bitmap bitmap1,bitmap2;
|
|
190 |
Bitmap bitmap1,bitmap2,bitmap3;
|
179 |
191 |
|
180 |
192 |
try
|
181 |
193 |
{
|
182 |
194 |
bitmap1 = BitmapFactory.decodeStream(is1);
|
183 |
195 |
bitmap2 = BitmapFactory.decodeStream(is2);
|
|
196 |
bitmap3 = BitmapFactory.decodeStream(is3);
|
184 |
197 |
}
|
185 |
198 |
finally
|
186 |
199 |
{
|
... | ... | |
188 |
201 |
{
|
189 |
202 |
is1.close();
|
190 |
203 |
is2.close();
|
|
204 |
is3.close();
|
191 |
205 |
}
|
192 |
206 |
catch(IOException e) { }
|
193 |
207 |
}
|
194 |
208 |
|
195 |
209 |
mObject.setBitmap(bitmap1);
|
196 |
210 |
mCenter.setBitmap(bitmap2);
|
197 |
|
|
|
211 |
mBackground.setBitmap(bitmap3)
|
|
212 |
;
|
198 |
213 |
try
|
199 |
214 |
{
|
200 |
215 |
Distorted.onSurfaceCreated(mView.getContext());
|
Improve Fragment3D app some more!