Revision 75cc1461
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/generic/GenericRenderer.java | ||
---|---|---|
57 | 57 |
private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
58 | 58 |
private DistortedEffects mObjectEffects; |
59 | 59 |
private DistortedScreen mScreen; |
60 |
private MeshQuad mRegionQuad, mCenterQuad, mBackgroundQuad; |
|
61 | 60 |
private DistortedNode mCenterNode, mRegionNode; |
62 | 61 |
private float mObjWidth, mObjHeight, mObjDepth; |
63 | 62 |
private Static3D mCenterPoint, mRegionPoint, mScaleRegion; |
... | ... | |
98 | 97 |
DistortedEffects regionEffects = new DistortedEffects(); |
99 | 98 |
|
100 | 99 |
MeshBase mesh = act.getMesh(); |
101 |
mRegionQuad = new MeshQuad(); |
|
102 |
mCenterQuad = new MeshQuad(); |
|
103 |
mBackgroundQuad = new MeshQuad(); |
|
100 |
MeshQuad quad = new MeshQuad(); |
|
104 | 101 |
|
105 | 102 |
mFactor = mesh instanceof MeshSphere ? 1.0f : 0.7f; |
106 | 103 |
|
... | ... | |
115 | 112 |
mRegionPoint= new Static3D(0,0,0); |
116 | 113 |
mScaleRegion = new Static3D(0,0,0); |
117 | 114 |
|
118 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, mCenterQuad);
|
|
119 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, mRegionQuad);
|
|
115 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, quad);
|
|
116 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, quad);
|
|
120 | 117 |
|
121 | 118 |
mScreen = new DistortedScreen(); |
122 | 119 |
mScreen.setProjection(FOV, NEAR); |
123 |
mScreen.attach(mBackgroundTexture, backgroundEffects, mBackgroundQuad );
|
|
120 |
mScreen.attach(mBackgroundTexture, backgroundEffects, quad );
|
|
124 | 121 |
mScreen.attach(mObjectTexture , mObjectEffects , mesh ); |
125 | 122 |
|
126 | 123 |
Static3D rotateCen = new Static3D(0,0,0); |
... | ... | |
221 | 218 |
|
222 | 219 |
void setRegion(float x, float y, float z, float r) |
223 | 220 |
{ |
224 |
float factorReg = 2*mFactorObj*r/mRegionQuad.getStretchX();
|
|
221 |
float factorReg = 2*mFactorObj*r; |
|
225 | 222 |
mRegionPoint.set(mFactorObj*x,mFactorObj*y, mFactorObj*z); |
226 | 223 |
mScaleRegion.set(factorReg,factorReg,factorReg); |
227 | 224 |
} |
... | ... | |
245 | 242 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
246 | 243 |
{ |
247 | 244 |
mWidth = width; |
248 |
mScreenMin = width<height ? width:height;
|
|
245 |
mScreenMin = Math.min(width, height);
|
|
249 | 246 |
|
250 | 247 |
float factorCen; |
251 |
float centerSize = mCenterQuad.getStretchX(); |
|
252 | 248 |
|
253 | 249 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
254 | 250 |
{ |
255 | 251 |
mFactorObj = (mFactor*height)/mObjHeight; |
256 |
factorCen = (0.08f *height)/centerSize;
|
|
252 |
factorCen = (0.08f *height); |
|
257 | 253 |
} |
258 | 254 |
else |
259 | 255 |
{ |
260 | 256 |
mFactorObj = (mFactor*width)/mObjWidth; |
261 |
factorCen = (0.08f *width)/centerSize;
|
|
257 |
factorCen = (0.08f *width); |
|
262 | 258 |
} |
263 | 259 |
|
264 | 260 |
setCenter(0,0,0); |
... | ... | |
268 | 264 |
mScaleObject.set(mFactorObj,mFactorObj,mFactorObj); |
269 | 265 |
mScaleCenter.set(factorCen,factorCen,factorCen); |
270 | 266 |
|
271 |
float backgroundSize = mBackgroundQuad.getStretchX(); |
|
272 |
float factorBackX = ((float)width)/backgroundSize; |
|
273 |
float factorBackY = ((float)height)/backgroundSize; |
|
274 |
|
|
275 | 267 |
// quite tricky: move the background exactly to the FAR plane! (see InternalOutputSurface.setProjection() ) |
276 | 268 |
mMoveBackground.set( 0,0, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) ); |
277 |
mScaleBackground.set( 2*factorBackX, 2*factorBackY, 1.0f );
|
|
269 |
mScaleBackground.set( 2*width, 2*height, 1.0f );
|
|
278 | 270 |
|
279 | 271 |
mScreen.resize(width, height); |
280 | 272 |
} |
... | ... | |
305 | 297 |
isC.close(); |
306 | 298 |
isR.close(); |
307 | 299 |
} |
308 |
catch(IOException e) { }
|
|
300 |
catch(IOException ignored) { }
|
|
309 | 301 |
} |
310 | 302 |
|
311 | 303 |
mObjectTexture.setTexture( act.getBitmap() ); |
Also available in: Unified diff
Improve Generic.