Revision 086a24d0
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/effect/SizeChangeEffect.java | ||
---|---|---|
33 | 33 |
{ |
34 | 34 |
public enum Type |
35 | 35 |
{ |
36 |
NONE (SizeChangeEffectAppearNone.class , SizeChangeEffectDisappearNone.class ),
|
|
37 |
TRANSPARENCY (SizeChangeEffectAppearTransparency.class, SizeChangeEffectDisappearTransparency.class),
|
|
38 |
MOVE (SizeChangeEffectAppearMove.class , SizeChangeEffectDisappearMove.class ),
|
|
39 |
ROUND (SizeChangeEffectAppearRound.class , SizeChangeEffectDisappearRound.class ),
|
|
40 |
SCALE (SizeChangeEffectAppearScale.class , SizeChangeEffectDisappearScale.class ),
|
|
36 |
NONE (SizeChangeEffectNone.class ), |
|
37 |
TRANSPARENCY (SizeChangeEffectTransparency.class), |
|
38 |
MOVE (SizeChangeEffectMove.class ), |
|
39 |
ROUND (SizeChangeEffectRound.class ), |
|
40 |
SCALE (SizeChangeEffectScale.class ), |
|
41 | 41 |
; |
42 | 42 |
|
43 |
final Class<? extends SizeChangeEffectAppear > appear; |
|
44 |
final Class<? extends SizeChangeEffectDisappear> disappear; |
|
43 |
final Class<? extends SizeChangeEffect> effect; |
|
45 | 44 |
|
46 |
Type(Class<? extends SizeChangeEffectAppear> appear, Class<? extends SizeChangeEffectDisappear> disappear )
|
|
45 |
Type(Class<? extends SizeChangeEffect> effect)
|
|
47 | 46 |
{ |
48 |
this.appear = appear; |
|
49 |
this.disappear = disappear; |
|
47 |
this.effect= effect; |
|
50 | 48 |
} |
51 | 49 |
} |
52 | 50 |
|
53 | 51 |
private static int NUM_EFFECTS = Type.values().length; |
52 |
private static final int NUM_PHASES = 2; |
|
53 |
private static final int FAKE_EFFECT_ID = -1; |
|
54 | 54 |
private static final Type[] types; |
55 | 55 |
|
56 | 56 |
static |
... | ... | |
65 | 65 |
} |
66 | 66 |
|
67 | 67 |
private EffectListener mListener; |
68 |
private int mCubeEffectNumber, mNodeEffectNumber, mEffectFinished, mEffectReturned; |
|
69 |
private int mFakeEffectID; |
|
68 |
private int mDuration; |
|
69 |
private int[] mEffectReturned; |
|
70 |
private int[] mCubeEffectNumber, mNodeEffectNumber; |
|
71 |
private int[] mEffectFinished; |
|
72 |
private boolean[] mPhaseActive; |
|
70 | 73 |
|
71 |
RubikCube mCube; |
|
74 |
RubikCube[] mCube;
|
|
72 | 75 |
DistortedScreen mScreen; |
73 |
Effect[] mCubeEffects; |
|
74 |
int[] mCubeEffectPosition; |
|
75 |
Effect[] mNodeEffects; |
|
76 |
int[] mNodeEffectPosition; |
|
76 |
Effect[][] mCubeEffects;
|
|
77 |
int[][] mCubeEffectPosition;
|
|
78 |
Effect[][] mNodeEffects;
|
|
79 |
int[][] mNodeEffectPosition;
|
|
77 | 80 |
|
78 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
79 | 82 |
|
80 |
SizeChangeEffect(int id)
|
|
83 |
SizeChangeEffect() |
|
81 | 84 |
{ |
82 |
mEffectReturned = 0; |
|
83 |
mFakeEffectID = id; |
|
85 |
mPhaseActive = new boolean[NUM_PHASES]; |
|
86 |
mEffectReturned = new int[NUM_PHASES]; |
|
87 |
mCubeEffectNumber = new int[NUM_PHASES]; |
|
88 |
mNodeEffectNumber = new int[NUM_PHASES]; |
|
89 |
mEffectFinished = new int[NUM_PHASES]; |
|
90 |
mCubeEffectPosition = new int[NUM_PHASES][]; |
|
91 |
mNodeEffectPosition = new int[NUM_PHASES][]; |
|
92 |
mCubeEffects = new Effect[NUM_PHASES][]; |
|
93 |
mNodeEffects = new Effect[NUM_PHASES][]; |
|
94 |
mCube = new RubikCube[NUM_PHASES]; |
|
84 | 95 |
} |
85 | 96 |
|
86 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
106 | 117 |
|
107 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
108 | 119 |
|
109 |
abstract int createEffects(int duration); |
|
110 |
abstract void effectsEnd(); |
|
111 |
abstract void startEnd(); |
|
120 |
public static SizeChangeEffect create(Type type) throws InstantiationException, IllegalAccessException |
|
121 |
{ |
|
122 |
return type.effect.newInstance(); |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
abstract int createEffectsPhase0(int duration); |
|
128 |
abstract int createEffectsPhase1(int duration); |
|
112 | 129 |
|
113 | 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
114 | 131 |
|
115 | 132 |
public void effectFinished(final long effectID) |
116 | 133 |
{ |
117 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
134 |
if( mPhaseActive[0] ) effectFinishedPhase(effectID,0); |
|
135 |
if( mPhaseActive[1] ) effectFinishedPhase(effectID,1); |
|
136 |
} |
|
137 |
|
|
138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
139 |
|
|
140 |
private void effectFinishedPhase(final long effectID, int phase) |
|
141 |
{ |
|
142 |
for(int i=0; i<mCubeEffectNumber[phase]; i++) |
|
118 | 143 |
{ |
119 |
long id = mCubeEffects[i].getID(); |
|
144 |
long id = mCubeEffects[phase][i].getID();
|
|
120 | 145 |
|
121 | 146 |
if( effectID == id ) |
122 | 147 |
{ |
123 |
mEffectReturned++; |
|
124 |
|
|
125 |
if( mEffectReturned == mEffectFinished ) |
|
126 |
{ |
|
127 |
mListener.effectFinished(mFakeEffectID); |
|
128 |
} |
|
129 |
|
|
130 |
if( mEffectReturned == mCubeEffectNumber+mNodeEffectNumber ) |
|
131 |
{ |
|
132 |
effectsEnd(); |
|
133 |
} |
|
134 |
|
|
135 |
mCube.remove(id); |
|
136 |
break; |
|
148 |
effectReturned(phase); |
|
149 |
mCube[phase].remove(id); |
|
150 |
return; |
|
137 | 151 |
} |
138 | 152 |
} |
139 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
153 |
for(int i=0; i<mNodeEffectNumber[phase]; i++)
|
|
140 | 154 |
{ |
141 |
long id = mNodeEffects[i].getID(); |
|
155 |
long id = mNodeEffects[phase][i].getID();
|
|
142 | 156 |
|
143 | 157 |
if( effectID == id ) |
144 | 158 |
{ |
145 |
mEffectReturned++; |
|
159 |
effectReturned(phase); |
|
160 |
mCube[phase].getEffects().abortById(id); |
|
161 |
return; |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
146 | 165 |
|
147 |
if( mEffectReturned == mEffectFinished ) |
|
148 |
{ |
|
149 |
mListener.effectFinished(mFakeEffectID); |
|
150 |
} |
|
166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
151 | 167 |
|
152 |
if( mEffectReturned == mCubeEffectNumber+mNodeEffectNumber ) |
|
153 |
{ |
|
154 |
effectsEnd(); |
|
155 |
} |
|
168 |
private void effectReturned(int phase) |
|
169 |
{ |
|
170 |
mEffectReturned[phase]++; |
|
156 | 171 |
|
157 |
mCube.getEffects().abortById(id); |
|
158 |
break; |
|
172 |
if( mEffectReturned[phase] == mEffectFinished[phase] ) |
|
173 |
{ |
|
174 |
switch(phase) |
|
175 |
{ |
|
176 |
case 0: mPhaseActive[1] = true; |
|
177 |
mEffectFinished[1] = createEffectsPhase1(mDuration); |
|
178 |
assignEffects(1); |
|
179 |
mScreen.attach(mCube[1]); |
|
180 |
break; |
|
181 |
case 1: mListener.effectFinished(FAKE_EFFECT_ID); |
|
182 |
break; |
|
183 |
} |
|
184 |
} |
|
185 |
if( mEffectReturned[phase] == mCubeEffectNumber[phase]+mNodeEffectNumber[phase] ) |
|
186 |
{ |
|
187 |
switch(phase) |
|
188 |
{ |
|
189 |
case 0: mPhaseActive[0] = false; |
|
190 |
mScreen.detach(mCube[0]); |
|
191 |
break; |
|
192 |
case 1: mPhaseActive[1] = false; |
|
193 |
break; |
|
159 | 194 |
} |
160 | 195 |
} |
161 | 196 |
} |
162 | 197 |
|
163 | 198 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
164 | 199 |
|
165 |
public long start(int duration, DistortedScreen screen, RubikCube cube, EffectListener listener) |
|
200 |
public long start(int duration, DistortedScreen screen, RubikCube oldcube, RubikCube newcube, EffectListener listener)
|
|
166 | 201 |
{ |
167 | 202 |
mScreen = screen; |
168 |
mCube = cube; |
|
203 |
mCube[0] = oldcube; |
|
204 |
mCube[1] = newcube; |
|
169 | 205 |
mListener = listener; |
206 |
mDuration = duration; |
|
207 |
|
|
208 |
if( oldcube!=null ) |
|
209 |
{ |
|
210 |
mPhaseActive[0] = true; |
|
211 |
mEffectFinished[0] = createEffectsPhase0(mDuration); |
|
212 |
assignEffects(0); |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
mPhaseActive[1] = true; |
|
217 |
mEffectFinished[1] = createEffectsPhase1(mDuration); |
|
218 |
assignEffects(1); |
|
219 |
mScreen.attach(mCube[1]); |
|
220 |
} |
|
170 | 221 |
|
171 |
mEffectFinished = createEffects(duration); |
|
222 |
return FAKE_EFFECT_ID; |
|
223 |
} |
|
172 | 224 |
|
173 |
mCubeEffectNumber = ( mCubeEffects!=null ) ? mCubeEffects.length : 0; |
|
174 |
mNodeEffectNumber = ( mNodeEffects!=null ) ? mNodeEffects.length : 0; |
|
225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
226 |
|
|
227 |
private void assignEffects(int phase) |
|
228 |
{ |
|
229 |
mCubeEffectNumber[phase] = ( mCubeEffects[phase]!=null ) ? mCubeEffects[phase].length : 0; |
|
230 |
mNodeEffectNumber[phase] = ( mNodeEffects[phase]!=null ) ? mNodeEffects[phase].length : 0; |
|
175 | 231 |
|
176 |
if( mCubeEffectNumber==0 && mNodeEffectNumber==0 )
|
|
232 |
if( mCubeEffectNumber[phase]==0 && mNodeEffectNumber[phase]==0 )
|
|
177 | 233 |
{ |
178 |
throw new RuntimeException("Cube and Node Effects both not created!"); |
|
234 |
throw new RuntimeException("Cube and Node Effects ("+phase+" phase) both not created!");
|
|
179 | 235 |
} |
180 | 236 |
|
181 |
for(int i=0; i<mCubeEffectNumber; i++) |
|
237 |
for(int i=0; i<mCubeEffectNumber[phase]; i++)
|
|
182 | 238 |
{ |
183 |
mCube.apply(mCubeEffects[i],mCubeEffectPosition[i]);
|
|
184 |
mCubeEffects[i].notifyWhenFinished(this); |
|
239 |
mCube[phase].apply(mCubeEffects[phase][i],mCubeEffectPosition[phase][i]);
|
|
240 |
mCubeEffects[phase][i].notifyWhenFinished(this);
|
|
185 | 241 |
} |
186 | 242 |
|
187 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
243 |
DistortedEffects nodeEffects = mCube[phase].getEffects();
|
|
188 | 244 |
|
189 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
245 |
for(int i=0; i<mNodeEffectNumber[phase]; i++)
|
|
190 | 246 |
{ |
191 |
nodeEffects.apply(mNodeEffects[i],mNodeEffectPosition[i]);
|
|
192 |
mNodeEffects[i].notifyWhenFinished(this); |
|
247 |
nodeEffects.apply(mNodeEffects[phase][i],mNodeEffectPosition[phase][i]);
|
|
248 |
mNodeEffects[phase][i].notifyWhenFinished(this);
|
|
193 | 249 |
} |
194 |
|
|
195 |
startEnd(); |
|
196 |
|
|
197 |
return mFakeEffectID; |
|
198 | 250 |
} |
199 | 251 |
|
200 | 252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
207 | 259 |
{ |
208 | 260 |
try |
209 | 261 |
{ |
210 |
method = type.appear.getMethod("enable"); |
|
211 |
} |
|
212 |
catch(NoSuchMethodException ex) |
|
213 |
{ |
|
214 |
android.util.Log.e("SizeChangeEffect", "exception getting method: "+ex.getMessage()); |
|
215 |
} |
|
216 |
|
|
217 |
try |
|
218 |
{ |
|
219 |
method.invoke(null); |
|
220 |
} |
|
221 |
catch(Exception ex) |
|
222 |
{ |
|
223 |
android.util.Log.e("SizeChangeEffect", "exception invoking method: "+ex.getMessage()); |
|
224 |
} |
|
225 |
|
|
226 |
try |
|
227 |
{ |
|
228 |
method = type.disappear.getMethod("enable"); |
|
262 |
method = type.effect.getMethod("enable"); |
|
229 | 263 |
} |
230 | 264 |
catch(NoSuchMethodException ex) |
231 | 265 |
{ |
src/main/java/org/distorted/effect/SizeChangeEffectAppear.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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
public abstract class SizeChangeEffectAppear extends SizeChangeEffect |
|
25 |
{ |
|
26 |
SizeChangeEffectAppear() |
|
27 |
{ |
|
28 |
super(-1); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
public static SizeChangeEffectAppear create(Type type) throws InstantiationException, IllegalAccessException |
|
34 |
{ |
|
35 |
return type.appear.newInstance(); |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
|
40 |
void effectsEnd() |
|
41 |
{ |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
46 |
|
|
47 |
void startEnd() |
|
48 |
{ |
|
49 |
mScreen.attach(mCube); |
|
50 |
} |
|
51 |
} |
src/main/java/org/distorted/effect/SizeChangeEffectAppearMove.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 SizeChangeEffectAppearMove extends SizeChangeEffectAppear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
int w = mScreen.getWidth(); |
|
34 |
int h = mScreen.getHeight(); |
|
35 |
int xmove = w/2 + (w<h?w:h)/2; |
|
36 |
|
|
37 |
mNodeEffectPosition = new int[] {1}; |
|
38 |
mNodeEffects = new Effect[mNodeEffectPosition.length]; |
|
39 |
|
|
40 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
41 |
d0.add(new Static3D(-xmove,0,0)); |
|
42 |
d0.add(new Static3D( 0,0,0)); |
|
43 |
mNodeEffects[0] = new MatrixEffectMove(d0); |
|
44 |
|
|
45 |
return 1; |
|
46 |
} |
|
47 |
|
|
48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
50 |
// Matrix Effects do not have to be enabled. |
|
51 |
|
|
52 |
@SuppressWarnings("unused") |
|
53 |
static void enable() |
|
54 |
{ |
|
55 |
|
|
56 |
} |
|
57 |
} |
|
58 |
|
src/main/java/org/distorted/effect/SizeChangeEffectAppearNone.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 SizeChangeEffectAppearNone extends SizeChangeEffectAppear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition = new int[] {-1}; |
|
34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(1,0.5f); |
|
37 |
d0.add(new Static3D(0,0,0)); |
|
38 |
mCubeEffects[0] = new MatrixEffectMove(d0); |
|
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/SizeChangeEffectAppearRound.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.Dynamic; |
|
26 |
import org.distorted.library.type.Dynamic3D; |
|
27 |
import org.distorted.library.type.Static3D; |
|
28 |
|
|
29 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectAppearRound extends SizeChangeEffectAppear |
|
34 |
{ |
|
35 |
public int createEffects(int duration) |
|
36 |
{ |
|
37 |
float X = TEXTURE_SIZE/3; |
|
38 |
|
|
39 |
mCubeEffectPosition = new int[] {6,7}; |
|
40 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
41 |
|
|
42 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
43 |
d0.add(new Static3D( 0.01f, 0.01f, 0.01f)); |
|
44 |
d0.add(new Static3D( 1.00f, 1.00f, 1.00f)); |
|
45 |
mCubeEffects[0] = new MatrixEffectScale(d0); |
|
46 |
|
|
47 |
Dynamic3D d1 = new Dynamic3D(duration, 0.5f); |
|
48 |
d1.setMode(Dynamic.MODE_PATH); |
|
49 |
d1.add(new Static3D( 0, 0, 0)); |
|
50 |
d1.add(new Static3D(-X, 0, 0)); |
|
51 |
d1.add(new Static3D( 0, 0, 0)); |
|
52 |
mCubeEffects[1] = new MatrixEffectMove(d1); |
|
53 |
|
|
54 |
return 2; |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
59 |
// Matrix Effects do not have to be enabled. |
|
60 |
|
|
61 |
@SuppressWarnings("unused") |
|
62 |
static void enable() |
|
63 |
{ |
|
64 |
|
|
65 |
} |
|
66 |
} |
|
67 |
|
src/main/java/org/distorted/effect/SizeChangeEffectAppearScale.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 SizeChangeEffectAppearScale extends SizeChangeEffectAppear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition = new int[] {6}; |
|
34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
37 |
d0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
38 |
d0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
39 |
mCubeEffects[0] = new MatrixEffectScale(d0); |
|
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/SizeChangeEffectAppearTransparency.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.effect.VertexEffectWave; |
|
25 |
import org.distorted.library.type.Dynamic1D; |
|
26 |
import org.distorted.library.type.Dynamic5D; |
|
27 |
import org.distorted.library.type.Static1D; |
|
28 |
import org.distorted.library.type.Static3D; |
|
29 |
import org.distorted.library.type.Static5D; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectAppearTransparency extends SizeChangeEffectAppear |
|
34 |
{ |
|
35 |
public int createEffects(int duration) |
|
36 |
{ |
|
37 |
mCubeEffectPosition = new int[] {-1}; |
|
38 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
39 |
|
|
40 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f); |
|
41 |
d0.add(new Static1D(0.0f)); |
|
42 |
d0.add(new Static1D(1.0f)); |
|
43 |
mCubeEffects[0] = new FragmentEffectAlpha(d0); |
|
44 |
|
|
45 |
mNodeEffectPosition = new int[] {-1}; |
|
46 |
mNodeEffects = new Effect[mNodeEffectPosition.length]; |
|
47 |
|
|
48 |
int w = mScreen.getWidth(); |
|
49 |
int h = mScreen.getHeight(); |
|
50 |
int min = w<h ? w:h; |
|
51 |
|
|
52 |
float init_amplitude = min/15.0f; |
|
53 |
float end_amplitude = 0.0f; |
|
54 |
float length = min/15.0f; |
|
55 |
float init_phase = 0.0f; |
|
56 |
float end_phase = 360.0f; |
|
57 |
float alpha = 30.0f; |
|
58 |
float beta = 90.0f; |
|
59 |
|
|
60 |
Dynamic5D d1 = new Dynamic5D(duration, 0.5f); |
|
61 |
d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) ); |
|
62 |
d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) ); |
|
63 |
Static3D center = new Static3D(min*0.5f,min*0.5f,0); |
|
64 |
mNodeEffects[0] = new VertexEffectWave(d1, center, null); |
|
65 |
|
|
66 |
return 2; |
|
67 |
} |
|
68 |
|
|
69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
70 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
71 |
|
|
72 |
@SuppressWarnings("unused") |
|
73 |
static void enable() |
|
74 |
{ |
|
75 |
FragmentEffectAlpha.enable(); |
|
76 |
VertexEffectWave.enable(); |
|
77 |
} |
|
78 |
} |
src/main/java/org/distorted/effect/SizeChangeEffectDisappear.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 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
public abstract class SizeChangeEffectDisappear extends SizeChangeEffect |
|
25 |
{ |
|
26 |
SizeChangeEffectDisappear() |
|
27 |
{ |
|
28 |
super(-2); |
|
29 |
} |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
public static SizeChangeEffectDisappear create(Type type) throws InstantiationException, IllegalAccessException |
|
34 |
{ |
|
35 |
return type.disappear.newInstance(); |
|
36 |
} |
|
37 |
|
|
38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
|
40 |
void effectsEnd() |
|
41 |
{ |
|
42 |
mScreen.detach(mCube); |
|
43 |
} |
|
44 |
|
|
45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
46 |
|
|
47 |
void startEnd() |
|
48 |
{ |
|
49 |
|
|
50 |
} |
|
51 |
} |
src/main/java/org/distorted/effect/SizeChangeEffectDisappearMove.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 SizeChangeEffectDisappearMove extends SizeChangeEffectDisappear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
int w = mScreen.getWidth(); |
|
34 |
int h = mScreen.getHeight(); |
|
35 |
int xmove = w/2 + (w<h?w:h)/2; |
|
36 |
|
|
37 |
mNodeEffectPosition = new int[] {1}; |
|
38 |
mNodeEffects = new Effect[mNodeEffectPosition.length]; |
|
39 |
|
|
40 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
41 |
d0.add(new Static3D( 0,0,0)); |
|
42 |
d0.add(new Static3D(xmove,0,0)); |
|
43 |
mNodeEffects[0] = new MatrixEffectMove(d0); |
|
44 |
|
|
45 |
return 1; |
|
46 |
} |
|
47 |
|
|
48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
50 |
// Matrix Effects do not have to be enabled. |
|
51 |
|
|
52 |
@SuppressWarnings("unused") |
|
53 |
static void enable() |
|
54 |
{ |
|
55 |
|
|
56 |
} |
|
57 |
} |
|
58 |
|
src/main/java/org/distorted/effect/SizeChangeEffectDisappearNone.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 SizeChangeEffectDisappearNone extends SizeChangeEffectDisappear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition = new int[] {-1}; |
|
34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(1,0.5f); |
|
37 |
d0.add(new Static3D(0,0,0)); |
|
38 |
mCubeEffects[0] = new MatrixEffectMove(d0); |
|
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/SizeChangeEffectDisappearRound.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.Dynamic; |
|
26 |
import org.distorted.library.type.Dynamic3D; |
|
27 |
import org.distorted.library.type.Static3D; |
|
28 |
|
|
29 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectDisappearRound extends SizeChangeEffectDisappear |
|
34 |
{ |
|
35 |
public int createEffects(int duration) |
|
36 |
{ |
|
37 |
float X = TEXTURE_SIZE/3; |
|
38 |
|
|
39 |
mCubeEffectPosition = new int[] {6,7}; |
|
40 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
41 |
|
|
42 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
43 |
d0.add(new Static3D( 1.00f, 1.00f, 1.00f)); |
|
44 |
d0.add(new Static3D( 0.01f, 0.01f, 0.01f)); |
|
45 |
mCubeEffects[0] = new MatrixEffectScale(d0); |
|
46 |
|
|
47 |
Dynamic3D d1 = new Dynamic3D(duration, 0.5f); |
|
48 |
d1.setMode(Dynamic.MODE_PATH); |
|
49 |
d1.add(new Static3D( 0, 0, 0)); |
|
50 |
d1.add(new Static3D(+X, 0, 0)); |
|
51 |
d1.add(new Static3D( 0, 0, 0)); |
|
52 |
mCubeEffects[1] = new MatrixEffectMove(d1); |
|
53 |
|
|
54 |
return 2; |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
59 |
// Matrix Effects do not have to be enabled. |
|
60 |
|
|
61 |
@SuppressWarnings("unused") |
|
62 |
static void enable() |
|
63 |
{ |
|
64 |
|
|
65 |
} |
|
66 |
} |
|
67 |
|
src/main/java/org/distorted/effect/SizeChangeEffectDisappearScale.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 SizeChangeEffectDisappearScale extends SizeChangeEffectDisappear |
|
30 |
{ |
|
31 |
public int createEffects(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition = new int[] {6}; |
|
34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
37 |
d0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
38 |
d0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
39 |
mCubeEffects[0] = new MatrixEffectScale(d0); |
|
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/SizeChangeEffectDisappearTransparency.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.effect.VertexEffectWave; |
|
25 |
import org.distorted.library.type.Dynamic1D; |
|
26 |
import org.distorted.library.type.Dynamic5D; |
|
27 |
import org.distorted.library.type.Static1D; |
|
28 |
import org.distorted.library.type.Static3D; |
|
29 |
import org.distorted.library.type.Static5D; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectDisappearTransparency extends SizeChangeEffectDisappear |
|
34 |
{ |
|
35 |
public int createEffects(int duration) |
|
36 |
{ |
|
37 |
mCubeEffectPosition = new int[] {-1}; |
|
38 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
39 |
|
|
40 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f); |
|
41 |
d0.add(new Static1D(1.0f)); |
|
42 |
d0.add(new Static1D(0.0f)); |
|
43 |
mCubeEffects[0] = new FragmentEffectAlpha(d0); |
|
44 |
|
|
45 |
mNodeEffectPosition = new int[] {-1}; |
|
46 |
mNodeEffects = new Effect[mNodeEffectPosition.length]; |
|
47 |
|
|
48 |
int w = mScreen.getWidth(); |
|
49 |
int h = mScreen.getHeight(); |
|
50 |
int min = w<h ? w:h; |
|
51 |
|
|
52 |
float init_amplitude = 0.0f; |
|
53 |
float end_amplitude = min/15.0f; |
|
54 |
float length = min/15.0f; |
|
55 |
float init_phase = 360.0f; |
|
56 |
float end_phase = 0.0f; |
|
57 |
float alpha = 30.0f; |
|
58 |
float beta = 90.0f; |
|
59 |
|
|
60 |
Dynamic5D d1 = new Dynamic5D(duration, 0.5f); |
|
61 |
d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) ); |
|
62 |
d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) ); |
|
63 |
Static3D center = new Static3D(min*0.5f,min*0.5f,0); |
|
64 |
mNodeEffects[0] = new VertexEffectWave(d1, center, null); |
|
65 |
|
|
66 |
return 2; |
|
67 |
} |
|
68 |
|
|
69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
70 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
71 |
|
|
72 |
@SuppressWarnings("unused") |
|
73 |
static void enable() |
|
74 |
{ |
|
75 |
FragmentEffectAlpha.enable(); |
|
76 |
VertexEffectWave.enable(); |
|
77 |
} |
|
78 |
} |
src/main/java/org/distorted/effect/SizeChangeEffectMove.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 SizeChangeEffectMove extends SizeChangeEffect |
|
30 |
{ |
|
31 |
public int createEffectsPhase0(int duration) |
|
32 |
{ |
|
33 |
int w = mScreen.getWidth(); |
|
34 |
int h = mScreen.getHeight(); |
|
35 |
int xmove = w/2 + (w<h?w:h)/2; |
|
36 |
|
|
37 |
mNodeEffectPosition[0] = new int[] {1}; |
|
38 |
mNodeEffects[0] = new Effect[mNodeEffectPosition[0].length]; |
|
39 |
|
|
40 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
41 |
d0.add(new Static3D( 0,0,0)); |
|
42 |
d0.add(new Static3D(xmove,0,0)); |
|
43 |
mNodeEffects[0][0] = new MatrixEffectMove(d0); |
|
44 |
|
|
45 |
return 1; |
|
46 |
} |
|
47 |
|
|
48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
|
|
50 |
public int createEffectsPhase1(int duration) |
|
51 |
{ |
|
52 |
int w = mScreen.getWidth(); |
|
53 |
int h = mScreen.getHeight(); |
|
54 |
int xmove = w/2 + (w<h?w:h)/2; |
|
55 |
|
|
56 |
mNodeEffectPosition[1] = new int[] {1}; |
|
57 |
mNodeEffects[1] = new Effect[mNodeEffectPosition[1].length]; |
|
58 |
|
|
59 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
60 |
d0.add(new Static3D(-xmove,0,0)); |
|
61 |
d0.add(new Static3D( 0,0,0)); |
|
62 |
mNodeEffects[1][0] = new MatrixEffectMove(d0); |
|
63 |
|
|
64 |
return 1; |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
69 |
// Matrix Effects do not have to be enabled. |
|
70 |
|
|
71 |
@SuppressWarnings("unused") |
|
72 |
static void enable() |
|
73 |
{ |
|
74 |
|
|
75 |
} |
|
76 |
} |
|
77 |
|
src/main/java/org/distorted/effect/SizeChangeEffectNone.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 SizeChangeEffectNone extends SizeChangeEffect |
|
30 |
{ |
|
31 |
public int createEffectsPhase0(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition[0] = new int[] {-1}; |
|
34 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(1,0.5f); |
|
37 |
d0.add(new Static3D(0,0,0)); |
|
38 |
mCubeEffects[0][0] = new MatrixEffectMove(d0); |
|
39 |
|
|
40 |
return 1; |
|
41 |
} |
|
42 |
|
|
43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
44 |
|
|
45 |
public int createEffectsPhase1(int duration) |
|
46 |
{ |
|
47 |
mCubeEffectPosition[1] = new int[] {-1}; |
|
48 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
|
49 |
|
|
50 |
Dynamic3D d0 = new Dynamic3D(1,0.5f); |
|
51 |
d0.add(new Static3D(0,0,0)); |
|
52 |
mCubeEffects[1][0] = new MatrixEffectMove(d0); |
|
53 |
|
|
54 |
return 1; |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
// enable all effects used in this Appear (here: none). Called by reflection from the parent class. |
|
59 |
|
|
60 |
@SuppressWarnings("unused") |
|
61 |
static void enable() |
|
62 |
{ |
|
63 |
|
|
64 |
} |
|
65 |
} |
src/main/java/org/distorted/effect/SizeChangeEffectRound.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.Dynamic; |
|
26 |
import org.distorted.library.type.Dynamic3D; |
|
27 |
import org.distorted.library.type.Static3D; |
|
28 |
|
|
29 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectRound extends SizeChangeEffect |
|
34 |
{ |
|
35 |
public int createEffectsPhase0(int duration) |
|
36 |
{ |
|
37 |
float X = TEXTURE_SIZE/3; |
|
38 |
|
|
39 |
mCubeEffectPosition[0] = new int[] {6,7}; |
|
40 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
|
41 |
|
|
42 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
43 |
d0.add(new Static3D( 1.00f, 1.00f, 1.00f)); |
|
44 |
d0.add(new Static3D( 0.01f, 0.01f, 0.01f)); |
|
45 |
mCubeEffects[0][0] = new MatrixEffectScale(d0); |
|
46 |
|
|
47 |
Dynamic3D d1 = new Dynamic3D(duration, 0.5f); |
|
48 |
d1.setMode(Dynamic.MODE_PATH); |
|
49 |
d1.add(new Static3D( 0, 0, 0)); |
|
50 |
d1.add(new Static3D(+X, 0, 0)); |
|
51 |
d1.add(new Static3D( 0, 0, 0)); |
|
52 |
mCubeEffects[0][1] = new MatrixEffectMove(d1); |
|
53 |
|
|
54 |
return 2; |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
public int createEffectsPhase1(int duration) |
|
60 |
{ |
|
61 |
float X = TEXTURE_SIZE/3; |
|
62 |
|
|
63 |
mCubeEffectPosition[1] = new int[] {6,7}; |
|
64 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
|
65 |
|
|
66 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
67 |
d0.add(new Static3D( 0.01f, 0.01f, 0.01f)); |
|
68 |
d0.add(new Static3D( 1.00f, 1.00f, 1.00f)); |
|
69 |
mCubeEffects[1][0] = new MatrixEffectScale(d0); |
|
70 |
|
|
71 |
Dynamic3D d1 = new Dynamic3D(duration, 0.5f); |
|
72 |
d1.setMode(Dynamic.MODE_PATH); |
|
73 |
d1.add(new Static3D( 0, 0, 0)); |
|
74 |
d1.add(new Static3D(-X, 0, 0)); |
|
75 |
d1.add(new Static3D( 0, 0, 0)); |
|
76 |
mCubeEffects[1][1] = new MatrixEffectMove(d1); |
|
77 |
|
|
78 |
return 2; |
|
79 |
} |
|
80 |
|
|
81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
82 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
83 |
// Matrix Effects do not have to be enabled. |
|
84 |
|
|
85 |
@SuppressWarnings("unused") |
|
86 |
static void enable() |
|
87 |
{ |
|
88 |
|
|
89 |
} |
|
90 |
} |
|
91 |
|
src/main/java/org/distorted/effect/SizeChangeEffectScale.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 SizeChangeEffectScale extends SizeChangeEffect |
|
30 |
{ |
|
31 |
public int createEffectsPhase0(int duration) |
|
32 |
{ |
|
33 |
mCubeEffectPosition[0] = new int[] {6}; |
|
34 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
|
35 |
|
|
36 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
37 |
d0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
38 |
d0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
39 |
mCubeEffects[0][0] = new MatrixEffectScale(d0); |
|
40 |
|
|
41 |
return 1; |
|
42 |
} |
|
43 |
|
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
|
|
46 |
public int createEffectsPhase1(int duration) |
|
47 |
{ |
|
48 |
mCubeEffectPosition[1] = new int[] {6}; |
|
49 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
|
50 |
|
|
51 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
|
52 |
d0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
53 |
d0.add(new Static3D(1.00f, 1.00f, 1.00f)); |
|
54 |
mCubeEffects[1][0] = new MatrixEffectScale(d0); |
|
55 |
|
|
56 |
return 1; |
|
57 |
} |
|
58 |
|
|
59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
60 |
// Enable all effects used in this Appear. Called by reflection from the parent class. |
|
61 |
// Matrix Effects do not have to be enabled. |
|
62 |
|
|
63 |
@SuppressWarnings("unused") |
|
64 |
static void enable() |
|
65 |
{ |
|
66 |
|
|
67 |
} |
|
68 |
} |
|
69 |
|
src/main/java/org/distorted/effect/SizeChangeEffectTransparency.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.effect.VertexEffectWave; |
|
25 |
import org.distorted.library.type.Dynamic1D; |
|
26 |
import org.distorted.library.type.Dynamic5D; |
|
27 |
import org.distorted.library.type.Static1D; |
|
28 |
import org.distorted.library.type.Static3D; |
|
29 |
import org.distorted.library.type.Static5D; |
|
30 |
|
|
31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
|
33 |
class SizeChangeEffectTransparency extends SizeChangeEffect |
|
34 |
{ |
|
35 |
public int createEffectsPhase0(int duration) |
|
36 |
{ |
|
37 |
mCubeEffectPosition[0] = new int[] {-1}; |
|
38 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
|
39 |
|
|
40 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f); |
|
41 |
d0.add(new Static1D(1.0f)); |
|
42 |
d0.add(new Static1D(0.0f)); |
|
43 |
mCubeEffects[0][0] = new FragmentEffectAlpha(d0); |
|
44 |
|
|
45 |
mNodeEffectPosition[0] = new int[] {-1}; |
|
46 |
mNodeEffects[0] = new Effect[mNodeEffectPosition[0].length]; |
|
47 |
|
|
48 |
int w = mScreen.getWidth(); |
|
49 |
int h = mScreen.getHeight(); |
|
50 |
int min = w<h ? w:h; |
|
51 |
|
|
52 |
float init_amplitude = 0.0f; |
|
53 |
float end_amplitude = min/15.0f; |
|
54 |
float length = min/15.0f; |
|
55 |
float init_phase = 360.0f; |
|
56 |
float end_phase = 0.0f; |
|
57 |
float alpha = 30.0f; |
|
58 |
float beta = 90.0f; |
|
59 |
|
|
60 |
Dynamic5D d1 = new Dynamic5D(duration, 0.5f); |
|
61 |
d1.add(new Static5D( init_amplitude, length, init_phase, alpha, beta) ); |
|
62 |
d1.add(new Static5D( end_amplitude , length, end_phase , alpha, beta) ); |
|
63 |
Static3D center = new Static3D(min*0.5f,min*0.5f,0); |
|
64 |
mNodeEffects[0][0] = new VertexEffectWave(d1, center, null); |
|
65 |
|
|
66 |
return 2; |
|
67 |
} |
|
68 |
|
|
69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
70 |
|
|
71 |
public int createEffectsPhase1(int duration) |
|
72 |
{ |
|
73 |
mCubeEffectPosition[1] = new int[] {-1}; |
|
74 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
|
75 |
|
|
76 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f); |
Also available in: Unified diff
- simplify the Effects