Revision 752c6b57
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
173 | 173 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
174 | 174 |
{ |
175 | 175 |
mScreenMin = width<height ? width:height; |
176 |
Static3D centerRot = new Static3D(0,0,0); |
|
176 | 177 |
|
177 |
mObjectEffects.abortEffects(EffectTypes.MATRIX); |
|
178 |
//// BACKGROUND //////////// |
|
179 |
// quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() ) |
|
180 |
float distToScreen = height/(2.0f*(float)Math.tan(FOV*Math.PI/360)); |
|
181 |
float distToFar = distToScreen*(2-NEAR); |
|
182 |
float factor = distToFar / distToScreen; |
|
178 | 183 |
mBackgroundEffects.abortEffects(EffectTypes.MATRIX); |
179 |
mCenterEffects.abortEffects(EffectTypes.MATRIX); |
|
180 |
mRegionEffects.abortEffects(EffectTypes.MATRIX); |
|
184 |
mBackgroundEffects.move(new Static3D( 0, 0, -(distToFar-distToScreen)/width ) ); |
|
185 |
mBackgroundEffects.scale(new Static3D(factor,factor,1.0f) ); |
|
186 |
|
|
187 |
//// OBJECT ////////////// |
|
188 |
float qObj= ((float)width/height)*((float)mObjHeight/mObjWidth); |
|
189 |
float sObj= 0.8f; |
|
190 |
|
|
191 |
mObjectEffects.abortEffects(EffectTypes.MATRIX); |
|
192 |
mObjectEffects.quaternion(mQuatInt1, centerRot); |
|
193 |
mObjectEffects.quaternion(mQuatInt2, centerRot); |
|
194 |
mObjectEffects.scale( qObj<1 ? (new Static3D(sObj,sObj*qObj,sObj)) : (new Static3D(sObj/qObj,sObj,sObj/qObj)) ); |
|
195 |
|
|
196 |
|
|
181 | 197 |
|
198 |
|
|
199 |
/* |
|
182 | 200 |
float factorCen; |
183 | 201 |
int centerSize = mCenterTexture.getWidth(); |
184 | 202 |
int regionSize = mRegionTexture.getWidth(); |
... | ... | |
200 | 218 |
|
201 | 219 |
mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize; |
202 | 220 |
mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg); |
221 |
*/ |
|
203 | 222 |
|
204 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
|
205 |
|
|
206 |
mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) ); |
|
207 |
mObjectEffects.scale(mFactorObj); |
|
208 |
mObjectEffects.quaternion(mQuatInt1, rotateObj); |
|
209 |
mObjectEffects.quaternion(mQuatInt2, rotateObj); |
|
210 |
|
|
211 |
Static3D rotateCen = new Static3D(width/2,height/2, 0); |
|
212 | 223 |
|
213 |
mCenterEffects.quaternion(mQuatInt1, rotateCen); |
|
214 |
mCenterEffects.quaternion(mQuatInt2, rotateCen); |
|
224 |
//// CENTER ////////////// |
|
225 |
float qCen= ((float)width/height); |
|
226 |
float sCen= 0.1f; |
|
215 | 227 |
|
216 |
mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 , |
|
217 |
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) ); |
|
228 |
mCenterEffects.abortEffects(EffectTypes.MATRIX); |
|
229 |
/* |
|
230 |
mCenterEffects.quaternion(mQuatInt1, centerRot); |
|
231 |
mCenterEffects.quaternion(mQuatInt2, centerRot); |
|
232 |
mCenterEffects.move( new Static3D(0,0,0.5f) ); |
|
218 | 233 |
mCenterEffects.move(mCenterInter); |
219 |
mCenterEffects.scale(factorCen); |
|
234 |
mCenterEffects.scale(qObj<1 ? (new Static3D(sCen,sCen*qCen,sCen)) : (new Static3D(sCen/qCen,sCen,sCen/qCen))); |
|
235 |
*/ |
|
236 |
/* |
|
237 |
//// REGION ////////////// |
|
238 |
mRegionEffects.abortEffects(EffectTypes.MATRIX); |
|
220 | 239 |
|
221 | 240 |
mRegionEffects.quaternion(mQuatInt1, rotateCen); |
222 | 241 |
mRegionEffects.quaternion(mQuatInt2, rotateCen); |
... | ... | |
227 | 246 |
mRegionEffects.move(mRegionInter); |
228 | 247 |
mRegionEffects.scale(mRegionScaleInter); |
229 | 248 |
mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) ); |
230 |
|
|
231 |
int backgroundSize = mBackgroundTexture.getWidth(); |
|
232 |
float factorBackX = ((float)width)/backgroundSize; |
|
233 |
float factorBackY = ((float)height)/backgroundSize; |
|
234 |
|
|
235 |
// quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() ) |
|
236 |
mBackgroundEffects.move(new Static3D( -width/2, -height/2, -height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360))) ); |
|
237 |
mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) ); |
|
238 |
|
|
249 |
*/ |
|
239 | 250 |
mScreen.resize(width, height); |
240 | 251 |
} |
241 | 252 |
|
Also available in: Unified diff
Progress with the last 2 Apps: Effects3D and Wind (not done yet)