Revision 65f622c1
Added by Leszek Koltunski over 7 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 34 | 34 |
<activity android:name=".olimpic.OlimpicActivity" /> |
| 35 | 35 |
<activity android:name=".cubes.CubesActivity" /> |
| 36 | 36 |
<activity android:name=".quaternion.QuaternionActivity" /> |
| 37 |
<activity android:name=".matrix3d.Matrix3DActivity" /> |
|
| 38 | 37 |
<activity android:name=".effects3d.Effects3DActivity" /> |
| 39 | 38 |
<activity android:name=".effects3d.Effects3DActivity2"/> |
| 40 | 39 |
<activity android:name=".plainmonalisa.PlainMonaLisaActivity" /> |
| src/main/java/org/distorted/examples/TableOfContents.java | ||
|---|---|---|
| 53 | 53 |
import org.distorted.examples.starwars.StarWarsActivity; |
| 54 | 54 |
import org.distorted.examples.cubes.CubesActivity; |
| 55 | 55 |
import org.distorted.examples.quaternion.QuaternionActivity; |
| 56 |
import org.distorted.examples.matrix3d.Matrix3DActivity; |
|
| 57 | 56 |
import org.distorted.examples.effects3d.Effects3DActivity; |
| 58 | 57 |
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity; |
| 59 | 58 |
import org.distorted.examples.save.SaveActivity; |
| ... | ... | |
| 261 | 260 |
data.add(item); |
| 262 | 261 |
activityMapping.put(i++, CubesActivity.class); |
| 263 | 262 |
} |
| 264 |
|
|
| 265 |
{
|
|
| 266 |
final Map<String, Object> item = new HashMap<>(); |
|
| 267 |
item.put(ITEM_IMAGE, R.drawable.icon_example_matrix3d); |
|
| 268 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_matrix3d)); |
|
| 269 |
item.put(ITEM_SUBTITLE, getText(R.string.example_matrix3d_subtitle)); |
|
| 270 |
data.add(item); |
|
| 271 |
activityMapping.put(i++, Matrix3DActivity.class); |
|
| 272 |
} |
|
| 273 | 263 |
|
| 274 | 264 |
{
|
| 275 | 265 |
final Map<String, Object> item = new HashMap<>(); |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java | ||
|---|---|---|
| 43 | 43 |
private static final int COLOR_ON = 0xff0000ff; |
| 44 | 44 |
private static final int COLOR_INAC= 0xff00ff00; |
| 45 | 45 |
|
| 46 |
private int mNumCols = 10;
|
|
| 47 |
private int mNumRows = 10;
|
|
| 48 |
private int mNumSlic = 1;
|
|
| 46 |
private int mNumCols = 1; |
|
| 47 |
private int mNumRows = 1; |
|
| 48 |
private int mNumSlic = 1; |
|
| 49 | 49 |
private boolean mGridInitialized; |
| 50 | 50 |
private NumberPicker mColsPicker, mRowsPicker, mSlicPicker; |
| 51 | 51 |
private boolean[] mShape; |
| src/main/java/org/distorted/examples/effects3d/Effects3DActivity2.java | ||
|---|---|---|
| 47 | 47 |
|
| 48 | 48 |
public class Effects3DActivity2 extends AppCompatActivity |
| 49 | 49 |
{
|
| 50 |
public static final int NUM_TABS = 3;
|
|
| 50 |
public static final int NUM_TABS = 4;
|
|
| 51 | 51 |
|
| 52 | 52 |
private int mNumCols; |
| 53 | 53 |
private int mNumRows; |
| ... | ... | |
| 267 | 267 |
|
| 268 | 268 |
public int getScreenWidth() |
| 269 | 269 |
{
|
| 270 |
return 0; |
|
| 270 |
Effects3DRenderer r = ((Effects3DSurfaceView)findViewById(R.id.effects3dSurfaceView)).getRenderer(); |
|
| 271 |
return r.getWidth(); |
|
| 271 | 272 |
} |
| 272 | 273 |
|
| 273 | 274 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 285 | 286 |
|
| 286 | 287 |
renderer.setCenter( mCenterX, mCenterY, mCenterZ ); |
| 287 | 288 |
renderer.setRegion( mRegionX, mRegionY, mRegionR ); |
| 288 |
renderer.mQuat1.set(0,0,0,1); |
|
| 289 |
renderer.mQuat2.set(0,0,0,1); |
|
| 290 | 289 |
} |
| 291 | 290 |
|
| 292 | 291 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 293 |
// 'second screen' methods |
|
| 292 |
|
|
| 293 |
void resetMatrixEffects() |
|
| 294 |
{
|
|
| 295 |
Effects3DSurfaceView view = findViewById(R.id.effects3dSurfaceView); |
|
| 296 |
Effects3DRenderer renderer= view.getRenderer(); |
|
| 297 |
|
|
| 298 |
renderer.resetMatrixEffects(); |
|
| 299 |
} |
|
| 300 |
|
|
| 294 | 301 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 295 | 302 |
|
| 296 | 303 |
public DistortedEffects getEffects() |
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 189 | 189 |
float sinAnorm = (float)Math.sin(qa/2)/len; |
| 190 | 190 |
mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA); |
| 191 | 191 |
break; |
| 192 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
|
| 193 |
float sh = mAct.get().getScreenWidth()/50.0f; |
|
| 192 |
case MOVE : float scr= mAct.get().getScreenWidth(); |
|
| 193 |
float sw = scr/20000.0f; |
|
| 194 |
float sh = scr/20000.0f; |
|
| 194 | 195 |
float xm = (mInter[0]-50)*sw; |
| 195 | 196 |
float ym = (mInter[1]-50)*sh; |
| 196 | 197 |
float zm = (mInter[2]-50)*(sw+sh)/2; |
| src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
|---|---|---|
| 24 | 24 |
import android.opengl.GLSurfaceView; |
| 25 | 25 |
|
| 26 | 26 |
import org.distorted.examples.R; |
| 27 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
| 28 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
| 29 |
import org.distorted.library.effect.FragmentEffectChroma; |
|
| 30 |
import org.distorted.library.effect.FragmentEffectContrast; |
|
| 31 |
import org.distorted.library.effect.FragmentEffectSaturation; |
|
| 32 | 27 |
import org.distorted.library.effect.MatrixEffectMove; |
| 33 | 28 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
| 34 | 29 |
import org.distorted.library.effect.MatrixEffectScale; |
| 35 |
import org.distorted.library.effect.PostprocessEffectBlur; |
|
| 36 |
import org.distorted.library.effect.PostprocessEffectGlow; |
|
| 37 |
import org.distorted.library.effect.VertexEffectDeform; |
|
| 38 |
import org.distorted.library.effect.VertexEffectDistort; |
|
| 39 |
import org.distorted.library.effect.VertexEffectPinch; |
|
| 40 |
import org.distorted.library.effect.VertexEffectSink; |
|
| 41 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
| 42 |
import org.distorted.library.effect.VertexEffectWave; |
|
| 43 | 30 |
import org.distorted.library.main.Distorted; |
| 44 | 31 |
import org.distorted.library.main.DistortedEffects; |
| 45 | 32 |
import org.distorted.library.main.DistortedNode; |
| ... | ... | |
| 73 | 60 |
private boolean mShowingCenter=false; |
| 74 | 61 |
private boolean mShowingRegion=false; |
| 75 | 62 |
private float mFactorObj, mFactorReg; |
| 63 |
private int mWidth; |
|
| 76 | 64 |
|
| 77 | 65 |
Static4D mQuat1, mQuat2; |
| 78 | 66 |
int mScreenMin; |
| ... | ... | |
| 104 | 92 |
DistortedEffects centerEffects = new DistortedEffects(); |
| 105 | 93 |
DistortedEffects regionEffects = new DistortedEffects(); |
| 106 | 94 |
|
| 107 |
MeshObject meshO = act.getMesh();
|
|
| 95 |
MeshObject mesh = act.getMesh();
|
|
| 108 | 96 |
MeshFlat quad = new MeshFlat(1,1); |
| 109 | 97 |
|
| 110 | 98 |
mObjWidth = mObjectTexture.getWidth(); |
| 111 | 99 |
mObjHeight= mObjectTexture.getHeight(); |
| 112 |
int objDepth = mObjectTexture.getDepth(meshO); |
|
| 113 | 100 |
|
| 114 | 101 |
mQuat1 = new Static4D(0,0,0,1); // unity |
| 115 | 102 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
| ... | ... | |
| 124 | 111 |
mScreen = new DistortedScreen(); |
| 125 | 112 |
mScreen.setProjection(FOV, NEAR); |
| 126 | 113 |
mScreen.attach(mBackgroundTexture, backgroundEffects, quad ); |
| 127 |
mScreen.attach(mObjectTexture , objectEffects , meshO);
|
|
| 114 |
mScreen.attach(mObjectTexture , objectEffects , mesh );
|
|
| 128 | 115 |
|
| 129 | 116 |
int regionSize = mRegionTexture.getWidth(); |
| 130 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)objDepth/2 ); |
|
| 131 | 117 |
mRotateCen = new Static3D(0 ,0, 0); |
| 132 | 118 |
|
| 133 |
MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1, rotateObj); |
|
| 134 |
MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2, rotateObj); |
|
| 135 | 119 |
MatrixEffectQuaternion quat1cen = new MatrixEffectQuaternion(mQuat1, mRotateCen); |
| 136 | 120 |
MatrixEffectQuaternion quat2cen = new MatrixEffectQuaternion(mQuat2, mRotateCen); |
| 137 | 121 |
MatrixEffectMove centerMove = new MatrixEffectMove(mCenterPoint); |
| 138 | 122 |
|
| 139 |
objectEffects.apply( new MatrixEffectMove(mMoveObject)); |
|
| 140 |
objectEffects.apply( new MatrixEffectScale(mScaleObject) ); |
|
| 141 |
objectEffects.apply(quat1obj); |
|
| 142 |
objectEffects.apply(quat2obj); |
|
| 143 |
|
|
| 144 | 123 |
centerEffects.apply(quat1cen); |
| 145 | 124 |
centerEffects.apply(quat2cen); |
| 146 | 125 |
centerEffects.apply( new MatrixEffectMove(mMoveCenter) ); |
| ... | ... | |
| 155 | 134 |
regionEffects.apply( new MatrixEffectScale(mRegionScalePoint) ); |
| 156 | 135 |
regionEffects.apply( new MatrixEffectMove(new Static3D( -regionSize/2 , -regionSize/2 , 0)) ); |
| 157 | 136 |
|
| 137 |
resetMatrixEffects(); |
|
| 138 |
|
|
| 158 | 139 |
// quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() ) |
| 159 | 140 |
backgroundEffects.apply(new MatrixEffectMove(mMoveBackground) ); |
| 160 | 141 |
backgroundEffects.apply(new MatrixEffectScale(mScaleBackground) ); |
| 161 | 142 |
} |
| 162 | 143 |
|
| 144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 145 |
|
|
| 146 |
void resetMatrixEffects() |
|
| 147 |
{
|
|
| 148 |
Effects3DActivity2 act = (Effects3DActivity2)mView.getContext(); |
|
| 149 |
|
|
| 150 |
DistortedEffects objectEffects= act.getEffects(); |
|
| 151 |
MeshObject mesh = act.getMesh(); |
|
| 152 |
|
|
| 153 |
int objDepth = mObjectTexture.getDepth(mesh); |
|
| 154 |
|
|
| 155 |
Static3D rotateObj = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, -(float)objDepth/2 ); |
|
| 156 |
|
|
| 157 |
MatrixEffectQuaternion quat1obj = new MatrixEffectQuaternion(mQuat1, rotateObj); |
|
| 158 |
MatrixEffectQuaternion quat2obj = new MatrixEffectQuaternion(mQuat2, rotateObj); |
|
| 159 |
|
|
| 160 |
objectEffects.apply( new MatrixEffectMove(mMoveObject)); |
|
| 161 |
objectEffects.apply( new MatrixEffectScale(mScaleObject) ); |
|
| 162 |
objectEffects.apply(quat1obj); |
|
| 163 |
objectEffects.apply(quat2obj); |
|
| 164 |
|
|
| 165 |
mQuat1.set(0,0,0,1); |
|
| 166 |
mQuat2.set(0,0,0,1); |
|
| 167 |
} |
|
| 168 |
|
|
| 163 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 170 |
|
| 165 | 171 |
void showRegionAndCenter(boolean showRegion, boolean showCenter) |
| ... | ... | |
| 181 | 187 |
} |
| 182 | 188 |
} |
| 183 | 189 |
|
| 190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 191 |
|
|
| 192 |
public int getWidth() |
|
| 193 |
{
|
|
| 194 |
return mWidth; |
|
| 195 |
} |
|
| 196 |
|
|
| 184 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 185 | 198 |
|
| 186 | 199 |
void setCenter(float x, float y, float z) |
| ... | ... | |
| 215 | 228 |
|
| 216 | 229 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
| 217 | 230 |
{
|
| 231 |
mWidth = width; |
|
| 218 | 232 |
mScreenMin = width<height ? width:height; |
| 219 | 233 |
|
| 220 | 234 |
float factorCen; |
| src/main/java/org/distorted/examples/effects3d/Effects3DTab.java | ||
|---|---|---|
| 69 | 69 |
|
| 70 | 70 |
switch(position) |
| 71 | 71 |
{
|
| 72 |
case 0: mTab = R.layout.effects3dtab1; |
|
| 72 |
case 0: mTab = R.layout.effects3dtab0; |
|
| 73 |
mLayout = R.id.effects3dlayout0; |
|
| 74 |
mSpinner = R.id.effects3dspinner0; |
|
| 75 |
mType = EffectType.MATRIX; |
|
| 76 |
break; |
|
| 77 |
case 1: mTab = R.layout.effects3dtab1; |
|
| 73 | 78 |
mLayout = R.id.effects3dlayout1; |
| 74 | 79 |
mSpinner = R.id.effects3dspinner1; |
| 75 | 80 |
mType = EffectType.VERTEX; |
| 76 | 81 |
break; |
| 77 |
case 1: mTab = R.layout.effects3dtab2;
|
|
| 82 |
case 2: mTab = R.layout.effects3dtab2;
|
|
| 78 | 83 |
mLayout = R.id.effects3dlayout2; |
| 79 | 84 |
mSpinner = R.id.effects3dspinner2; |
| 80 | 85 |
mType = EffectType.FRAGMENT; |
| 81 | 86 |
break; |
| 82 |
case 2: mTab = R.layout.effects3dtab3;
|
|
| 87 |
case 3: mTab = R.layout.effects3dtab3;
|
|
| 83 | 88 |
mLayout = R.id.effects3dlayout3; |
| 84 | 89 |
mSpinner = R.id.effects3dspinner3; |
| 85 | 90 |
mType = EffectType.POSTPROCESS; |
| ... | ... | |
| 87 | 92 |
} |
| 88 | 93 |
|
| 89 | 94 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity(); |
| 90 |
act.setTab(position, this); |
|
| 91 | 95 |
|
| 92 |
mEffects = act.getEffects(); |
|
| 96 |
if( act!=null ) |
|
| 97 |
{
|
|
| 98 |
act.setTab(position, this); |
|
| 99 |
mEffects = act.getEffects(); |
|
| 100 |
} |
|
| 93 | 101 |
|
| 94 | 102 |
createEffectNames(mType); |
| 95 | 103 |
mEffectStrings = new String[mEffectNames.length]; |
| ... | ... | |
| 99 | 107 |
mEffectStrings[i] = mEffectNames[i].name(); |
| 100 | 108 |
} |
| 101 | 109 |
|
| 102 |
View rootView = inflater.inflate( mTab, container, false); |
|
| 103 |
return rootView; |
|
| 110 |
return inflater.inflate( mTab, container, false); |
|
| 104 | 111 |
} |
| 105 | 112 |
|
| 106 | 113 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 221 | 228 |
|
| 222 | 229 |
resetData(); |
| 223 | 230 |
act.resetData(); |
| 231 |
|
|
| 232 |
if( mType==EffectType.MATRIX ) |
|
| 233 |
{
|
|
| 234 |
act.resetMatrixEffects(); |
|
| 235 |
} |
|
| 224 | 236 |
} |
| 225 | 237 |
|
| 226 | 238 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/examples/effects3d/Effects3DTabViewPager.java | ||
|---|---|---|
| 49 | 49 |
{
|
| 50 | 50 |
if( position>=0 && position<Effects3DActivity2.NUM_TABS ) |
| 51 | 51 |
{
|
| 52 |
Effects3DTab tab = new Effects3DTab(); |
|
| 53 |
|
|
| 52 | 54 |
Bundle bundle = new Bundle(); |
| 53 | 55 |
bundle.putInt("position", position);
|
| 54 |
|
|
| 55 |
Effects3DTab tab = new Effects3DTab(); |
|
| 56 | 56 |
tab.setArguments(bundle); |
| 57 |
|
|
| 57 | 58 |
return tab; |
| 58 | 59 |
} |
| 59 | 60 |
|
| ... | ... | |
| 75 | 76 |
{
|
| 76 | 77 |
switch (position) |
| 77 | 78 |
{
|
| 78 |
case 0 : return mAct.get().getString(R.string.type_vertex); |
|
| 79 |
case 1 : return mAct.get().getString(R.string.type_fragment); |
|
| 80 |
case 2 : return mAct.get().getString(R.string.type_postprocess); |
|
| 79 |
case 0 : return mAct.get().getString(R.string.type_matrix); |
|
| 80 |
case 1 : return mAct.get().getString(R.string.type_vertex); |
|
| 81 |
case 2 : return mAct.get().getString(R.string.type_fragment); |
|
| 82 |
case 3 : return mAct.get().getString(R.string.type_postprocess); |
|
| 81 | 83 |
default: return null; |
| 82 | 84 |
} |
| 83 | 85 |
} |
| src/main/java/org/distorted/examples/matrix3d/Matrix3DActivity.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.matrix3d; |
|
| 21 |
|
|
| 22 |
import android.app.Activity; |
|
| 23 |
import android.graphics.Bitmap; |
|
| 24 |
import android.graphics.BitmapFactory; |
|
| 25 |
import android.opengl.GLSurfaceView; |
|
| 26 |
import android.os.Bundle; |
|
| 27 |
import android.view.View; |
|
| 28 |
import android.widget.AdapterView; |
|
| 29 |
import android.widget.ArrayAdapter; |
|
| 30 |
import android.widget.LinearLayout; |
|
| 31 |
import android.widget.Spinner; |
|
| 32 |
|
|
| 33 |
import org.distorted.examples.R; |
|
| 34 |
import org.distorted.library.effect.EffectName; |
|
| 35 |
import org.distorted.library.effect.EffectType; |
|
| 36 |
import org.distorted.library.main.Distorted; |
|
| 37 |
import org.distorted.library.main.DistortedEffects; |
|
| 38 |
import org.distorted.library.main.MeshCubes; |
|
| 39 |
import org.distorted.library.main.MeshObject; |
|
| 40 |
import org.distorted.library.main.DistortedTexture; |
|
| 41 |
|
|
| 42 |
import java.io.IOException; |
|
| 43 |
import java.io.InputStream; |
|
| 44 |
import java.util.ArrayList; |
|
| 45 |
|
|
| 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 47 |
|
|
| 48 |
public class Matrix3DActivity extends Activity implements AdapterView.OnItemSelectedListener |
|
| 49 |
{
|
|
| 50 |
private DistortedTexture mTexture; |
|
| 51 |
private MeshObject mMesh; |
|
| 52 |
private DistortedEffects mEffects; |
|
| 53 |
|
|
| 54 |
private ArrayList<Matrix3DEffect> mList; |
|
| 55 |
private int mEffectAdd; |
|
| 56 |
|
|
| 57 |
private EffectName[] mEffectNames; |
|
| 58 |
|
|
| 59 |
private static boolean mSupportsCenter; |
|
| 60 |
|
|
| 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 62 |
|
|
| 63 |
@Override |
|
| 64 |
protected void onCreate(Bundle savedState) |
|
| 65 |
{
|
|
| 66 |
super.onCreate(savedState); |
|
| 67 |
|
|
| 68 |
mList = new ArrayList<>(); |
|
| 69 |
|
|
| 70 |
createEffectNames(); |
|
| 71 |
|
|
| 72 |
mEffects = new DistortedEffects(); |
|
| 73 |
mMesh = new MeshCubes(1,1,1); |
|
| 74 |
mTexture = new DistortedTexture(100,100); |
|
| 75 |
|
|
| 76 |
setEffectView(); |
|
| 77 |
} |
|
| 78 |
|
|
| 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 80 |
|
|
| 81 |
private void createEffectNames() |
|
| 82 |
{
|
|
| 83 |
EffectType type = EffectType.MATRIX; |
|
| 84 |
|
|
| 85 |
EffectName[] names = EffectName.values(); |
|
| 86 |
|
|
| 87 |
int numEffects=0; |
|
| 88 |
|
|
| 89 |
for(int i=0; i<names.length; i++) |
|
| 90 |
if( names[i].getType() == type ) numEffects++; |
|
| 91 |
|
|
| 92 |
mEffectNames = new EffectName[numEffects]; |
|
| 93 |
|
|
| 94 |
numEffects=0; |
|
| 95 |
|
|
| 96 |
for(int i=0; i<names.length; i++) |
|
| 97 |
if( names[i].getType() == type ) |
|
| 98 |
{
|
|
| 99 |
mEffectNames[numEffects++] = names[i]; |
|
| 100 |
} |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 104 |
|
|
| 105 |
public DistortedEffects getEffects() |
|
| 106 |
{
|
|
| 107 |
return mEffects; |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 111 |
|
|
| 112 |
public DistortedTexture getTexture() |
|
| 113 |
{
|
|
| 114 |
return mTexture; |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 118 |
|
|
| 119 |
public MeshObject getMesh() |
|
| 120 |
{
|
|
| 121 |
return mMesh; |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 125 |
|
|
| 126 |
public void setRegion(float x, float y, float r) |
|
| 127 |
{
|
|
| 128 |
|
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 132 |
|
|
| 133 |
public void setCenter(float x, float y, float z) |
|
| 134 |
{
|
|
| 135 |
|
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 139 |
|
|
| 140 |
public static void setSupportsRegion(boolean supports) |
|
| 141 |
{
|
|
| 142 |
|
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 146 |
|
|
| 147 |
public static void setSupportsCenter(boolean supports) |
|
| 148 |
{
|
|
| 149 |
mSupportsCenter = supports; |
|
| 150 |
} |
|
| 151 |
|
|
| 152 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 153 |
|
|
| 154 |
public Bitmap getBitmap() |
|
| 155 |
{
|
|
| 156 |
Bitmap bmp; |
|
| 157 |
|
|
| 158 |
InputStream is = getResources().openRawResource(R.raw.grid); |
|
| 159 |
|
|
| 160 |
try |
|
| 161 |
{
|
|
| 162 |
bmp = BitmapFactory.decodeStream(is); |
|
| 163 |
} |
|
| 164 |
finally |
|
| 165 |
{
|
|
| 166 |
try |
|
| 167 |
{
|
|
| 168 |
is.close(); |
|
| 169 |
} |
|
| 170 |
catch(IOException e) { }
|
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
return bmp; |
|
| 174 |
} |
|
| 175 |
|
|
| 176 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 177 |
|
|
| 178 |
public int getWidth() |
|
| 179 |
{
|
|
| 180 |
return mTexture==null ? 0: mTexture.getWidth(); |
|
| 181 |
} |
|
| 182 |
|
|
| 183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 184 |
|
|
| 185 |
public int getHeight() |
|
| 186 |
{
|
|
| 187 |
return mTexture==null ? 0: mTexture.getHeight(); |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 191 |
|
|
| 192 |
public int getDepth() |
|
| 193 |
{
|
|
| 194 |
return mTexture==null ? 0: mTexture.getDepth(mMesh); |
|
| 195 |
} |
|
| 196 |
|
|
| 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 198 |
|
|
| 199 |
public int getScreenWidth() |
|
| 200 |
{
|
|
| 201 |
Matrix3DRenderer r = ((Matrix3DSurfaceView)findViewById(R.id.matrix3dSurfaceView)).getRenderer(); |
|
| 202 |
return r.getWidth(); |
|
| 203 |
} |
|
| 204 |
|
|
| 205 |
////////////////////////////////////////////////////////////////////////////////// |
|
| 206 |
|
|
| 207 |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
|
| 208 |
{
|
|
| 209 |
switch(parent.getId()) |
|
| 210 |
{
|
|
| 211 |
case R.id.matrix3dspinner: mEffectAdd = pos; |
|
| 212 |
break; |
|
| 213 |
} |
|
| 214 |
} |
|
| 215 |
|
|
| 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 217 |
|
|
| 218 |
public void onNothingSelected(AdapterView<?> parent) |
|
| 219 |
{
|
|
| 220 |
} |
|
| 221 |
|
|
| 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 223 |
|
|
| 224 |
private void resetData() |
|
| 225 |
{
|
|
| 226 |
mSupportsCenter=false; |
|
| 227 |
} |
|
| 228 |
|
|
| 229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 230 |
|
|
| 231 |
private void setEffectView() |
|
| 232 |
{
|
|
| 233 |
resetData(); |
|
| 234 |
|
|
| 235 |
final View view = getLayoutInflater().inflate(R.layout.matrix3dlayout, null); |
|
| 236 |
|
|
| 237 |
setContentView(view); |
|
| 238 |
|
|
| 239 |
String[] effects = new String[mEffectNames.length]; |
|
| 240 |
|
|
| 241 |
for(int i=0; i<mEffectNames.length; i++) effects[i] = mEffectNames[i].name(); |
|
| 242 |
|
|
| 243 |
Spinner effectSpinner = (Spinner)findViewById(R.id.matrix3dspinner ); |
|
| 244 |
effectSpinner.setOnItemSelectedListener(this); |
|
| 245 |
|
|
| 246 |
ArrayAdapter<String> adapterEffect = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, effects); |
|
| 247 |
adapterEffect.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
| 248 |
effectSpinner.setAdapter(adapterEffect); |
|
| 249 |
|
|
| 250 |
mEffectAdd = 0; |
|
| 251 |
} |
|
| 252 |
|
|
| 253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 254 |
|
|
| 255 |
public void newEffect(View v) |
|
| 256 |
{
|
|
| 257 |
Matrix3DEffect eff = new Matrix3DEffect(mEffectNames[mEffectAdd], this); |
|
| 258 |
mList.add(eff); |
|
| 259 |
|
|
| 260 |
LinearLayout layout = (LinearLayout)findViewById(R.id.matrix3dlayout); |
|
| 261 |
View view = eff.createView(); |
|
| 262 |
layout.addView(view); |
|
| 263 |
|
|
| 264 |
if( mSupportsCenter ) |
|
| 265 |
{
|
|
| 266 |
View center = eff.createCenter(); |
|
| 267 |
layout.addView(center); |
|
| 268 |
} |
|
| 269 |
|
|
| 270 |
eff.apply(mEffects); |
|
| 271 |
} |
|
| 272 |
|
|
| 273 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 274 |
|
|
| 275 |
public void removeAll(View v) |
|
| 276 |
{
|
|
| 277 |
mList.clear(); |
|
| 278 |
LinearLayout layout = (LinearLayout)findViewById(R.id.matrix3dlayout); |
|
| 279 |
layout.removeAllViews(); |
|
| 280 |
mEffects.abortByType(EffectType.MATRIX); |
|
| 281 |
|
|
| 282 |
resetData(); |
|
| 283 |
} |
|
| 284 |
|
|
| 285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 286 |
|
|
| 287 |
public void remove(View v) |
|
| 288 |
{
|
|
| 289 |
for(Matrix3DEffect effect: mList) |
|
| 290 |
{
|
|
| 291 |
if( effect.thisView(v) ) |
|
| 292 |
{
|
|
| 293 |
LinearLayout layout = (LinearLayout)findViewById(R.id.matrix3dlayout); |
|
| 294 |
View view; |
|
| 295 |
|
|
| 296 |
view = effect.getEffect(); |
|
| 297 |
if( view!=null ) layout.removeView(view); |
|
| 298 |
view = effect.getCenter(); |
|
| 299 |
if( view!=null ) layout.removeView(view); |
|
| 300 |
view = effect.getRegion(); |
|
| 301 |
if( view!=null ) layout.removeView(view); |
|
| 302 |
|
|
| 303 |
mEffects.abortById(effect.getId()); |
|
| 304 |
mList.remove(effect); |
|
| 305 |
|
|
| 306 |
resetData(); |
|
| 307 |
|
|
| 308 |
break; |
|
| 309 |
} |
|
| 310 |
} |
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 314 |
// Overrides |
|
| 315 |
|
|
| 316 |
@Override |
|
| 317 |
protected void onPause() |
|
| 318 |
{
|
|
| 319 |
GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.matrix3dSurfaceView); |
|
| 320 |
if( mView!=null ) mView.onPause(); |
|
| 321 |
|
|
| 322 |
Distorted.onPause(); |
|
| 323 |
super.onPause(); |
|
| 324 |
} |
|
| 325 |
|
|
| 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 327 |
|
|
| 328 |
@Override |
|
| 329 |
protected void onResume() |
|
| 330 |
{
|
|
| 331 |
super.onResume(); |
|
| 332 |
GLSurfaceView mView = (GLSurfaceView)findViewById(R.id.matrix3dSurfaceView); |
|
| 333 |
if( mView!=null ) mView.onResume(); |
|
| 334 |
} |
|
| 335 |
|
|
| 336 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 337 |
|
|
| 338 |
@Override |
|
| 339 |
protected void onDestroy() |
|
| 340 |
{
|
|
| 341 |
Distorted.onDestroy(); |
|
| 342 |
super.onDestroy(); |
|
| 343 |
} |
|
| 344 |
|
|
| 345 |
} |
|
| src/main/java/org/distorted/examples/matrix3d/Matrix3DEffect.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.matrix3d; |
|
| 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.VertexEffectDeform; |
|
| 41 |
import org.distorted.library.effect.VertexEffectDistort; |
|
| 42 |
import org.distorted.library.effect.VertexEffectPinch; |
|
| 43 |
import org.distorted.library.effect.VertexEffectSink; |
|
| 44 |
import org.distorted.library.effect.VertexEffectSwirl; |
|
| 45 |
import org.distorted.library.effect.VertexEffectWave; |
|
| 46 |
import org.distorted.library.main.DistortedEffects; |
|
| 47 |
import org.distorted.library.type.Dynamic1D; |
|
| 48 |
import org.distorted.library.type.Dynamic2D; |
|
| 49 |
import org.distorted.library.type.Dynamic3D; |
|
| 50 |
import org.distorted.library.type.Dynamic4D; |
|
| 51 |
import org.distorted.library.type.Dynamic5D; |
|
| 52 |
import org.distorted.library.type.Static1D; |
|
| 53 |
import org.distorted.library.type.Static2D; |
|
| 54 |
import org.distorted.library.type.Static3D; |
|
| 55 |
import org.distorted.library.type.Static4D; |
|
| 56 |
import org.distorted.library.type.Static5D; |
|
| 57 |
|
|
| 58 |
import java.lang.ref.WeakReference; |
|
| 59 |
|
|
| 60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 61 |
|
|
| 62 |
class Matrix3DEffect implements SeekBar.OnSeekBarChangeListener |
|
| 63 |
{
|
|
| 64 |
private WeakReference<Matrix3DActivity> mAct; |
|
| 65 |
|
|
| 66 |
private EffectName mName; |
|
| 67 |
private int[] mInter; |
|
| 68 |
private int[] mInterRegion; |
|
| 69 |
private int[] mInterCenter; |
|
| 70 |
private int[] mSeekID; |
|
| 71 |
private int[] mSeekRegionID; |
|
| 72 |
private int[] mSeekCenterID; |
|
| 73 |
private int mDimension; |
|
| 74 |
private TextView mText,mTextRegion,mTextCenter; |
|
| 75 |
|
|
| 76 |
private Dynamic1D mDyn1; |
|
| 77 |
private Dynamic2D mDyn2; |
|
| 78 |
private Dynamic3D mDyn3; |
|
| 79 |
private Dynamic4D mDyn4; |
|
| 80 |
private Dynamic5D mDyn5; |
|
| 81 |
private Static1D mSta1; |
|
| 82 |
private Static2D mSta2; |
|
| 83 |
private Static3D mSta3; |
|
| 84 |
private Static4D mSta4; |
|
| 85 |
private Static5D mSta5; |
|
| 86 |
private Dynamic4D mRegionDyn; |
|
| 87 |
private Static4D mRegionSta; |
|
| 88 |
private Dynamic3D mCenterDyn; |
|
| 89 |
private Static3D mCenterSta; |
|
| 90 |
|
|
| 91 |
private View mButton, mEffect, mCenter, mRegion; |
|
| 92 |
private long mId; |
|
| 93 |
|
|
| 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 95 |
// requires knowledge about effect nature |
|
| 96 |
|
|
| 97 |
void apply(DistortedEffects effects) |
|
| 98 |
{
|
|
| 99 |
Effect effect=null; |
|
| 100 |
|
|
| 101 |
switch(mName) |
|
| 102 |
{
|
|
| 103 |
case ROTATE : effect = new MatrixEffectRotate (mDyn1, mDyn3, mCenterDyn); break; |
|
| 104 |
case QUATERNION : effect = new MatrixEffectQuaternion (mDyn4, mCenterDyn); break; |
|
| 105 |
case MOVE : effect = new MatrixEffectMove (mDyn3 ); break; |
|
| 106 |
case SCALE : effect = new MatrixEffectScale (mDyn3 ); break; |
|
| 107 |
case SHEAR : effect = new MatrixEffectShear (mDyn3, mCenterDyn); break; |
|
| 108 |
|
|
| 109 |
case DISTORT : effect = new VertexEffectDistort (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 110 |
case DEFORM : effect = new VertexEffectDeform (mDyn3, mCenterDyn, mRegionDyn); break; |
|
| 111 |
case SINK : effect = new VertexEffectSink (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 112 |
case PINCH : effect = new VertexEffectPinch (mDyn2, mCenterDyn, mRegionDyn); break; |
|
| 113 |
case SWIRL : effect = new VertexEffectSwirl (mDyn1, mCenterDyn, mRegionDyn); break; |
|
| 114 |
case WAVE : effect = new VertexEffectWave (mDyn5, mCenterDyn, mRegionDyn); break; |
|
| 115 |
|
|
| 116 |
case ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, false); break; |
|
| 117 |
case SMOOTH_ALPHA : effect = new FragmentEffectAlpha (mDyn1, mRegionDyn, true ); break; |
|
| 118 |
case CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, false); break; |
|
| 119 |
case SMOOTH_CHROMA : effect = new FragmentEffectChroma (mDyn1, mDyn3, mRegionDyn, true ); break; |
|
| 120 |
case BRIGHTNESS : effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, false); break; |
|
| 121 |
case SMOOTH_BRIGHTNESS: effect = new FragmentEffectBrightness(mDyn1, mRegionDyn, true ); break; |
|
| 122 |
case SATURATION : effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, false); break; |
|
| 123 |
case SMOOTH_SATURATION: effect = new FragmentEffectSaturation(mDyn1, mRegionDyn, true ); break; |
|
| 124 |
case CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, false); break; |
|
| 125 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mDyn1, mRegionDyn, true ); break; |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
if( effect!=null ) |
|
| 129 |
{
|
|
| 130 |
effects.apply(effect); |
|
| 131 |
mId = effect.getID(); |
|
| 132 |
} |
|
| 133 |
} |
|
| 134 |
|
|
| 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 136 |
// requires knowledge about effect nature |
|
| 137 |
|
|
| 138 |
private void fillStatics() |
|
| 139 |
{
|
|
| 140 |
switch(mName) |
|
| 141 |
{
|
|
| 142 |
case ROTATE : float an = (mInter[0]-50)*180/50; |
|
| 143 |
float rx = (mInter[1]-50)/ 50.0f; |
|
| 144 |
float ry = (mInter[2]-50)/ 50.0f; |
|
| 145 |
float rz = (mInter[3]-50)/ 50.0f; |
|
| 146 |
mSta1.set(an); |
|
| 147 |
mSta3.set(rx,ry,rz); |
|
| 148 |
break; |
|
| 149 |
case QUATERNION : float qx = (mInter[0]-50)/ 50.0f; |
|
| 150 |
float qy = (mInter[1]-50)/ 50.0f; |
|
| 151 |
float qz = (mInter[2]-50)/ 50.0f; |
|
| 152 |
float qa = (mInter[3]-50)*3.1415f/50; |
|
| 153 |
float cosA = (float)Math.cos(qa/2); |
|
| 154 |
float len = (float)Math.sqrt(qx*qx+qy*qy+qz*qz); |
|
| 155 |
float sinAnorm = (float)Math.sin(qa/2)/len; |
|
| 156 |
mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA); |
|
| 157 |
break; |
|
| 158 |
case MOVE : float sw = mAct.get().getScreenWidth()/50.0f; |
|
| 159 |
float sh = mAct.get().getScreenWidth()/50.0f; |
|
| 160 |
float xm = (mInter[0]-50)*sw; |
|
| 161 |
float ym = (mInter[1]-50)*sh; |
|
| 162 |
float zm = (mInter[2]-50)*(sw+sh)/2; |
|
| 163 |
mSta3.set(xm,ym,zm); |
|
| 164 |
break; |
|
| 165 |
case SCALE : float xs = (mInter[0]-50)/10.0f; |
|
| 166 |
float ys = (mInter[1]-50)/10.0f; |
|
| 167 |
float zs = (mInter[2]-50)/10.0f; |
|
| 168 |
mSta3.set(xs,ys,zs); |
|
| 169 |
break; |
|
| 170 |
case SHEAR : float xsh = (mInter[0]-50)/25.0f; |
|
| 171 |
float ysh = (mInter[1]-50)/25.0f; |
|
| 172 |
float zsh = (mInter[2]-50)/25.0f; |
|
| 173 |
mSta3.set(xsh,ysh,zsh); |
|
| 174 |
break; |
|
| 175 |
|
|
| 176 |
case DISTORT : |
|
| 177 |
case DEFORM : float ld = mAct.get().getWidth()/50.0f; |
|
| 178 |
float xd = (mInter[0]-50)*ld; |
|
| 179 |
float yd = (mInter[1]-50)*ld; |
|
| 180 |
float zd = (mInter[2]-50)*ld; |
|
| 181 |
mSta3.set(xd,yd,zd); |
|
| 182 |
break; |
|
| 183 |
case WAVE : float l2 = mAct.get().getWidth()/50.0f; |
|
| 184 |
float x2 = (mInter[0]-50)*l2; |
|
| 185 |
float y2 = (mInter[1]-50)*l2; |
|
| 186 |
float z2 = (mInter[2]-50)*180 / 50; |
|
| 187 |
float w2 = (mInter[3]-50)*180 / 50; |
|
| 188 |
float v2 = (mInter[4]-50)*180 / 50; |
|
| 189 |
mSta5.set(x2,y2,z2,w2,v2); |
|
| 190 |
break; |
|
| 191 |
case SWIRL : mSta1.set( 3.6f*(mInter[0]-50) ); |
|
| 192 |
break; |
|
| 193 |
case SINK : mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f); |
|
| 194 |
break; |
|
| 195 |
case PINCH : float dp = mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f; |
|
| 196 |
float ap = (mInter[1]-50)*180 / 50; |
|
| 197 |
mSta2.set(dp,ap); |
|
| 198 |
break; |
|
| 199 |
|
|
| 200 |
case ALPHA : |
|
| 201 |
case SMOOTH_ALPHA : mSta1.set(mInter[0]/100.0f); |
|
| 202 |
break; |
|
| 203 |
case SATURATION : |
|
| 204 |
case SMOOTH_SATURATION: |
|
| 205 |
case CONTRAST : |
|
| 206 |
case SMOOTH_CONTRAST : |
|
| 207 |
case BRIGHTNESS : |
|
| 208 |
case SMOOTH_BRIGHTNESS: mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f); |
|
| 209 |
break; |
|
| 210 |
case CHROMA : |
|
| 211 |
case SMOOTH_CHROMA : mSta1.set(mInter[0]/100.0f); |
|
| 212 |
mSta3.set(mInter[1]/100.0f, |
|
| 213 |
mInter[2]/100.0f, |
|
| 214 |
mInter[3]/100.0f); |
|
| 215 |
break; |
|
| 216 |
} |
|
| 217 |
} |
|
| 218 |
|
|
| 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 220 |
|
|
| 221 |
private void setDefaultInter() |
|
| 222 |
{
|
|
| 223 |
switch(mDimension) |
|
| 224 |
{
|
|
| 225 |
case 5: mInter[4] = 50; |
|
| 226 |
case 4: mInter[3] = 50; |
|
| 227 |
case 3: mInter[2] = 50; |
|
| 228 |
case 2: mInter[1] = 50; |
|
| 229 |
case 1: mInter[0] = 50; |
|
| 230 |
} |
|
| 231 |
|
|
| 232 |
if( mName==EffectName.ROTATE || mName==EffectName.QUATERNION ) |
|
| 233 |
{
|
|
| 234 |
mInter[1]= 100; |
|
| 235 |
} |
|
| 236 |
if( mName==EffectName.SCALE ) |
|
| 237 |
{
|
|
| 238 |
mInter[0]= 60; |
|
| 239 |
mInter[1]= 60; |
|
| 240 |
mInter[2]= 60; |
|
| 241 |
} |
|
| 242 |
} |
|
| 243 |
|
|
| 244 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 245 |
|
|
| 246 |
private void setText() |
|
| 247 |
{
|
|
| 248 |
String text = mName.name(); |
|
| 249 |
|
|
| 250 |
if( mSta1 !=null ) |
|
| 251 |
{
|
|
| 252 |
float f1 = ((int)(mSta1.get1()*100))/100.0f; |
|
| 253 |
text += " "+f1; |
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
if( mSta2 !=null ) |
|
| 257 |
{
|
|
| 258 |
float f1 = ((int)(mSta2.get1()*100))/100.0f; |
|
| 259 |
float f2 = ((int)(mSta2.get2()*100))/100.0f; |
|
| 260 |
text += " ("+f1+","+f2+")";
|
|
| 261 |
} |
|
| 262 |
|
|
| 263 |
if( mSta3 !=null ) |
|
| 264 |
{
|
|
| 265 |
float f1 = ((int)(mSta3.get1()*100))/100.0f; |
|
| 266 |
float f2 = ((int)(mSta3.get2()*100))/100.0f; |
|
| 267 |
float f3 = ((int)(mSta3.get3()*100))/100.0f; |
|
| 268 |
text += " ("+f1+","+f2+","+f3+")";
|
|
| 269 |
} |
|
| 270 |
|
|
| 271 |
if( mSta4 !=null ) |
|
| 272 |
{
|
|
| 273 |
float f1 = ((int)(mSta4.get1()*100))/100.0f; |
|
| 274 |
float f2 = ((int)(mSta4.get2()*100))/100.0f; |
|
| 275 |
float f3 = ((int)(mSta4.get3()*100))/100.0f; |
|
| 276 |
float f4 = ((int)(mSta4.get4()*100))/100.0f; |
|
| 277 |
text += " ("+f1+","+f2+","+f3+","+f4+")";
|
|
| 278 |
} |
|
| 279 |
|
|
| 280 |
if( mSta5 !=null ) |
|
| 281 |
{
|
|
| 282 |
float f1 = ((int)(mSta5.get1()*100))/100.0f; |
|
| 283 |
float f2 = ((int)(mSta5.get2()*100))/100.0f; |
|
| 284 |
float f3 = ((int)(mSta5.get3()*100))/100.0f; |
|
| 285 |
float f4 = ((int)(mSta5.get4()*100))/100.0f; |
|
| 286 |
float f5 = ((int)(mSta5.get5()*100))/100.0f; |
|
| 287 |
text += " ("+f1+","+f2+","+f3+","+f4+","+f5+")";
|
|
| 288 |
} |
|
| 289 |
|
|
| 290 |
mText.setText(text); |
|
| 291 |
} |
|
| 292 |
|
|
| 293 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 294 |
|
|
| 295 |
private void fillCenterStatics() |
|
| 296 |
{
|
|
| 297 |
Matrix3DActivity act = mAct.get(); |
|
| 298 |
|
|
| 299 |
float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth(); |
|
| 300 |
float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight(); |
|
| 301 |
float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth(); |
|
| 302 |
|
|
| 303 |
mCenterSta.set(x,y,z); |
|
| 304 |
} |
|
| 305 |
|
|
| 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 307 |
|
|
| 308 |
private void setDefaultCenterInter() |
|
| 309 |
{
|
|
| 310 |
mInterCenter[0] = 50; |
|
| 311 |
mInterCenter[1] = 50; |
|
| 312 |
mInterCenter[2] = 50; |
|
| 313 |
} |
|
| 314 |
|
|
| 315 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 316 |
|
|
| 317 |
private void setCenterText() |
|
| 318 |
{
|
|
| 319 |
int f0 = (int)mCenterSta.get1(); |
|
| 320 |
int f1 = (int)mCenterSta.get2(); |
|
| 321 |
int f2 = (int)mCenterSta.get3(); |
|
| 322 |
|
|
| 323 |
mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
|
|
| 324 |
} |
|
| 325 |
|
|
| 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 327 |
|
|
| 328 |
private void fillRegionStatics() |
|
| 329 |
{
|
|
| 330 |
Matrix3DActivity act = mAct.get(); |
|
| 331 |
|
|
| 332 |
float factorX = act.getWidth() / 100.0f; |
|
| 333 |
float factorY = act.getHeight()/ 100.0f; |
|
| 334 |
|
|
| 335 |
int deduct = (mName.getType() == EffectType.VERTEX ? 50:0); |
|
| 336 |
|
|
| 337 |
float x = (mInterRegion[0]-deduct)*factorX; |
|
| 338 |
float y = (mInterRegion[1]-deduct)*factorY; |
|
| 339 |
float rx = mInterRegion[2] *factorX; |
|
| 340 |
float ry = mInterRegion[3] *factorY; |
|
| 341 |
|
|
| 342 |
mRegionSta.set(x,y,rx,ry); |
|
| 343 |
} |
|
| 344 |
|
|
| 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 346 |
|
|
| 347 |
private void setDefaultRegionInter() |
|
| 348 |
{
|
|
| 349 |
mInterRegion[0] = 50; |
|
| 350 |
mInterRegion[1] = 50; |
|
| 351 |
mInterRegion[2] = 50; |
|
| 352 |
mInterRegion[3] = 50; |
|
| 353 |
} |
|
| 354 |
|
|
| 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 356 |
|
|
| 357 |
private void setRegionText() |
|
| 358 |
{
|
|
| 359 |
int f0 = (int)mRegionSta.get1(); |
|
| 360 |
int f1 = (int)mRegionSta.get2(); |
|
| 361 |
int f2 = (int)mRegionSta.get3(); |
|
| 362 |
int f3 = (int)mRegionSta.get4(); |
|
| 363 |
|
|
| 364 |
mTextRegion.setText("region ("+f0+","+f1+","+f2+","+f3+")");
|
|
| 365 |
} |
|
| 366 |
|
|
| 367 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 368 |
|
|
| 369 |
Matrix3DEffect(EffectName name, Matrix3DActivity act) |
|
| 370 |
{
|
|
| 371 |
mAct = new WeakReference<>(act); |
|
| 372 |
mName = name; |
|
| 373 |
|
|
| 374 |
mDyn1 = null; |
|
| 375 |
mDyn2 = null; |
|
| 376 |
mDyn3 = null; |
|
| 377 |
mDyn4 = null; |
|
| 378 |
mDyn5 = null; |
|
| 379 |
mSta1 = null; |
|
| 380 |
mSta2 = null; |
|
| 381 |
mSta3 = null; |
|
| 382 |
mSta4 = null; |
|
| 383 |
mSta5 = null; |
|
| 384 |
|
|
| 385 |
mDimension = mName.getDimension(); |
|
| 386 |
|
|
| 387 |
switch(mDimension) |
|
| 388 |
{
|
|
| 389 |
case 1 : mDyn1 = new Dynamic1D(); |
|
| 390 |
mSta1 = new Static1D(0); |
|
| 391 |
mDyn1.add(mSta1); |
|
| 392 |
break; |
|
| 393 |
case 2 : mDyn2 = new Dynamic2D(); |
|
| 394 |
mSta2 = new Static2D(0,0); |
|
| 395 |
mDyn2.add(mSta2); |
|
| 396 |
break; |
|
| 397 |
case 3 : mDyn3 = new Dynamic3D(); |
|
| 398 |
mSta3 = new Static3D(0,0,0); |
|
| 399 |
mDyn3.add(mSta3); |
|
| 400 |
break; |
|
| 401 |
case 4 : if( mName == EffectName.QUATERNION ) |
|
| 402 |
{
|
|
| 403 |
mDyn4 = new Dynamic4D(); |
|
| 404 |
mSta4 = new Static4D(0,0,0,0); |
|
| 405 |
mDyn4.add(mSta4); |
|
| 406 |
} |
|
| 407 |
else |
|
| 408 |
{
|
|
| 409 |
mDyn3 = new Dynamic3D(); |
|
| 410 |
mSta3 = new Static3D(0,0,0); |
|
| 411 |
mDyn3.add(mSta3); |
|
| 412 |
mDyn1 = new Dynamic1D(); |
|
| 413 |
mSta1 = new Static1D(0); |
|
| 414 |
mDyn1.add(mSta1); |
|
| 415 |
} |
|
| 416 |
break; |
|
| 417 |
case 5 : mDyn5 = new Dynamic5D(); |
|
| 418 |
mSta5 = new Static5D(0,0,0,0,0); |
|
| 419 |
mDyn5.add(mSta5); |
|
| 420 |
break; |
|
| 421 |
default: throw new RuntimeException("unsupported effect");
|
|
| 422 |
} |
|
| 423 |
|
|
| 424 |
mInter = new int[mDimension]; |
|
| 425 |
mSeekID= new int[mDimension]; |
|
| 426 |
|
|
| 427 |
mInterRegion = new int[4]; |
|
| 428 |
mSeekRegionID= new int[4]; |
|
| 429 |
mRegionDyn = new Dynamic4D(); |
|
| 430 |
mRegionSta = new Static4D(0,0,0,0); |
|
| 431 |
mRegionDyn.add(mRegionSta); |
|
| 432 |
|
|
| 433 |
mInterCenter = new int[3]; |
|
| 434 |
mSeekCenterID= new int[3]; |
|
| 435 |
mCenterDyn = new Dynamic3D(); |
|
| 436 |
mCenterSta = new Static3D(0,0,0); |
|
| 437 |
mCenterDyn.add(mCenterSta); |
|
| 438 |
|
|
| 439 |
mButton = null; |
|
| 440 |
mEffect = null; |
|
| 441 |
mCenter = null; |
|
| 442 |
mRegion = null; |
|
| 443 |
} |
|
| 444 |
|
|
| 445 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 446 |
|
|
| 447 |
View createView() |
|
| 448 |
{
|
|
| 449 |
SeekBar[] seek = new SeekBar[mDimension]; |
|
| 450 |
|
|
| 451 |
Matrix3DActivity act = mAct.get(); |
|
| 452 |
|
|
| 453 |
switch(mDimension) |
|
| 454 |
{
|
|
| 455 |
case 1 : mEffect = act.getLayoutInflater().inflate(R.layout.effect1d, null); |
|
| 456 |
mText = (TextView)mEffect.findViewById(R.id.effect1dText); |
|
| 457 |
seek[0] = (SeekBar)mEffect.findViewById(R.id.effect1dbar1); |
|
| 458 |
mSeekID[0] = seek[0].getId(); |
|
| 459 |
mButton = mEffect.findViewById(R.id.button1dRemove); |
|
| 460 |
break; |
|
| 461 |
case 2 : mEffect = act.getLayoutInflater().inflate(R.layout.effect2d, null); |
|
| 462 |
mText = (TextView)mEffect.findViewById(R.id.effect2dText); |
|
| 463 |
seek[0] = (SeekBar)mEffect.findViewById(R.id.effect2dbar1); |
|
| 464 |
seek[1] = (SeekBar)mEffect.findViewById(R.id.effect2dbar2); |
|
| 465 |
mSeekID[0] = seek[0].getId(); |
|
| 466 |
mSeekID[1] = seek[1].getId(); |
|
| 467 |
mButton = mEffect.findViewById(R.id.button2dRemove); |
|
| 468 |
break; |
|
| 469 |
case 3 : mEffect = act.getLayoutInflater().inflate(R.layout.effect3d, null); |
|
| 470 |
mText = (TextView)mEffect.findViewById(R.id.effect3dText); |
|
| 471 |
seek[0] = (SeekBar)mEffect.findViewById(R.id.effect3dbar1); |
|
| 472 |
seek[1] = (SeekBar)mEffect.findViewById(R.id.effect3dbar2); |
|
| 473 |
seek[2] = (SeekBar)mEffect.findViewById(R.id.effect3dbar3); |
|
| 474 |
mSeekID[0] = seek[0].getId(); |
|
| 475 |
mSeekID[1] = seek[1].getId(); |
|
| 476 |
mSeekID[2] = seek[2].getId(); |
|
| 477 |
mButton = mEffect.findViewById(R.id.button3dRemove); |
|
| 478 |
break; |
|
| 479 |
case 4 : mEffect = act.getLayoutInflater().inflate(R.layout.effect4d, null); |
|
| 480 |
mText = (TextView)mEffect.findViewById(R.id.effect4dText); |
|
| 481 |
seek[0] = (SeekBar)mEffect.findViewById(R.id.effect4dbar1); |
|
| 482 |
seek[1] = (SeekBar)mEffect.findViewById(R.id.effect4dbar2); |
|
| 483 |
seek[2] = (SeekBar)mEffect.findViewById(R.id.effect4dbar3); |
|
| 484 |
seek[3] = (SeekBar)mEffect.findViewById(R.id.effect4dbar4); |
|
| 485 |
mSeekID[0] = seek[0].getId(); |
|
| 486 |
mSeekID[1] = seek[1].getId(); |
|
| 487 |
mSeekID[2] = seek[2].getId(); |
|
| 488 |
mSeekID[3] = seek[3].getId(); |
|
| 489 |
mButton = mEffect.findViewById(R.id.button4dRemove); |
|
| 490 |
break; |
|
| 491 |
case 5 : mEffect = act.getLayoutInflater().inflate(R.layout.effect5d, null); |
|
| 492 |
mText = (TextView)mEffect.findViewById(R.id.effect5dText); |
|
| 493 |
seek[0] = (SeekBar)mEffect.findViewById(R.id.effect5dbar1); |
|
| 494 |
seek[1] = (SeekBar)mEffect.findViewById(R.id.effect5dbar2); |
|
| 495 |
seek[2] = (SeekBar)mEffect.findViewById(R.id.effect5dbar3); |
|
| 496 |
seek[3] = (SeekBar)mEffect.findViewById(R.id.effect5dbar4); |
|
| 497 |
seek[4] = (SeekBar)mEffect.findViewById(R.id.effect5dbar5); |
|
| 498 |
mSeekID[0] = seek[0].getId(); |
|
| 499 |
mSeekID[1] = seek[1].getId(); |
|
| 500 |
mSeekID[2] = seek[2].getId(); |
|
| 501 |
mSeekID[3] = seek[3].getId(); |
|
| 502 |
mSeekID[4] = seek[4].getId(); |
|
| 503 |
mButton = mEffect.findViewById(R.id.button5dRemove); |
|
| 504 |
break; |
|
| 505 |
default: android.util.Log.e("Matrix3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 506 |
return null; |
|
| 507 |
} |
|
| 508 |
|
|
| 509 |
setDefaultInter(); |
|
| 510 |
|
|
| 511 |
for(int i=0; i<mDimension; i++) |
|
| 512 |
{
|
|
| 513 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 514 |
seek[i].setProgress( mInter[i] ); |
|
| 515 |
} |
|
| 516 |
|
|
| 517 |
Matrix3DActivity.setSupportsRegion(mName.supportsRegion()); |
|
| 518 |
Matrix3DActivity.setSupportsCenter(mName.supportsCenter()); |
|
| 519 |
|
|
| 520 |
return mEffect; |
|
| 521 |
} |
|
| 522 |
|
|
| 523 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 524 |
|
|
| 525 |
View createRegion() |
|
| 526 |
{
|
|
| 527 |
Matrix3DActivity act = mAct.get(); |
|
| 528 |
|
|
| 529 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion, null); |
|
| 530 |
|
|
| 531 |
SeekBar[] seek = new SeekBar[4]; |
|
| 532 |
|
|
| 533 |
seek[0] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarX ); |
|
| 534 |
seek[1] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarY ); |
|
| 535 |
seek[2] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRX); |
|
| 536 |
seek[3] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRY); |
|
| 537 |
|
|
| 538 |
mSeekRegionID[0] = seek[0].getId(); |
|
| 539 |
mSeekRegionID[1] = seek[1].getId(); |
|
| 540 |
mSeekRegionID[2] = seek[2].getId(); |
|
| 541 |
mSeekRegionID[3] = seek[3].getId(); |
|
| 542 |
|
|
| 543 |
mTextRegion = (TextView)mRegion.findViewById(R.id.effectRegionText); |
|
| 544 |
|
|
| 545 |
setDefaultRegionInter(); |
|
| 546 |
|
|
| 547 |
for(int i=0; i<4; i++) |
|
| 548 |
{
|
|
| 549 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 550 |
seek[i].setProgress( mInterRegion[i] ); |
|
| 551 |
} |
|
| 552 |
|
|
| 553 |
act.setRegion(mRegionSta.get1(),mRegionSta.get2(),mRegionSta.get3()); |
|
| 554 |
|
|
| 555 |
return mRegion; |
|
| 556 |
} |
|
| 557 |
|
|
| 558 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 559 |
|
|
| 560 |
View createCenter() |
|
| 561 |
{
|
|
| 562 |
Matrix3DActivity act = mAct.get(); |
|
| 563 |
|
|
| 564 |
mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null); |
|
| 565 |
|
|
| 566 |
SeekBar[] seek = new SeekBar[3]; |
|
| 567 |
|
|
| 568 |
seek[0] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarX ); |
|
| 569 |
seek[1] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarY ); |
|
| 570 |
seek[2] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarZ ); |
|
| 571 |
|
|
| 572 |
mSeekCenterID[0] = seek[0].getId(); |
|
| 573 |
mSeekCenterID[1] = seek[1].getId(); |
|
| 574 |
mSeekCenterID[2] = seek[2].getId(); |
|
| 575 |
|
|
| 576 |
mTextCenter = (TextView)mCenter.findViewById(R.id.effectCenterText); |
|
| 577 |
|
|
| 578 |
setDefaultCenterInter(); |
|
| 579 |
|
|
| 580 |
for(int i=0; i<3; i++) |
|
| 581 |
{
|
|
| 582 |
seek[i].setOnSeekBarChangeListener(this); |
|
| 583 |
seek[i].setProgress( mInterCenter[i] ); |
|
| 584 |
} |
|
| 585 |
|
|
| 586 |
act.setCenter(mCenterSta.get1(),mCenterSta.get2(),mCenterSta.get3()); |
|
| 587 |
|
|
| 588 |
return mCenter; |
|
| 589 |
} |
|
| 590 |
|
|
| 591 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 592 |
|
|
| 593 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
| 594 |
{
|
|
| 595 |
if ( mDimension>=1 && bar.getId()==mSeekID[0] ) |
|
| 596 |
{
|
|
| 597 |
mInter[0] = progress; |
|
| 598 |
fillStatics(); |
|
| 599 |
setText(); |
|
| 600 |
} |
|
| 601 |
if ( mDimension>=2 && bar.getId()==mSeekID[1] ) |
|
| 602 |
{
|
|
| 603 |
mInter[1] = progress; |
|
| 604 |
fillStatics(); |
|
| 605 |
setText(); |
|
| 606 |
} |
|
| 607 |
if ( mDimension>=3 && bar.getId()==mSeekID[2] ) |
|
| 608 |
{
|
|
| 609 |
mInter[2] = progress; |
|
| 610 |
fillStatics(); |
|
| 611 |
setText(); |
|
| 612 |
} |
|
| 613 |
if ( mDimension>=4 && bar.getId()==mSeekID[3] ) |
|
| 614 |
{
|
|
| 615 |
mInter[3] = progress; |
|
| 616 |
fillStatics(); |
|
| 617 |
setText(); |
|
| 618 |
} |
|
| 619 |
if ( mDimension>=5 && bar.getId()==mSeekID[4] ) |
|
| 620 |
{
|
|
| 621 |
mInter[4] = progress; |
|
| 622 |
fillStatics(); |
|
| 623 |
setText(); |
|
| 624 |
} |
|
| 625 |
|
|
| 626 |
if( bar.getId() == mSeekRegionID[0] ) |
|
| 627 |
{
|
|
| 628 |
mInterRegion[0] = progress; |
|
| 629 |
fillRegionStatics(); |
|
| 630 |
setRegionText(); |
|
| 631 |
} |
|
| 632 |
if( bar.getId() == mSeekRegionID[1] ) |
|
| 633 |
{
|
|
| 634 |
mInterRegion[1] = progress; |
|
| 635 |
fillRegionStatics(); |
|
| 636 |
setRegionText(); |
|
| 637 |
} |
|
| 638 |
if( bar.getId() == mSeekRegionID[2] ) |
|
| 639 |
{
|
|
| 640 |
mInterRegion[2] = progress; |
|
| 641 |
fillRegionStatics(); |
|
| 642 |
setRegionText(); |
|
| 643 |
} |
|
| 644 |
if( bar.getId() == mSeekRegionID[3] ) |
|
| 645 |
{
|
|
| 646 |
mInterRegion[3] = progress; |
|
| 647 |
fillRegionStatics(); |
|
| 648 |
setRegionText(); |
|
| 649 |
} |
|
| 650 |
|
|
| 651 |
if( bar.getId() == mSeekCenterID[0] ) |
|
| 652 |
{
|
|
| 653 |
mInterCenter[0] = progress; |
|
| 654 |
fillCenterStatics(); |
|
| 655 |
setCenterText(); |
|
| 656 |
} |
|
| 657 |
if( bar.getId() == mSeekCenterID[1] ) |
|
| 658 |
{
|
|
| 659 |
mInterCenter[1] = progress; |
|
| 660 |
fillCenterStatics(); |
|
| 661 |
setCenterText(); |
|
| 662 |
} |
|
| 663 |
if( bar.getId() == mSeekCenterID[2] ) |
|
| 664 |
{
|
|
| 665 |
mInterCenter[2] = progress; |
|
| 666 |
fillCenterStatics(); |
|
| 667 |
setCenterText(); |
|
| 668 |
} |
|
| 669 |
|
|
| 670 |
if( fromUser ) |
|
| 671 |
{
|
|
| 672 |
Matrix3DActivity.setSupportsRegion(mName.supportsRegion()); |
|
| 673 |
Matrix3DActivity.setSupportsCenter(mName.supportsCenter()); |
|
| 674 |
|
|
| 675 |
Matrix3DActivity act = mAct.get(); |
|
| 676 |
|
|
| 677 |
act.setCenter(mCenterSta.get1(),mCenterSta.get2(),mCenterSta.get3()); |
|
| 678 |
act.setRegion(mRegionSta.get1(),mRegionSta.get2(),mRegionSta.get3()); |
|
| 679 |
} |
|
| 680 |
} |
|
| 681 |
|
|
| 682 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 683 |
|
|
| 684 |
boolean thisView(View v) |
|
| 685 |
{
|
|
| 686 |
return v==mButton; |
|
| 687 |
} |
|
| 688 |
|
|
| 689 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 690 |
|
|
| 691 |
public long getId() |
|
| 692 |
{
|
|
| 693 |
return mId; |
|
| 694 |
} |
|
| 695 |
|
|
| 696 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 697 |
|
|
| 698 |
public View getEffect() |
|
| 699 |
{
|
|
| 700 |
return mEffect; |
|
| 701 |
} |
|
| 702 |
|
|
| 703 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 704 |
|
|
| 705 |
public View getRegion() |
|
| 706 |
{
|
|
| 707 |
return mRegion; |
|
| 708 |
} |
|
| 709 |
|
|
| 710 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 711 |
|
|
| 712 |
public View getCenter() |
|
| 713 |
{
|
|
| 714 |
return mCenter; |
|
| 715 |
} |
|
| 716 |
|
|
| 717 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 718 |
|
|
| 719 |
public void onStartTrackingTouch(SeekBar bar) { }
|
|
| 720 |
|
|
| 721 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 722 |
|
|
| 723 |
public void onStopTrackingTouch(SeekBar bar) { }
|
|
| 724 |
} |
|
| src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.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.matrix3d; |
|
| 21 |
|
|
| 22 |
import android.opengl.GLSurfaceView; |
|
| 23 |
|
|
| 24 |
import org.distorted.library.main.Distorted; |
|
| 25 |
import org.distorted.library.main.DistortedScreen; |
|
| 26 |
import org.distorted.library.main.DistortedTexture; |
|
| 27 |
|
|
| 28 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 29 |
import javax.microedition.khronos.opengles.GL10; |
|
| 30 |
|
|
| 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 32 |
|
|
| 33 |
class Matrix3DRenderer implements GLSurfaceView.Renderer |
|
| 34 |
{
|
|
| 35 |
private GLSurfaceView mView; |
|
| 36 |
private DistortedTexture mTexture; |
|
| 37 |
private DistortedScreen mScreen; |
|
| 38 |
|
|
| 39 |
private int mWidth, mHeight; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 42 |
|
|
| 43 |
Matrix3DRenderer(GLSurfaceView v) |
|
| 44 |
{
|
|
| 45 |
mView = v; |
|
| 46 |
Matrix3DActivity act = (Matrix3DActivity)v.getContext(); |
|
| 47 |
mTexture= act.getTexture(); |
|
| 48 |
mScreen = new DistortedScreen(); |
|
| 49 |
mScreen.attach(mTexture,act.getEffects(),act.getMesh()); |
|
| 50 |
mScreen.setProjection(60.0f,0.1f); |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 54 |
|
|
| 55 |
public void onDrawFrame(GL10 glUnused) |
|
Also available in: Unified diff
Progress with Effects3D app - merge Matrix effects