Project

General

Profile

« Previous | Next » 

Revision 56e4be07

Added by Leszek Koltunski over 8 years ago

Improve Fragment3D app some more!

View differences:

src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java
310 310

  
311 311
    View view = chroma.createView(this);
312 312
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
313
    layout.addView(view,0);
313
    layout.addView(view);
314 314

  
315 315
    Dynamic1D dyn1 = chroma.getDyn1();
316 316
    Dynamic3D dyn3 = chroma.getDyn3();
......
327 327

  
328 328
    View view = alpha.createView(this);
329 329
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
330
    layout.addView(view,0);
330
    layout.addView(view);
331 331

  
332 332
    Dynamic1D dyn1 = alpha.getDyn1();
333 333

  
......
343 343

  
344 344
    View view = brightness.createView(this);
345 345
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
346
    layout.addView(view,0);
346
    layout.addView(view);
347 347

  
348 348
    Dynamic1D dyn1 = brightness.getDyn1();
349 349

  
......
359 359

  
360 360
    View view = saturation.createView(this);
361 361
    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
362
    layout.addView(view,0);
362
    layout.addView(view);
363 363

  
364 364
    Dynamic1D dyn1 = saturation.getDyn1();
365 365

  
src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
55 55
    private GLSurfaceView mView;
56 56
    private DistortedObject mObject;
57 57
    private DistortedBitmap mCenter;
58
    private DistortedBitmap mBackground;
58 59
    private float mFactorCen, mFactorObj;
59 60

  
60 61
    private int mObjWidth, mObjHeight;
......
83 84
      {
84 85
      mView = v;
85 86

  
86
      mObject = ((Fragment3DActivity)v.getContext()).getObject();
87
      mCenter = new DistortedBitmap(SIZE, SIZE, 1);
87
      mObject     = ((Fragment3DActivity)v.getContext()).getObject();
88
      mCenter     = new DistortedBitmap(SIZE, SIZE, 1);
89
      mBackground = new DistortedBitmap(SIZE, SIZE, 1);
88 90

  
89 91
      mObjWidth = mObject.getWidth();
90 92
      mObjHeight= mObject.getHeight();
......
112 114

  
113 115
      long time = System.currentTimeMillis();
114 116

  
117
      mBackground.draw(time);
115 118
      mObject.draw(time);
116 119
      mCenter.draw(time);
117 120
      }
......
124 127

  
125 128
      mObject.abortEffects(EffectTypes.MATRIX);
126 129
      mCenter.abortEffects(EffectTypes.MATRIX);
130
      mBackground.abortEffects(EffectTypes.MATRIX);
127 131

  
128 132
      int centerSize = mCenter.getWidth();
129 133

  
......
163 167
      mCenter.move(mMoveInter);
164 168
      mCenter.scale(mFactorCen);
165 169

  
170
      int backgroundSize = mBackground.getWidth();
171
      float factorBackX = ((float)width)/backgroundSize;
172
      float factorBackY = ((float)height)/backgroundSize;
173

  
174
      mBackground.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
175
      mBackground.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
176

  
166 177
      Distorted.onSurfaceChanged(width, height); 
167 178
      }
168 179

  
......
174 185

  
175 186
      InputStream is1 = act.getResources().openRawResource(act.getBitmap());
176 187
      InputStream is2 = act.getResources().openRawResource(R.raw.center);
188
      InputStream is3 = act.getResources().openRawResource(R.raw.water);
177 189

  
178
      Bitmap bitmap1,bitmap2;
190
      Bitmap bitmap1,bitmap2,bitmap3;
179 191
        
180 192
      try 
181 193
        {
182 194
        bitmap1 = BitmapFactory.decodeStream(is1);
183 195
        bitmap2 = BitmapFactory.decodeStream(is2);
196
        bitmap3 = BitmapFactory.decodeStream(is3);
184 197
        }
185 198
      finally 
186 199
        {
......
188 201
          {
189 202
          is1.close();
190 203
          is2.close();
204
          is3.close();
191 205
          } 
192 206
        catch(IOException e) { }
193 207
        }  
194 208
      
195 209
      mObject.setBitmap(bitmap1);
196 210
      mCenter.setBitmap(bitmap2);
197

  
211
      mBackground.setBitmap(bitmap3)
212
      ;
198 213
      try
199 214
        {
200 215
        Distorted.onSurfaceCreated(mView.getContext());

Also available in: Unified diff