Revision f6d884d5
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 |
import org.distorted.library.DistortedObject; |
|
30 |
import org.distorted.library.DistortedTexture; |
|
31 |
import org.distorted.library.DistortedEffectQueues; |
|
31 | 32 |
import org.distorted.library.GridObject; |
32 | 33 |
import org.distorted.library.EffectTypes; |
33 | 34 |
import org.distorted.library.type.DynamicQuat; |
... | ... | |
45 | 46 |
class CubesRenderer implements GLSurfaceView.Renderer |
46 | 47 |
{ |
47 | 48 |
private GLSurfaceView mView; |
48 |
private DistortedObject mObject; |
|
49 |
private DistortedTexture mTexture; |
|
50 |
private DistortedEffectQueues mQueues; |
|
49 | 51 |
private GridObject mGrid; |
52 |
private DynamicQuat mQuatInt1, mQuatInt2; |
|
50 | 53 |
private int mObjWidth, mObjHeight; |
51 | 54 |
|
52 |
private DynamicQuat mQuatInt1, mQuatInt2; |
|
53 |
|
|
54 | 55 |
Static4D mQuat1, mQuat2; |
55 | 56 |
int mScreenMin; |
56 | 57 |
|
... | ... | |
62 | 63 |
|
63 | 64 |
CubesActivity act = (CubesActivity)v.getContext(); |
64 | 65 |
|
65 |
mObject = act.getObject(); |
|
66 |
mGrid = act.getGrid(); |
|
66 |
mQueues = new DistortedEffectQueues(); |
|
67 |
mTexture = act.getTexture(); |
|
68 |
mGrid = act.getGrid(); |
|
67 | 69 |
|
68 |
mObjWidth = mObject.getWidth();
|
|
69 |
mObjHeight= mObject.getHeight();
|
|
70 |
mObjWidth = mTexture.getWidth();
|
|
71 |
mObjHeight= mTexture.getHeight();
|
|
70 | 72 |
|
71 | 73 |
mQuat1 = new Static4D(0,0,0,1); // unity |
72 | 74 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
... | ... | |
83 | 85 |
public void onDrawFrame(GL10 glUnused) |
84 | 86 |
{ |
85 | 87 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
86 |
mObject.draw(System.currentTimeMillis(),mGrid);
|
|
88 |
mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
|
|
87 | 89 |
} |
88 | 90 |
|
89 | 91 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
92 | 94 |
{ |
93 | 95 |
mScreenMin = width<height ? width:height; |
94 | 96 |
|
95 |
mObject.abortEffects(EffectTypes.MATRIX);
|
|
97 |
mQueues.abortEffects(EffectTypes.MATRIX);
|
|
96 | 98 |
float factor; |
97 | 99 |
|
98 | 100 |
if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object |
... | ... | |
104 | 106 |
factor = (0.8f*width)/mObjWidth; |
105 | 107 |
} |
106 | 108 |
|
107 |
mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
108 |
mObject.scale(factor);
|
|
109 |
mQueues.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
|
|
110 |
mQueues.scale(factor);
|
|
109 | 111 |
Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0); |
110 | 112 |
|
111 |
mObject.quaternion(mQuatInt1, center);
|
|
112 |
mObject.quaternion(mQuatInt2, center);
|
|
113 |
mQueues.quaternion(mQuatInt1, center);
|
|
114 |
mQueues.quaternion(mQuatInt2, center);
|
|
113 | 115 |
|
114 | 116 |
Distorted.onSurfaceChanged(width, height); |
115 | 117 |
} |
... | ... | |
136 | 138 |
catch(IOException e) { } |
137 | 139 |
} |
138 | 140 |
|
139 |
mObject.setTexture(bitmap);
|
|
141 |
mTexture.setTexture(bitmap);
|
|
140 | 142 |
|
141 | 143 |
try |
142 | 144 |
{ |
Also available in: Unified diff
Complete the split DistortedObject -> (DistortedTexture,DistortedEffectQueue)