Revision 40eef4b9
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
---|---|---|
27 | 27 |
import org.distorted.examples.R; |
28 | 28 |
import org.distorted.library.Distorted; |
29 | 29 |
import org.distorted.library.GridCubes; |
30 |
import org.distorted.library.DistortedObject; |
|
30 |
import org.distorted.library.DistortedEffectQueues; |
|
31 |
import org.distorted.library.DistortedTexture; |
|
31 | 32 |
import org.distorted.library.EffectTypes; |
32 | 33 |
import org.distorted.library.type.Dynamic; |
33 | 34 |
import org.distorted.library.type.Dynamic5D; |
... | ... | |
47 | 48 |
class FlagRenderer implements GLSurfaceView.Renderer |
48 | 49 |
{ |
49 | 50 |
private GLSurfaceView mView; |
50 |
private DistortedObject mObject; |
|
51 |
private DistortedEffectQueues mQueues; |
|
52 |
private DistortedTexture mTexture; |
|
51 | 53 |
private GridCubes mGrid; |
52 | 54 |
private int mObjWidth, mObjHeight; |
53 | 55 |
private DynamicQuat mQuatInt1, mQuatInt2; |
... | ... | |
63 | 65 |
{ |
64 | 66 |
mView = v; |
65 | 67 |
|
66 |
mGrid = new GridCubes(50,30,false); |
|
67 |
mObject = new DistortedObject(500,300,10); |
|
68 |
mQueues = new DistortedEffectQueues(); |
|
69 |
mGrid = new GridCubes(50,30,false); |
|
70 |
mTexture = new DistortedTexture(500,300,10); |
|
68 | 71 |
|
69 |
mObjWidth = mObject.getWidth();
|
|
70 |
mObjHeight= mObject.getHeight();
|
|
72 |
mObjWidth = mTexture.getWidth();
|
|
73 |
mObjHeight= mTexture.getHeight();
|
|
71 | 74 |
|
72 | 75 |
mWaveDyn = new Dynamic5D(1000,0.0f); |
73 | 76 |
mWaveSta1= new Static5D(0,0,-180,0,0); // all other values besides the |
... | ... | |
89 | 92 |
Static3D waveCenter = new Static3D(mObjWidth, mObjHeight/2, 0); // middle of the right edge |
90 | 93 |
Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth); |
91 | 94 |
|
92 |
mObject.wave(mWaveDyn, waveCenter, waveRegion);
|
|
95 |
mQueues.wave(mWaveDyn, waveCenter, waveRegion);
|
|
93 | 96 |
} |
94 | 97 |
|
95 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
136 | 139 |
public void onDrawFrame(GL10 glUnused) |
137 | 140 |
{ |
138 | 141 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
139 |
mObject.draw(System.currentTimeMillis(), mGrid);
|
|
142 |
mQueues.draw(System.currentTimeMillis(), mTexture, mGrid);
|
|
140 | 143 |
} |
141 | 144 |
|
142 | 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
145 | 148 |
{ |
146 | 149 |
mScreenMin = width<height ? width:height; |
147 | 150 |
|
148 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
151 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
149 | 152 |
float factor; |
150 | 153 |
|
151 | 154 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
... | ... | |
157 | 160 |
factor = (0.8f*width)/mObjWidth; |
158 | 161 |
} |
159 | 162 |
|
160 |
mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
161 |
mObject.scale(factor);
|
|
163 |
mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
164 |
mQueues.scale(factor);
|
|
162 | 165 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
163 | 166 |
|
164 |
mObject.quaternion(mQuatInt1, center);
|
|
165 |
mObject.quaternion(mQuatInt2, center);
|
|
167 |
mQueues.quaternion(mQuatInt1, center);
|
|
168 |
mQueues.quaternion(mQuatInt2, center);
|
|
166 | 169 |
|
167 | 170 |
Distorted.onSurfaceChanged(width, height); |
168 | 171 |
} |
... | ... | |
189 | 192 |
catch(IOException e) { } |
190 | 193 |
} |
191 | 194 |
|
192 |
mObject.setTexture(bitmap);
|
|
195 |
mTexture.setTexture(bitmap);
|
|
193 | 196 |
|
194 | 197 |
try |
195 | 198 |
{ |
Also available in: Unified diff
Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.
Still does not compile, but pushing already.