Project

General

Profile

« Previous | Next » 

Revision 3bec5dc2

Added by Leszek Koltunski over 8 years ago

Fragment3D finished.

View differences:

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

  
293 293
    setContentView(view);
294 294

  
295
    String[] effects = new String[] {"CHROMA", "ALPHA", "BRIGHTNESS", "SATURATION"};
295
    String[] effects = new String[] { "MACROBLOCK",
296
                                      "ALPHA",
297
                                      "SMOOTH_ALPHA",
298
                                      "CHROMA",
299
                                      "SMOOTH_CHROMA",
300
                                      "BRIGHTNESS",
301
                                      "SMOOTH_BRIGHTNESS",
302
                                      "SATURATION",
303
                                      "SMOOTH_SATURATION",
304
                                      "CONTRAST",
305
                                      "SMOOTH_CONTRAST" };
296 306

  
297 307
    Spinner effectSpinner = (Spinner)findViewById(R.id.fragment3dspinner );
298 308
    effectSpinner.setOnItemSelectedListener(this);
......
312 322

  
313 323
    switch(mEffectAdd)
314 324
      {
315
      case 0 : name = EffectNames.CHROMA    ; break;
316
      case 1 : name = EffectNames.ALPHA     ; break;
317
      case 2 : name = EffectNames.BRIGHTNESS; break;
318
      case 3 : name = EffectNames.SATURATION; break;
325
      case 0 : name = EffectNames.MACROBLOCK       ; break;
326
      case 1 : name = EffectNames.ALPHA            ; break;
327
      case 2 : name = EffectNames.SMOOTH_ALPHA     ; break;
328
      case 3 : name = EffectNames.CHROMA           ; break;
329
      case 4 : name = EffectNames.SMOOTH_CHROMA    ; break;
330
      case 5 : name = EffectNames.BRIGHTNESS       ; break;
331
      case 6 : name = EffectNames.SMOOTH_BRIGHTNESS; break;
332
      case 7 : name = EffectNames.SATURATION       ; break;
333
      case 8 : name = EffectNames.SMOOTH_SATURATION; break;
334
      case 9 : name = EffectNames.CONTRAST         ; break;
335
      case 10: name = EffectNames.SMOOTH_CONTRAST  ; break;
319 336
      default: return;
320 337
      }
321 338

  
......
334 351

  
335 352
    switch(mEffectAdd)
336 353
      {
337
      case 0: mObject.chroma    (dyn1, dyn3, regi, false); break;
354
      case 0: mObject.macroblock(dyn1,       regi       ); break;
338 355
      case 1: mObject.alpha     (dyn1,       regi, false); break;
339
      case 2: mObject.brightness(dyn1,       regi, false); break;
340
      case 3: mObject.saturation(dyn1,       regi, false); break;
356
      case 2: mObject.alpha     (dyn1,       regi, true ); break;
357
      case 3: mObject.chroma    (dyn1, dyn3, regi, false); break;
358
      case 4: mObject.chroma    (dyn1, dyn3, regi, true ); break;
359
      case 5: mObject.brightness(dyn1,       regi, false); break;
360
      case 6: mObject.brightness(dyn1,       regi, true ); break;
361
      case 7: mObject.saturation(dyn1,       regi, false); break;
362
      case 8: mObject.saturation(dyn1,       regi, true ); break;
363
      case 9: mObject.contrast  (dyn1,       regi, false); break;
364
      case 10:mObject.contrast  (dyn1,       regi, true ); break;
365

  
341 366
      }
342 367
    }
343 368

  
src/main/java/org/distorted/examples/fragment3d/Fragment3DEffect.java
87 87

  
88 88
  private void setRegionText()
89 89
    {
90
    float f0 = ((int)(mRegionSta.getX()*100))/100.0f;
91
    float f1 = ((int)(mRegionSta.getY()*100))/100.0f;
92
    float f2 = ((int)(mRegionSta.getZ()*100))/100.0f;
93
    float f3 = ((int)(mRegionSta.getW()*100))/100.0f;
90
    int f0 = (int)mRegionSta.getX();
91
    int f1 = (int)mRegionSta.getY();
92
    int f2 = (int)mRegionSta.getZ();
93
    int f3 = (int)mRegionSta.getW();
94 94

  
95 95
    mTextRegion.setText("region ("+f0+","+f1+","+f2+","+f3+")");
96 96
    }
