Project

General

Profile

« Previous | Next » 

Revision 41d39cea

Added by Leszek Koltunski about 8 years ago

Flag app finished

View differences:

src/main/java/org/distorted/examples/flag/FlagActivity.java
142 142

  
143 143
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
144 144
      {
145
      FlagSurfaceView mView = (FlagSurfaceView) this.findViewById(R.id.flagSurfaceView);
146
      FlagRenderer renderer = mView.getRenderer();
147

  
145 148
      switch (bar.getId())
146 149
        {
147
        case R.id.flagSeekAmplitude     : FlagRenderer.setAmplitude(progress);
150
        case R.id.flagSeekAmplitude     : renderer.setAmplitude(progress);
148 151
                                          textAmplitude.setText("Amplitude "+progress);
149 152
                                          break;
150
        case R.id.flagSeekNoiseAmplitude: noise.set( (float)progress, noise.getY(), noise.getZ(), noise.getW(), noise.getV() );
151
                                          FlagRenderer.setNoise(noise);
153
        case R.id.flagSeekNoiseAmplitude: noise.set1((float)progress/100);
154
                                          renderer.setNoise(noise);
152 155
                                          convert(progress);
153 156
                                          textNoiseAmplitude.setText("Noise "+mStr );
154 157
                                          break;
155
        case R.id.flagSeekLength        : FlagRenderer.setLength(progress);
156
                                          textLength.setText("Length "+(progress*2));
158
        case R.id.flagSeekLength        : progress = progress*2;
159
                                          renderer.setLength(progress);
160
                                          textLength.setText("Length "+progress);
157 161
                                          break;
158
        case R.id.flagSeekNoiseLength   : noise.set( noise.getX(), (float)progress, noise.getZ(), noise.getW(), noise.getV() );
159
                                          FlagRenderer.setNoise(noise);
162
        case R.id.flagSeekNoiseLength   : noise.set2((float)progress/100);
163
                                          renderer.setNoise(noise);
160 164
                                          convert(progress);
161 165
                                          textNoiseLength.setText("Noise "+mStr );
162 166
                                          break;
163
        case R.id.flagSeekAngleA        : FlagRenderer.setAngleA(progress);
164
                                          textAngleA.setText("Alpha "+((360*progress)/100));
167
        case R.id.flagSeekAngleA        : progress = (360*progress)/100;
168
                                          renderer.setAngleA(progress);
169
                                          textAngleA.setText("Alpha "+progress);
165 170
                                          break;
166
        case R.id.flagSeekNoiseAngleA   : noise.set( noise.getX(), noise.getY(), noise.getZ() ,(float)progress, noise.getV() );
167
                                          FlagRenderer.setNoise(noise);
171
        case R.id.flagSeekNoiseAngleA   : noise.set4((float)progress/100);
172
                                          renderer.setNoise(noise);
168 173
                                          convert(progress);
169 174
                                          textNoiseAngleA.setText("Noise "+mStr );
170 175
                                          break;
171
        case R.id.flagSeekAngleB        : FlagRenderer.setAngleB(progress);
172
                                          textAngleB.setText("Beta "+((360*progress)/100));
176
        case R.id.flagSeekAngleB        : progress = ((360*progress)/100);
177
                                          renderer.setAngleB(progress);
178
                                          textAngleB.setText("Beta "+progress);
173 179
                                          break;
174
        case R.id.flagSeekNoiseAngleB   : noise.set( noise.getX(), noise.getY(), noise.getZ(), noise.getW(), (float)progress );
175
                                          FlagRenderer.setNoise(noise);
180
        case R.id.flagSeekNoiseAngleB   : noise.set5((float)progress/100);
181
                                          renderer.setNoise(noise);
176 182
                                          convert(progress);
177 183
                                          textNoiseAngleB.setText("Noise "+mStr );
178 184
                                          break;
src/main/java/org/distorted/examples/flag/FlagRenderer.java
51 51
    private DistortedObject mObject;
52 52
    private int mObjWidth, mObjHeight;
53 53
    private DynamicQuat mQuatInt1, mQuatInt2;
54
    private Dynamic5D mWaveDyn;
55
    private Static5D mWaveSta1, mWaveSta2;
54 56

  
55 57
    Static4D mQuat1, mQuat2;
56 58

  
......
67 69
      mObjWidth = mObject.getWidth();
68 70
      mObjHeight= mObject.getHeight();
69 71

  
70
      Static2D mWaveCenter = new Static2D(mObjWidth, mObjHeight/2);  // middle of the right edge
71
      Static4D mWaveRegion = new Static4D(0,0,mObjWidth,mObjWidth);
72

  
73
      Dynamic5D mWaveDyn = new Dynamic5D(1000,0.0f);
74
      Static5D  mWaveSta1= new Static5D(50,100,-180,90,0);
75
      Static5D  mWaveSta2= new Static5D(50,100,+180,90,0);
72
      mWaveDyn = new Dynamic5D(1000,0.0f);
73
      mWaveSta1= new Static5D(0,0,-180,0,0);  // all other values besides the
74
      mWaveSta2= new Static5D(0,0,+180,0,0);  // fourth will be set from the UI
76 75

  
77 76
      mWaveDyn.add(mWaveSta1);
78 77
      mWaveDyn.add(mWaveSta2);
79 78
      mWaveDyn.setMode(Dynamic.MODE_JUMP);
80 79

  
81
      //mWaveDyn.setNoise( new Static5D(0.1f, 0.1f, 0.1f, 0.1f, 0.1f) );
82

  
83 80
      mQuat1 = new Static4D(           0,         0,           0,          1);  // unity quaternion
84 81
      mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);  // something semi-random that looks good
85 82

  
......
89 86
      mQuatInt1.add(mQuat1);
90 87
      mQuatInt2.add(mQuat2);
91 88

  
92
      mObject.wave(mWaveDyn, mWaveCenter, mWaveRegion);
89
      Static2D waveCenter = new Static2D(mObjWidth, mObjHeight/2);  // middle of the right edge
90
      Static4D waveRegion = new Static4D(0,0,mObjWidth,mObjWidth);
91

  
92
      mObject.wave(mWaveDyn, waveCenter, waveRegion);
93 93
      }
