Revision 34747dd1
Added by Leszek Koltunski over 6 years ago
| src/main/java/org/distorted/effect/AppearEffect.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.main.DistortedScreen; |
|
| 24 |
import org.distorted.library.message.EffectListener; |
|
| 25 |
import org.distorted.library.message.EffectMessage; |
|
| 26 |
import org.distorted.magic.RubikCube; |
|
| 27 |
|
|
| 28 |
import java.lang.reflect.Method; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
public abstract class AppearEffect implements EffectListener |
|
| 33 |
{
|
|
| 34 |
public enum Type |
|
| 35 |
{
|
|
| 36 |
EMPTY (AppearEffectEmpty.class ), |
|
| 37 |
TRANSPARENCY (AppearEffectTransparency.class), |
|
| 38 |
MOVE (AppearEffectMove.class ), |
|
| 39 |
ROUND (AppearEffectRound.class ), |
|
| 40 |
SCALE (AppearEffectScale.class ), |
|
| 41 |
; |
|
| 42 |
|
|
| 43 |
private final Class<? extends AppearEffect> effectClass; |
|
| 44 |
|
|
| 45 |
Type(Class<? extends AppearEffect> effectClass) |
|
| 46 |
{
|
|
| 47 |
this.effectClass = effectClass; |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
private final int FAKE_EFFECT_ID = -1; |
|
| 52 |
|
|
| 53 |
private int mCubeEffectNumber, mCubeEffectFinished, mCubeEffectReturned; |
|
| 54 |
|
|
| 55 |
private EffectListener mListener; |
|
| 56 |
private DistortedScreen mScreen; |
|
| 57 |
private RubikCube mCube; |
|
| 58 |
|
|
| 59 |
Effect[] mCubeEffects; |
|
| 60 |
int[] mCubeEffectPosition; |
|
| 61 |
|
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
AppearEffect() |
|
| 65 |
{
|
|
| 66 |
mCubeEffectReturned = 0; |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 70 |
|
|
| 71 |
abstract int createEffects(int duration); |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 |
|
|
| 75 |
public void effectMessage(final EffectMessage em, final long effectID, final long objectID) |
|
| 76 |
{
|
|
| 77 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
| 78 |
{
|
|
| 79 |
long id = mCubeEffects[i].getID(); |
|
| 80 |
|
|
| 81 |
if( effectID == id ) |
|
| 82 |
{
|
|
| 83 |
mCubeEffectReturned++; |
|
| 84 |
|
|
| 85 |
if( mCubeEffectReturned == mCubeEffectFinished ) |
|
| 86 |
{
|
|
| 87 |
mListener.effectMessage(null, FAKE_EFFECT_ID, 0); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
if( mCubeEffectReturned == mCubeEffectNumber ) |
|
| 91 |
{
|
|
| 92 |
mCube.deregisterForMessages(this); |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
mCube.remove(id); |
|
| 96 |
break; |
|
| 97 |
} |
|
| 98 |
} |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 102 |
|
|
| 103 |
public long start(DistortedScreen screen, RubikCube cube, EffectListener listener) |
|
| 104 |
{
|
|
| 105 |
mScreen = screen; |
|
| 106 |
mCube = cube; |
|
| 107 |
mListener = listener; |
|
| 108 |
|
|
| 109 |
mCubeEffectFinished = createEffects(2000); |
|
| 110 |
|
|
| 111 |
if( mCubeEffects!=null ) |
|
| 112 |
{
|
|
| 113 |
mCubeEffectNumber = mCubeEffects.length; |
|
| 114 |
} |
|
| 115 |
else |
|
| 116 |
{
|
|
| 117 |
throw new RuntimeException("Appear Cube Effects not created!");
|
|
| 118 |
} |
|
| 119 |
|
|
| 120 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
| 121 |
{
|
|
| 122 |
mCube.apply(mCubeEffects[i],mCubeEffectPosition[i]); |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
mCube.registerForMessages(this); |
|
| 126 |
mScreen.attach(mCube); |
|
| 127 |
|
|
| 128 |
return FAKE_EFFECT_ID; |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 132 |
|
|
| 133 |
public static AppearEffect create(Type type) throws InstantiationException, IllegalAccessException |
|
| 134 |
{
|
|
| 135 |
return type.effectClass.newInstance(); |
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 139 |
|
|
| 140 |
public static void enableEffects() |
|
| 141 |
{
|
|
| 142 |
Method method=null; |
|
| 143 |
|
|
| 144 |
for(Type type: Type.values()) |
|
| 145 |
{
|
|
| 146 |
Class<? extends AppearEffect> cls = type.effectClass; |
|
| 147 |
|
|
| 148 |
try |
|
| 149 |
{
|
|
| 150 |
method = cls.getMethod("enable");
|
|
| 151 |
} |
|
| 152 |
catch(NoSuchMethodException ex) |
|
| 153 |
{
|
|
| 154 |
android.util.Log.e("transitionEffect", "exception getting method: "+ex.getMessage());
|
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
try |
|
| 158 |
{
|
|
| 159 |
method.invoke(null); |
|
| 160 |
} |
|
| 161 |
catch(Exception ex) |
|
| 162 |
{
|
|
| 163 |
android.util.Log.e("transitionEffect", "exception invoking method: "+ex.getMessage());
|
|
| 164 |
} |
|
| 165 |
} |
|
| 166 |
} |
|
| 167 |
} |
|
| src/main/java/org/distorted/effect/AppearEffectEmpty.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class AppearEffectEmpty extends AppearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {-1};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic3D oldCube0 = new Dynamic3D(1,0.5f); |
|
| 37 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 38 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 39 |
|
|
| 40 |
return 1; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
// enable all effects used in this Appear (here: none). Called by reflection from the parent class. |
|
| 45 |
|
|
| 46 |
@SuppressWarnings("unused")
|
|
| 47 |
static void enable() |
|
| 48 |
{
|
|
| 49 |
|
|
| 50 |
} |
|
| 51 |
} |
|
| src/main/java/org/distorted/effect/AppearEffectMove.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 28 |
|
|
| 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 30 |
|
|
| 31 |
class AppearEffectMove extends AppearEffect |
|
| 32 |
{
|
|
| 33 |
public int createEffects(int duration) |
|
| 34 |
{
|
|
| 35 |
mCubeEffectPosition = new int[] {2};
|
|
| 36 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 37 |
|
|
| 38 |
Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f); |
|
| 39 |
oldCube0.add(new Static3D(-TEXTURE_SIZE,0,0)); |
|
| 40 |
oldCube0.add(new Static3D( 0,0,0)); |
|
| 41 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 42 |
|
|
| 43 |
return 1; |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 47 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 48 |
// Matrix Effects do not have to be enabled. |
|
| 49 |
|
|
| 50 |
@SuppressWarnings("unused")
|
|
| 51 |
static void enable() |
|
| 52 |
{
|
|
| 53 |
|
|
| 54 |
} |
|
| 55 |
} |
|
| 56 |
|
|
| src/main/java/org/distorted/effect/AppearEffectRound.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 25 |
import org.distorted.library.type.Dynamic3D; |
|
| 26 |
import org.distorted.library.type.Static3D; |
|
| 27 |
|
|
| 28 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
class AppearEffectRound extends AppearEffect |
|
| 33 |
{
|
|
| 34 |
public int createEffects(int duration) |
|
| 35 |
{
|
|
| 36 |
mCubeEffectPosition = new int[] {2, 2};
|
|
| 37 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 38 |
|
|
| 39 |
Dynamic3D oldCube0 = new Dynamic3D(duration/2, 0.5f); |
|
| 40 |
oldCube0.add(new Static3D(-TEXTURE_SIZE,0,0)); |
|
| 41 |
oldCube0.add(new Static3D( 0,0,0)); |
|
| 42 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 43 |
|
|
| 44 |
Dynamic3D oldCube1 = new Dynamic3D(duration/2, 0.5f); |
|
| 45 |
oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 46 |
oldCube1.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
| 47 |
mCubeEffects[1] = new MatrixEffectScale(oldCube1); |
|
| 48 |
|
|
| 49 |
return 2; |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 54 |
// Matrix Effects do not have to be enabled. |
|
| 55 |
|
|
| 56 |
@SuppressWarnings("unused")
|
|
| 57 |
static void enable() |
|
| 58 |
{
|
|
| 59 |
|
|
| 60 |
} |
|
| 61 |
} |
|
| 62 |
|
|
| src/main/java/org/distorted/effect/AppearEffectScale.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class AppearEffectScale extends AppearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {5};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f); |
|
| 37 |
oldCube0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 38 |
oldCube0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
| 39 |
mCubeEffects[0] = new MatrixEffectScale(oldCube0); |
|
| 40 |
|
|
| 41 |
return 1; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 46 |
// Matrix Effects do not have to be enabled. |
|
| 47 |
|
|
| 48 |
@SuppressWarnings("unused")
|
|
| 49 |
static void enable() |
|
| 50 |
{
|
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
} |
|
| 54 |
|
|
| src/main/java/org/distorted/effect/AppearEffectTransparency.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
| 24 |
import org.distorted.library.type.Dynamic1D; |
|
| 25 |
import org.distorted.library.type.Static1D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class AppearEffectTransparency extends AppearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {-1};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic1D oldCube0 = new Dynamic1D(duration, 0.5f); |
|
| 37 |
oldCube0.add(new Static1D(0.0f)); |
|
| 38 |
oldCube0.add(new Static1D(1.0f)); |
|
| 39 |
mCubeEffects[0] = new FragmentEffectAlpha(oldCube0); |
|
| 40 |
|
|
| 41 |
return 1; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 46 |
|
|
| 47 |
@SuppressWarnings("unused")
|
|
| 48 |
static void enable() |
|
| 49 |
{
|
|
| 50 |
FragmentEffectAlpha.enable(); |
|
| 51 |
} |
|
| 52 |
} |
|
| src/main/java/org/distorted/effect/DisappearEffect.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.main.DistortedScreen; |
|
| 24 |
import org.distorted.library.message.EffectListener; |
|
| 25 |
import org.distorted.library.message.EffectMessage; |
|
| 26 |
import org.distorted.magic.RubikCube; |
|
| 27 |
|
|
| 28 |
import java.lang.reflect.Method; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
public abstract class DisappearEffect implements EffectListener |
|
| 33 |
{
|
|
| 34 |
public enum Type |
|
| 35 |
{
|
|
| 36 |
EMPTY (DisappearEffectEmpty.class ), |
|
| 37 |
TRANSPARENCY (DisappearEffectTransparency.class), |
|
| 38 |
MOVE (DisappearEffectMove.class ), |
|
| 39 |
ROUND (DisappearEffectRound.class ), |
|
| 40 |
SCALE (DisappearEffectScale.class ), |
|
| 41 |
; |
|
| 42 |
|
|
| 43 |
private final Class<? extends DisappearEffect> effectClass; |
|
| 44 |
|
|
| 45 |
Type(Class<? extends DisappearEffect> effectClass) |
|
| 46 |
{
|
|
| 47 |
this.effectClass = effectClass; |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
private final int FAKE_EFFECT_ID = -2; |
|
| 52 |
|
|
| 53 |
private int mCubeEffectNumber, mCubeEffectFinished, mCubeEffectReturned; |
|
| 54 |
|
|
| 55 |
private EffectListener mListener; |
|
| 56 |
private DistortedScreen mScreen; |
|
| 57 |
private RubikCube mCube; |
|
| 58 |
|
|
| 59 |
Effect[] mCubeEffects; |
|
| 60 |
int[] mCubeEffectPosition; |
|
| 61 |
|
|
| 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 63 |
|
|
| 64 |
DisappearEffect() |
|
| 65 |
{
|
|
| 66 |
mCubeEffectReturned = 0; |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 70 |
|
|
| 71 |
abstract int createEffects(int duration); |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 74 |
|
|
| 75 |
public void effectMessage(final EffectMessage em, final long effectID, final long objectID) |
|
| 76 |
{
|
|
| 77 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
| 78 |
{
|
|
| 79 |
long id = mCubeEffects[i].getID(); |
|
| 80 |
|
|
| 81 |
if( effectID == id ) |
|
| 82 |
{
|
|
| 83 |
mCubeEffectReturned++; |
|
| 84 |
|
|
| 85 |
if( mCubeEffectReturned == mCubeEffectFinished ) |
|
| 86 |
{
|
|
| 87 |
mListener.effectMessage(null, FAKE_EFFECT_ID, 0); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
if( mCubeEffectReturned == mCubeEffectNumber ) |
|
| 91 |
{
|
|
| 92 |
mScreen.detach(mCube); |
|
| 93 |
mCube.deregisterForMessages(this); |
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
mCube.remove(id); |
|
| 97 |
break; |
|
| 98 |
} |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
public long start(DistortedScreen screen, RubikCube cube, EffectListener listener) |
|
| 105 |
{
|
|
| 106 |
mScreen = screen; |
|
| 107 |
mCube = cube; |
|
| 108 |
mListener = listener; |
|
| 109 |
|
|
| 110 |
mCubeEffectFinished = createEffects(2000); |
|
| 111 |
|
|
| 112 |
if( mCubeEffects!=null ) |
|
| 113 |
{
|
|
| 114 |
mCubeEffectNumber = mCubeEffects.length; |
|
| 115 |
} |
|
| 116 |
else |
|
| 117 |
{
|
|
| 118 |
throw new RuntimeException("Disappear Cube Effects not created!");
|
|
| 119 |
} |
|
| 120 |
|
|
| 121 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
| 122 |
{
|
|
| 123 |
mCube.apply(mCubeEffects[i],mCubeEffectPosition[i]); |
|
| 124 |
} |
|
| 125 |
|
|
| 126 |
mCube.registerForMessages(this); |
|
| 127 |
|
|
| 128 |
return FAKE_EFFECT_ID; |
|
| 129 |
} |
|
| 130 |
|
|
| 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 132 |
|
|
| 133 |
public static DisappearEffect create(Type type) throws InstantiationException, IllegalAccessException |
|
| 134 |
{
|
|
| 135 |
return type.effectClass.newInstance(); |
|
| 136 |
} |
|
| 137 |
|
|
| 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 139 |
|
|
| 140 |
public static void enableEffects() |
|
| 141 |
{
|
|
| 142 |
Method method=null; |
|
| 143 |
|
|
| 144 |
for(Type type: Type.values()) |
|
| 145 |
{
|
|
| 146 |
Class<? extends DisappearEffect> cls = type.effectClass; |
|
| 147 |
|
|
| 148 |
try |
|
| 149 |
{
|
|
| 150 |
method = cls.getMethod("enable");
|
|
| 151 |
} |
|
| 152 |
catch(NoSuchMethodException ex) |
|
| 153 |
{
|
|
| 154 |
android.util.Log.e("transitionEffect", "exception getting method: "+ex.getMessage());
|
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
try |
|
| 158 |
{
|
|
| 159 |
method.invoke(null); |
|
| 160 |
} |
|
| 161 |
catch(Exception ex) |
|
| 162 |
{
|
|
| 163 |
android.util.Log.e("transitionEffect", "exception invoking method: "+ex.getMessage());
|
|
| 164 |
} |
|
| 165 |
} |
|
| 166 |
} |
|
| 167 |
} |
|
| src/main/java/org/distorted/effect/DisappearEffectEmpty.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class DisappearEffectEmpty extends DisappearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {-1};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic3D oldCube0 = new Dynamic3D(1,0.5f); |
|
| 37 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 38 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 39 |
|
|
| 40 |
return 1; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 44 |
// enable all effects used in this Appear (here: none). Called by reflection from the parent class. |
|
| 45 |
|
|
| 46 |
@SuppressWarnings("unused")
|
|
| 47 |
static void enable() |
|
| 48 |
{
|
|
| 49 |
|
|
| 50 |
} |
|
| 51 |
} |
|
| src/main/java/org/distorted/effect/DisappearEffectMove.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 28 |
|
|
| 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 30 |
|
|
| 31 |
class DisappearEffectMove extends DisappearEffect |
|
| 32 |
{
|
|
| 33 |
public int createEffects(int duration) |
|
| 34 |
{
|
|
| 35 |
mCubeEffectPosition = new int[] {2};
|
|
| 36 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 37 |
|
|
| 38 |
Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f); |
|
| 39 |
oldCube0.add(new Static3D( 0,0,0)); |
|
| 40 |
oldCube0.add(new Static3D(TEXTURE_SIZE,0,0)); |
|
| 41 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 42 |
|
|
| 43 |
return 1; |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 47 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 48 |
// Matrix Effects do not have to be enabled. |
|
| 49 |
|
|
| 50 |
@SuppressWarnings("unused")
|
|
| 51 |
static void enable() |
|
| 52 |
{
|
|
| 53 |
|
|
| 54 |
} |
|
| 55 |
} |
|
| 56 |
|
|
| src/main/java/org/distorted/effect/DisappearEffectRound.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 25 |
import org.distorted.library.type.Dynamic3D; |
|
| 26 |
import org.distorted.library.type.Static3D; |
|
| 27 |
|
|
| 28 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
class DisappearEffectRound extends DisappearEffect |
|
| 33 |
{
|
|
| 34 |
public int createEffects(int duration) |
|
| 35 |
{
|
|
| 36 |
mCubeEffectPosition = new int[] {2, 2};
|
|
| 37 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 38 |
|
|
| 39 |
Dynamic3D oldCube0 = new Dynamic3D(duration/2, 0.5f); |
|
| 40 |
oldCube0.add(new Static3D( 0,0,0)); |
|
| 41 |
oldCube0.add(new Static3D(TEXTURE_SIZE,0,0)); |
|
| 42 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 43 |
|
|
| 44 |
Dynamic3D oldCube1 = new Dynamic3D(duration/2, 0.5f); |
|
| 45 |
oldCube1.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
| 46 |
oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 47 |
mCubeEffects[1] = new MatrixEffectScale(oldCube1); |
|
| 48 |
|
|
| 49 |
return 2; |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 54 |
// Matrix Effects do not have to be enabled. |
|
| 55 |
|
|
| 56 |
@SuppressWarnings("unused")
|
|
| 57 |
static void enable() |
|
| 58 |
{
|
|
| 59 |
|
|
| 60 |
} |
|
| 61 |
} |
|
| 62 |
|
|
| src/main/java/org/distorted/effect/DisappearEffectScale.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class DisappearEffectScale extends DisappearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {5};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f); |
|
| 37 |
oldCube0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
| 38 |
oldCube0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 39 |
mCubeEffects[0] = new MatrixEffectScale(oldCube0); |
|
| 40 |
|
|
| 41 |
return 1; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 46 |
// Matrix Effects do not have to be enabled. |
|
| 47 |
|
|
| 48 |
@SuppressWarnings("unused")
|
|
| 49 |
static void enable() |
|
| 50 |
{
|
|
| 51 |
|
|
| 52 |
} |
|
| 53 |
} |
|
| 54 |
|
|
| src/main/java/org/distorted/effect/DisappearEffectTransparency.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
| 24 |
import org.distorted.library.type.Dynamic1D; |
|
| 25 |
import org.distorted.library.type.Static1D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class DisappearEffectTransparency extends DisappearEffect |
|
| 30 |
{
|
|
| 31 |
public int createEffects(int duration) |
|
| 32 |
{
|
|
| 33 |
mCubeEffectPosition = new int[] {-1};
|
|
| 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
| 35 |
|
|
| 36 |
Dynamic1D oldCube0 = new Dynamic1D(duration, 0.5f); |
|
| 37 |
oldCube0.add(new Static1D(1.0f)); |
|
| 38 |
oldCube0.add(new Static1D(0.0f)); |
|
| 39 |
mCubeEffects[0] = new FragmentEffectAlpha(oldCube0); |
|
| 40 |
|
|
| 41 |
return 1; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 45 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
| 46 |
|
|
| 47 |
@SuppressWarnings("unused")
|
|
| 48 |
static void enable() |
|
| 49 |
{
|
|
| 50 |
FragmentEffectAlpha.enable(); |
|
| 51 |
} |
|
| 52 |
} |
|
| src/main/java/org/distorted/effect/TransitionEffect.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.main.DistortedScreen; |
|
| 24 |
import org.distorted.library.message.EffectListener; |
|
| 25 |
import org.distorted.library.message.EffectMessage; |
|
| 26 |
import org.distorted.magic.RubikCube; |
|
| 27 |
|
|
| 28 |
import java.lang.reflect.Method; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
public abstract class TransitionEffect implements EffectListener |
|
| 33 |
{
|
|
| 34 |
public enum Type |
|
| 35 |
{
|
|
| 36 |
EMPTY (TransitionEffectEmpty.class ), |
|
| 37 |
DISAPPEAR (TransitionEffectDisappear.class), |
|
| 38 |
MOVE (TransitionEffectMove.class ), |
|
| 39 |
ROUND (TransitionEffectRound.class ), |
|
| 40 |
SCALE (TransitionEffectScale.class ), |
|
| 41 |
; |
|
| 42 |
|
|
| 43 |
private final Class<? extends TransitionEffect> effectClass; |
|
| 44 |
|
|
| 45 |
Type(Class<? extends TransitionEffect> effectClass) |
|
| 46 |
{
|
|
| 47 |
this.effectClass = effectClass; |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
private final int FAKE_EFFECT_ID = -1; |
|
| 52 |
|
|
| 53 |
private int mOldCubeEffectNumber , mNewCubeEffectNumber; |
|
| 54 |
private int mOldCubeEffectReturned, mNewCubeEffectReturned; |
|
| 55 |
|
|
| 56 |
private EffectListener mListener; |
|
| 57 |
private DistortedScreen mScreen; |
|
| 58 |
private RubikCube mOldCube, mNewCube; |
|
| 59 |
|
|
| 60 |
Effect[] mOldCubeEffects, mNewCubeEffects; |
|
| 61 |
int[] mOldCubeEffectPosition, mNewCubeEffectPosition; |
|
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 64 |
|
|
| 65 |
TransitionEffect() |
|
| 66 |
{
|
|
| 67 |
mOldCubeEffectReturned = 0; |
|
| 68 |
mNewCubeEffectReturned = 0; |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 72 |
|
|
| 73 |
public void effectMessage(final EffectMessage em, final long effectID, final long objectID) |
|
| 74 |
{
|
|
| 75 |
//android.util.Log.e("transition", "transition effect "+System.currentTimeMillis());
|
|
| 76 |
|
|
| 77 |
for(int i=0; i<mOldCubeEffectNumber; i++) |
|
| 78 |
{
|
|
| 79 |
long id = mOldCubeEffects[i].getID(); |
|
| 80 |
|
|
| 81 |
if( effectID == id ) |
|
| 82 |
{
|
|
| 83 |
//android.util.Log.e("transition", i+" old effect "+System.currentTimeMillis());
|
|
| 84 |
|
|
| 85 |
mOldCubeEffectReturned++; |
|
| 86 |
mOldCube.remove(id); |
|
| 87 |
|
|
| 88 |
if( mOldCubeEffectReturned == mOldCubeEffectNumber ) |
|
| 89 |
{
|
|
| 90 |
mScreen.detach(mOldCube); |
|
| 91 |
mOldCube.deregisterForMessages(this); |
|
| 92 |
|
|
| 93 |
for(int j=0; j<mOldCubeEffectNumber; j++) |
|
| 94 |
{
|
|
| 95 |
mNewCube.apply(mNewCubeEffects[j],mNewCubeEffectPosition[j]); |
|
| 96 |
} |
|
| 97 |
mScreen.attach(mNewCube); |
|
| 98 |
} |
|
| 99 |
break; |
|
| 100 |
} |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
for(int i=0; i<mNewCubeEffectNumber; i++) |
|
| 104 |
{
|
|
| 105 |
long id = mNewCubeEffects[i].getID(); |
|
| 106 |
|
|
| 107 |
if( effectID == id ) |
|
| 108 |
{
|
|
| 109 |
//android.util.Log.e("transition", i+" new effect "+System.currentTimeMillis());
|
|
| 110 |
|
|
| 111 |
mNewCubeEffectReturned++; |
|
| 112 |
mNewCube.remove(id); |
|
| 113 |
|
|
| 114 |
if( mNewCubeEffectReturned == mNewCubeEffectNumber ) |
|
| 115 |
{
|
|
| 116 |
mNewCube.deregisterForMessages(this); |
|
| 117 |
mListener.effectMessage(null, FAKE_EFFECT_ID, 0); |
|
| 118 |
} |
|
| 119 |
break; |
|
| 120 |
} |
|
| 121 |
} |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 125 |
|
|
| 126 |
public long start(DistortedScreen screen, RubikCube oldCube, RubikCube newCube,EffectListener listener) |
|
| 127 |
{
|
|
| 128 |
mScreen = screen; |
|
| 129 |
mNewCube = newCube; |
|
| 130 |
mOldCube = oldCube; |
|
| 131 |
mListener = listener; |
|
| 132 |
|
|
| 133 |
if( mOldCubeEffects!=null ) |
|
| 134 |
{
|
|
| 135 |
mOldCubeEffectNumber = mOldCubeEffects.length; |
|
| 136 |
} |
|
| 137 |
else |
|
| 138 |
{
|
|
| 139 |
throw new RuntimeException("Old Cube Effects not created!");
|
|
| 140 |
} |
|
| 141 |
|
|
| 142 |
if( mNewCubeEffects!=null ) |
|
| 143 |
{
|
|
| 144 |
mNewCubeEffectNumber = mNewCubeEffects.length; |
|
| 145 |
} |
|
| 146 |
else |
|
| 147 |
{
|
|
| 148 |
throw new RuntimeException("New Cube Effects not created!");
|
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
for(int i=0; i<mOldCubeEffectNumber; i++) |
|
| 152 |
{
|
|
| 153 |
mOldCube.apply(mOldCubeEffects[i],mOldCubeEffectPosition[i]); |
|
| 154 |
} |
|
| 155 |
|
|
| 156 |
mOldCube.registerForMessages(this); |
|
| 157 |
mNewCube.registerForMessages(this); |
|
| 158 |
|
|
| 159 |
return FAKE_EFFECT_ID; |
|
| 160 |
} |
|
| 161 |
|
|
| 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 163 |
|
|
| 164 |
public static TransitionEffect create(Type type) throws InstantiationException, IllegalAccessException |
|
| 165 |
{
|
|
| 166 |
return type.effectClass.newInstance(); |
|
| 167 |
} |
|
| 168 |
|
|
| 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 170 |
|
|
| 171 |
public static void enableEffects() |
|
| 172 |
{
|
|
| 173 |
Method method=null; |
|
| 174 |
|
|
| 175 |
for(Type type: Type.values()) |
|
| 176 |
{
|
|
| 177 |
Class<? extends TransitionEffect> cls = type.effectClass; |
|
| 178 |
|
|
| 179 |
try |
|
| 180 |
{
|
|
| 181 |
method = cls.getMethod("enable");
|
|
| 182 |
} |
|
| 183 |
catch(NoSuchMethodException ex) |
|
| 184 |
{
|
|
| 185 |
android.util.Log.e("transitionEffect", "exception getting method: "+ex.getMessage());
|
|
| 186 |
} |
|
| 187 |
|
|
| 188 |
try |
|
| 189 |
{
|
|
| 190 |
method.invoke(null); |
|
| 191 |
} |
|
| 192 |
catch(Exception ex) |
|
| 193 |
{
|
|
| 194 |
android.util.Log.e("transitionEffect", "exception invoking method: "+ex.getMessage());
|
|
| 195 |
} |
|
| 196 |
} |
|
| 197 |
} |
|
| 198 |
} |
|
| src/main/java/org/distorted/effect/TransitionEffectDisappear.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.FragmentEffectAlpha; |
|
| 24 |
import org.distorted.library.type.Dynamic1D; |
|
| 25 |
import org.distorted.library.type.Static1D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class TransitionEffectDisappear extends TransitionEffect |
|
| 30 |
{
|
|
| 31 |
TransitionEffectDisappear() |
|
| 32 |
{
|
|
| 33 |
final int DURATION_IN_MILLIS = 1000; |
|
| 34 |
|
|
| 35 |
mOldCubeEffectPosition = new int[] {-1};
|
|
| 36 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
| 37 |
|
|
| 38 |
Dynamic1D oldCube0 = new Dynamic1D(DURATION_IN_MILLIS, 0.5f); |
|
| 39 |
oldCube0.add(new Static1D(1.0f)); |
|
| 40 |
oldCube0.add(new Static1D(0.0f)); |
|
| 41 |
mOldCubeEffects[0] = new FragmentEffectAlpha(oldCube0); |
|
| 42 |
|
|
| 43 |
mNewCubeEffectPosition = new int[] {-1};
|
|
| 44 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
| 45 |
|
|
| 46 |
Dynamic1D newCube0 = new Dynamic1D(DURATION_IN_MILLIS, 0.5f); |
|
| 47 |
newCube0.add(new Static1D(0.0f)); |
|
| 48 |
newCube0.add(new Static1D(1.0f)); |
|
| 49 |
mNewCubeEffects[0] = new FragmentEffectAlpha(newCube0); |
|
| 50 |
} |
|
| 51 |
|
|
| 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 53 |
// enable all effects used in this Transition. |
|
| 54 |
// called by reflection from the parent class. |
|
| 55 |
|
|
| 56 |
@SuppressWarnings("unused")
|
|
| 57 |
static void enable() |
|
| 58 |
{
|
|
| 59 |
FragmentEffectAlpha.enable(); |
|
| 60 |
} |
|
| 61 |
} |
|
| src/main/java/org/distorted/effect/TransitionEffectEmpty.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class TransitionEffectEmpty extends TransitionEffect |
|
| 30 |
{
|
|
| 31 |
TransitionEffectEmpty() |
|
| 32 |
{
|
|
| 33 |
final int DURATION_IN_MILLIS = 1; |
|
| 34 |
|
|
| 35 |
mOldCubeEffectPosition = new int[] {-1};
|
|
| 36 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
| 37 |
|
|
| 38 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 39 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 40 |
mOldCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 41 |
|
|
| 42 |
mNewCubeEffectPosition = new int[] {-1};
|
|
| 43 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
| 44 |
|
|
| 45 |
Dynamic3D newCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 46 |
newCube0.add(new Static3D(0,0,0)); |
|
| 47 |
mNewCubeEffects[0] = new MatrixEffectMove(newCube0); |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 51 |
// enable all effects used in this Transition (here: none). |
|
| 52 |
// called by reflection from the parent class. |
|
| 53 |
|
|
| 54 |
@SuppressWarnings("unused")
|
|
| 55 |
static void enable() |
|
| 56 |
{
|
|
| 57 |
|
|
| 58 |
} |
|
| 59 |
} |
|
| src/main/java/org/distorted/effect/TransitionEffectMove.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 28 |
|
|
| 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 30 |
|
|
| 31 |
class TransitionEffectMove extends TransitionEffect |
|
| 32 |
{
|
|
| 33 |
TransitionEffectMove() |
|
| 34 |
{
|
|
| 35 |
final int DURATION_IN_MILLIS = 1000; |
|
| 36 |
|
|
| 37 |
mOldCubeEffectPosition = new int[] {2};
|
|
| 38 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
| 39 |
|
|
| 40 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 41 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 42 |
oldCube0.add(new Static3D(TEXTURE_SIZE,0,0)); |
|
| 43 |
mOldCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 44 |
|
|
| 45 |
mNewCubeEffectPosition = new int[] {2};
|
|
| 46 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
| 47 |
|
|
| 48 |
Dynamic3D newCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 49 |
newCube0.add(new Static3D(-TEXTURE_SIZE,0,0)); |
|
| 50 |
newCube0.add(new Static3D(0,0,0)); |
|
| 51 |
mNewCubeEffects[0] = new MatrixEffectMove(newCube0); |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 55 |
// enable all effects used in this Transition. Called by reflection from the parent class. |
|
| 56 |
// Matrix Effects do not have to be enabled. |
|
| 57 |
|
|
| 58 |
@SuppressWarnings("unused")
|
|
| 59 |
static void enable() |
|
| 60 |
{
|
|
| 61 |
|
|
| 62 |
} |
|
| 63 |
} |
|
| 64 |
|
|
| src/main/java/org/distorted/effect/TransitionEffectRound.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 24 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 25 |
import org.distorted.library.type.Dynamic3D; |
|
| 26 |
import org.distorted.library.type.Static3D; |
|
| 27 |
|
|
| 28 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
| 29 |
|
|
| 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 31 |
|
|
| 32 |
class TransitionEffectRound extends TransitionEffect |
|
| 33 |
{
|
|
| 34 |
TransitionEffectRound() |
|
| 35 |
{
|
|
| 36 |
final int DURATION_IN_MILLIS = 10000; |
|
| 37 |
|
|
| 38 |
mOldCubeEffectPosition = new int[] {2, 2};
|
|
| 39 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
| 40 |
|
|
| 41 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 42 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 43 |
oldCube0.add(new Static3D(TEXTURE_SIZE,0,0)); |
|
| 44 |
oldCube0.add(new Static3D(0,0,0)); |
|
| 45 |
mOldCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
| 46 |
|
|
| 47 |
Dynamic3D oldCube1 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 48 |
oldCube1.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
| 49 |
oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 50 |
mOldCubeEffects[1] = new MatrixEffectScale(oldCube1); |
|
| 51 |
|
|
| 52 |
|
|
| 53 |
mNewCubeEffectPosition = new int[] {2, 2};
|
|
| 54 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
| 55 |
|
|
| 56 |
Dynamic3D newCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 57 |
newCube0.add(new Static3D(0,0,0)); |
|
| 58 |
newCube0.add(new Static3D(-TEXTURE_SIZE,0,0)); |
|
| 59 |
newCube0.add(new Static3D(0,0,0)); |
|
| 60 |
mNewCubeEffects[0] = new MatrixEffectMove(newCube0); |
|
| 61 |
|
|
| 62 |
Dynamic3D newCube1 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 63 |
newCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
| 64 |
newCube1.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
| 65 |
mNewCubeEffects[1] = new MatrixEffectScale(newCube1); |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 69 |
// enable all effects used in this Transition. Called by reflection from the parent class. |
|
| 70 |
// Matrix Effects do not have to be enabled. |
|
| 71 |
|
|
| 72 |
@SuppressWarnings("unused")
|
|
| 73 |
static void enable() |
|
| 74 |
{
|
|
| 75 |
|
|
| 76 |
} |
|
| 77 |
} |
|
| 78 |
|
|
| src/main/java/org/distorted/effect/TransitionEffectScale.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 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.effect; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.effect.Effect; |
|
| 23 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 24 |
import org.distorted.library.type.Dynamic3D; |
|
| 25 |
import org.distorted.library.type.Static3D; |
|
| 26 |
|
|
| 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 28 |
|
|
| 29 |
class TransitionEffectScale extends TransitionEffect |
|
| 30 |
{
|
|
| 31 |
TransitionEffectScale() |
|
| 32 |
{
|
|
| 33 |
final int DURATION_IN_MILLIS = 1000; |
|
| 34 |
|
|
| 35 |
mOldCubeEffectPosition = new int[] {5};
|
|
| 36 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
| 37 |
|
|
| 38 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
| 39 |
oldCube0.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
Also available in: Unified diff
Major progress with DistortedCube:
- split transition effect into separate 'appear' and 'disappear' effects
- apply the 'appear' effects to a new cube being displayed at the start of the app
- remember cube size across activity restarts