Revision 2ec2dc32
Added by Leszek Koltunski over 6 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 35 | 35 |
<activity android:name=".inflate.InflateActivity" /> |
| 36 | 36 |
<activity android:name=".inflate.InflateActivity2" /> |
| 37 | 37 |
<activity android:name=".quaternion.QuaternionActivity" /> |
| 38 |
<activity android:name=".effects3d.Effects3DActivity" />
|
|
| 39 |
<activity android:name=".effects3d.Effects3DActivity2"/>
|
|
| 38 |
<activity android:name=".generic.Effects3DActivity" />
|
|
| 39 |
<activity android:name=".generic.Effects3DActivity2"/>
|
|
| 40 | 40 |
<activity android:name=".plainmonalisa.PlainMonaLisaActivity" /> |
| 41 | 41 |
<activity android:name=".save.SaveActivity"/> |
| 42 | 42 |
<activity android:name=".flag.FlagActivity"/> |
| src/main/java/org/distorted/examples/TableOfContents.java | ||
|---|---|---|
| 53 | 53 |
import org.distorted.examples.starwars.StarWarsActivity; |
| 54 | 54 |
import org.distorted.examples.inflate.InflateActivity; |
| 55 | 55 |
import org.distorted.examples.quaternion.QuaternionActivity; |
| 56 |
import org.distorted.examples.effects3d.Effects3DActivity;
|
|
| 56 |
import org.distorted.examples.generic.Effects3DActivity;
|
|
| 57 | 57 |
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity; |
| 58 | 58 |
import org.distorted.examples.save.SaveActivity; |
| 59 | 59 |
import org.distorted.examples.flag.FlagActivity; |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.effects3d; |
|
| 21 |
|
|
| 22 |
import android.app.Activity; |
|
| 23 |
import android.content.Intent; |
|
| 24 |
import android.os.Bundle; |
|
| 25 |
import android.view.Gravity; |
|
| 26 |
import android.view.View; |
|
| 27 |
import android.widget.AdapterView; |
|
| 28 |
import android.widget.ArrayAdapter; |
|
| 29 |
import android.widget.Button; |
|
| 30 |
import android.widget.LinearLayout; |
|
| 31 |
import android.widget.NumberPicker; |
|
| 32 |
import android.widget.Spinner; |
|
| 33 |
import android.widget.TableRow; |
|
| 34 |
|
|
| 35 |
import org.distorted.examples.R; |
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
public class Effects3DActivity extends Activity |
|
| 40 |
implements View.OnClickListener, AdapterView.OnItemSelectedListener |
|
| 41 |
{
|
|
| 42 |
private static final int COLOR_OFF = 0xffffe81f; |
|
| 43 |
private static final int COLOR_ON = 0xff0000ff; |
|
| 44 |
private static final int COLOR_INAC= 0xff999999; |
|
| 45 |
|
|
| 46 |
private int mNumCols = 1; |
|
| 47 |
private int mNumRows = 1; |
|
| 48 |
private int mNumSlic = 1; |
|
| 49 |
private boolean mGridInitialized; |
|
| 50 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
|
| 51 |
private boolean[] mShape; |
|
| 52 |
private int mObjectType; |
|
| 53 |
private int mBitmapID; |
|
| 54 |
private LinearLayout mLay; |
|
| 55 |
|
|
| 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 57 |
|
|
| 58 |
@Override |
|
| 59 |
protected void onCreate(Bundle savedState) |
|
| 60 |
{
|
|
| 61 |
super.onCreate(savedState); |
|
| 62 |
|
|
| 63 |
setContentView(R.layout.objectpickerlayout); |
|
| 64 |
|
|
| 65 |
mLay = findViewById(R.id.objectpicker_buttongrid); |
|
| 66 |
|
|
| 67 |
mColsPicker = findViewById(R.id.objectpicker_cols); |
|
| 68 |
mRowsPicker = findViewById(R.id.objectpicker_rows); |
|
| 69 |
mSlicPicker = findViewById(R.id.objectpicker_slices); |
|
| 70 |
|
|
| 71 |
mColsPicker.setMaxValue(40); |
|
| 72 |
mColsPicker.setMinValue( 1); |
|
| 73 |
mRowsPicker.setMaxValue(40); |
|
| 74 |
mRowsPicker.setMinValue( 1); |
|
| 75 |
mSlicPicker.setMaxValue(40); |
|
| 76 |
mSlicPicker.setMinValue( 0); |
|
| 77 |
|
|
| 78 |
mColsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 79 |
{
|
|
| 80 |
@Override |
|
| 81 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 82 |
{
|
|
| 83 |
setGrid(); |
|
| 84 |
} |
|
| 85 |
}); |
|
| 86 |
|
|
| 87 |
mRowsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 88 |
{
|
|
| 89 |
@Override |
|
| 90 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 91 |
{
|
|
| 92 |
setGrid(); |
|
| 93 |
} |
|
| 94 |
}); |
|
| 95 |
|
|
| 96 |
mSlicPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() |
|
| 97 |
{
|
|
| 98 |
@Override |
|
| 99 |
public void onValueChange(NumberPicker picker, int oldVal, int newVal) |
|
| 100 |
{
|
|
| 101 |
mNumSlic = mSlicPicker.getValue(); |
|
| 102 |
} |
|
| 103 |
}); |
|
| 104 |
|
|
| 105 |
mObjectType = 0; |
|
| 106 |
mGridInitialized = false; |
|
| 107 |
|
|
| 108 |
Spinner typeSpinner = findViewById(R.id.objectpicker_spinnerType); |
|
| 109 |
typeSpinner.setOnItemSelectedListener(this); |
|
| 110 |
|
|
| 111 |
String[] objectType = new String[] {"Mesh: Cubes", "Mesh: Flat", "Mesh: Sphere", "Mesh: Quad"};
|
|
| 112 |
|
|
| 113 |
ArrayAdapter<String> adapterType = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectType); |
|
| 114 |
adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 115 |
typeSpinner.setAdapter(adapterType); |
|
| 116 |
|
|
| 117 |
Spinner bitmapSpinner = findViewById(R.id.objectpicker_spinnerBitmap); |
|
| 118 |
bitmapSpinner.setOnItemSelectedListener(this); |
|
| 119 |
|
|
| 120 |
String[] objectBitmap = new String[] { "Texture: Grid", "Texture: Girl", "Texture: Dog", "Texture: Cat",
|
|
| 121 |
"Texture: Squares", "Texture: Bean", "Texture: Lisa", "Texture: World" }; |
|
| 122 |
|
|
| 123 |
ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap); |
|
| 124 |
adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 125 |
bitmapSpinner.setAdapter(adapterBitmap); |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
private void setGrid() |
|
| 131 |
{
|
|
| 132 |
mGridInitialized = true; |
|
| 133 |
|
|
| 134 |
mNumCols = mColsPicker.getValue(); |
|
| 135 |
mNumRows = mRowsPicker.getValue(); |
|
| 136 |
|
|
| 137 |
int width = mLay.getWidth(); |
|
| 138 |
int height= mLay.getHeight(); |
|
| 139 |
int w = mNumCols>0 ? (int)( 0.9f*width / mNumCols) : 0; |
|
| 140 |
int h = mNumRows>0 ? (int)( 0.9f*height/ mNumRows) : 0; |
|
| 141 |
int size= w<h ? w:h; |
|
| 142 |
int pad = size<20 ? 1 : size/20; |
|
| 143 |
|
|
| 144 |
mLay.removeAllViews(); |
|
| 145 |
|
|
| 146 |
mShape = new boolean[mNumRows*mNumCols]; |
|
| 147 |
|
|
| 148 |
TableRow.LayoutParams p = new TableRow.LayoutParams(); |
|
| 149 |
|
|
| 150 |
p.rightMargin = pad; |
|
| 151 |
p.leftMargin = pad; |
|
| 152 |
p.topMargin = pad; |
|
| 153 |
p.bottomMargin = pad; |
|
| 154 |
p.height = size; |
|
| 155 |
p.width = size; |
|
| 156 |
|
|
| 157 |
for (int rows=0; rows<mNumRows; rows++) |
|
| 158 |
{
|
|
| 159 |
TableRow tr = new TableRow(this); |
|
| 160 |
tr.setGravity(Gravity.CENTER); |
|
| 161 |
|
|
| 162 |
for(int cols=0; cols<mNumCols; cols++) |
|
| 163 |
{
|
|
| 164 |
Button b = new Button(this); |
|
| 165 |
b.setOnClickListener(this); |
|
| 166 |
b.setId(rows*mNumCols+cols); |
|
| 167 |
b.setLayoutParams(p); |
|
| 168 |
b.setBackgroundColor(mObjectType==0 ? COLOR_ON:COLOR_INAC); |
|
| 169 |
tr.addView(b, p); |
|
| 170 |
mShape[rows*mNumCols+cols] = true; |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
mLay.addView(tr); |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
|
|
| 177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 178 |
|
|
| 179 |
public void onClick(View view) |
|
| 180 |
{
|
|
| 181 |
if( mObjectType==0 ) // cubes |
|
| 182 |
{
|
|
| 183 |
Button tmp = (Button)view; |
|
| 184 |
int id = tmp.getId(); |
|
| 185 |
mShape[id] = !mShape[id]; |
|
| 186 |
tmp.setBackgroundColor(mShape[id] ? COLOR_ON:COLOR_OFF); |
|
| 187 |
} |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 191 |
|
|
| 192 |
private void uncheckAll() |
|
| 193 |
{
|
|
| 194 |
TableRow tr; |
|
| 195 |
Button butt; |
|
| 196 |
|
|
| 197 |
for (int row=0; row<mNumRows; row++) |
|
| 198 |
{
|
|
| 199 |
tr = (TableRow)mLay.getChildAt(row); |
|
| 200 |
|
|
| 201 |
for(int col=0; col<mNumCols; col++) |
|
| 202 |
{
|
|
| 203 |
butt = (Button)tr.getVirtualChildAt(col); |
|
| 204 |
butt.setBackgroundColor(mObjectType==0 ? COLOR_ON : COLOR_INAC); |
|
| 205 |
mShape[row*mNumCols+col] = true; |
|
| 206 |
} |
|
| 207 |
} |
|
| 208 |
} |
|
| 209 |
|
|
| 210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 211 |
|
|
| 212 |
public void Create(View v) |
|
| 213 |
{
|
|
| 214 |
Intent mainInt = new Intent( getApplicationContext(), Effects3DActivity2.class); |
|
| 215 |
Bundle b = new Bundle(); |
|
| 216 |
|
|
| 217 |
int rows=0, cols=0; |
|
| 218 |
|
|
| 219 |
switch(mObjectType) |
|
| 220 |
{
|
|
| 221 |
case 0: |
|
| 222 |
case 1: rows = mNumRows; |
|
| 223 |
cols = mNumCols; |
|
| 224 |
break; |
|
| 225 |
case 2: rows = mNumRows; // always make the sphere equal in X and Y |
|
| 226 |
cols = mNumRows; // |
|
| 227 |
break; |
|
| 228 |
case 3: rows = 1; // a quad is always 1x1 |
|
| 229 |
cols = 1; |
|
| 230 |
break; |
|
| 231 |
} |
|
| 232 |
|
|
| 233 |
b.putInt("type", mObjectType);
|
|
| 234 |
b.putInt("cols", cols);
|
|
| 235 |
b.putInt("rows", rows);
|
|
| 236 |
b.putInt("slices", mNumSlic);
|
|
| 237 |
b.putInt("bitmap", mBitmapID);
|
|
| 238 |
|
|
| 239 |
if( mObjectType==0 ) // cubes |
|
| 240 |
{
|
|
| 241 |
String str = ""; |
|
| 242 |
|
|
| 243 |
for(int i=0; i<mNumRows*mNumCols; i++) |
|
| 244 |
str += mShape[i] ? "1" : "0"; |
|
| 245 |
|
|
| 246 |
b.putString("string", str);
|
|
| 247 |
} |
|
| 248 |
else |
|
| 249 |
{
|
|
| 250 |
b.putString("string", "");
|
|
| 251 |
} |
|
| 252 |
|
|
| 253 |
mainInt.putExtras(b); |
|
| 254 |
startActivity(mainInt); |
|
| 255 |
} |
|
| 256 |
|
|
| 257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 258 |
|
|
| 259 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
| 260 |
{
|
|
| 261 |
switch(parent.getId()) |
|
| 262 |
{
|
|
| 263 |
case R.id.objectpicker_spinnerType : if( mObjectType!=pos ) |
|
| 264 |
{
|
|
| 265 |
mObjectType = pos; |
|
| 266 |
uncheckAll(); |
|
| 267 |
|
|
| 268 |
switch(mObjectType) |
|
| 269 |
{
|
|
| 270 |
case 0: mColsPicker.setEnabled(true); |
|
| 271 |
mRowsPicker.setEnabled(true); |
|
| 272 |
mSlicPicker.setEnabled(true); |
|
| 273 |
break; |
|
| 274 |
case 1: mColsPicker.setEnabled(true); |
|
| 275 |
mRowsPicker.setEnabled(true); |
|
| 276 |
mSlicPicker.setEnabled(false); |
|
| 277 |
break; |
|
| 278 |
case 2: mColsPicker.setEnabled(false); |
|
| 279 |
mRowsPicker.setEnabled(true); |
|
| 280 |
mSlicPicker.setEnabled(false); |
|
| 281 |
break; |
|
| 282 |
case 3: mColsPicker.setEnabled(false); |
|
| 283 |
mRowsPicker.setEnabled(false); |
|
| 284 |
mSlicPicker.setEnabled(false); |
|
| 285 |
break; |
|
| 286 |
} |
|
| 287 |
} |
|
| 288 |
break; |
|
| 289 |
case R.id.objectpicker_spinnerBitmap: switch(pos) |
|
| 290 |
{
|
|
| 291 |
case 0: mBitmapID = -1 ; break; |
|
| 292 |
case 1: mBitmapID = R.raw.face ; break; |
|
| 293 |
case 2: mBitmapID = R.raw.dog ; break; |
|
| 294 |
case 3: mBitmapID = R.raw.cat ; break; |
|
| 295 |
case 4: mBitmapID = R.raw.grid ; break; |
|
| 296 |
case 5: mBitmapID = R.raw.bean ; break; |
|
| 297 |
case 6: mBitmapID = R.raw.monalisa; break; |
|
| 298 |
case 7: mBitmapID = R.raw.world ; break; |
|
| 299 |
} |
|
| 300 |
break; |
|
| 301 |
} |
|
| 302 |
} |
|
| 303 |
|
|
| 304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 305 |
|
|
| 306 |
public void onNothingSelected(AdapterView<?> parent) |
|
| 307 |
{
|
|
| 308 |
} |
|
| 309 |
|
|
| 310 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 311 |
// Overrides |
|
| 312 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 313 |
|
|
| 314 |
@Override |
|
| 315 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 316 |
{
|
|
| 317 |
super.onWindowFocusChanged(hasFocus); |
|
| 318 |
|
|
| 319 |
mColsPicker.setValue(mNumCols); |
|
| 320 |
mRowsPicker.setValue(mNumRows); |
|
| 321 |
mSlicPicker.setValue(mNumSlic); |
|
| 322 |
|
|
| 323 |
if( !mGridInitialized ) setGrid(); |
|
| 324 |
} |
|
| 325 |
} |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity2.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.effects3d; |
|
| 21 |
|
|
| 22 |
import android.graphics.Bitmap; |
|
| 23 |
import android.graphics.BitmapFactory; |
|
| 24 |
import android.graphics.Canvas; |
|
| 25 |
import android.graphics.Paint; |
|
| 26 |
import android.opengl.GLSurfaceView; |
|
| 27 |
import android.os.Bundle; |
|
| 28 |
import android.support.design.widget.TabLayout; |
|
| 29 |
import android.support.v4.view.ViewPager; |
|
| 30 |
import android.support.v7.app.AppCompatActivity; |
|
| 31 |
import android.view.View; |
|
| 32 |
import android.widget.CheckBox; |
|
| 33 |
|
|
| 34 |
import org.distorted.examples.R; |
|
| 35 |
import org.distorted.library.main.Distorted; |
|
| 36 |
import org.distorted.library.main.DistortedEffects; |
|
| 37 |
import org.distorted.library.main.DistortedTexture; |
|
| 38 |
import org.distorted.library.mesh.MeshCubes; |
|
| 39 |
import org.distorted.library.mesh.MeshFlat; |
|
| 40 |
import org.distorted.library.mesh.MeshBase; |
|
| 41 |
import org.distorted.library.mesh.MeshQuad; |
|
| 42 |
import org.distorted.library.mesh.MeshSphere; |
|
| 43 |
import org.distorted.library.type.Static4D; |
|
| 44 |
|
|
| 45 |
import java.io.IOException; |
|
| 46 |
import java.io.InputStream; |
|
| 47 |
|
|
| 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 49 |
|
|
| 50 |
public class Effects3DActivity2 extends AppCompatActivity |
|
| 51 |
{
|
|
| 52 |
public static final int NUM_TABS = 4; |
|
| 53 |
|
|
| 54 |
private DistortedTexture mTexture; |
|
| 55 |
private MeshBase mMesh; |
|
| 56 |
private Bitmap mBitmap; |
|
| 57 |
|
|
| 58 |
private float mCenterX, mCenterY, mCenterZ; |
|
| 59 |
private float mRegionX, mRegionY, mRegionZ, mRegionR; |
|
| 60 |
private DistortedEffects mEffects; |
|
| 61 |
private ViewPager mViewPager; |
|
| 62 |
|
|
| 63 |
private boolean mShowCenter; |
|
| 64 |
private boolean mShowRegion; |
|
| 65 |
private boolean mShowNormal; |
|
| 66 |
private boolean mUseOIT ; |
|
| 67 |
|
|
| 68 |
private Effects3DTab[] mTab; |
|
| 69 |
|
|
| 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 71 |
|
|
| 72 |
@Override |
|
| 73 |
protected void onCreate(Bundle savedState) |
|
| 74 |
{
|
|
| 75 |
super.onCreate(savedState); |
|
| 76 |
|
|
| 77 |
setTheme(R.style.CustomActivityThemeNoActionBar); |
|
| 78 |
|
|
| 79 |
mTab = new Effects3DTab[NUM_TABS]; |
|
| 80 |
|
|
| 81 |
Bundle b = getIntent().getExtras(); |
|
| 82 |
|
|
| 83 |
int objectType = b.getInt("type");
|
|
| 84 |
int numCols = b.getInt("cols");
|
|
| 85 |
int numRows = b.getInt("rows");
|
|
| 86 |
int numSlic = b.getInt("slices");
|
|
| 87 |
int bitmapID = b.getInt("bitmap");
|
|
| 88 |
String str = b.getString("string");
|
|
| 89 |
|
|
| 90 |
mShowCenter = false; |
|
| 91 |
mShowRegion = false; |
|
| 92 |
mShowNormal = false; |
|
| 93 |
mUseOIT = false; |
|
| 94 |
|
|
| 95 |
int maxsize = numCols > numRows ? (numCols>numSlic ? numCols:numSlic) : (numRows>numSlic ? numRows:numSlic) ; |
|
| 96 |
|
|
| 97 |
createBitmap(maxsize, bitmapID); |
|
| 98 |
|
|
| 99 |
switch(objectType) |
|
| 100 |
{
|
|
| 101 |
case 0: if( bitmapID!=-1 ) |
|
| 102 |
{
|
|
| 103 |
mMesh = new MeshCubes(numCols, str, numSlic); |
|
| 104 |
} |
|
| 105 |
else |
|
| 106 |
{
|
|
| 107 |
Static4D mapFB = new Static4D(0.0f,0.0f, (float)numCols/maxsize, (float)numRows/maxsize); |
|
| 108 |
Static4D mapLR = new Static4D(0.0f,0.0f, (float)numSlic/maxsize, (float)numRows/maxsize); |
|
| 109 |
Static4D mapTB = new Static4D(0.0f,0.0f, (float)numCols/maxsize, (float)numSlic/maxsize); |
|
| 110 |
|
|
| 111 |
mMesh = new MeshCubes(numCols, str, numSlic, mapFB, mapFB, mapLR, mapLR, mapTB, mapTB); |
|
| 112 |
} |
|
| 113 |
break; |
|
| 114 |
case 1: mMesh = new MeshFlat(numCols,numRows); |
|
| 115 |
break; |
|
| 116 |
case 2: mMesh = new MeshSphere(numRows); |
|
| 117 |
break; |
|
| 118 |
case 3: mMesh = new MeshQuad(); |
|
| 119 |
break; |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
mMesh.setShowNormals(mShowNormal); |
|
| 123 |
mTexture= new DistortedTexture(numCols,numRows); |
|
| 124 |
mEffects= new DistortedEffects(); |
|
| 125 |
|
|
| 126 |
final View view = getLayoutInflater().inflate(R.layout.effects3dlayout, null); |
|
| 127 |
|
|
| 128 |
setContentView(view); |
|
| 129 |
|
|
| 130 |
mViewPager = findViewById(R.id.effects3d_viewpager); |
|
| 131 |
mViewPager.setOffscreenPageLimit( NUM_TABS-1 ); |
|
| 132 |
Effects3DTabViewPager pager = new Effects3DTabViewPager(this, getSupportFragmentManager() ); |
|
| 133 |
mViewPager.setAdapter(pager); |
|
| 134 |
TabLayout tabLayout = findViewById(R.id.effects3d_sliding_tabs); |
|
| 135 |
tabLayout.setupWithViewPager(mViewPager); |
|
| 136 |
|
|
| 137 |
resetData(); |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 141 |
|
|
| 142 |
private void createBitmap(int size, int bitmapID) |
|
| 143 |
{
|
|
| 144 |
if( bitmapID!=-1) |
|
| 145 |
{
|
|
| 146 |
InputStream is = getResources().openRawResource(bitmapID); |
|
| 147 |
|
|
| 148 |
try |
|
| 149 |
{
|
|
| 150 |
mBitmap = BitmapFactory.decodeStream(is); |
|
| 151 |
} |
|
| 152 |
finally |
|
| 153 |
{
|
|
| 154 |
try |
|
| 155 |
{
|
|
| 156 |
is.close(); |
|
| 157 |
} |
|
| 158 |
catch(IOException e) { }
|
|
| 159 |
} |
|
| 160 |
} |
|
| 161 |
else |
|
| 162 |
{
|
|
| 163 |
final int T = 64; |
|
| 164 |
final int S = T*size; |
|
| 165 |
|
|
| 166 |
Paint paint = new Paint(); |
|
| 167 |
mBitmap = Bitmap.createBitmap(S,S, Bitmap.Config.ARGB_8888); |
|
| 168 |
Canvas canvas = new Canvas(mBitmap); |
|
| 169 |
|
|
| 170 |
paint.setAntiAlias(true); |
|
| 171 |
paint.setTextAlign(Paint.Align.CENTER); |
|
| 172 |
paint.setColor(0xff008800); |
|
| 173 |
paint.setStyle(Paint.Style.FILL); |
|
| 174 |
canvas.drawRect(0, 0, S, S, paint); |
|
| 175 |
paint.setColor(0xffffffff); |
|
| 176 |
|
|
| 177 |
for(int i=0; i<=size ; i++ ) |
|
| 178 |
{
|
|
| 179 |
canvas.drawRect( T*i-1, 0, T*i+1, S, paint); |
|
| 180 |
canvas.drawRect( 0, T*i-1, S, T*i+1, paint); |
|
| 181 |
} |
|
| 182 |
} |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 186 |
|
|
| 187 |
public DistortedTexture getTexture() |
|
| 188 |
{
|
|
| 189 |
return mTexture; |
|
| 190 |
} |
|
| 191 |
|
|
| 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 193 |
|
|
| 194 |
public MeshBase getMesh() |
|
| 195 |
{
|
|
| 196 |
return mMesh; |
|
| 197 |
} |
|
| 198 |
|
|
| 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 200 |
|
|
| 201 |
public Bitmap getBitmap() |
|
| 202 |
{
|
|
| 203 |
return mBitmap; |
|
| 204 |
} |
|
| 205 |
|
|
| 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 207 |
|
|
| 208 |
public void setRegion(float x, float y, float z, float r) |
|
| 209 |
{
|
|
| 210 |
mRegionX = x; |
|
| 211 |
mRegionY =-y; |
|
| 212 |
mRegionZ = z; |
|
| 213 |
mRegionR = r; |
|
| 214 |
|
|
| 215 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 216 |
view.getRenderer().setRegion(mRegionX, mRegionY, mRegionZ, mRegionR); |
|
| 217 |
} |
|
| 218 |
|
|
| 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 220 |
|
|
| 221 |
public void setCenter(float x, float y, float z) |
|
| 222 |
{
|
|
| 223 |
mCenterX = x; |
|
| 224 |
mCenterY = y; |
|
| 225 |
mCenterZ = z; |
|
| 226 |
|
|
| 227 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 228 |
view.getRenderer().setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 229 |
} |
|
| 230 |
|
|
| 231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 232 |
|
|
| 233 |
public float getCenterX() |
|
| 234 |
{
|
|
| 235 |
return mCenterX; |
|
| 236 |
} |
|
| 237 |
|
|
| 238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 239 |
|
|
| 240 |
public float getCenterY() |
|
| 241 |
{
|
|
| 242 |
return mCenterY; |
|
| 243 |
} |
|
| 244 |
|
|
| 245 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 246 |
|
|
| 247 |
public float getRegionX() |
|
| 248 |
{
|
|
| 249 |
return mRegionX; |
|
| 250 |
} |
|
| 251 |
|
|
| 252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 253 |
|
|
| 254 |
public float getRegionY() |
|
| 255 |
{
|
|
| 256 |
return mRegionY; |
|
| 257 |
} |
|
| 258 |
|
|
| 259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 260 |
|
|
| 261 |
public float getRegionZ() |
|
| 262 |
{
|
|
| 263 |
return mRegionZ; |
|
| 264 |
} |
|
| 265 |
|
|
| 266 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 267 |
|
|
| 268 |
public float getRegionR() |
|
| 269 |
{
|
|
| 270 |
return mRegionR; |
|
| 271 |
} |
|
| 272 |
|
|
| 273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 274 |
|
|
| 275 |
public int getWidth() |
|
| 276 |
{
|
|
| 277 |
return mTexture==null ? 0: mTexture.getWidth(); |
|
| 278 |
} |
|
| 279 |
|
|
| 280 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 281 |
|
|
| 282 |
public int getHeight() |
|
| 283 |
{
|
|
| 284 |
return mTexture==null ? 0: mTexture.getHeight(); |
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 288 |
|
|
| 289 |
public int getDepth() |
|
| 290 |
{
|
|
| 291 |
return mTexture==null ? 0: mTexture.getDepth(mMesh); |
|
| 292 |
} |
|
| 293 |
|
|
| 294 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 295 |
|
|
| 296 |
public int getScreenWidth() |
|
| 297 |
{
|
|
| 298 |
Effects3DRenderer r = ((Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView)).getRenderer(); |
|
| 299 |
return r.getWidth(); |
|
| 300 |
} |
|
| 301 |
|
|
| 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 303 |
|
|
| 304 |
void resetData() |
|
| 305 |
{
|
|
| 306 |
mCenterX = 0.5f*getWidth(); |
|
| 307 |
mCenterY = 0.5f*getHeight(); |
|
| 308 |
mRegionX = 0; |
|
| 309 |
mRegionY = 0; |
|
| 310 |
mRegionZ = 0; |
|
| 311 |
mRegionR = getWidth()/2; |
|
| 312 |
|
|
| 313 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 314 |
Effects3DRenderer renderer= view.getRenderer(); |
|
| 315 |
|
|
| 316 |
renderer.setCenter( mCenterX, mCenterY, mCenterZ ); |
|
| 317 |
renderer.setRegion( mRegionX, mRegionY, mRegionZ, mRegionR ); |
|
| 318 |
} |
|
| 319 |
|
|
| 320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 321 |
|
|
| 322 |
void resetMatrixEffects() |
|
| 323 |
{
|
|
| 324 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 325 |
Effects3DRenderer renderer= view.getRenderer(); |
|
| 326 |
|
|
| 327 |
renderer.resetMatrixEffects(); |
|
| 328 |
} |
|
| 329 |
|
|
| 330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 331 |
|
|
| 332 |
public DistortedEffects getEffects() |
|
| 333 |
{
|
|
| 334 |
return mEffects; |
|
| 335 |
} |
|
| 336 |
|
|
| 337 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 338 |
|
|
| 339 |
public void newEffect(View v) |
|
| 340 |
{
|
|
| 341 |
int pos = mViewPager.getCurrentItem(); |
|
| 342 |
|
|
| 343 |
if( pos>=0 && pos<NUM_TABS ) mTab[pos].newEffect(); |
|
| 344 |
} |
|
| 345 |
|
|
| 346 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 347 |
|
|
| 348 |
public void removeAll(View v) |
|
| 349 |
{
|
|
| 350 |
int pos = mViewPager.getCurrentItem(); |
|
| 351 |
|
|
| 352 |
if( pos>=0 && pos<NUM_TABS ) mTab[pos].removeAll(); |
|
| 353 |
} |
|
| 354 |
|
|
| 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 356 |
|
|
| 357 |
public void remove(View v) |
|
| 358 |
{
|
|
| 359 |
int pos = mViewPager.getCurrentItem(); |
|
| 360 |
|
|
| 361 |
if( pos>=0 && pos<NUM_TABS ) mTab[pos].remove(v); |
|
| 362 |
} |
|
| 363 |
|
|
| 364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 365 |
|
|
| 366 |
void setTab(int pos, Effects3DTab tab) |
|
| 367 |
{
|
|
| 368 |
if( pos>=0 && pos<NUM_TABS ) mTab[pos] = tab; |
|
| 369 |
} |
|
| 370 |
|
|
| 371 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 372 |
|
|
| 373 |
boolean getShowCenter() |
|
| 374 |
{
|
|
| 375 |
return mShowCenter; |
|
| 376 |
} |
|
| 377 |
|
|
| 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 379 |
|
|
| 380 |
boolean getShowRegion() |
|
| 381 |
{
|
|
| 382 |
return mShowRegion; |
|
| 383 |
} |
|
| 384 |
|
|
| 385 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 386 |
|
|
| 387 |
public void showCenter(View view) |
|
| 388 |
{
|
|
| 389 |
CheckBox box = (CheckBox)view; |
|
| 390 |
mShowCenter = box.isChecked(); |
|
| 391 |
|
|
| 392 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 393 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 394 |
} |
|
| 395 |
|
|
| 396 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 397 |
|
|
| 398 |
public void showRegion(View view) |
|
| 399 |
{
|
|
| 400 |
CheckBox box = (CheckBox)view; |
|
| 401 |
mShowRegion = box.isChecked(); |
|
| 402 |
|
|
| 403 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 404 |
sv.getRenderer().showRegionAndCenter(mShowRegion,mShowCenter); |
|
| 405 |
} |
|
| 406 |
|
|
| 407 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 408 |
|
|
| 409 |
public void showNormal(View view) |
|
| 410 |
{
|
|
| 411 |
CheckBox box = (CheckBox)view; |
|
| 412 |
mShowNormal = box.isChecked(); |
|
| 413 |
|
|
| 414 |
if ( mMesh!=null ) |
|
| 415 |
{
|
|
| 416 |
mMesh.setShowNormals(mShowNormal); |
|
| 417 |
} |
|
| 418 |
} |
|
| 419 |
|
|
| 420 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 421 |
|
|
| 422 |
public void triggerOIT(View view) |
|
| 423 |
{
|
|
| 424 |
CheckBox box = (CheckBox)view; |
|
| 425 |
mUseOIT = box.isChecked(); |
|
| 426 |
|
|
| 427 |
Effects3DSurfaceView sv = findViewById(R.id.effects3dSurfaceView); |
|
| 428 |
sv.getRenderer().useOIT(mUseOIT); |
|
| 429 |
} |
|
| 430 |
|
|
| 431 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 432 |
// Overrides |
|
| 433 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 434 |
|
|
| 435 |
@Override |
|
| 436 |
protected void onPause() |
|
| 437 |
{
|
|
| 438 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 439 |
if( mView!=null ) mView.onPause(); |
|
| 440 |
|
|
| 441 |
Distorted.onPause(); |
|
| 442 |
super.onPause(); |
|
| 443 |
} |
|
| 444 |
|
|
| 445 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 446 |
|
|
| 447 |
@Override |
|
| 448 |
protected void onResume() |
|
| 449 |
{
|
|
| 450 |
super.onResume(); |
|
| 451 |
GLSurfaceView mView = findViewById(R.id.effects3dSurfaceView); |
|
| 452 |
if( mView!=null ) mView.onResume(); |
|
| 453 |
} |
|
| 454 |
|
|
| 455 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 456 |
|
|
| 457 |
@Override |
|
| 458 |
protected void onDestroy() |
|
| 459 |
{
|
|
| 460 |
Distorted.onDestroy(); |
|
| 461 |
super.onDestroy(); |
|
| 462 |
} |
|
| 463 |
|
|
| 464 |
} |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.effects3d; |
|
| 21 |
|
|
| 22 |
import android.view.View; |
|
| 23 |
import android.widget.SeekBar; |
|
| 24 |
import android.widget.TextView; |
|
| 25 |
|
|
| 26 |
import org.distorted.examples.R; |
|
| 27 |
import org.distorted.library.effect.Effect; |
|
| 28 |
import org.distorted.library.effect.EffectName; |
|
| 29 |
import org.distorted.library.effect.EffectType; |
|
| 30 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
| 31 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
| 32 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
| 33 |
import org.distorted.library.effect.FragmentEffectContrast; |
|
| 34 |
import org.distorted.library.effect.FragmentEffectSaturation; |
|
| 35 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 36 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
| 37 |
import org.distorted.library.effect.MatrixEffectRotate; |
|
| 38 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 39 |
import org.distorted.library.effect.MatrixEffectShear; |
|
| 40 |
import org.distorted.library.effect.PostprocessEffectBlur; |
|
| 41 |
import org.distorted.library.effect.PostprocessEffectGlow; |
|
| 42 |
import org.distorted.library.effect.VertexEffectDeform; |
|
| 43 |
import org.distorted.library.effect.VertexEffectDistort; |
|
| 44 |
import org.distorted.library.effect.VertexEffectPinch; |
|
| 45 |
import org.distorted.library.effect.VertexEffectSink; |
|
| 46 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
| 47 |
import org.distorted.library.effect.VertexEffectWave; |
|
| 48 |
import org.distorted.library.main.DistortedEffects; |
|
| 49 |
import org.distorted.library.type.Dynamic1D; |
|
| 50 |
import org.distorted.library.type.Dynamic2D; |
|
| 51 |
import org.distorted.library.type.Dynamic3D; |
|
| 52 |
import org.distorted.library.type.Dynamic4D; |
|
| 53 |
import org.distorted.library.type.Dynamic5D; |
|
| 54 |
import org.distorted.library.type.Static1D; |
|
| 55 |
import org.distorted.library.type.Static2D; |
|
| 56 |
import org.distorted.library.type.Static3D; |
|
| 57 |
import org.distorted.library.type.Static4D; |
|
| 58 |
import org.distorted.library.type.Static5D; |
|
| 59 |
|
|
| 60 |
import java.lang.ref.WeakReference; |
|
| 61 |
import java.lang.reflect.Method; |
|
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 64 |
|
|
| 65 |
class Effects3DEffect implements SeekBar.OnSeekBarChangeListener |
|
| 66 |
{
|
|
| 67 |
private static final int BACKGROUND_ODD = 0xff555555; |
|
| 68 |
private static final int BACKGROUND_EVEN= 0xff333333; |
|
| 69 |
|
|
| 70 |
private WeakReference<Effects3DActivity2> mAct; |
|
| 71 |
|
|
| 72 |
private EffectName mName; |
|
| 73 |
private int[] mInter; |
|
| 74 |
private int[] mInterRegion; |
|
| 75 |
private int[] mInterCenter; |
|
| 76 |
private int[] mSeekID; |
|
| 77 |
private int[] mSeekRegionID; |
|
| 78 |
private int[] mSeekCenterID; |
|
| 79 |
private int mDimension, mRegionDimension; |
|
| 80 |
private TextView mText,mTextRegion,mTextCenter; |
|
| 81 |
|
|
| 82 |
private Dynamic1D mDyn1; |
|
| 83 |
private Dynamic2D mDyn2; |
|
| 84 |
private Dynamic3D mDyn3; |
|
| 85 |
private Dynamic4D mDyn4; |
|
| 86 |
private Dynamic5D mDyn5; |
|
| 87 |
private Static1D mSta1; |
|
| 88 |
private Static2D mSta2; |
|
| 89 |
private Static3D mSta3; |
|
| 90 |
private Static4D mSta4; |
|
| 91 |
private Static5D mSta5; |
|
| 92 |
private Dynamic4D mRegion4Dyn; |
|
| 93 |
private Static4D mRegion4Sta; |
|
| 94 |
private Dynamic3D mRegion3Dyn; |
|
| 95 |
private Static3D mRegion3Sta; |
|
| 96 |
private Dynamic3D mCenterDyn; |
|
| 97 |
private Static3D mCenterSta; |
|
| 98 |
|
|
| 99 |
private View mButton, mEffect, mCenter, mRegion; |
|
| 100 |
private long mId; |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
// requires knowledge about effect nature |
|
| 104 |
|
|
| 105 |
void apply(DistortedEffects effects) |
|
| 106 |
{
|
|
| 107 |
Effect effect=null; |
|
| 108 |
|
|
| 109 |
switch(mName) |
|
| 110 |
{
|
|
| 111 |
case ROTATE : effect = new MatrixEffectRotate (mDyn1, mDyn3, mCenterDyn); break; |
|
| 112 |
case QUATERNION : effect = new MatrixEffectQuaternion (mDyn4, mCenterDyn); break; |
|
| 113 |
case MOVE : effect = new MatrixEffectMove (mDyn3) ; break; |
|
| 114 |
case SCALE : effect = new MatrixEffectScale (mDyn3) ; break; |
|
| 115 |
case SHEAR : effect = new MatrixEffectShear (mDyn3, mCenterDyn); break; |
|
| 116 |
|
|
| 117 |
case DISTORT : effect = new VertexEffectDistort (mDyn3, mCenterDyn, mRegion4Dyn); break; |
|
| 118 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, mCenterDyn, mRegion4Dyn); break; |
|
| 119 |
case SINK : effect = new VertexEffectSink (mDyn1, mCenterDyn, mRegion4Dyn); break; |
|
| 120 |
case PINCH : effect = new VertexEffectPinch (mDyn2, mCenterDyn, mRegion4Dyn); break; |
|
| 121 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, mCenterDyn, mRegion4Dyn); break; |
|
| 122 |
case WAVE : effect = new VertexEffectWave (mDyn5, mCenterDyn, mRegion4Dyn); break; |
|
| 123 |
|
|
| 124 |
case ALPHA : effect = new FragmentEffectAlpha (mDyn1, mCenterDyn, mRegion3Dyn, false); break; |
|
| 125 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mCenterDyn, mRegion3Dyn, true ); break; |
|
| 126 |
case CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mCenterDyn, mRegion3Dyn, false); break; |
|
| 127 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mCenterDyn, mRegion3Dyn, true ); break; |
|
| 128 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mCenterDyn, mRegion3Dyn, false); break; |
|
| 129 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mCenterDyn, mRegion3Dyn, true ); break; |
|
| 130 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mCenterDyn, mRegion3Dyn, false); break; |
|
| 131 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mCenterDyn, mRegion3Dyn, true ); break; |
|
| 132 |
case CONTRAST : effect = new FragmentEffectContrast (mDyn1, mCenterDyn, mRegion3Dyn, false); break; |
|
| 133 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mCenterDyn, mRegion3Dyn, true ); break; |
|
| 134 |
|
|
| 135 |
case BLUR : effect = new PostprocessEffectBlur (mDyn1 ); break; |
|
| 136 |
case GLOW : effect = new PostprocessEffectGlow (mDyn1, mDyn4); break; |
|
| 137 |
} |
|
| 138 |
|
|
| 139 |
if( effect!=null ) |
|
| 140 |
{
|
|
| 141 |
effects.apply(effect); |
|
| 142 |
mId = effect.getID(); |
|
| 143 |
} |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 147 |
// requires knowledge about effect nature |
|
| 148 |
|
|
| 149 |
private void fillStatics() |
|
| 150 |
{
|
|
| 151 |
switch(mName) |
|
| 152 |
{
|
|
| 153 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 154 |
// MATRIX |
|
| 155 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 156 |
|
|
| 157 |
case ROTATE : float an = (mInter[0]-50)*180/50; |
|
| 158 |
float rx = (mInter[1]-50)/ 50.0f; |
|
| 159 |
float ry = (mInter[2]-50)/ 50.0f; |
|
| 160 |
float rz = (mInter[3]-50)/ 50.0f; |
|
| 161 |
mSta1.set(an); |
|
| 162 |
mSta3.set(rx,ry,rz); |
|
| 163 |
break; |
|
| 164 |
case QUATERNION : float qx = (mInter[0]-50)/ 50.0f; |
|
| 165 |
float qy = (mInter[1]-50)/ 50.0f; |
|
| 166 |
float qz = (mInter[2]-50)/ 50.0f; |
|
| 167 |
float qa = (mInter[3]-50)*3.1415f/50; |
|
| 168 |
float cosA = (float)Math.cos(qa/2); |
|
| 169 |
float len = (float)Math.sqrt(qx*qx+qy*qy+qz*qz); |
|
| 170 |
float sinAnorm = (float)Math.sin(qa/2)/len; |
|
| 171 |
mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA); |
|
| 172 |
break; |
|
| 173 |
case MOVE : float scr= mAct.get().getScreenWidth(); |
|
| 174 |
float sw = scr/20000.0f; |
|
| 175 |
float sh = scr/20000.0f; |
|
| 176 |
float xm = (mInter[0]-50)*sw; |
|
| 177 |
float ym = (mInter[1]-50)*sh; |
|
| 178 |
float zm = (mInter[2]-50)*(sw+sh)/2; |
|
| 179 |
mSta3.set(xm,ym,zm); |
|
| 180 |
break; |
|
| 181 |
case SCALE : float xs = (mInter[0]>50 ? 0.18f : 0.018f)*(mInter[0]-50) + 1; |
|
| 182 |
float ys = (mInter[1]>50 ? 0.18f : 0.018f)*(mInter[1]-50) + 1; |
|
| 183 |
float zs = (mInter[2]>50 ? 0.18f : 0.018f)*(mInter[2]-50) + 1; |
|
| 184 |
mSta3.set(xs,ys,zs); |
|
| 185 |
break; |
|
| 186 |
case SHEAR : float xsh = (mInter[0]-50)/25.0f; |
|
| 187 |
float ysh = (mInter[1]-50)/25.0f; |
|
| 188 |
float zsh = (mInter[2]-50)/25.0f; |
|
| 189 |
mSta3.set(xsh,ysh,zsh); |
|
| 190 |
break; |
|
| 191 |
|
|
| 192 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 193 |
// VERTEX |
|
| 194 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 195 |
|
|
| 196 |
case DISTORT : |
|
| 197 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f; |
|
| 198 |
float xd = (mInter[0]-50)*ld; |
|
| 199 |
float yd = (mInter[1]-50)*ld; |
|
| 200 |
float zd = (mInter[2]-50)*ld; |
|
| 201 |
mSta3.set(xd,yd,zd); |
|
| 202 |
break; |
|
| 203 |
case WAVE : float l2 = mAct.get().getWidth()/50.0f; |
|
| 204 |
float x2 = (mInter[0]-50)*l2; |
|
| 205 |
float y2 = (mInter[1]-50)*l2; |
|
| 206 |
float z2 = (mInter[2]-50)*180 / 50; |
|
| 207 |
float w2 = (mInter[3]-50)*180 / 50; |
|
| 208 |
float v2 = (mInter[4]-50)*180 / 50; |
|
| 209 |
mSta5.set(x2,y2,z2,w2,v2); |
|
| 210 |
break; |
|
| 211 |
case SWIRL : mSta1.set( 3.6f*(mInter[0]-50) ); |
|
| 212 |
break; |
|
| 213 |
case SINK : mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f); |
|
| 214 |
break; |
|
| 215 |
case PINCH : float dp = mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f; |
|
| 216 |
float ap = (mInter[1]-50)*180 / 50; |
|
| 217 |
mSta2.set(dp,ap); |
|
| 218 |
break; |
|
| 219 |
|
|
| 220 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 221 |
// FRAGMENT |
|
| 222 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 223 |
|
|
| 224 |
case ALPHA : |
|
| 225 |
case SMOOTH_ALPHA : mSta1.set(mInter[0]/100.0f); |
|
| 226 |
break; |
|
| 227 |
case SATURATION : |
|
| 228 |
case SMOOTH_SATURATION: |
|
| 229 |
case CONTRAST : |
|
| 230 |
case SMOOTH_CONTRAST : |
|
| 231 |
case BRIGHTNESS : |
|
| 232 |
case SMOOTH_BRIGHTNESS: mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f); |
|
| 233 |
break; |
|
| 234 |
case CHROMA : |
|
| 235 |
case SMOOTH_CHROMA : mSta1.set(mInter[0]/100.0f); |
|
| 236 |
mSta3.set(mInter[1]/100.0f, |
|
| 237 |
mInter[2]/100.0f, |
|
| 238 |
mInter[3]/100.0f); |
|
| 239 |
break; |
|
| 240 |
|
|
| 241 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 242 |
// POSTPROCESS |
|
| 243 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
| 244 |
|
|
| 245 |
case BLUR : mSta1.set(mInter[0]/2.0f); |
|
| 246 |
break; |
|
| 247 |
case GLOW : mSta1.set(mInter[0]/2.0f); |
|
| 248 |
mSta4.set(mInter[1]/100.0f, |
|
| 249 |
mInter[2]/100.0f, |
|
| 250 |
mInter[3]/100.0f, |
|
| 251 |
mInter[4]/100.0f ); |
|
| 252 |
break; |
|
| 253 |
} |
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 257 |
|
|
| 258 |
private void setDefaultInter() |
|
| 259 |
{
|
|
| 260 |
switch(mDimension) |
|
| 261 |
{
|
|
| 262 |
case 5: mInter[4] = 50; |
|
| 263 |
case 4: mInter[3] = 50; |
|
| 264 |
case 3: mInter[2] = 50; |
|
| 265 |
case 2: mInter[1] = 50; |
|
| 266 |
case 1: mInter[0] = 50; |
|
| 267 |
} |
|
| 268 |
|
|
| 269 |
if( mName==EffectName.ROTATE || mName==EffectName.QUATERNION ) mInter[1]= 100; |
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 273 |
|
|
| 274 |
private void setText() |
|
| 275 |
{
|
|
| 276 |
String text = mName.name(); |
|
| 277 |
|
|
| 278 |
if( mSta1 !=null ) |
|
| 279 |
{
|
|
| 280 |
float f1 = ((int)(mSta1.get1()*100))/100.0f; |
|
| 281 |
text += " "+f1; |
|
| 282 |
} |
|
| 283 |
|
|
| 284 |
if( mSta2 !=null ) |
|
| 285 |
{
|
|
| 286 |
float f1 = ((int)(mSta2.get1()*100))/100.0f; |
|
| 287 |
float f2 = ((int)(mSta2.get2()*100))/100.0f; |
|
| 288 |
text += " ("+f1+","+f2+")";
|
|
| 289 |
} |
|
| 290 |
|
|
| 291 |
if( mSta3 !=null ) |
|
| 292 |
{
|
|
| 293 |
float f1 = ((int)(mSta3.get1()*100))/100.0f; |
|
| 294 |
float f2 = ((int)(mSta3.get2()*100))/100.0f; |
|
| 295 |
float f3 = ((int)(mSta3.get3()*100))/100.0f; |
|
| 296 |
text += " ("+f1+","+f2+","+f3+")";
|
|
| 297 |
} |
|
| 298 |
|
|
| 299 |
if( mSta4 !=null ) |
|
| 300 |
{
|
|
| 301 |
float f1 = ((int)(mSta4.get1()*100))/100.0f; |
|
| 302 |
float f2 = ((int)(mSta4.get2()*100))/100.0f; |
|
| 303 |
float f3 = ((int)(mSta4.get3()*100))/100.0f; |
|
| 304 |
float f4 = ((int)(mSta4.get4()*100))/100.0f; |
|
| 305 |
text += " ("+f1+","+f2+","+f3+","+f4+")";
|
|
| 306 |
} |
|
| 307 |
|
|
| 308 |
if( mSta5 !=null ) |
|
| 309 |
{
|
|
| 310 |
float f1 = ((int)(mSta5.get1()*100))/100.0f; |
|
| 311 |
float f2 = ((int)(mSta5.get2()*100))/100.0f; |
|
| 312 |
float f3 = ((int)(mSta5.get3()*100))/100.0f; |
|
| 313 |
float f4 = ((int)(mSta5.get4()*100))/100.0f; |
|
| 314 |
float f5 = ((int)(mSta5.get5()*100))/100.0f; |
|
| 315 |
text += " ("+f1+","+f2+","+f3+","+f4+","+f5+")";
|
|
| 316 |
} |
|
| 317 |
|
|
| 318 |
mText.setText(text); |
|
| 319 |
} |
|
| 320 |
|
|
| 321 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 322 |
|
|
| 323 |
private void fillCenterStatics() |
|
| 324 |
{
|
|
| 325 |
Effects3DActivity2 act = mAct.get(); |
|
| 326 |
|
|
| 327 |
float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth(); |
|
| 328 |
float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight(); |
|
| 329 |
float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth(); |
|
| 330 |
|
|
| 331 |
mCenterSta.set(x,y,z); |
|
| 332 |
} |
|
| 333 |
|
|
| 334 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 335 |
|
|
| 336 |
private void setDefaultCenterInter() |
|
| 337 |
{
|
|
| 338 |
mInterCenter[0] = 50; |
|
| 339 |
mInterCenter[1] = 50; |
|
| 340 |
mInterCenter[2] = 50; |
|
| 341 |
} |
|
| 342 |
|
|
| 343 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 344 |
|
|
| 345 |
private void setCenterText() |
|
| 346 |
{
|
|
| 347 |
float f0 = ((int)(mCenterSta.get1()*100))/100.0f; |
|
| 348 |
float f1 = ((int)(mCenterSta.get2()*100))/100.0f; |
|
| 349 |
float f2 = ((int)(mCenterSta.get3()*100))/100.0f; |
|
| 350 |
|
|
| 351 |
mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
|
|
| 352 |
} |
|
| 353 |
|
|
| 354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 355 |
|
|
| 356 |
private void fillRegionStatics() |
|
| 357 |
{
|
|
| 358 |
Effects3DActivity2 act = mAct.get(); |
|
| 359 |
|
|
| 360 |
float factorX = act.getWidth() / 100.0f; |
|
| 361 |
float factorY = act.getHeight()/ 100.0f; |
|
| 362 |
// float factorZ = act.getDepth() / 100.0f; |
|
| 363 |
|
|
| 364 |
int deduct = (mName.getType() == EffectType.VERTEX ? 50:0); |
|
| 365 |
|
|
| 366 |
float x = (mInterRegion[0]-deduct)*factorX; |
|
| 367 |
float y = (mInterRegion[1]-deduct)*factorY; |
|
| 368 |
float z = (mInterRegion[2]-deduct)*factorX; // ?? |
|
| 369 |
float r = mInterRegion[3] *(factorX+factorY)/2; |
|
| 370 |
|
|
| 371 |
mRegion4Sta.set(x,y,z,r); |
|
| 372 |
mRegion3Sta.set(x,y,z); |
|
| 373 |
} |
|
| 374 |
|
|
| 375 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 376 |
|
|
| 377 |
private void setDefaultRegionInter() |
|
| 378 |
{
|
|
| 379 |
mInterRegion[0] = 50; |
|
| 380 |
mInterRegion[1] = 50; |
|
| 381 |
mInterRegion[2] = 50; |
|
| 382 |
mInterRegion[3] = 50; |
|
| 383 |
} |
|
| 384 |
|
|
| 385 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 386 |
|
|
| 387 |
private void setRegionText() |
|
| 388 |
{
|
|
| 389 |
if( mRegionDimension==4 ) |
|
| 390 |
{
|
|
| 391 |
float f0 = ((int)(mRegion4Sta.get1()*100))/100.0f; |
|
| 392 |
float f1 = ((int)(mRegion4Sta.get2()*100))/100.0f; |
|
| 393 |
float f2 = ((int)(mRegion4Sta.get3()*100))/100.0f; |
|
| 394 |
float f3 = ((int)(mRegion4Sta.get4()*100))/100.0f; |
|
| 395 |
|
|
| 396 |
mTextRegion.setText("region (" + f0 + "," + f1 + "," + f2 + "," + f3 + ")");
|
|
| 397 |
} |
|
| 398 |
|
|
| 399 |
if( mRegionDimension==3 ) |
|
| 400 |
{
|
|
| 401 |
float f0 = ((int)(mRegion4Sta.get1()*100))/100.0f; |
|
| 402 |
float f1 = ((int)(mRegion4Sta.get2()*100))/100.0f; |
|
| 403 |
float f2 = ((int)(mRegion4Sta.get3()*100))/100.0f; |
|
| 404 |
|
|
| 405 |
mTextRegion.setText("region (" + f0 + "," + f1 + "," + f2 + ")");
|
|
| 406 |
} |
|
| 407 |
} |
|
| 408 |
|
|
| 409 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 410 |
|
|
| 411 |
void setBackground(int pos) |
|
| 412 |
{
|
|
| 413 |
int color = (pos%2==1 ? BACKGROUND_ODD:BACKGROUND_EVEN); |
|
| 414 |
|
|
| 415 |
if( mEffect!=null ) mEffect.setBackgroundColor(color); |
|
| 416 |
if( mCenter!=null ) mCenter.setBackgroundColor(color); |
|
| 417 |
if( mRegion!=null ) mRegion.setBackgroundColor(color); |
|
| 418 |
} |
|
| 419 |
|
|
| 420 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 421 |
|
|
| 422 |
Effects3DEffect(EffectName name, Effects3DActivity2 act) |
|
| 423 |
{
|
|
| 424 |
mAct = new WeakReference<>(act); |
|
| 425 |
mName = name; |
|
| 426 |
|
|
| 427 |
mDyn1 = null; |
|
| 428 |
mDyn2 = null; |
|
| 429 |
mDyn3 = null; |
|
| 430 |
mDyn4 = null; |
|
| 431 |
mDyn5 = null; |
|
| 432 |
mSta1 = null; |
|
| 433 |
mSta2 = null; |
|
| 434 |
mSta3 = null; |
|
| 435 |
mSta4 = null; |
|
| 436 |
mSta5 = null; |
|
| 437 |
|
|
| 438 |
mDimension = mName.getEffectDimension(); |
|
| 439 |
mRegionDimension = mName.getRegionDimension(); |
|
| 440 |
|
|
| 441 |
switch(mDimension) |
|
| 442 |
{
|
|
| 443 |
case 1 : mDyn1 = new Dynamic1D(); |
|
| 444 |
mSta1 = new Static1D(0); |
|
| 445 |
mDyn1.add(mSta1); |
|
| 446 |
break; |
|
| 447 |
case 2 : mDyn2 = new Dynamic2D(); |
|
| 448 |
mSta2 = new Static2D(0,0); |
|
| 449 |
mDyn2.add(mSta2); |
|
| 450 |
break; |
|
| 451 |
case 3 : mDyn3 = new Dynamic3D(); |
|
| 452 |
mSta3 = new Static3D(0,0,0); |
|
| 453 |
mDyn3.add(mSta3); |
|
| 454 |
break; |
|
| 455 |
case 4 : if( mName == EffectName.QUATERNION ) |
|
| 456 |
{
|
|
| 457 |
mDyn4 = new Dynamic4D(); |
|
| 458 |
mSta4 = new Static4D(0,0,0,0); |
|
| 459 |
mDyn4.add(mSta4); |
|
| 460 |
} |
|
| 461 |
else |
|
| 462 |
{
|
|
| 463 |
mDyn3 = new Dynamic3D(); |
|
| 464 |
mSta3 = new Static3D(0,0,0); |
|
| 465 |
mDyn3.add(mSta3); |
|
| 466 |
mDyn1 = new Dynamic1D(); |
|
| 467 |
mSta1 = new Static1D(0); |
|
| 468 |
mDyn1.add(mSta1); |
|
| 469 |
} |
|
| 470 |
break; |
|
| 471 |
case 5 : if( mName == EffectName.WAVE ) |
|
| 472 |
{
|
|
| 473 |
mDyn5 = new Dynamic5D(); |
|
| 474 |
mSta5 = new Static5D(0, 0, 0, 0, 0); |
|
| 475 |
mDyn5.add(mSta5); |
|
| 476 |
} |
|
| 477 |
else |
|
| 478 |
{
|
|
| 479 |
mDyn4 = new Dynamic4D(); |
|
| 480 |
mSta4 = new Static4D(0,0,0,0); |
|
| 481 |
mDyn4.add(mSta4); |
|
| 482 |
mDyn1 = new Dynamic1D(); |
|
| 483 |
mSta1 = new Static1D(0); |
|
| 484 |
mDyn1.add(mSta1); |
|
| 485 |
} |
|
| 486 |
break; |
|
| 487 |
default: throw new RuntimeException("unsupported effect");
|
|
| 488 |
} |
|
| 489 |
|
|
| 490 |
mInter = new int[mDimension]; |
|
| 491 |
mSeekID= new int[mDimension]; |
|
| 492 |
|
|
| 493 |
mInterRegion = new int[4]; |
|
| 494 |
mSeekRegionID= new int[4]; |
|
| 495 |
mRegion4Dyn = new Dynamic4D(); |
|
| 496 |
mRegion4Sta = new Static4D(0,0,0,0); |
|
| 497 |
mRegion4Dyn.add(mRegion4Sta); |
|
| 498 |
mRegion3Dyn = new Dynamic3D(); |
|
| 499 |
mRegion3Sta = new Static3D(0,0,0); |
|
| 500 |
mRegion3Dyn.add(mRegion3Sta); |
|
| 501 |
|
|
| 502 |
mInterCenter = new int[3]; |
|
| 503 |
mSeekCenterID= new int[3]; |
|
| 504 |
mCenterDyn = new Dynamic3D(); |
|
| 505 |
mCenterSta = new Static3D(0,0,0); |
|
| 506 |
mCenterDyn.add(mCenterSta); |
|
| 507 |
|
|
| 508 |
mButton = null; |
|
| 509 |
mEffect = null; |
|
| 510 |
mCenter = null; |
|
| 511 |
mRegion = null; |
|
| 512 |
} |
|
| 513 |
|
|
| 514 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 515 |
|
|
| 516 |
View createView(int num) |
|
| 517 |
{
|
|
| 518 |
SeekBar[] seek = new SeekBar[mDimension]; |
|
| 519 |
|
|
| 520 |
Effects3DActivity2 act = mAct.get(); |
|
| 521 |
|
|
| 522 |
switch(mDimension) |
|
| 523 |
{
|
|
| 524 |
case 1 : mEffect = act.getLayoutInflater().inflate(R.layout.effect1d, null); |
|
| 525 |
mText = mEffect.findViewById(R.id.effect1dText); |
|
| 526 |
seek[0] = mEffect.findViewById(R.id.effect1dbar1); |
|
| 527 |
mSeekID[0] = seek[0].getId(); |
|
| 528 |
mButton = mEffect.findViewById(R.id.button1dRemove); |
|
| 529 |
break; |
|
| 530 |
case 2 : mEffect = act.getLayoutInflater().inflate(R.layout.effect2d, null); |
|
| 531 |
mText = mEffect.findViewById(R.id.effect2dText); |
|
| 532 |
seek[0] = mEffect.findViewById(R.id.effect2dbar1); |
|
| 533 |
seek[1] = mEffect.findViewById(R.id.effect2dbar2); |
|
| 534 |
mSeekID[0] = seek[0].getId(); |
|
| 535 |
mSeekID[1] = seek[1].getId(); |
|
| 536 |
mButton = mEffect.findViewById(R.id.button2dRemove); |
|
| 537 |
break; |
|
| 538 |
case 3 : mEffect = act.getLayoutInflater().inflate(R.layout.effect3d, null); |
|
| 539 |
mText = mEffect.findViewById(R.id.effect3dText); |
|
| 540 |
seek[0] = mEffect.findViewById(R.id.effect3dbar1); |
|
| 541 |
seek[1] = mEffect.findViewById(R.id.effect3dbar2); |
|
| 542 |
seek[2] = mEffect.findViewById(R.id.effect3dbar3); |
|
| 543 |
mSeekID[0] = seek[0].getId(); |
|
| 544 |
mSeekID[1] = seek[1].getId(); |
|
| 545 |
mSeekID[2] = seek[2].getId(); |
|
| 546 |
mButton = mEffect.findViewById(R.id.button3dRemove); |
|
| 547 |
break; |
|
| 548 |
case 4 : mEffect = act.getLayoutInflater().inflate(R.layout.effect4d, null); |
|
| 549 |
mText = mEffect.findViewById(R.id.effect4dText); |
|
| 550 |
seek[0] = mEffect.findViewById(R.id.effect4dbar1); |
|
| 551 |
seek[1] = mEffect.findViewById(R.id.effect4dbar2); |
|
| 552 |
seek[2] = mEffect.findViewById(R.id.effect4dbar3); |
|
| 553 |
seek[3] = mEffect.findViewById(R.id.effect4dbar4); |
|
| 554 |
mSeekID[0] = seek[0].getId(); |
|
| 555 |
mSeekID[1] = seek[1].getId(); |
|
| 556 |
mSeekID[2] = seek[2].getId(); |
|
| 557 |
mSeekID[3] = seek[3].getId(); |
|
| 558 |
mButton = mEffect.findViewById(R.id.button4dRemove); |
|
| 559 |
break; |
|
| 560 |
case 5 : mEffect = act.getLayoutInflater().inflate(R.layout.effect5d, null); |
|
| 561 |
mText = mEffect.findViewById(R.id.effect5dText); |
|
| 562 |
seek[0] = mEffect.findViewById(R.id.effect5dbar1); |
|
| 563 |
seek[1] = mEffect.findViewById(R.id.effect5dbar2); |
|
| 564 |
seek[2] = mEffect.findViewById(R.id.effect5dbar3); |
|
| 565 |
seek[3] = mEffect.findViewById(R.id.effect5dbar4); |
|
| 566 |
seek[4] = mEffect.findViewById(R.id.effect5dbar5); |
|
| 567 |
mSeekID[0] = seek[0].getId(); |
|
| 568 |
mSeekID[1] = seek[1].getId(); |
|
| 569 |
mSeekID[2] = seek[2].getId(); |
|
| 570 |
mSeekID[3] = seek[3].getId(); |
|
| 571 |
mSeekID[4] = seek[4].getId(); |
|
| 572 |
mButton = mEffect.findViewById(R.id.button5dRemove); |
|
| 573 |
break; |
|
| 574 |
default: android.util.Log.e("Effects3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 575 |
return null; |
|
| 576 |
} |
|
| 577 |
|
|
| 578 |
mEffect.setBackgroundColor( num%2==1 ? BACKGROUND_EVEN: BACKGROUND_ODD ); |
|
| 579 |
|
|
| 580 |
setDefaultInter(); |
|
| 581 |
|
|
| 582 |
for(int i=0; i<mDimension; i++) |
|
| 583 |
{
|
|
| 584 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 585 |
seek[i].setProgress( mInter[i] ); |
|
| 586 |
} |
|
| 587 |
|
|
| 588 |
return mEffect; |
|
| 589 |
} |
|
| 590 |
|
|
| 591 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 592 |
|
|
| 593 |
View createRegion(int num) |
|
| 594 |
{
|
|
| 595 |
Effects3DActivity2 act = mAct.get(); |
|
| 596 |
|
|
| 597 |
if( mRegionDimension== 4 ) |
|
| 598 |
{
|
|
| 599 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion4, null); |
|
| 600 |
mRegion.setBackgroundColor(num % 2 == 1 ? BACKGROUND_EVEN : BACKGROUND_ODD); |
|
| 601 |
|
|
| 602 |
SeekBar[] seek = new SeekBar[4]; |
|
| 603 |
|
|
| 604 |
seek[0] = mRegion.findViewById(R.id.effectRegion4BarX); |
|
| 605 |
seek[1] = mRegion.findViewById(R.id.effectRegion4BarY); |
|
| 606 |
seek[2] = mRegion.findViewById(R.id.effectRegion4BarZ); |
|
| 607 |
seek[3] = mRegion.findViewById(R.id.effectRegion4BarR); |
|
| 608 |
|
|
| 609 |
mSeekRegionID[0] = seek[0].getId(); |
|
| 610 |
mSeekRegionID[1] = seek[1].getId(); |
|
| 611 |
mSeekRegionID[2] = seek[2].getId(); |
|
| 612 |
mSeekRegionID[3] = seek[3].getId(); |
|
| 613 |
|
|
| 614 |
mTextRegion = mRegion.findViewById(R.id.effectRegion4Text); |
|
| 615 |
|
|
| 616 |
setDefaultRegionInter(); |
|
| 617 |
|
|
| 618 |
for (int i = 0; i < 4; i++) |
|
| 619 |
{
|
|
| 620 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 621 |
seek[i].setProgress(mInterRegion[i]); |
|
| 622 |
} |
|
| 623 |
|
|
| 624 |
act.setRegion(mRegion4Sta.get1(), mRegion4Sta.get2(), mRegion4Sta.get3(), mRegion4Sta.get4()); |
|
| 625 |
} |
|
| 626 |
else |
|
| 627 |
{
|
|
| 628 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion3, null); |
|
| 629 |
mRegion.setBackgroundColor(num % 2 == 1 ? BACKGROUND_EVEN : BACKGROUND_ODD); |
|
| 630 |
|
|
| 631 |
SeekBar[] seek = new SeekBar[3]; |
|
| 632 |
|
|
| 633 |
seek[0] = mRegion.findViewById(R.id.effectRegion3BarRX); |
|
| 634 |
seek[1] = mRegion.findViewById(R.id.effectRegion3BarRY); |
|
| 635 |
seek[2] = mRegion.findViewById(R.id.effectRegion3BarRZ); |
|
| 636 |
|
|
| 637 |
mSeekRegionID[0] = seek[0].getId(); |
|
| 638 |
mSeekRegionID[1] = seek[1].getId(); |
|
| 639 |
mSeekRegionID[2] = seek[2].getId(); |
|
| 640 |
|
|
| 641 |
mTextRegion = mRegion.findViewById(R.id.effectRegion3Text); |
|
| 642 |
|
|
| 643 |
setDefaultRegionInter(); |
|
| 644 |
|
|
| 645 |
for (int i = 0; i < 3; i++) |
|
| 646 |
{
|
|
| 647 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 648 |
seek[i].setProgress(mInterRegion[i]); |
|
| 649 |
} |
|
| 650 |
|
|
| 651 |
act.setRegion(mRegion3Sta.get1(), mRegion3Sta.get2(), mRegion3Sta.get3(), 1.0f ); |
|
| 652 |
} |
|
| 653 |
|
|
| 654 |
return mRegion; |
|
| 655 |
} |
|
| 656 |
|
|
| 657 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 658 |
|
|
| 659 |
View createCenter(int num) |
|
| 660 |
{
|
|
Also available in: Unified diff
Rename the 'Effects3D' app.