......
101 101
    {
102 102
    switch(mName)
103 103
      {
104
      case CHROMA    : mSta1.set(mInter[0]/100.0f);
105
                       mSta3.set(255.0f*mInter[1]/100,
106
                                 255.0f*mInter[2]/100,
107
                                 255.0f*mInter[3]/100);
108
                       break;
109
      case ALPHA     : mSta1.set(mInter[0]/100.0f);
110
                       break;
111
      case BRIGHTNESS: mSta1.set(mInter[0]/100.0f);
112
                       break;
113
      case SATURATION: mSta1.set(mInter[0]/100.0f);
114
                       break;
104
      case MACROBLOCK       : Fragment3DActivity act = mAct.get();
105
                              mSta1.set(mInter[0]*act.getWidth() / 100.0f);
106
                              break;
107
      case ALPHA            :
108
      case SMOOTH_ALPHA     :
109
      case BRIGHTNESS       :
110
      case SMOOTH_BRIGHTNESS:
111
      case SATURATION       :
112
      case SMOOTH_SATURATION:
113
      case CONTRAST         :
114
      case SMOOTH_CONTRAST  : mSta1.set(mInter[0]/100.0f);
115
                              break;
116

  
117
      case CHROMA           :
118
      case SMOOTH_CHROMA    : mSta1.set(mInter[0]/100.0f);
119
                              mSta3.set(255.0f*mInter[1]/100,
120
                                        255.0f*mInter[2]/100,
121
                                        255.0f*mInter[3]/100);
122
                              break;
115 123
      }
116 124
    }
117 125

  
......
121 129
    {
122 130
    switch(mName)
123 131
      {
124
      case CHROMA    : mInter[0] =   0;
125
                       mInter[1] =   0;
126
                       mInter[2] =   0;
127
                       mInter[3] =   0;
128
                       break;
129
      case ALPHA     : mInter[0] = 100;
130
                       break;
131
      case BRIGHTNESS: mInter[0] = 100;
132
                       break;
133
      case SATURATION: mInter[0] = 100;
134
                       break;
132
      case MACROBLOCK       : mInter[0] =  3;
133
                              break;
134
      case ALPHA            :
135
      case SMOOTH_ALPHA     :
136
      case BRIGHTNESS       :
137
      case SMOOTH_BRIGHTNESS:
138
      case SATURATION       :
139
      case SMOOTH_SATURATION:
140
      case CONTRAST         :
141
      case SMOOTH_CONTRAST  : mInter[0] = 50;
142
                              break;
143

  
144
      case CHROMA           :
145
      case SMOOTH_CHROMA    : mInter[0] = 50;
146
                              mInter[1] =  0;
147
                              mInter[2] =  0;
148
                              mInter[3] =  0;
149
                              break;
135 150
      }
136 151
    }
137 152

  
......
139 154

  
140 155
  private void setText()
141 156
    {
142
    float f1 = ((int)mSta1.getX()*100)/100.0f;
157
    float f1 = ((int)(mSta1.getX()*100))/100.0f;
143 158

  
144
    switch(mName)
159
    String text = mName.name() +" "+f1;
160

  
161
    if( mName==EffectNames.CHROMA || mName==EffectNames.SMOOTH_CHROMA)
145 162
      {
146
      case CHROMA    : float f2 = ((int)mSta3.getX()*100)/100.0f;
147
                       float f3 = ((int)mSta3.getY()*100)/100.0f;
148
                       float f4 = ((int)mSta3.getZ()*100)/100.0f;
149
                       mText.setText("chroma "+f1+"("+f2+","+f3+","+f4+")");
150
                       break;
151
      case ALPHA     : mText.setText("alpha ("+f1+")");
152
                       break;
153
      case BRIGHTNESS: mText.setText("brightness ("+f1+")");
154
                       break;
155
      case SATURATION: mText.setText("saturation ("+f1+")");
156
                       break;
163
      int f2 = (int)mSta3.getX();
164
      int f3 = (int)mSta3.getY();
165
      int f4 = (int)mSta3.getZ();
166
      text += "("+f2+","+f3+","+f4+")";
157 167
      }
168

  
169
    mText.setText(text);
158 170
    }
159 171

  
160 172
///////////////////////////////////////////////////////////////////////////////////////////////////
......
164 176
    mAct = new WeakReference<>(act);
165 177
    mName = name;
166 178

  
167
    if( mName==EffectNames.CHROMA )
179
    if( mName==EffectNames.CHROMA || mName==EffectNames.SMOOTH_CHROMA )
168 180
      {
169 181
      mDimension = 4;
170 182
      mDyn3 = new Dynamic3D();
src/main/res/values/strings.xml
93 93
    <string name="example_cubes_subtitle">Tests the DistortedCubes render target.</string>
94 94
    <string name="example_quaternion">Quaternion</string>  
95 95
    <string name="example_quaternion_subtitle">Random rotations using quaternions.</string>
96
    <string name="example_matrix3d">3D Matrix Effects</string>
96
    <string name="example_matrix3d">Matrix Effects</string>
97 97
    <string name="example_matrix3d_subtitle">Test results of Matrix effects on a 3D object.</string>
98
    <string name="example_vertex3d">3D Vertex Effects</string>
98
    <string name="example_vertex3d">Vertex Effects</string>
99 99
    <string name="example_vertex3d_subtitle">Test results of Vertex effects on a 3D object.</string>
100
    <string name="example_fragment3d">3D Fragment Effects</string>
100
    <string name="example_fragment3d">Fragment Effects</string>
101 101
    <string name="example_fragment3d_subtitle">Test results of Fragment effects on a 3D object.</string>
102 102
    <string name="example_plainmonalisa">PlainMonaLisa</string>
103 103
    <string name="example_plainmonalisa_subtitle">MonaLisa rendered on a plain SurfaceView</string>

Also available in: Unified diff