Revision 2666a48c
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/examples/dynamic/DynamicActivity.java | ||
---|---|---|
20 | 20 |
package org.distorted.examples.dynamic; |
21 | 21 |
|
22 | 22 |
import org.distorted.library.main.DistortedLibrary; |
23 |
import org.distorted.library.type.Dynamic; |
|
23 | 24 |
import org.distorted.library.type.Dynamic1D; |
24 | 25 |
import org.distorted.examples.R; |
25 | 26 |
|
... | ... | |
27 | 28 |
import android.opengl.GLSurfaceView; |
28 | 29 |
import android.os.Bundle; |
29 | 30 |
import android.view.View; |
31 |
import android.widget.AdapterView; |
|
32 |
import android.widget.ArrayAdapter; |
|
30 | 33 |
import android.widget.SeekBar; |
34 |
import android.widget.Spinner; |
|
31 | 35 |
import android.widget.TextView; |
32 | 36 |
import android.widget.SeekBar.OnSeekBarChangeListener; |
33 | 37 |
|
34 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
35 | 39 |
|
36 |
public class DynamicActivity extends Activity implements OnSeekBarChangeListener |
|
40 |
public class DynamicActivity extends Activity implements OnSeekBarChangeListener, AdapterView.OnItemSelectedListener
|
|
37 | 41 |
{ |
38 |
private TextView textD, textN; |
|
42 |
private TextView textD, textC, textN;
|
|
39 | 43 |
private int p0,p1,p2; |
40 | 44 |
private int mDim, mMode; |
41 | 45 |
|
... | ... | |
46 | 50 |
super.onCreate(savedState); |
47 | 51 |
setContentView(R.layout.dynamicslayout); |
48 | 52 |
|
49 |
textD = (TextView)findViewById(R.id.dynamicTextDuration); |
|
50 |
textN = (TextView)findViewById(R.id.dynamicTextNoise); |
|
53 |
textD = findViewById(R.id.dynamicTextDuration); |
|
54 |
textC = findViewById(R.id.dynamicTextCount); |
|
55 |
textN = findViewById(R.id.dynamicTextNoise); |
|
51 | 56 |
|
52 | 57 |
p0=p1=p2=0; |
53 | 58 |
mDim = DynamicSurfaceView.DIM_2D; |
54 | 59 |
mMode= Dynamic1D.MODE_LOOP; |
55 | 60 |
|
56 |
SeekBar barD = (SeekBar)findViewById(R.id.dynamicSeekDuration);
|
|
61 |
SeekBar barD = findViewById(R.id.dynamicSeekDuration); |
|
57 | 62 |
barD.setOnSeekBarChangeListener(this); |
58 |
SeekBar bar0 = (SeekBar)findViewById(R.id.dynamicSeekNoise0); |
|
63 |
SeekBar barC = findViewById(R.id.dynamicSeekCount); |
|
64 |
barC.setOnSeekBarChangeListener(this); |
|
65 |
SeekBar bar0 = findViewById(R.id.dynamicSeekNoise0); |
|
59 | 66 |
bar0.setOnSeekBarChangeListener(this); |
60 |
SeekBar bar1 = (SeekBar)findViewById(R.id.dynamicSeekNoise1);
|
|
67 |
SeekBar bar1 = findViewById(R.id.dynamicSeekNoise1); |
|
61 | 68 |
bar1.setOnSeekBarChangeListener(this); |
62 |
SeekBar bar2 = (SeekBar)findViewById(R.id.dynamicSeekNoise2);
|
|
69 |
SeekBar bar2 = findViewById(R.id.dynamicSeekNoise2); |
|
63 | 70 |
bar2.setOnSeekBarChangeListener(this); |
64 | 71 |
|
72 |
Spinner dimensionSpinner = findViewById(R.id.dynamicSpinnerDimension); |
|
73 |
dimensionSpinner.setOnItemSelectedListener(this); |
|
74 |
String[] dimensions = { "Dimension 1" , "Dimension 2" , "Dimension 3 (XY)" , "Dimension 3 (XZ)" }; |
|
75 |
|
|
76 |
ArrayAdapter<String> adapterDim = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dimensions ); |
|
77 |
adapterDim.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
78 |
dimensionSpinner.setAdapter(adapterDim); |
|
79 |
dimensionSpinner.setSelection(1); |
|
80 |
|
|
81 |
Spinner modeSpinner = findViewById(R.id.dynamicSpinnerMode); |
|
82 |
modeSpinner.setOnItemSelectedListener(this); |
|
83 |
String[] modes = { "MODE_LOOP" , "MODE_PATH" , "MODE_JUMP" }; |
|
84 |
|
|
85 |
ArrayAdapter<String> adapterMode = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, modes ); |
|
86 |
adapterMode.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
87 |
modeSpinner.setAdapter(adapterMode); |
|
88 |
|
|
65 | 89 |
if( savedState==null ) |
66 | 90 |
{ |
67 | 91 |
barD.setProgress(50); |
92 |
barC.setProgress(20); |
|
68 | 93 |
bar0.setProgress(0); |
69 | 94 |
bar1.setProgress(0); |
70 | 95 |
bar2.setProgress(0); |
... | ... | |
77 | 102 |
{ |
78 | 103 |
super.onResume(); |
79 | 104 |
|
80 |
GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
105 |
GLSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
81 | 106 |
view.onResume(); |
82 | 107 |
} |
83 | 108 |
|
... | ... | |
85 | 110 |
@Override |
86 | 111 |
protected void onPause() |
87 | 112 |
{ |
88 |
GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
113 |
GLSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
89 | 114 |
view.onPause(); |
90 | 115 |
|
91 | 116 |
DistortedLibrary.onPause(); |
... | ... | |
106 | 131 |
DistortedLibrary.onDestroy(); |
107 | 132 |
super.onDestroy(); |
108 | 133 |
} |
109 |
|
|
110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
111 |
|
|
112 |
public void Loop(View v) |
|
113 |
{ |
|
114 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView); |
|
115 |
view.setMode(Dynamic1D.MODE_LOOP); |
|
116 |
mMode = Dynamic1D.MODE_LOOP; |
|
117 |
} |
|
118 |
|
|
119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
120 |
|
|
121 |
public void Path(View v) |
|
122 |
{ |
|
123 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView); |
|
124 |
view.setMode(Dynamic1D.MODE_PATH); |
|
125 |
mMode = Dynamic1D.MODE_PATH; |
|
126 |
} |
|
127 | 134 |
|
128 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
129 | 136 |
|
130 |
public void Jump(View v)
|
|
137 |
public void setDim(int dim)
|
|
131 | 138 |
{ |
132 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
133 |
view.setMode(Dynamic1D.MODE_JUMP);
|
|
134 |
mMode = Dynamic1D.MODE_JUMP;
|
|
135 |
}
|
|
136 |
|
|
139 |
DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
140 |
view.setDimension(dim);
|
|
141 |
mDim = dim;
|
|
142 |
} |
|
143 |
|
|
137 | 144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
138 | 145 |
|
139 |
public void Dim1D(View v)
|
|
146 |
public void setMode(int mode)
|
|
140 | 147 |
{ |
141 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
142 |
view.setDimension(DynamicSurfaceView.DIM_1D);
|
|
143 |
mDim = DynamicSurfaceView.DIM_1D;
|
|
144 |
}
|
|
148 |
DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
149 |
view.setMode(mode);
|
|
150 |
mMode = mode;
|
|
151 |
} |
|
145 | 152 |
|
146 | 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
147 | 154 |
|
148 |
public void Dim2D(View v)
|
|
155 |
public void Start(View v)
|
|
149 | 156 |
{ |
150 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView); |
|
151 |
view.setDimension(DynamicSurfaceView.DIM_2D); |
|
152 |
mDim = DynamicSurfaceView.DIM_2D; |
|
153 |
} |
|
154 |
|
|
157 |
DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
158 |
view.startDynamic(); |
|
159 |
} |
|
160 |
|
|
155 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
156 | 162 |
|
157 |
public void Dim3DXY(View v)
|
|
163 |
public void Reset(View v)
|
|
158 | 164 |
{ |
159 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
160 |
view.setDimension(DynamicSurfaceView.DIM_3DXY);
|
|
161 |
mDim = DynamicSurfaceView.DIM_3DXY;
|
|
162 |
}
|
|
165 |
DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
166 |
view.resetPoints();
|
|
167 |
view.stopDynamic();
|
|
168 |
} |
|
163 | 169 |
|
164 | 170 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
165 | 171 |
|
166 |
public void Dim3DXZ(View v)
|
|
172 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
|
|
167 | 173 |
{ |
168 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView); |
|
169 |
view.setDimension(DynamicSurfaceView.DIM_3DXZ); |
|
170 |
mDim = DynamicSurfaceView.DIM_3DXZ; |
|
171 |
} |
|
174 |
int spinnerID = parent.getId(); |
|
175 |
|
|
176 |
if( spinnerID == R.id.dynamicSpinnerDimension ) |
|
177 |
{ |
|
178 |
switch(pos) |
|
179 |
{ |
|
180 |
case 0: setDim(DynamicSurfaceView.DIM_1D ); break; |
|
181 |
case 1: setDim(DynamicSurfaceView.DIM_2D ); break; |
|
182 |
case 2: setDim(DynamicSurfaceView.DIM_3DXY); break; |
|
183 |
case 3: setDim(DynamicSurfaceView.DIM_3DXZ); break; |
|
184 |
} |
|
185 |
} |
|
186 |
else if( spinnerID == R.id.dynamicSpinnerMode ) |
|
187 |
{ |
|
188 |
switch(pos) |
|
189 |
{ |
|
190 |
case 0: setMode(Dynamic.MODE_LOOP); break; |
|
191 |
case 1: setMode(Dynamic.MODE_PATH); break; |
|
192 |
case 2: setMode(Dynamic.MODE_JUMP); break; |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
172 | 196 |
|
173 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
174 | 198 |
|
... | ... | |
191 | 215 |
mDim = savedInstanceState.getInt("dim"); |
192 | 216 |
mMode= savedInstanceState.getInt("mode"); |
193 | 217 |
|
194 |
switch(mDim) |
|
195 |
{ |
|
196 |
case DynamicSurfaceView.DIM_1D : Dim1D(null) ; break; |
|
197 |
case DynamicSurfaceView.DIM_2D : Dim2D(null) ; break; |
|
198 |
case DynamicSurfaceView.DIM_3DXY: Dim3DXY(null); break; |
|
199 |
case DynamicSurfaceView.DIM_3DXZ: Dim3DXZ(null); break; |
|
200 |
} |
|
201 |
|
|
202 |
switch(mMode) |
|
203 |
{ |
|
204 |
case Dynamic1D.MODE_JUMP: Jump(null); break; |
|
205 |
case Dynamic1D.MODE_PATH: Path(null); break; |
|
206 |
case Dynamic1D.MODE_LOOP: Loop(null); break; |
|
207 |
} |
|
218 |
setDim(mDim); |
|
219 |
setMode(mMode); |
|
208 | 220 |
} |
209 | 221 |
|
210 |
/////////////////////////////////////////////////////////////////// |
|
211 |
|
|
222 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
223 |
|
|
212 | 224 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
213 | 225 |
{ |
214 |
DynamicSurfaceView view = (DynamicSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
226 |
DynamicSurfaceView view = findViewById(R.id.dynamicSurfaceView); |
|
215 | 227 |
int id = bar.getId(); |
216 | 228 |
|
217 | 229 |
if( id == R.id.dynamicSeekDuration ) |
... | ... | |
220 | 232 |
int i = (int)(v/100); |
221 | 233 |
float t = i/10.0f; |
222 | 234 |
view.setDuration((int)v); |
223 |
textD.setText("Duration: "+(int)t+" s"); |
|
235 |
textD.setText(getString(R.string.duration_placeholder, (int)t )); |
|
236 |
} |
|
237 |
else if( id == R.id.dynamicSeekCount ) |
|
238 |
{ |
|
239 |
float count = progress*0.05f; |
|
240 |
view.setCount(count); |
|
241 |
textC.setText(getString(R.string.count_placeholder, count )); |
|
224 | 242 |
} |
225 | 243 |
else |
226 | 244 |
{ |
... | ... | |
232 | 250 |
} |
233 | 251 |
|
234 | 252 |
view.setNoise(p0/100.0f,p1/100.0f,p2/100.0f); |
235 |
textN.setText("Noise: "+(p0/100.f)+" "+(p1/100.f)+" "+(p2/100.f));
|
|
253 |
textN.setText(getString(R.string.noise2_placeholder, (p0/100.f) , (p1/100.f), (p2/100.f) ));
|
|
236 | 254 |
} |
237 | 255 |
} |
238 | 256 |
|
239 |
/////////////////////////////////////////////////////////////////// |
|
257 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
240 | 258 |
|
241 | 259 |
public void onStartTrackingTouch(SeekBar bar) { } |
242 |
|
|
243 |
/////////////////////////////////////////////////////////////////// |
|
244 |
|
|
245 | 260 |
public void onStopTrackingTouch(SeekBar bar) { } |
246 |
|
|
247 |
/////////////////////////////////////////////////////////////////// |
|
248 |
// end of file |
|
261 |
public void onNothingSelected(AdapterView<?> parent) { } |
|
249 | 262 |
} |
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
---|---|---|
47 | 47 |
private Bitmap mBitmap; |
48 | 48 |
private Paint mPaint; |
49 | 49 |
|
50 |
static int texW, texH; |
|
50 |
private static int texW, texH;
|
|
51 | 51 |
|
52 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
53 | 53 |
|
... | ... | |
86 | 86 |
texW = width; |
87 | 87 |
texH = height; |
88 | 88 |
|
89 |
DynamicSurfaceView.setHalfHeight(texH/2); |
|
90 |
DynamicSurfaceView.setHalfWidth(texW/2); |
|
91 |
|
|
89 | 92 |
if( mTexture!=null ) mTexture.markForDeletion(); |
90 | 93 |
mTexture= new DistortedTexture(texW,texH); |
91 | 94 |
mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888); |
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java | ||
---|---|---|
22 | 22 |
import android.app.ActivityManager; |
23 | 23 |
import android.content.Context; |
24 | 24 |
import android.content.pm.ConfigurationInfo; |
25 |
import android.graphics.Rect; |
|
25 | 26 |
import android.opengl.GLSurfaceView; |
26 | 27 |
import android.view.MotionEvent; |
27 | 28 |
import android.util.AttributeSet; |
... | ... | |
47 | 48 |
public static final int DIM_3DXZ = 3; |
48 | 49 |
|
49 | 50 |
private static final int NUM_POINTS = 250; |
50 |
private static final int MAX_POINTS = 6; |
|
51 |
|
|
52 | 51 |
private static final Object lock = new Object(); |
53 | 52 |
|
53 |
private static int halfScreenHeight=0; |
|
54 |
private static int halfScreenWidth =0; |
|
55 |
|
|
54 | 56 |
private Dynamic1D di1D; |
55 | 57 |
private Dynamic2D di2D; |
56 | 58 |
private Dynamic3D di3D; |
57 | 59 |
|
58 | 60 |
private Paint mPaint; |
59 |
private int moving; |
|
61 |
private int mMoving;
|
|
60 | 62 |
private int mDuration; |
61 | 63 |
private int mPosition; |
62 |
private long mDiffTime, mLastTime; |
|
64 |
private long mDiffTime, mLastTime, mStartTime;
|
|
63 | 65 |
private float mNoise0, mNoise1, mNoise2; |
66 |
private float mCount; |
|
64 | 67 |
|
65 | 68 |
private int mSize1, mSize2, mSizeT, mAvg; |
69 |
private float mFontHeight; |
|
66 | 70 |
|
67 | 71 |
private int currentDim= DIM_2D; |
68 | 72 |
|
... | ... | |
75 | 79 |
private Static3D p3N; |
76 | 80 |
|
77 | 81 |
private float[] mPoints = new float[3*NUM_POINTS]; |
78 |
|
|
82 |
private boolean mRunning; |
|
83 |
|
|
79 | 84 |
/////////////////////////////////////////////////////////////////// |
80 | 85 |
|
81 | 86 |
public DynamicSurfaceView(Context context, AttributeSet attrs) |
... | ... | |
86 | 91 |
mPaint.setStyle(Style.FILL); |
87 | 92 |
mPaint.setAntiAlias(true); |
88 | 93 |
|
89 |
moving = -1;
|
|
94 |
mMoving = -1;
|
|
90 | 95 |
mDuration = 10000; |
96 |
mCount = 0.0f; |
|
91 | 97 |
mPosition = 0; |
92 | 98 |
mNoise0 = 0.0f; |
93 | 99 |
mNoise1 = 0.0f; |
94 | 100 |
mNoise2 = 0.0f; |
95 | 101 |
mDiffTime = -1; |
96 | 102 |
mLastTime = -1; |
103 |
mStartTime= -1; |
|
104 |
|
|
105 |
mRunning = false; |
|
97 | 106 |
|
98 |
di1D = new Dynamic1D(mDuration,0.0f);
|
|
107 |
di1D = new Dynamic1D(mDuration,mCount);
|
|
99 | 108 |
p1N = new Static1D(mNoise0); |
100 |
di2D = new Dynamic2D(mDuration,0.0f);
|
|
109 |
di2D = new Dynamic2D(mDuration,mCount);
|
|
101 | 110 |
p2N = new Static2D(mNoise0,mNoise1); |
102 |
di3D = new Dynamic3D(mDuration,0.0f);
|
|
111 |
di3D = new Dynamic3D(mDuration,mCount);
|
|
103 | 112 |
p3N = new Static3D(mNoise0,mNoise1,mNoise2); |
104 | 113 |
|
105 | 114 |
di1D.setAccessMode(Dynamic.ACCESS_SEQUENTIAL); |
... | ... | |
125 | 134 |
mAvg = (width+height)/2; |
126 | 135 |
|
127 | 136 |
mSize1 = mAvg/150; |
128 |
mSize2 = mAvg/60;
|
|
137 |
mSize2 = mAvg/50;
|
|
129 | 138 |
mSizeT = mAvg/30; |
130 | 139 |
|
131 | 140 |
mPaint.setTextSize(mSizeT); |
141 |
mPaint.setTextAlign(Paint.Align.CENTER); |
|
142 |
|
|
143 |
final Rect textBounds = new Rect(); |
|
144 |
String text = "1"; |
|
145 |
mPaint.getTextBounds(text, 0, text.length(), textBounds); |
|
146 |
mFontHeight = textBounds.exactCenterY(); |
|
132 | 147 |
|
133 | 148 |
clearPoints(); |
134 | 149 |
} |
135 | 150 |
|
151 |
/////////////////////////////////////////////////////////////////// |
|
152 |
|
|
153 |
public static void setHalfWidth(int hw) |
|
154 |
{ |
|
155 |
halfScreenWidth = hw; |
|
156 |
} |
|
157 |
|
|
158 |
/////////////////////////////////////////////////////////////////// |
|
159 |
|
|
160 |
public static void setHalfHeight(int hh) |
|
161 |
{ |
|
162 |
halfScreenHeight = hh; |
|
163 |
} |
|
164 |
|
|
136 | 165 |
/////////////////////////////////////////////////////////////////// |
137 | 166 |
|
138 | 167 |
public void setMode(int mode) |
... | ... | |
148 | 177 |
{ |
149 | 178 |
mDuration = duration; |
150 | 179 |
|
151 |
di1D.makeRunNowFor(duration); |
|
152 |
di2D.makeRunNowFor(duration); |
|
153 |
di3D.makeRunNowFor(duration); |
|
180 |
di1D.setDuration(duration); |
|
181 |
di2D.setDuration(duration); |
|
182 |
di3D.setDuration(duration); |
|
183 |
} |
|
184 |
|
|
185 |
/////////////////////////////////////////////////////////////////// |
|
186 |
|
|
187 |
public void setCount(float count) |
|
188 |
{ |
|
189 |
mCount = count; |
|
190 |
|
|
191 |
di1D.setCount(count); |
|
192 |
di2D.setCount(count); |
|
193 |
di3D.setCount(count); |
|
154 | 194 |
} |
155 | 195 |
|
156 | 196 |
/////////////////////////////////////////////////////////////////// |
... | ... | |
178 | 218 |
{ |
179 | 219 |
if( !(currentDim==DIM_3DXY && dim==DIM_3DXZ) && !(currentDim==DIM_3DXZ && dim==DIM_3DXY) ) |
180 | 220 |
{ |
181 |
synchronized(lock) |
|
182 |
{ |
|
183 |
di1D.removeAll(); |
|
184 |
di2D.removeAll(); |
|
185 |
di3D.removeAll(); |
|
186 |
|
|
187 |
clearPoints(); |
|
188 |
} |
|
221 |
resetPoints(); |
|
189 | 222 |
} |
190 |
|
|
223 |
|
|
191 | 224 |
currentDim = dim; |
192 | 225 |
} |
193 | 226 |
} |
... | ... | |
196 | 229 |
|
197 | 230 |
public void drawCurve(Canvas c, long time) |
198 | 231 |
{ |
199 |
if ( ++mPosition >= NUM_POINTS ) mPosition=0; |
|
200 |
|
|
201 | 232 |
if( mLastTime<0 ) |
202 | 233 |
{ |
203 | 234 |
mLastTime = time; |
... | ... | |
211 | 242 |
{ |
212 | 243 |
switch(currentDim) |
213 | 244 |
{ |
214 |
case DIM_1D: drawCurve1D(c,time); break; |
|
215 |
case DIM_2D: drawCurve2D(c,time); break; |
|
216 |
default : drawCurve3D(c,time); break; |
|
245 |
case DIM_1D: drawHorizontalAxis(c,"x"); |
|
246 |
drawPath(c,di1D,1,time); |
|
247 |
drawRedPoints1D(c); |
|
248 |
break; |
|
249 |
case DIM_2D: drawHorizontalAxis(c,"x"); |
|
250 |
drawVerticalAxis (c,"y"); |
|
251 |
drawPath(c,di2D,1,time); |
|
252 |
drawRedPoints2D(c); |
|
253 |
break; |
|
254 |
default : drawHorizontalAxis(c,"x"); |
|
255 |
drawVerticalAxis (c, currentDim==DIM_3DXY ? "y" : "z" ); |
|
256 |
drawPath(c,di3D,(currentDim==DIM_3DXY ? 1:2),time); |
|
257 |
drawRedPoints3D(c); |
|
258 |
break; |
|
217 | 259 |
} |
218 | 260 |
} |
219 | 261 |
|
... | ... | |
232 | 274 |
|
233 | 275 |
/////////////////////////////////////////////////////////////////// |
234 | 276 |
|
235 |
private void drawCurve1D(Canvas c, long time)
|
|
277 |
public void resetPoints()
|
|
236 | 278 |
{ |
237 |
int len = di1D.getNumPoints(); |
|
238 |
mPaint.setColor(0xff000000); |
|
239 |
|
|
240 |
c.drawLine(0, DynamicRenderer.texH/2, DynamicRenderer.texW, DynamicRenderer.texH/2, mPaint); |
|
241 |
c.drawText("x", 0.95f*DynamicRenderer.texW, DynamicRenderer.texH /2 + mSizeT , mPaint); |
|
242 |
|
|
243 |
if( len>=2 ) |
|
279 |
synchronized(lock) |
|
244 | 280 |
{ |
245 |
di1D.get(mPoints,3*mPosition, time, mDiffTime);
|
|
281 |
clearPoints();
|
|
246 | 282 |
|
247 |
for(int i=0; i<NUM_POINTS; i++)
|
|
283 |
switch(currentDim)
|
|
248 | 284 |
{ |
249 |
int color = i<=mPosition ? 0xff - (mPosition -i)*0xff/(NUM_POINTS-1) |
|
250 |
: 0xff - (mPosition+NUM_POINTS-i)*0xff/(NUM_POINTS-1); |
|
251 |
|
|
252 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
253 |
c.drawCircle(mPoints[3*i], DynamicRenderer.texH/2 , mSize1, mPaint ); |
|
285 |
case DIM_1D : di1D.removeAll(); break; |
|
286 |
case DIM_2D : di2D.removeAll(); break; |
|
287 |
case DIM_3DXY: |
|
288 |
case DIM_3DXZ: di3D.removeAll(); break; |
|
254 | 289 |
} |
255 | 290 |
} |
256 |
|
|
257 |
mPaint.setColor(0xffff0000); |
|
258 |
|
|
259 |
for(int curr=0; curr<len; curr++) |
|
260 |
{ |
|
261 |
p1D = di1D.getPoint(curr); |
|
262 |
c.drawCircle(p1D.get1(), DynamicRenderer.texH/2 , mSize2, mPaint); |
|
263 |
} |
|
264 | 291 |
} |
265 |
|
|
292 |
|
|
266 | 293 |
/////////////////////////////////////////////////////////////////// |
267 |
|
|
268 |
private void drawCurve2D(Canvas c, long time) |
|
294 |
|
|
295 |
public void startDynamic() |
|
296 |
{ |
|
297 |
mRunning = true; |
|
298 |
mLastTime= -1; |
|
299 |
mStartTime = System.currentTimeMillis(); |
|
300 |
|
|
301 |
clearPoints(); |
|
302 |
di1D.resetToBeginning(); |
|
303 |
di2D.resetToBeginning(); |
|
304 |
di3D.resetToBeginning(); |
|
305 |
} |
|
306 |
|
|
307 |
/////////////////////////////////////////////////////////////////// |
|
308 |
|
|
309 |
public void stopDynamic() |
|
310 |
{ |
|
311 |
mRunning = false; |
|
312 |
} |
|
313 |
|
|
314 |
/////////////////////////////////////////////////////////////////// |
|
315 |
|
|
316 |
private void drawHorizontalAxis(Canvas c, String label) |
|
269 | 317 |
{ |
270 |
int len = di2D.getNumPoints(); |
|
271 | 318 |
mPaint.setColor(0xff000000); |
272 |
|
|
273 |
c.drawLine(0, DynamicRenderer.texH/2, DynamicRenderer.texW, DynamicRenderer.texH/2, mPaint); |
|
274 |
c.drawLine(DynamicRenderer.texW/2, 0, DynamicRenderer.texW/2, DynamicRenderer.texH, mPaint); |
|
275 |
|
|
276 |
c.drawText("x", 0.95f* DynamicRenderer.texW , DynamicRenderer.texH/2+mSizeT , mPaint); |
|
277 |
c.drawText("y", DynamicRenderer.texW/2 + mSizeT, mSizeT , mPaint); |
|
278 |
|
|
319 |
|
|
320 |
c.drawLine(0, halfScreenHeight, halfScreenWidth*2, halfScreenHeight, mPaint); |
|
321 |
c.drawText( label, 0.95f*halfScreenWidth*2, halfScreenHeight + mSizeT , mPaint); |
|
322 |
} |
|
323 |
|
|
324 |
|
|
325 |
/////////////////////////////////////////////////////////////////// |
|
326 |
|
|
327 |
private void drawVerticalAxis(Canvas c, String label) |
|
328 |
{ |
|
329 |
mPaint.setColor(0xff000000); |
|
330 |
|
|
331 |
c.drawLine(halfScreenWidth, 0, halfScreenWidth, halfScreenHeight*2, mPaint); |
|
332 |
c.drawText(label, halfScreenWidth + mSizeT, mSizeT , mPaint); |
|
333 |
} |
|
334 |
|
|
335 |
/////////////////////////////////////////////////////////////////// |
|
336 |
|
|
337 |
private void drawPath(Canvas c, Dynamic dyn, int index, long time) |
|
338 |
{ |
|
339 |
int len = dyn.getNumPoints(); |
|
340 |
|
|
279 | 341 |
if( len>=2 ) |
280 | 342 |
{ |
281 |
di2D.get(mPoints,3*mPosition, time, mDiffTime); |
|
343 |
if( mRunning ) |
|
344 |
{ |
|
345 |
if ( ++mPosition >= NUM_POINTS ) mPosition=0; |
|
346 |
|
|
347 |
if( dyn.getDimension()==1 ) |
|
348 |
{ |
|
349 |
mPoints[3*mPosition+index] = halfScreenHeight; |
|
350 |
} |
|
351 |
|
|
352 |
if( dyn.get(mPoints,3*mPosition, time-mStartTime, mDiffTime) ) |
|
353 |
{ |
|
354 |
stopDynamic(); |
|
355 |
} |
|
356 |
} |
|
282 | 357 |
|
283 | 358 |
for(int i=0; i<NUM_POINTS; i++) |
284 | 359 |
{ |
285 | 360 |
int color = i<=mPosition ? 0xff - (mPosition -i)*0xff/(NUM_POINTS-1) |
286 | 361 |
: 0xff - (mPosition+NUM_POINTS-i)*0xff/(NUM_POINTS-1); |
287 |
|
|
362 |
|
|
288 | 363 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
289 |
c.drawCircle(mPoints[3*i], mPoints[3*i+1], mSize1, mPaint );
|
|
364 |
c.drawCircle(mPoints[3*i], mPoints[3*i+index] , mSize1, mPaint );
|
|
290 | 365 |
} |
291 | 366 |
} |
292 |
|
|
293 |
mPaint.setColor(0xffff0000); |
|
294 |
|
|
367 |
} |
|
368 |
|
|
369 |
/////////////////////////////////////////////////////////////////// |
|
370 |
|
|
371 |
private void drawRedPoints1D(Canvas c) |
|
372 |
{ |
|
373 |
int len = di1D.getNumPoints(); |
|
374 |
|
|
295 | 375 |
for(int curr=0; curr<len; curr++) |
296 |
{
|
|
297 |
p2D = di2D.getPoint(curr);
|
|
298 |
c.drawCircle(p2D.get1(),p2D.get2(), mSize2, mPaint);
|
|
376 |
{ |
|
377 |
p1D = di1D.getPoint(curr);
|
|
378 |
drawRedPoint(c,curr+"", p1D.get1(), halfScreenHeight);
|
|
299 | 379 |
} |
300 | 380 |
} |
301 | 381 |
|
302 | 382 |
/////////////////////////////////////////////////////////////////// |
303 |
|
|
304 |
private void drawCurve3D(Canvas c, long time)
|
|
383 |
|
|
384 |
private void drawRedPoints2D(Canvas c)
|
|
305 | 385 |
{ |
306 |
int len = di3D.getNumPoints(); |
|
307 |
mPaint.setColor(0xff000000); |
|
308 |
|
|
309 |
c.drawLine(0, DynamicRenderer.texH/2, DynamicRenderer.texW , DynamicRenderer.texH/2, mPaint); |
|
310 |
c.drawLine(DynamicRenderer.texW/2, 0, DynamicRenderer.texW/2, DynamicRenderer.texH , mPaint); |
|
311 |
|
|
312 |
c.drawText( "x" , 0.95f* DynamicRenderer.texW , DynamicRenderer.texH/2 + mSizeT , mPaint); |
|
313 |
c.drawText( currentDim==DIM_3DXY ? "y" : "z", DynamicRenderer.texW/2 + mSizeT, mSizeT , mPaint); |
|
314 |
|
|
315 |
if( len>=2 ) |
|
316 |
{ |
|
317 |
di3D.get(mPoints, 3*mPosition, time, mDiffTime); |
|
386 |
int len = di2D.getNumPoints(); |
|
318 | 387 |
|
319 |
for(int i=0; i<NUM_POINTS; i++) |
|
320 |
{ |
|
321 |
int color = i<=mPosition ? 0xff - (mPosition -i)*0xff/(NUM_POINTS-1) |
|
322 |
: 0xff - (mPosition+NUM_POINTS-i)*0xff/(NUM_POINTS-1); |
|
323 |
|
|
324 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
325 |
c.drawCircle(mPoints[3*i], mPoints[3*i + (currentDim==DIM_3DXY ? 1:2) ], mSize1, mPaint ); |
|
326 |
} |
|
388 |
for(int curr=0; curr<len; curr++) |
|
389 |
{ |
|
390 |
p2D = di2D.getPoint(curr); |
|
391 |
drawRedPoint(c,curr+"", p2D.get1(), p2D.get2()); |
|
327 | 392 |
} |
328 |
|
|
329 |
mPaint.setColor(0xffff0000); |
|
330 |
|
|
393 |
} |
|
394 |
|
|
395 |
/////////////////////////////////////////////////////////////////// |
|
396 |
|
|
397 |
private void drawRedPoints3D(Canvas c) |
|
398 |
{ |
|
399 |
int len = di3D.getNumPoints(); |
|
400 |
|
|
331 | 401 |
for(int curr=0; curr<len; curr++) |
332 |
{
|
|
402 |
{ |
|
333 | 403 |
p3D = di3D.getPoint(curr); |
334 |
c.drawCircle(p3D.get1(), currentDim==DIM_3DXY ? p3D.get2():p3D.get3(), mSize2, mPaint);
|
|
335 |
}
|
|
404 |
drawRedPoint(c,curr+"", p3D.get1(), currentDim==DIM_3DXY ? p3D.get2():p3D.get3());
|
|
405 |
} |
|
336 | 406 |
} |
337 |
|
|
407 |
|
|
408 |
/////////////////////////////////////////////////////////////////// |
|
409 |
|
|
410 |
private void drawRedPoint(Canvas c, String label, float width, float height) |
|
411 |
{ |
|
412 |
mPaint.setColor(0xffff0000); |
|
413 |
c.drawCircle( width, height, mSize2, mPaint); |
|
414 |
mPaint.setColor(0xffffffff); |
|
415 |
c.drawText(label, width,height-mFontHeight, mPaint); |
|
416 |
} |
|
417 |
|
|
338 | 418 |
/////////////////////////////////////////////////////////////////// |
339 | 419 |
|
340 | 420 |
private void addNewPoint(int x, int y) |
... | ... | |
353 | 433 |
|
354 | 434 |
if( (x-gx)*(x-gx) < (mAvg*mAvg/100) ) |
355 | 435 |
{ |
356 |
moving = g; |
|
436 |
mMoving = g;
|
|
357 | 437 |
break; |
358 | 438 |
} |
359 | 439 |
} |
360 |
if( moving<0 )
|
|
440 |
if( mMoving <0 )
|
|
361 | 441 |
{ |
362 | 442 |
synchronized(lock) |
363 | 443 |
{ |
364 |
if( len>=MAX_POINTS ) |
|
365 |
{ |
|
366 |
di1D.removeAll(); |
|
367 |
clearPoints(); |
|
368 |
} |
|
369 | 444 |
di1D.add(new Static1D(x)); |
370 | 445 |
} |
371 | 446 |
} |
... | ... | |
380 | 455 |
|
381 | 456 |
if( (x-gx)*(x-gx) + (y-gy)*(y-gy) < (mAvg*mAvg/100) ) |
382 | 457 |
{ |
383 |
moving = g; |
|
458 |
mMoving = g;
|
|
384 | 459 |
break; |
385 | 460 |
} |
386 | 461 |
} |
387 |
if( moving<0 )
|
|
462 |
if( mMoving <0 )
|
|
388 | 463 |
{ |
389 | 464 |
synchronized(lock) |
390 | 465 |
{ |
391 |
if( len>=MAX_POINTS ) |
|
392 |
{ |
|
393 |
di2D.removeAll(); |
|
394 |
clearPoints(); |
|
395 |
} |
|
396 | 466 |
di2D.add(new Static2D(x,y)); |
397 | 467 |
} |
398 | 468 |
} |
... | ... | |
410 | 480 |
{ |
411 | 481 |
if( (x-gx)*(x-gx) + (y-gy)*(y-gy) < (mAvg*mAvg/100) ) |
412 | 482 |
{ |
413 |
moving = g; |
|
483 |
mMoving = g;
|
|
414 | 484 |
break; |
415 | 485 |
} |
416 | 486 |
} |
... | ... | |
418 | 488 |
{ |
419 | 489 |
if( (x-gx)*(x-gx) + (y-gz)*(y-gz) < (mAvg*mAvg/100) ) |
420 | 490 |
{ |
421 |
moving = g; |
|
491 |
mMoving = g;
|
|
422 | 492 |
break; |
423 | 493 |
} |
424 | 494 |
} |
425 | 495 |
} |
426 |
if( moving<0 )
|
|
496 |
if( mMoving <0 )
|
|
427 | 497 |
{ |
428 | 498 |
synchronized(lock) |
429 | 499 |
{ |
430 |
if( len>=MAX_POINTS ) |
|
431 |
{ |
|
432 |
di3D.removeAll(); |
|
433 |
clearPoints(); |
|
434 |
} |
|
435 |
|
|
436 | 500 |
if( currentDim==DIM_3DXY ) |
437 | 501 |
{ |
438 |
di3D.add(new Static3D(x,y, DynamicRenderer.texH/2));
|
|
502 |
di3D.add(new Static3D(x,y, halfScreenHeight));
|
|
439 | 503 |
} |
440 | 504 |
if( currentDim==DIM_3DXZ ) |
441 | 505 |
{ |
442 |
di3D.add(new Static3D(x, DynamicRenderer.texH/2,y));
|
|
506 |
di3D.add(new Static3D(x, halfScreenHeight,y));
|
|
443 | 507 |
} |
444 | 508 |
} |
445 | 509 |
} |
... | ... | |
449 | 513 |
|
450 | 514 |
/////////////////////////////////////////////////////////////////// |
451 | 515 |
|
452 |
@Override public boolean onTouchEvent(MotionEvent event) |
|
516 |
@Override |
|
517 |
public boolean onTouchEvent(MotionEvent event) |
|
453 | 518 |
{ |
454 | 519 |
int action = event.getAction(); |
455 | 520 |
int xDown, yDown; |
... | ... | |
462 | 527 |
addNewPoint(xDown,yDown); |
463 | 528 |
|
464 | 529 |
break; |
465 |
case MotionEvent.ACTION_MOVE: if( moving>=0 )
|
|
530 |
case MotionEvent.ACTION_MOVE: if( mMoving >=0 )
|
|
466 | 531 |
{ |
467 | 532 |
xDown = (int)event.getX(); |
468 | 533 |
yDown = (int)event.getY(); |
469 | 534 |
|
470 | 535 |
switch(currentDim) |
471 | 536 |
{ |
472 |
case DIM_1D : di1D.setPoint(moving, xDown);
|
|
537 |
case DIM_1D : di1D.setPoint(mMoving, xDown);
|
|
473 | 538 |
break; |
474 |
case DIM_2D : di2D.setPoint(moving, xDown, yDown); |
|
539 |
case DIM_2D : di2D.setPoint(mMoving, xDown, yDown);
|
|
475 | 540 |
break; |
476 |
case DIM_3DXY: di3D.setPoint(moving, xDown, yDown, (int)di3D.getPoint(moving).get3());
|
|
541 |
case DIM_3DXY: di3D.setPoint(mMoving, xDown, yDown, (int)di3D.getPoint(mMoving).get3());
|
|
477 | 542 |
break; |
478 |
case DIM_3DXZ: di3D.setPoint(moving, xDown, (int)di3D.getPoint(moving).get2(), yDown);
|
|
543 |
case DIM_3DXZ: di3D.setPoint(mMoving, xDown, (int)di3D.getPoint(mMoving).get2(), yDown);
|
|
479 | 544 |
break; |
480 | 545 |
} |
481 | 546 |
} |
482 | 547 |
break; |
483 |
case MotionEvent.ACTION_UP : moving = -1; |
|
548 |
case MotionEvent.ACTION_UP : mMoving = -1;
|
|
484 | 549 |
break; |
485 | 550 |
} |
486 | 551 |
|
src/main/java/org/distorted/examples/earth/EarthActivity.java | ||
---|---|---|
39 | 39 |
{ |
40 | 40 |
private EffectName[] mEffectNames; |
41 | 41 |
|
42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void onCreate(Bundle savedState) |
|
46 |
{ |
|
47 |
super.onCreate(savedState); |
|
48 |
|
|
49 |
setContentView(R.layout.earthlayout); |
|
50 |
|
|
51 |
SeekBar levelBar = findViewById(R.id.earthInflateLevel); |
|
52 |
levelBar.setOnSeekBarChangeListener(this); |
|
53 |
levelBar.setProgress(50); |
|
54 |
|
|
55 |
Spinner renderSpinner = findViewById(R.id.earthSpinnerEffect); |
|
56 |
renderSpinner.setOnItemSelectedListener(this); |
|
57 |
|
|
58 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, createEffectNames() ); |
|
59 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
60 |
renderSpinner.setAdapter(adapterBitmap); |
|
61 |
} |
|
62 |
|
|
42 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 64 |
|
44 | 65 |
@Override |
... | ... | |
76 | 97 |
DistortedLibrary.onDestroy(); |
77 | 98 |
super.onDestroy(); |
78 | 99 |
} |
79 |
|
|
80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
81 |
|
|
82 |
@Override |
|
83 |
protected void onCreate(Bundle savedState) |
|
84 |
{ |
|
85 |
super.onCreate(savedState); |
|
86 |
|
|
87 |
setContentView(R.layout.earthlayout); |
|
88 |
|
|
89 |
SeekBar levelBar = findViewById(R.id.earthInflateLevel); |
|
90 |
levelBar.setOnSeekBarChangeListener(this); |
|
91 |
levelBar.setProgress(50); |
|
92 |
|
|
93 |
Spinner renderSpinner = findViewById(R.id.earthSpinnerEffect); |
|
94 |
renderSpinner.setOnItemSelectedListener(this); |
|
95 |
|
|
96 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, createEffectNames() ); |
|
97 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
98 |
renderSpinner.setAdapter(adapterBitmap); |
|
99 |
} |
|
100 |
|
|
101 | 100 |
|
102 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
103 | 102 |
|
... | ... | |
133 | 132 |
} |
134 | 133 |
} |
135 | 134 |
|
136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
137 |
|
|
138 |
public void onStartTrackingTouch(SeekBar bar) { } |
|
139 |
|
|
140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
141 |
|
|
142 |
public void onStopTrackingTouch(SeekBar bar) { } |
|
143 |
|
|
144 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 136 |
|
146 | 137 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
... | ... | |
149 | 140 |
mPick.setEffectMode(mEffectNames[pos]); |
150 | 141 |
} |
151 | 142 |
|
152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
153 |
|
|
154 |
public void onNothingSelected(AdapterView<?> parent) { } |
|
155 |
|
|
156 | 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
157 | 144 |
|
158 | 145 |
public void Remove(View v) |
... | ... | |
211 | 198 |
|
212 | 199 |
return effectStrings; |
213 | 200 |
} |
201 |
|
|
202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
203 |
|
|
204 |
public void onStartTrackingTouch(SeekBar bar) { } |
|
205 |
public void onStopTrackingTouch(SeekBar bar) { } |
|
206 |
public void onNothingSelected(AdapterView<?> parent) { } |
|
214 | 207 |
} |
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
rot.setCount(0); |
88 |
rot.makeRunNowFor(8000);
|
|
88 |
rot.setDuration(8000);
|
|
89 | 89 |
rot.setMode(Dynamic.MODE_LOOP); |
90 | 90 |
|
91 | 91 |
mMove = new Static3D(0,0,0); |
src/main/java/org/distorted/examples/rubik/RubikCube.java | ||
---|---|---|
221 | 221 |
if( belongsToRotation(x,y,z,vector,rotRow) ) |
222 | 222 |
{ |
223 | 223 |
mRotationAxis[x][y][z].set(axis); |
224 |
mRotationAngle[x][y][z].makeRunNowFor(ROTATION_MILLISEC); |
|
224 |
mRotationAngle[x][y][z].setDuration(ROTATION_MILLISEC); |
|
225 |
mRotationAngle[x][y][z].resetToBeginning(); |
|
225 | 226 |
mRotationAngle[x][y][z].setPoint(1,90.0f); |
226 | 227 |
|
227 | 228 |
if( first ) |
src/main/java/org/distorted/examples/wind/WindEffectsManager.java | ||
---|---|---|
131 | 131 |
shearFactor.set2(tanAngle); |
132 | 132 |
scaleFactor.set1(1/(float)Math.sqrt(1+tanAngle*tanAngle)); |
133 | 133 |
|
134 |
windDynamic1.makeRunNowFor( wind > 0 ? 900 + 10000/wind : Long.MAX_VALUE);
|
|
135 |
windDynamic2.makeRunNowFor( wind > 0 ? 720 + 8000/wind : Long.MAX_VALUE);
|
|
136 |
windDynamic3.makeRunNowFor( wind > 0 ? 900 + 10000/wind : Long.MAX_VALUE);
|
|
134 |
windDynamic1.setDuration( wind > 0 ? 900 + 10000/wind : Long.MAX_VALUE);
|
|
135 |
windDynamic2.setDuration( wind > 0 ? 720 + 8000/wind : Long.MAX_VALUE);
|
|
136 |
windDynamic3.setDuration( wind > 0 ? 900 + 10000/wind : Long.MAX_VALUE);
|
|
137 | 137 |
|
138 | 138 |
float wave2 = mHeight*( 0.05f + 0.002f*wind); |
139 | 139 |
windFactor21.set1(wave2); |
src/main/res/layout/dynamicslayout.xml | ||
---|---|---|
6 | 6 |
android:gravity="fill_horizontal" |
7 | 7 |
android:orientation="vertical" > |
8 | 8 |
|
9 |
<org.distorted.examples.dynamic.DynamicSurfaceView |
|
10 |
android:id="@+id/dynamicSurfaceView" |
|
11 |
android:layout_width="fill_parent" |
|
12 |
android:layout_height="0dp" |
|
13 |
android:layout_weight="1" /> |
|
9 |
<LinearLayout |
|
10 |
android:orientation="horizontal" |
|
11 |
android:layout_width="match_parent" |
|
12 |
android:layout_height="48dp"> |
|
14 | 13 |
|
15 |
<RadioGroup
|
|
16 |
android:id="@+id/radioGroup2"
|
|
14 |
<Button
|
|
15 |
android:id="@+id/dynamicButtonStart"
|
|
17 | 16 |
android:layout_width="wrap_content" |
18 |
android:layout_height="wrap_content" |
|
19 |
android:gravity="fill_horizontal" |
|
20 |
android:orientation="horizontal" |
|
21 |
android:paddingBottom="5dp" |
|
22 |
android:paddingTop="5dp" |
|
23 |
android:weightSum="1.0" > |
|
24 |
|
|
25 |
<RadioButton |
|
26 |
android:id="@+id/dynamic1D" |
|
27 |
android:layout_width="fill_parent" |
|
28 |
android:layout_height="wrap_content" |
|
29 |
android:layout_weight="0.25" |
|
30 |
android:onClick="Dim1D" |
|
31 |
android:text="@string/dim1D" /> |
|
32 |
|
|
33 |
<RadioButton |
|
34 |
android:id="@+id/dynamic2D" |
|
35 |
android:layout_width="fill_parent" |
|
36 |
android:layout_height="wrap_content" |
|
37 |
android:layout_weight="0.25" |
|
38 |
android:checked="true" |
|
39 |
android:onClick="Dim2D" |
|
40 |
android:text="@string/dim2D" /> |
|
41 |
|
|
42 |
<RadioButton |
|
43 |
android:id="@+id/dynamic3DXY" |
|
44 |
android:layout_width="fill_parent" |
|
45 |
android:layout_height="wrap_content" |
|
46 |
android:layout_weight="0.25" |
|
47 |
android:onClick="Dim3DXY" |
|
48 |
android:text="@string/dim3DXY" /> |
|
49 |
|
|
50 |
<RadioButton |
|
51 |
android:id="@+id/dynamic3DXZ" |
|
52 |
android:layout_width="fill_parent" |
|
53 |
android:layout_height="wrap_content" |
|
54 |
android:layout_weight="0.25" |
|
55 |
android:onClick="Dim3DXZ" |
|
56 |
android:text="@string/dim3DXZ" /> |
|
57 |
|
|
58 |
</RadioGroup> |
|
17 |
android:layout_height="match_parent" |
|
18 |
android:layout_weight="0.5" |
|
19 |
android:paddingLeft="10dp" |
|
20 |
android:paddingRight="10dp" |
|
21 |
android:onClick="Start" |
|
22 |
android:text="@string/start" /> |
|
59 | 23 |
|
60 |
<RadioGroup
|
|
61 |
android:id="@+id/radioGroup1"
|
|
24 |
<Button
|
|
25 |
android:id="@+id/dynamicButtonReset"
|
|
62 | 26 |
android:layout_width="wrap_content" |
63 |
android:layout_height="wrap_content" |
|
64 |
android:orientation="horizontal" |
|
65 |
android:paddingRight="20dp" > |
|
66 |
|
|
67 |
<RadioButton |
|
68 |
android:id="@+id/dynamicLoopButton" |
|
69 |
android:layout_width="wrap_content" |
|
70 |
android:layout_height="wrap_content" |
|
71 |
android:checked="true" |
|
72 |
android:onClick="Loop" |
|
73 |
android:text="@string/loop" /> |
|
27 |
android:layout_height="match_parent" |
|
28 |
android:layout_weight="0.5" |
|
29 |
android:paddingLeft="10dp" |
|
30 |
android:paddingRight="10dp" |
|
31 |
android:onClick="Reset" |
|
32 |
android:text="@string/reset" /> |
|
33 |
</LinearLayout> |
|
74 | 34 |
|
75 |
<RadioButton |
|
76 |
android:id="@+id/dynamicPathButton" |
|
77 |
android:layout_width="wrap_content" |
|
78 |
android:layout_height="wrap_content" |
|
79 |
android:checked="false" |
|
80 |
android:onClick="Path" |
|
81 |
android:text="@string/path" /> |
|
35 |
<org.distorted.examples.dynamic.DynamicSurfaceView |
|
36 |
android:id="@+id/dynamicSurfaceView" |
|
37 |
android:layout_width="fill_parent" |
|
38 |
android:layout_height="0dp" |
|
39 |
android:layout_weight="1" /> |
|
82 | 40 |
|
83 |
<RadioButton |
|
84 |
android:id="@+id/dynamicJumpButton" |
|
85 |
android:layout_width="wrap_content" |
|
86 |
android:layout_height="wrap_content" |
|
87 |
android:checked="false" |
|
88 |
android:onClick="Jump" |
|
89 |
android:text="@string/jump" /> |
|
41 |
<LinearLayout |
|
42 |
android:orientation="horizontal" |
|
43 |
android:layout_width="match_parent" |
|
44 |
android:layout_height="48dp"> |
|
45 |
|
|
46 |
<Spinner |
|
47 |
android:layout_width="0dp" |
|
48 |
android:layout_height="50dp" |
|
49 |
android:layout_weight="0.5" |
|
50 |
android:id="@+id/dynamicSpinnerDimension"/> |
|
51 |
|
|
52 |
<Spinner |
|
53 |
android:layout_width="0dp" |
|
54 |
android:layout_height="50dp" |
|
55 |
android:layout_weight="0.5" |
|
56 |
android:id="@+id/dynamicSpinnerMode"/> |
|
90 | 57 |
|
91 |
</RadioGroup>
|
|
58 |
</LinearLayout>
|
|
92 | 59 |
|
93 | 60 |
<LinearLayout |
94 |
android:id="@+id/linearLayout1" |
|
95 | 61 |
android:layout_width="fill_parent" |
96 | 62 |
android:layout_height="wrap_content" |
97 | 63 |
android:layout_gravity="center_vertical" |
98 | 64 |
android:gravity="center|fill_horizontal" |
99 | 65 |
android:orientation="vertical"> |
100 | 66 |
|
101 |
<TextView |
|
102 |
android:id="@+id/dynamicTextDuration" |
|
103 |
android:layout_width="wrap_content" |
|
67 |
<LinearLayout |
|
68 |
android:layout_width="fill_parent" |
|
104 | 69 |
android:layout_height="wrap_content" |
105 |
android:layout_gravity="center_horizontal" |
|
106 |
android:layout_weight="15" |
|
107 |
android:paddingLeft="10dp" |
|
108 |
android:text="@string/duration" |
|
109 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
110 |
android:textSize="12sp" /> |
|
70 |
android:orientation="horizontal" |
|
71 |
android:baselineAligned="false"> |
|
111 | 72 |
|
112 |
<SeekBar |
|
113 |
android:id="@+id/dynamicSeekDuration" |
|
114 |
android:layout_width="match_parent" |
|
115 |
android:layout_height="wrap_content" |
|
116 |
android:layout_weight="15" |
|
117 |
android:paddingLeft="5dp" |
|
118 |
android:paddingRight="10dp" /> |
|
73 |
<LinearLayout |
|
74 |
android:layout_width="wrap_content" |
|
75 |
android:layout_height="fill_parent" |
|
76 |
android:layout_weight="0.5" |
|
77 |
android:layout_gravity="center_vertical" |
|
78 |
android:gravity="center|fill_horizontal" |
|
79 |
android:orientation="vertical"> |
|
80 |
|
|
81 |
<TextView |
|
82 |
android:id="@+id/dynamicTextDuration" |
|
83 |
android:layout_width="wrap_content" |
|
84 |
android:layout_height="wrap_content" |
|
85 |
android:layout_gravity="center_horizontal" |
|
86 |
android:text="@string/duration" |
|
87 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
88 |
android:textSize="12sp" /> |
|
89 |
|
|
90 |
<SeekBar |
|
91 |
android:id="@+id/dynamicSeekDuration" |
|
92 |
android:layout_width="match_parent" |
|
93 |
android:layout_height="wrap_content" |
|
94 |
android:paddingStart="10dp" |
|
95 |
android:paddingEnd="10dp" /> |
|
96 |
|
|
97 |
</LinearLayout> |
|
98 |
|
|
99 |
<LinearLayout |
|
100 |
android:layout_width="wrap_content" |
|
101 |
android:layout_height="fill_parent" |
|
102 |
android:layout_weight="0.5" |
|
103 |
android:layout_gravity="center_vertical" |
|
104 |
android:gravity="center|fill_horizontal" |
|
105 |
android:orientation="vertical"> |
|
106 |
|
|
107 |
<TextView |
|
108 |
android:id="@+id/dynamicTextCount" |
|
109 |
android:layout_width="wrap_content" |
|
110 |
android:layout_height="wrap_content" |
|
111 |
android:layout_gravity="center_horizontal" |
|
112 |
android:text="@string/count" |
|
113 |
android:textAppearance="?android:attr/textAppearanceMedium" |
|
114 |
android:textSize="12sp" /> |
|
115 |
|
|
116 |
<SeekBar |
|
117 |
android:id="@+id/dynamicSeekCount" |
|
118 |
android:layout_width="match_parent" |
|
119 |
android:layout_height="wrap_content" |
|
120 |
android:paddingStart="5dp" |
|
121 |
android:paddingEnd="10dp" /> |
|
122 |
|
|
123 |
</LinearLayout> |
|
124 |
|
|
125 |
</LinearLayout> |
|
119 | 126 |
|
120 | 127 |
<TextView |
121 | 128 |
android:id="@+id/dynamicTextNoise" |
... | ... | |
123 | 130 |
android:layout_height="wrap_content" |
124 | 131 |
android:layout_gravity="center_horizontal" |
125 | 132 |
android:layout_weight="15" |
126 |
android:paddingLeft="10dp" |
|
127 | 133 |
android:text="@string/noise" |
128 | 134 |
android:textAppearance="?android:attr/textAppearanceMedium" |
129 | 135 |
android:textSize="12sp" /> |
... | ... | |
139 | 145 |
android:layout_width="match_parent" |
140 | 146 |
android:layout_height="wrap_content" |
141 | 147 |
android:layout_weight="1" |
142 |
android:paddingLeft="5dp"
|
|
143 |
android:paddingRight="10dp" />
|
|
148 |
android:paddingLeft="10dp"
|
|
149 |
android:paddingRight="5dp" />
|
|
144 | 150 |
|
145 | 151 |
<SeekBar |
146 | 152 |
android:id="@+id/dynamicSeekNoise1" |
... | ... | |
148 | 154 |
android:layout_height="wrap_content" |
149 | 155 |
android:layout_weight="1" |
150 | 156 |
android:paddingLeft="5dp" |
151 |
android:paddingRight="10dp" />
|
|
157 |
android:paddingRight="5dp" />
|
|
152 | 158 |
|
153 | 159 |
<SeekBar |
154 | 160 |
android:id="@+id/dynamicSeekNoise2" |
src/main/res/values/strings.xml | ||
---|---|---|
82 | 82 |
<string name="effect_finished">FINISHED </string> |
83 | 83 |
<string name="scramble">Scramble</string> |
84 | 84 |
<string name="credits">Credits</string> |
85 |
<string name="start">Start</string> |
|
85 | 86 |
|
86 | 87 |
<string name="quality0">Highest</string> |
87 | 88 |
<string name="quality1">High</string> |
... | ... | |
114 | 115 |
<string name="inflate_placeholder">Inflate: %1$.2f</string> |
115 | 116 |
<string name="effect_id_placeholder">ID: %1$d</string> |
116 | 117 |
<string name="rubik_placeholder">Cube: %1$d Available Memory: %2$d MB</string> |
118 |
<string name="duration_placeholder">Duration: %1$d s</string> |
|
119 |
<string name="count_placeholder">Count: %1$.2f</string> |
|
120 |
<string name="noise2_placeholder">Noise: %1$.2f %2$.2f %3$.2f</string> |
|
117 | 121 |
|
118 | 122 |
<string name="example_monalisa">Mona Lisa</string> |
119 | 123 |
<string name="example_monalisa_subtitle">The basics of Distortions.</string> |
Also available in: Unified diff
1. Change the API of Dynamic: split makeNowRunFor into two separate 'setDuration' and 'resetToBeginning'
2. Major changes to the 'Dynamic' app so that we can check more about the Dynamics.