Project

General

Profile

« Previous | Next » 

Revision dea555b9

Added by Leszek Koltunski over 5 years ago

Add the 'convexity' param to Dynamics and the Dynamic app.

View differences:

src/main/java/org/distorted/examples/dynamic/DynamicActivity.java
41 41

  
42 42
public class DynamicActivity extends Activity implements OnSeekBarChangeListener, AdapterView.OnItemSelectedListener
43 43
    {
44
    private TextView textD, textC, textN;
44
    private TextView textD, textC, textN, textX;
45 45
    private int p0,p1,p2;
46 46
    private int mDim, mMode;
47 47

  
......
55 55

  
56 56
      textD = findViewById(R.id.dynamicTextDuration);
57 57
      textC = findViewById(R.id.dynamicTextCount);
58
      textX = findViewById(R.id.dynamicTextConvexity);
58 59
      textN = findViewById(R.id.dynamicTextNoise);
59 60

  
60 61
      p0=p1=p2=0;
......
65 66
      barD.setOnSeekBarChangeListener(this);
66 67
      SeekBar barC = findViewById(R.id.dynamicSeekCount);
67 68
      barC.setOnSeekBarChangeListener(this);
69
      SeekBar barX = findViewById(R.id.dynamicSeekConvexity);
70
      barX.setOnSeekBarChangeListener(this);
68 71
      SeekBar bar0 = findViewById(R.id.dynamicSeekNoise0);
69 72
      bar0.setOnSeekBarChangeListener(this);
70 73
      SeekBar bar1 = findViewById(R.id.dynamicSeekNoise1);
......
94 97
        {
95 98
        barD.setProgress(50);
96 99
        barC.setProgress(20);
100
        barX.setProgress(50);
97 101
        bar0.setProgress(0);
98 102
        bar1.setProgress(0);
99 103
        bar2.setProgress(0);
......
285 289
        view.setCount(count);
286 290
        textC.setText(getString(R.string.count_placeholder, count ));
287 291
        }
292
      else if( id == R.id.dynamicSeekConvexity )
293
        {
294
        float convexity = progress/25.0f - 1.0f;
295
        view.setConvexity(convexity);
296
        textX.setText(getString(R.string.convexity_placeholder, convexity ));
297
        }
288 298
      else
289 299
        {
290 300
        switch(id)
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java
202 202
      di3D.setCount(count);
203 203
      }
204 204

  
205
///////////////////////////////////////////////////////////////////////////////////////////////////
206

  
207
    public void setConvexity(float convexity)
208
      {
209
      di1D.setConvexity(convexity);
210
      di2D.setConvexity(convexity);
211
      di3D.setConvexity(convexity);
212
      }
213

  
205 214
///////////////////////////////////////////////////////////////////////////////////////////////////
206 215

  
207 216
    public void setNoise(float noise0, float noise1, float noise2)
......
436 445
      {
437 446
      float gx,gy,gz;
438 447
      int len;
439
      
448

  
440 449
      switch(currentDim)
441 450
        {
442 451
        case DIM_1D: len = di1D.getNumPoints();
443
                
452

  
444 453
                     for(int g=0; g<len; g++)
445 454
                       {
446 455
                       p1D = di1D.getPoint(g);  
src/main/res/layout/dynamicslayout.xml
41 41
            <LinearLayout
42 42
                android:layout_width="wrap_content"
43 43
                android:layout_height="fill_parent"
44
                android:layout_weight="0.5"
44
                android:layout_weight="1"
45 45
                android:layout_gravity="center_vertical"
46 46
                android:gravity="center|fill_horizontal"
47 47
                android:orientation="vertical">
......
54 54
                    android:text="@string/duration"
55 55
                    android:textAppearance="?android:attr/textAppearanceMedium"
56 56
                    android:textSize="12sp" />
57

  
58
                <SeekBar
59
                    android:id="@+id/dynamicSeekDuration"
60
                    android:layout_width="match_parent"
61
                    android:layout_height="wrap_content"
62
                    android:paddingStart="10dp"
63
                    android:paddingEnd="10dp" />
64

  
65 57
            </LinearLayout>
66 58

  
67 59
            <LinearLayout
68 60
                android:layout_width="wrap_content"
69 61
                android:layout_height="fill_parent"
70
                android:layout_weight="0.5"
62
                android:layout_weight="1"
71 63
                android:layout_gravity="center_vertical"
72 64
                android:gravity="center|fill_horizontal"
73 65
                android:orientation="vertical">
......
80 72
                    android:text="@string/count"
81 73
                    android:textAppearance="?android:attr/textAppearanceMedium"
82 74
                    android:textSize="12sp" />
75
            </LinearLayout>
83 76

  
84
                <SeekBar
85
                    android:id="@+id/dynamicSeekCount"
86
                    android:layout_width="match_parent"
87
                    android:layout_height="wrap_content"
88
                    android:paddingStart="5dp"
89
                    android:paddingEnd="10dp" />
77
            <LinearLayout
78
                android:layout_width="wrap_content"
79
                android:layout_height="fill_parent"
80
                android:layout_weight="1"
81
                android:layout_gravity="center_vertical"
82
                android:gravity="center|fill_horizontal"
83
                android:orientation="vertical">
90 84

  
85
                <TextView
86
                    android:id="@+id/dynamicTextConvexity"
87
                    android:layout_width="wrap_content"
88
                    android:layout_height="wrap_content"
89
                    android:layout_gravity="center_horizontal"
90
                    android:text="@string/convexity"
91
                    android:textAppearance="?android:attr/textAppearanceMedium"
92
                    android:textSize="12sp" />
91 93
            </LinearLayout>
94
        </LinearLayout>
95

  
96
        <LinearLayout
97
            android:orientation="horizontal"
98
            android:layout_width="match_parent"
99
            android:layout_height="match_parent"
100
            android:layout_weight="15"
101
            android:paddingBottom="5dp">
102

  
103
            <SeekBar
104
                android:id="@+id/dynamicSeekDuration"
105
                android:layout_width="match_parent"
106
                android:layout_height="wrap_content"
107
                android:layout_weight="1"
108
                android:paddingLeft="10dp"
109
                android:paddingRight="5dp" />
110

  
111
            <SeekBar
112
                android:id="@+id/dynamicSeekCount"
113
                android:layout_width="match_parent"
114
                android:layout_height="wrap_content"
115
                android:layout_weight="1"
116
                android:paddingLeft="5dp"
117
                android:paddingRight="5dp" />
92 118

  
119
            <SeekBar
120
                android:id="@+id/dynamicSeekConvexity"
121
                android:layout_width="match_parent"
122
                android:layout_height="wrap_content"
123
                android:layout_weight="1"
124
                android:paddingLeft="5dp"
125
                android:paddingRight="10dp" />
93 126
        </LinearLayout>
94 127

  
95 128
        <TextView
src/main/res/values/strings.xml
42 42
    <string name="print">Print</string>
43 43
    <string name="abort">Abort</string>
44 44
    <string name="count">Count</string>
45
    <string name="convexity">Convex</string>
45 46
    <string name="maxv">vertex:</string>
46 47
    <string name="maxf">fragment:</string>
47 48
    <string name="introduction">Set maximum number of vertex and fragment effects and press \'Check\' to see if shaders compile:</string>
......
117 118
    <string name="rubik_placeholder">Cube: %1$d Available Memory: %2$d MB</string>
118 119
    <string name="duration_placeholder">Duration: %1$d s</string>
119 120
    <string name="count_placeholder">Count: %1$.2f</string>
121
    <string name="convexity_placeholder">Convexity: %1$.2f</string>
120 122
    <string name="noise2_placeholder">Noise: %1$.2f %2$.2f %3$.2f</string>
121 123

  
122 124
    <string name="example_monalisa">Mona Lisa</string>

Also available in: Unified diff