60 |
60 |
private MeshQuad mRegionQuad, mCenterQuad, mBackgroundQuad;
|
61 |
61 |
private DistortedNode mCenterNode, mRegionNode;
|
62 |
62 |
private float mObjWidth, mObjHeight, mObjDepth;
|
63 |
|
private Static3D mCenterPoint, mRegionPoint, mRegionScalePoint;
|
64 |
|
private Static3D mRotateCen, mMoveObject, mScaleObject, mMoveCenter, mScaleCenter, mMoveRegion, mMoveBackground, mScaleBackground;
|
|
63 |
private Static3D mCenterPoint, mRegionPoint, mScaleRegion;
|
|
64 |
private Static3D mMoveObject, mScaleObject, mScaleCenter, mMoveBackground, mScaleBackground;
|
65 |
65 |
private boolean mShowingCenter=false;
|
66 |
66 |
private boolean mShowingRegion=false;
|
67 |
67 |
private float mFactorObj;
|
... | ... | |
79 |
79 |
|
80 |
80 |
GenericActivity2 act = (GenericActivity2)v.getContext();
|
81 |
81 |
|
82 |
|
mRotateCen = new Static3D(0,0,0);
|
83 |
82 |
mMoveObject = new Static3D(0,0,0);
|
84 |
83 |
mScaleObject = new Static3D(1,1,1);
|
85 |
|
mMoveCenter = new Static3D(0,0,0);
|
86 |
84 |
mScaleCenter = new Static3D(1,1,1);
|
87 |
|
mMoveRegion = new Static3D(0,0,0);
|
88 |
85 |
mMoveBackground = new Static3D(0,0,0);
|
89 |
86 |
mScaleBackground= new Static3D(1,1,1);
|
90 |
87 |
|
... | ... | |
116 |
113 |
|
117 |
114 |
mCenterPoint= new Static3D(0,0,0);
|
118 |
115 |
mRegionPoint= new Static3D(0,0,0);
|
119 |
|
mRegionScalePoint = new Static3D(0,0,0);
|
|
116 |
mScaleRegion = new Static3D(0,0,0);
|
120 |
117 |
|
121 |
118 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, mCenterQuad);
|
122 |
119 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, mRegionQuad);
|
... | ... | |
126 |
123 |
mScreen.attach(mBackgroundTexture, backgroundEffects, mBackgroundQuad );
|
127 |
124 |
mScreen.attach(mObjectTexture , mObjectEffects , mesh );
|
128 |
125 |
|
129 |
|
float regionSize = mRegionQuad.getStretchX();
|
130 |
|
mRotateCen = new Static3D(0 ,0, 0);
|
|
126 |
Static3D rotateCen = new Static3D(0,0,0);
|
131 |
127 |
|
132 |
|
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, mRotateCen);
|
133 |
|
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, mRotateCen);
|
134 |
|
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint);
|
|
128 |
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, rotateCen);
|
|
129 |
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, rotateCen);
|
|
130 |
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint);
|
135 |
131 |
|
136 |
132 |
centerEffects.apply( new MatrixEffectScale(mScaleCenter) );
|
137 |
133 |
centerEffects.apply( centerMove );
|
138 |
|
centerEffects.apply( new MatrixEffectMove(mMoveCenter) );
|
|
134 |
centerEffects.apply( new MatrixEffectMove(new Static3D(0,0,12)) );
|
139 |
135 |
centerEffects.apply(quat2cen);
|
140 |
136 |
centerEffects.apply(quat1cen);
|
141 |
137 |
|
142 |
|
regionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize*0.5f , -regionSize*0.5f , 0)) );
|
143 |
|
regionEffects.apply( new MatrixEffectScale(mRegionScalePoint) );
|
144 |
|
regionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
138 |
regionEffects.apply( new MatrixEffectScale(mScaleRegion) );
|
145 |
139 |
regionEffects.apply( centerMove );
|
146 |
|
regionEffects.apply( new MatrixEffectMove(mMoveRegion) );
|
|
140 |
regionEffects.apply( new MatrixEffectMove(mRegionPoint) );
|
|
141 |
regionEffects.apply( new MatrixEffectMove(new Static3D(0,0,10)) );
|
147 |
142 |
regionEffects.apply(quat2cen);
|
148 |
143 |
regionEffects.apply(quat1cen);
|
149 |
144 |
|
... | ... | |
158 |
153 |
|
159 |
154 |
void resetMatrixEffects()
|
160 |
155 |
{
|
161 |
|
Static3D rotateObj = new Static3D( mObjWidth/2, mObjHeight/2, mObjDepth/2 );
|
|
156 |
Static3D rotateObj = new Static3D(0,0,0);
|
162 |
157 |
|
163 |
158 |
MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1, rotateObj);
|
164 |
159 |
MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2, rotateObj);
|
... | ... | |
221 |
216 |
{
|
222 |
217 |
float factorReg = 2*mFactorObj*r/mRegionQuad.getStretchX();
|
223 |
218 |
mRegionPoint.set(mFactorObj*x,mFactorObj*y, mFactorObj*z);
|
224 |
|
mRegionScalePoint.set(factorReg,factorReg,factorReg);
|
|
219 |
mScaleRegion.set(factorReg,factorReg,factorReg);
|
225 |
220 |
}
|
226 |
221 |
|
227 |
222 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
... | ... | |
259 |
254 |
factorCen = (0.08f *width)/centerSize;
|
260 |
255 |
}
|
261 |
256 |
|
262 |
|
setCenter(0.5f*mObjWidth,0.5f*mObjHeight,0.5f*mObjDepth);
|
|
257 |
setCenter(0,0,0);
|
263 |
258 |
setRegion(0.0f,0.0f,0.0f,0.25f*(mObjWidth+mObjHeight));
|
264 |
259 |
|
265 |
|
mMoveObject.set( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , -mFactorObj*mObjDepth );
|
266 |
|
mRotateCen.set(width*0.5f,height*0.5f, 0);
|
|
260 |
mMoveObject.set( 0, 0 , -mFactorObj*mObjDepth );
|
267 |
261 |
mScaleObject.set(mFactorObj,mFactorObj,mFactorObj);
|
268 |
|
mMoveCenter.set( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
|
269 |
|
(height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , 15 );
|
270 |
262 |
mScaleCenter.set(factorCen,factorCen,factorCen);
|
271 |
|
mMoveRegion.set( (width -mFactorObj*mObjWidth )/2 ,(height-mFactorObj*mObjHeight)/2 , 12 );
|
272 |
263 |
|
273 |
264 |
float backgroundSize = mBackgroundQuad.getStretchX();
|
274 |
265 |
float factorBackX = ((float)width)/backgroundSize;
|
275 |
266 |
float factorBackY = ((float)height)/backgroundSize;
|
276 |
267 |
|
277 |
268 |
// quite tricky: move the background exactly to the FAR plane! (see InternalOutputSurface.setProjection() )
|
278 |
|
mMoveBackground.set( -width*0.5f, -height*0.5f, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) );
|
|
269 |
mMoveBackground.set( 0,0, -0.9f*height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360)) );
|
279 |
270 |
mScaleBackground.set( 2*factorBackX, 2*factorBackY, 1.0f );
|
280 |
271 |
|
281 |
272 |
mScreen.resize(width, height);
|
Fixes for the merge. Everything works now!
Next step: make the center of Vertex & Fragment effects be in the center of the Object, rather than the lower-left corner.