Project

General

Profile

« Previous | Next » 

Revision 71d8ad03

Added by Leszek Koltunski over 8 years ago

Vertex3D: beginnings of support for a visible 'center' cross.

View differences:

src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
54 54

  
55 55
    private GLSurfaceView mView;
56 56
    private static DistortedObject mObject;
57
    private DistortedBitmap mCenter;
57 58

  
58 59
    private int mObjWidth, mObjHeight;
59 60

  
......
141 142

  
142 143
      mObject = new DistortedCubes( Vertex3DActivity.getCols(), Vertex3DActivity.getShape(), SIZE);
143 144
      //mObject = new DistortedBitmap( SIZE, SIZE, 10);
145
      mCenter = new DistortedBitmap(SIZE, SIZE, 1);
144 146

  
145 147
      mObjWidth = mObject.getWidth();
146 148
      mObjHeight= mObject.getHeight();
......
179 181
      {
180 182
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
181 183
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
182
      
183
      mObject.draw(System.currentTimeMillis());
184

  
185
      long time = System.currentTimeMillis();
186

  
187
      mObject.draw(time);
188
      mCenter.draw(time);
184 189
      }
185 190

  
186 191
///////////////////////////////////////////////////////////////////////////////////////////////////
......
190 195
      mScreenMin = width<height ? width:height;
191 196

  
192 197
      mObject.abortEffects(EffectTypes.MATRIX);
198
      mCenter.abortEffects(EffectTypes.MATRIX);
199

  
193 200
      float factor;
194 201

  
195 202
      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
......
201 208
        factor = (0.7f*width)/mObjWidth;
202 209
        }
203 210

  
204
      mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
205
      mObject.scale(factor);
206

  
207 211
      Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
208 212

  
213
      mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
214
      mObject.scale(factor);
209 215
      mObject.quaternion(mQuatInt1, center);
210 216
      mObject.quaternion(mQuatInt2, center);
211 217

  
218
      factor *= 0.5f;
219

  
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);
224

  
212 225
      setVertexEffects();
213 226

  
214 227
      Distorted.onSurfaceChanged(width, height); 
......
218 231
    
219 232
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
220 233
      {
221
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.grid);
222
      Bitmap bitmap;
234
      InputStream is1 = mView.getContext().getResources().openRawResource(R.raw.grid);
235
      InputStream is2 = mView.getContext().getResources().openRawResource(R.raw.center);
236

  
237
      Bitmap bitmap1,bitmap2;
223 238
        
224 239
      try 
225 240
        {
226
        bitmap = BitmapFactory.decodeStream(is);
227
        } 
241
        bitmap1 = BitmapFactory.decodeStream(is1);
242
        bitmap2 = BitmapFactory.decodeStream(is2);
243
        }
228 244
      finally 
229 245
        {
230 246
        try 
231 247
          {
232
          is.close();
248
          is1.close();
249
          is2.close();
233 250
          } 
234 251
        catch(IOException e) { }
235 252
        }  
236 253
      
237
      mObject.setBitmap(bitmap);
238
      
254
      mObject.setBitmap(bitmap1);
255
      mCenter.setBitmap(bitmap2);
256

  
239 257
      try
240 258
        {
241 259
        Distorted.onSurfaceCreated(mView.getContext());

Also available in: Unified diff