94 94

  
95 95
///////////////////////////////////////////////////////////////////////////////////////////////////
96 96

  
97
    public static void setAmplitude(int a)
97
    void setAmplitude(int a)
98 98
      {
99

  
99
      mWaveSta1.set1(a);
100
      mWaveSta2.set1(a);
100 101
      }
101 102

  
102 103
///////////////////////////////////////////////////////////////////////////////////////////////////
103 104

  
104
    public static void setLength(int l)
105
    void setLength(int l)
105 106
      {
106

  
107
      mWaveSta1.set2(l);
108
      mWaveSta2.set2(l);
107 109
      }
108 110

  
109 111
///////////////////////////////////////////////////////////////////////////////////////////////////
110 112

  
111
    public static void setAngleA(int a)
113
    void setAngleA(int a)
112 114
      {
113

  
115
      mWaveSta1.set4(a);
116
      mWaveSta2.set4(a);
114 117
      }
115 118

  
116 119
///////////////////////////////////////////////////////////////////////////////////////////////////
117 120

  
118
    public static void setAngleB(int b)
121
    void setAngleB(int b)
119 122
      {
120

  
123
      mWaveSta1.set5(b);
124
      mWaveSta2.set5(b);
121 125
      }
122 126

  
123 127
///////////////////////////////////////////////////////////////////////////////////////////////////
124 128

  
125
    public static void setNoise(Static5D noise)
129
    void setNoise(Static5D noise)
126 130
      {
127

  
131
      mWaveDyn.setNoise(noise);
128 132
      }
129 133

  
130 134
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/examples/flag/FlagSurfaceView.java
57 57
      }
58 58
    
59 59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
    
60

  
61
    public FlagRenderer getRenderer()
62
      {
63
      return mRenderer;
64
      }
65

  
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

  
61 68
    @Override public boolean onTouchEvent(MotionEvent event) 
62 69
      {
63 70
      int action = event.getAction();

Also available in: Unified diff