Revision 2bf60c29
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java | ||
---|---|---|
55 | 55 |
private GLSurfaceView mView; |
56 | 56 |
private static DistortedObject mObject; |
57 | 57 |
private DistortedBitmap mCenter; |
58 |
private int mCols; |
|
58 | 59 |
|
59 | 60 |
private int mObjWidth, mObjHeight; |
60 | 61 |
|
... | ... | |
63 | 64 |
private static EffectNames[] order; |
64 | 65 |
|
65 | 66 |
private static Dynamic2D mCenterInter; |
66 |
private static Dynamic3D mDeformInter, mDistortInter; |
|
67 |
private static Dynamic3D mDeformInter, mDistortInter, mMoveInter;
|
|
67 | 68 |
private static Dynamic1D mSinkInter, mSwirlInter; |
68 | 69 |
|
69 | 70 |
private static Static2D mCenterPoint; |
70 |
private static Static3D mDeformPoint, mDistortPoint; |
|
71 |
private static Static3D mDeformPoint, mDistortPoint, mMovePoint;
|
|
71 | 72 |
private static Static1D mSinkPoint, mSwirlPoint; |
72 | 73 |
|
73 | 74 |
Static4D mQuat1, mQuat2; |
... | ... | |
106 | 107 |
public static void setCenter(float x, float y) |
107 | 108 |
{ |
108 | 109 |
mCenterPoint.set(x,y); |
110 |
mMovePoint.set(x,y,0); |
|
109 | 111 |
} |
110 | 112 |
|
111 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
140 | 142 |
{ |
141 | 143 |
mView = v; |
142 | 144 |
|
143 |
mObject = new DistortedCubes( Vertex3DActivity.getCols(), Vertex3DActivity.getShape(), SIZE); |
|
145 |
mCols = Vertex3DActivity.getCols(); |
|
146 |
|
|
147 |
mObject = new DistortedCubes( mCols, Vertex3DActivity.getShape(), SIZE); |
|
144 | 148 |
//mObject = new DistortedBitmap( SIZE, SIZE, 10); |
145 | 149 |
mCenter = new DistortedBitmap(SIZE, SIZE, 1); |
146 | 150 |
|
... | ... | |
148 | 152 |
mObjHeight= mObject.getHeight(); |
149 | 153 |
|
150 | 154 |
mCenterPoint = new Static2D(0,0); |
155 |
mMovePoint = new Static3D(0,0,0); |
|
151 | 156 |
mDeformPoint = new Static3D(0,0,0); |
152 | 157 |
mDistortPoint= new Static3D(1,1,1); |
153 | 158 |
mSwirlPoint = new Static1D(0); |
... | ... | |
156 | 161 |
mCenterInter = new Dynamic2D(); |
157 | 162 |
mDeformInter = new Dynamic3D(); |
158 | 163 |
mDistortInter = new Dynamic3D(); |
164 |
mMoveInter = new Dynamic3D(); |
|
159 | 165 |
mSwirlInter = new Dynamic1D(); |
160 | 166 |
mSinkInter = new Dynamic1D(); |
161 | 167 |
|
162 | 168 |
mCenterInter.add(mCenterPoint); |
169 |
mMoveInter.add(mMovePoint); |
|
163 | 170 |
mDeformInter.add(mDeformPoint); |
164 | 171 |
mDistortInter.add(mDistortPoint); |
165 | 172 |
mSwirlInter.add(mSwirlPoint); |
... | ... | |
197 | 204 |
mObject.abortEffects(EffectTypes.MATRIX); |
198 | 205 |
mCenter.abortEffects(EffectTypes.MATRIX); |
199 | 206 |
|
200 |
float factor; |
|
207 |
float factorObj;
|
|
201 | 208 |
|
202 | 209 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
203 | 210 |
{ |
204 |
factor = (0.7f*height)/mObjHeight; |
|
211 |
factorObj = (0.7f*height)/mObjHeight;
|
|
205 | 212 |
} |
206 | 213 |
else |
207 | 214 |
{ |
208 |
factor = (0.7f*width)/mObjWidth; |
|
215 |
factorObj = (0.7f*width)/mObjWidth;
|
|
209 | 216 |
} |
210 | 217 |
|
211 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
|
218 |
Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
|
219 |
|
|
220 |
mObject.move( new Static3D( (width-factorObj*mObjWidth)/2 , (height-factorObj*mObjHeight)/2 , 0) ); |
|
221 |
mObject.scale(factorObj); |
|
222 |
mObject.quaternion(mQuatInt1, rotateObj); |
|
223 |
mObject.quaternion(mQuatInt2, rotateObj); |
|
212 | 224 |
|
213 |
mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) ); |
|
214 |
mObject.scale(factor); |
|
215 |
mObject.quaternion(mQuatInt1, center); |
|
216 |
mObject.quaternion(mQuatInt2, center); |
|
225 |
int centerSize = mCenter.getWidth(); |
|
226 |
Static3D rotateCen = new Static3D(width/2,height/2, 0); |
|
217 | 227 |
|
218 |
factor *= 0.5f;
|
|
228 |
float factorCen = (float)(mCols*SIZE) / (5*centerSize); // make the 'center' bitmap 1/5 of the Object's width
|
|
219 | 229 |
|
220 |
mCenter.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 10) ); |
|
221 |
mCenter.scale(factor); |
|
222 |
mCenter.quaternion(mQuatInt1, center); |
|
223 |
mCenter.quaternion(mQuatInt2, center); |
|
230 |
mCenter.quaternion(mQuatInt1, rotateCen); |
|
231 |
mCenter.quaternion(mQuatInt2, rotateCen); |
|
232 |
mCenter.move( new Static3D( (width -factorCen*centerSize-factorObj*mObjWidth )/2 , |
|
233 |
(height-factorCen*centerSize-factorObj*mObjHeight)/2 , 10) ); |
|
234 |
mCenter.move(mMoveInter); |
|
235 |
mCenter.scale(factorCen); |
|
224 | 236 |
|
225 | 237 |
setVertexEffects(); |
226 | 238 |
|
Also available in: Unified diff
Progress with vertex3D