Project

General

Profile

« Previous | Next » 

Revision 7e9be46d

Added by Leszek Koltunski almost 8 years ago

Improve Fragment3D app some more!

View differences:

src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
61 61

  
62 62
    private DynamicQuat mQuatInt1, mQuatInt2;
63 63

  
64
    private EffectNames[] order;
65

  
66
    private Dynamic2D mCenterInter;
67
    private Dynamic3D mChromaInter, mMoveInter;
68
    private Dynamic1D mChromaLevelInter, mAlphaInter, mBrightnessInter, mSaturationInter;
69

  
70
    private Static2D mCenterPoint;
71
    private Static3D mChromaPoint, mMovePoint;
72
    private Static1D mChromaLevel, mAlphaPoint, mBrightnessPoint, mSaturationPoint;
64
    private Dynamic3D mMoveInter;
65
    private Static3D mMovePoint;
73 66

  
74 67
    Static4D mQuat1, mQuat2;
75 68
    int mScreenMin;
76 69

  
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

  
79
    public void setChroma(float level, float r, float g, float b)
80
      {
81
      mChromaLevel.set(level);
82
      mChromaPoint.set(r, g, b);
83
      }
84
    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

  
87
    public void setAlpha(float level)
88
      {
89
      mAlphaPoint.set(level);
90
      }
91
     
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
    public void setBrightness(float level)
95
      {
96
      mBrightnessPoint.set(level);
97
      }
98
    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

  
101
    public void setSaturation(float level)
102
      {
103
      mSaturationPoint.set(level);
104
      }
105

  
106 70
///////////////////////////////////////////////////////////////////////////////////////////////////
107 71

  
108 72
    public void setCenter(float x, float y)
......
110 74
      x = (0.012f*x-0.1f)*mObjWidth;
111 75
      y = (0.012f*y-0.1f)*mObjHeight;
112 76

  
113
      mCenterPoint.set(x,y);
114 77
      mMovePoint.set(mFactorObj*x,mFactorObj*y,0);
115 78
      }
116 79

  
117
///////////////////////////////////////////////////////////////////////////////////////////////////
118

  
119
    public void setOrder(EffectNames[] effects)
120
      {
121
      order = effects;
122
      setFragmentEffects();
123
      }
124
      
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

  
127
    private void setFragmentEffects()
128
      {
129
      mObject.abortEffects(EffectTypes.FRAGMENT);
130

  
131
      for( int i=0; i<=order.length-1 ; i++ )
132
        {
133
        switch(order[i])
134
          {
135
          case CHROMA    : mObject.chroma    ( mChromaLevelInter , mChromaInter) ; break;
136
          case ALPHA     : mObject.alpha     ( mAlphaInter                     ) ; break;
137
          case BRIGHTNESS: mObject.brightness( mBrightnessInter                ) ; break;
138
          case SATURATION: mObject.saturation( mSaturationInter                ) ; break;
139
          }
140
        }
141
      }
142
    
143 80
///////////////////////////////////////////////////////////////////////////////////////////////////
144 81

  
145 82
    public Fragment3DRenderer(GLSurfaceView v)
......
152 89
      mObjWidth = mObject.getWidth();
153 90
      mObjHeight= mObject.getHeight();
154 91

  
155
      mCenterPoint    = new Static2D(0,0);
156
      mMovePoint      = new Static3D(0,0,0);
157
      mChromaPoint    = new Static3D(0,0,0);
158
      mChromaLevel    = new Static1D(0);
159
      mAlphaPoint     = new Static1D(1);
160
      mBrightnessPoint= new Static1D(1);
161
      mSaturationPoint= new Static1D(0.5f);
162

  
163
      mCenterInter     = new Dynamic2D();
164
      mMoveInter       = new Dynamic3D();
165
      mChromaInter     = new Dynamic3D();
166
      mChromaLevelInter= new Dynamic1D();
167
      mAlphaInter      = new Dynamic1D();
168
      mBrightnessInter = new Dynamic1D();
169
      mSaturationInter = new Dynamic1D();
170

  
171
      mCenterInter.add(mCenterPoint);
92
      mMovePoint= new Static3D(0,0,0);
93
      mMoveInter= new Dynamic3D();
172 94
      mMoveInter.add(mMovePoint);
173
      mChromaInter.add(mChromaPoint);
174
      mChromaLevelInter.add(mChromaLevel);
175
      mAlphaInter.add(mAlphaPoint);
176
      mBrightnessInter.add(mBrightnessPoint);
177
      mSaturationInter.add(mSaturationPoint);
178 95

  
179 96
      mQuat1 = new Static4D(0,0,0,1);  // unity
180 97
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
246 163
      mCenter.move(mMoveInter);
247 164
      mCenter.scale(mFactorCen);
248 165

  
249
      setFragmentEffects();
250

  
251 166
      Distorted.onSurfaceChanged(width, height); 
252 167
      }
253 168

  

Also available in: Unified diff