Revision 794e6c4f
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import org.distorted.examples.R; |
28 | 28 |
import org.distorted.library.Distorted; |
29 |
import org.distorted.library.DistortedBitmap; |
|
29 | 30 |
import org.distorted.library.DistortedCubes; |
30 | 31 |
import org.distorted.library.DistortedObject; |
31 | 32 |
import org.distorted.library.EffectNames; |
32 | 33 |
import org.distorted.library.EffectTypes; |
33 | 34 |
import org.distorted.library.type.Dynamic1D; |
35 |
import org.distorted.library.type.Dynamic2D; |
|
34 | 36 |
import org.distorted.library.type.Dynamic3D; |
35 | 37 |
import org.distorted.library.type.DynamicQuat; |
36 | 38 |
import org.distorted.library.type.Static1D; |
... | ... | |
48 | 50 |
|
49 | 51 |
class Vertex3DRenderer implements GLSurfaceView.Renderer |
50 | 52 |
{ |
53 |
public static final int SIZE = 100; |
|
54 |
|
|
51 | 55 |
private GLSurfaceView mView; |
52 | 56 |
private static DistortedObject mObject; |
53 | 57 |
|
... | ... | |
56 | 60 |
private DynamicQuat mQuatInt1, mQuatInt2; |
57 | 61 |
|
58 | 62 |
private static EffectNames[] order; |
59 |
|
|
63 |
|
|
64 |
private static Dynamic2D mCenterInter; |
|
60 | 65 |
private static Dynamic3D mDeformInter, mDistortInter; |
61 | 66 |
private static Dynamic1D mSinkInter, mSwirlInter; |
62 | 67 |
|
... | ... | |
95 | 100 |
mSwirlPoint.set(s); |
96 | 101 |
} |
97 | 102 |
|
103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
104 |
|
|
105 |
public static void setCenter(float x, float y) |
|
106 |
{ |
|
107 |
mCenterPoint.set(x,y); |
|
108 |
} |
|
109 |
|
|
98 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
99 | 111 |
|
100 | 112 |
public static void setOrder(EffectNames[] effects) |
... | ... | |
108 | 120 |
public static void setVertexEffects() |
109 | 121 |
{ |
110 | 122 |
mObject.abortEffects(EffectTypes.VERTEX); |
111 |
|
|
123 |
|
|
112 | 124 |
for( int i=0; i<=order.length-1 ; i++ ) |
113 | 125 |
{ |
114 | 126 |
switch(order[i]) |
115 | 127 |
{ |
116 |
case DEFORM : mObject.deform( mDeformInter , mCenterPoint) ; break;
|
|
117 |
case DISTORT: mObject.distort(mDistortInter, mCenterPoint) ; break;
|
|
118 |
case SINK : mObject.sink( mSinkInter , mCenterPoint) ; break;
|
|
119 |
case SWIRL : mObject.swirl( mSwirlInter , mCenterPoint) ; break;
|
|
128 |
case DEFORM : mObject.deform( mDeformInter , mCenterInter) ; break;
|
|
129 |
case DISTORT: mObject.distort(mDistortInter, mCenterInter) ; break;
|
|
130 |
case SINK : mObject.sink( mSinkInter , mCenterInter) ; break;
|
|
131 |
case SWIRL : mObject.swirl( mSwirlInter , mCenterInter) ; break;
|
|
120 | 132 |
} |
121 | 133 |
} |
122 | 134 |
} |
... | ... | |
127 | 139 |
{ |
128 | 140 |
mView = v; |
129 | 141 |
|
130 |
mObject = new DistortedCubes( Vertex3DActivity.getCols(), Vertex3DActivity.getShape(), 100);
|
|
131 |
//mObject = new DistortedBitmap( 100, 100, 10);
|
|
142 |
mObject = new DistortedCubes( Vertex3DActivity.getCols(), Vertex3DActivity.getShape(), SIZE);
|
|
143 |
//mObject = new DistortedBitmap( SIZE, SIZE, 10);
|
|
132 | 144 |
|
133 | 145 |
mObjWidth = mObject.getWidth(); |
134 | 146 |
mObjHeight= mObject.getHeight(); |
... | ... | |
139 | 151 |
mSwirlPoint = new Static1D(0); |
140 | 152 |
mSinkPoint = new Static1D(1); |
141 | 153 |
|
154 |
mCenterInter = new Dynamic2D(); |
|
142 | 155 |
mDeformInter = new Dynamic3D(); |
143 | 156 |
mDistortInter = new Dynamic3D(); |
144 | 157 |
mSwirlInter = new Dynamic1D(); |
145 | 158 |
mSinkInter = new Dynamic1D(); |
146 | 159 |
|
160 |
mCenterInter.add(mCenterPoint); |
|
147 | 161 |
mDeformInter.add(mDeformPoint); |
148 | 162 |
mDistortInter.add(mDistortPoint); |
149 | 163 |
mSwirlInter.add(mSwirlPoint); |
... | ... | |
180 | 194 |
|
181 | 195 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
182 | 196 |
{ |
183 |
factor = (0.8f*height)/mObjHeight;
|
|
197 |
factor = (0.7f*height)/mObjHeight;
|
|
184 | 198 |
} |
185 | 199 |
else |
186 | 200 |
{ |
187 |
factor = (0.8f*width)/mObjWidth;
|
|
201 |
factor = (0.7f*width)/mObjWidth;
|
|
188 | 202 |
} |
189 | 203 |
|
190 | 204 |
mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) ); |
Also available in: Unified diff
Vertex3D: add configurable center