Revision 4fd9efa1
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/effect/AppearEffect.java | ||
---|---|---|
20 | 20 |
package org.distorted.effect; |
21 | 21 |
|
22 | 22 |
import org.distorted.library.effect.Effect; |
23 |
import org.distorted.library.main.DistortedEffects; |
|
23 | 24 |
import org.distorted.library.main.DistortedScreen; |
24 | 25 |
import org.distorted.library.message.EffectListener; |
25 | 26 |
import org.distorted.magic.RubikCube; |
... | ... | |
65 | 66 |
|
66 | 67 |
private final int FAKE_EFFECT_ID = -1; |
67 | 68 |
|
68 |
private int mCubeEffectNumber, mCubeEffectFinished, mCubeEffectReturned; |
|
69 |
|
|
70 | 69 |
private EffectListener mListener; |
71 |
private DistortedScreen mScreen; |
|
72 | 70 |
private RubikCube mCube; |
71 |
private int mCubeEffectNumber, mNodeEffectNumber, mEffectFinished, mEffectReturned; |
|
73 | 72 |
|
73 |
DistortedScreen mScreen; |
|
74 | 74 |
Effect[] mCubeEffects; |
75 | 75 |
int[] mCubeEffectPosition; |
76 |
Effect[] mNodeEffects; |
|
77 |
int[] mNodeEffectPosition; |
|
76 | 78 |
|
77 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
78 | 80 |
|
79 | 81 |
AppearEffect() |
80 | 82 |
{ |
81 |
mCubeEffectReturned = 0;
|
|
83 |
mEffectReturned = 0; |
|
82 | 84 |
} |
83 | 85 |
|
84 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
102 | 104 |
|
103 | 105 |
if( effectID == id ) |
104 | 106 |
{ |
105 |
mCubeEffectReturned++; |
|
106 |
|
|
107 |
if( mCubeEffectReturned == mCubeEffectFinished ) |
|
108 |
{ |
|
109 |
mListener.effectFinished(FAKE_EFFECT_ID); |
|
110 |
} |
|
111 |
|
|
107 |
effectReturned(); |
|
112 | 108 |
mCube.remove(id); |
113 | 109 |
break; |
114 | 110 |
} |
115 | 111 |
} |
112 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
113 |
{ |
|
114 |
long id = mNodeEffects[i].getID(); |
|
115 |
|
|
116 |
if( effectID == id ) |
|
117 |
{ |
|
118 |
effectReturned(); |
|
119 |
mCube.getEffects().abortById(id); |
|
120 |
break; |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
private void effectReturned() |
|
128 |
{ |
|
129 |
mEffectReturned++; |
|
130 |
|
|
131 |
if( mEffectReturned == mEffectFinished ) |
|
132 |
{ |
|
133 |
mListener.effectFinished(FAKE_EFFECT_ID); |
|
134 |
} |
|
116 | 135 |
} |
117 | 136 |
|
118 | 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
123 | 142 |
mCube = cube; |
124 | 143 |
mListener = listener; |
125 | 144 |
|
126 |
mCubeEffectFinished = createEffects(duration);
|
|
145 |
mEffectFinished = createEffects(duration); |
|
127 | 146 |
|
128 |
if( mCubeEffects!=null ) |
|
129 |
{ |
|
130 |
mCubeEffectNumber = mCubeEffects.length; |
|
131 |
} |
|
132 |
else |
|
147 |
mCubeEffectNumber = ( mCubeEffects!=null ) ? mCubeEffects.length : 0; |
|
148 |
mNodeEffectNumber = ( mNodeEffects!=null ) ? mNodeEffects.length : 0; |
|
149 |
|
|
150 |
if( mCubeEffectNumber==0 && mNodeEffectNumber==0 ) |
|
133 | 151 |
{ |
134 |
throw new RuntimeException("Appear Cube Effects not created!");
|
|
152 |
throw new RuntimeException("Cube and Node Effects both not created!");
|
|
135 | 153 |
} |
136 | 154 |
|
137 | 155 |
for(int i=0; i<mCubeEffectNumber; i++) |
... | ... | |
140 | 158 |
mCubeEffects[i].notifyWhenFinished(this); |
141 | 159 |
} |
142 | 160 |
|
161 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
162 |
|
|
163 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
164 |
{ |
|
165 |
nodeEffects.apply(mNodeEffects[i],mNodeEffectPosition[i]); |
|
166 |
mNodeEffects[i].notifyWhenFinished(this); |
|
167 |
} |
|
168 |
|
|
143 | 169 |
mScreen.attach(mCube); |
144 | 170 |
|
145 | 171 |
return FAKE_EFFECT_ID; |
src/main/java/org/distorted/effect/AppearEffectMove.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Dynamic3D; |
25 | 25 |
import org.distorted.library.type.Static3D; |
26 | 26 |
|
27 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
28 |
|
|
29 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 28 |
|
31 | 29 |
class AppearEffectMove extends AppearEffect |
32 | 30 |
{ |
33 | 31 |
public int createEffects(int duration) |
34 | 32 |
{ |
35 |
mCubeEffectPosition = new int[] {6}; |
|
36 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
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]; |
|
37 | 39 |
|
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);
|
|
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);
|
|
42 | 44 |
|
43 | 45 |
return 1; |
44 | 46 |
} |
src/main/java/org/distorted/effect/AppearEffectNone.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {-1}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 35 |
|
36 |
Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
|
|
37 |
oldCube0.add(new Static3D(0,0,0));
|
|
38 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0);
|
|
36 |
Dynamic3D d0 = new Dynamic3D(1,0.5f);
|
|
37 |
d0.add(new Static3D(0,0,0));
|
|
38 |
mCubeEffects[0] = new MatrixEffectMove(d0);
|
|
39 | 39 |
|
40 | 40 |
return 1; |
41 | 41 |
} |
src/main/java/org/distorted/effect/AppearEffectScale.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {6}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 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);
|
|
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 | 40 |
|
41 | 41 |
return 1; |
42 | 42 |
} |
src/main/java/org/distorted/effect/AppearEffectTransparency.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {-1}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 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);
|
|
36 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f);
|
|
37 |
d0.add(new Static1D(0.0f));
|
|
38 |
d0.add(new Static1D(1.0f));
|
|
39 |
mCubeEffects[0] = new FragmentEffectAlpha(d0);
|
|
40 | 40 |
|
41 | 41 |
return 1; |
42 | 42 |
} |
src/main/java/org/distorted/effect/DisappearEffect.java | ||
---|---|---|
20 | 20 |
package org.distorted.effect; |
21 | 21 |
|
22 | 22 |
import org.distorted.library.effect.Effect; |
23 |
import org.distorted.library.main.DistortedEffects; |
|
23 | 24 |
import org.distorted.library.main.DistortedScreen; |
24 | 25 |
import org.distorted.library.message.EffectListener; |
25 | 26 |
import org.distorted.magic.RubikCube; |
... | ... | |
65 | 66 |
|
66 | 67 |
private final int FAKE_EFFECT_ID = -2; |
67 | 68 |
|
68 |
private int mCubeEffectNumber, mCubeEffectFinished, mCubeEffectReturned; |
|
69 |
|
|
70 | 69 |
private EffectListener mListener; |
71 |
private DistortedScreen mScreen; |
|
72 | 70 |
private RubikCube mCube; |
71 |
private int mCubeEffectNumber, mNodeEffectNumber, mEffectFinished, mEffectReturned; |
|
73 | 72 |
|
73 |
DistortedScreen mScreen; |
|
74 | 74 |
Effect[] mCubeEffects; |
75 | 75 |
int[] mCubeEffectPosition; |
76 |
Effect[] mNodeEffects; |
|
77 |
int[] mNodeEffectPosition; |
|
76 | 78 |
|
77 | 79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
78 | 80 |
|
79 | 81 |
DisappearEffect() |
80 | 82 |
{ |
81 |
mCubeEffectReturned = 0;
|
|
83 |
mEffectReturned = 0; |
|
82 | 84 |
} |
83 | 85 |
|
84 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
102 | 104 |
|
103 | 105 |
if( effectID == id ) |
104 | 106 |
{ |
105 |
mCubeEffectReturned++; |
|
106 |
|
|
107 |
if( mCubeEffectReturned == mCubeEffectFinished ) |
|
108 |
{ |
|
109 |
mListener.effectFinished(FAKE_EFFECT_ID); |
|
110 |
} |
|
111 |
|
|
112 |
if( mCubeEffectReturned == mCubeEffectNumber ) |
|
113 |
{ |
|
114 |
mScreen.detach(mCube); |
|
115 |
} |
|
116 |
|
|
107 |
effectReturned(); |
|
117 | 108 |
mCube.remove(id); |
118 | 109 |
break; |
119 | 110 |
} |
120 | 111 |
} |
112 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
113 |
{ |
|
114 |
long id = mNodeEffects[i].getID(); |
|
115 |
|
|
116 |
if( effectID == id ) |
|
117 |
{ |
|
118 |
effectReturned(); |
|
119 |
mCube.getEffects().abortById(id); |
|
120 |
break; |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
private void effectReturned() |
|
128 |
{ |
|
129 |
mEffectReturned++; |
|
130 |
|
|
131 |
if( mEffectReturned == mEffectFinished ) |
|
132 |
{ |
|
133 |
mListener.effectFinished(FAKE_EFFECT_ID); |
|
134 |
} |
|
135 |
|
|
136 |
if( mEffectReturned == mCubeEffectNumber+mNodeEffectNumber ) |
|
137 |
{ |
|
138 |
mScreen.detach(mCube); |
|
139 |
} |
|
121 | 140 |
} |
122 | 141 |
|
123 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
128 | 147 |
mCube = cube; |
129 | 148 |
mListener = listener; |
130 | 149 |
|
131 |
mCubeEffectFinished = createEffects(duration);
|
|
150 |
mEffectFinished = createEffects(duration); |
|
132 | 151 |
|
133 |
if( mCubeEffects!=null ) |
|
134 |
{ |
|
135 |
mCubeEffectNumber = mCubeEffects.length; |
|
136 |
} |
|
137 |
else |
|
152 |
mCubeEffectNumber = ( mCubeEffects!=null ) ? mCubeEffects.length : 0; |
|
153 |
mNodeEffectNumber = ( mNodeEffects!=null ) ? mNodeEffects.length : 0; |
|
154 |
|
|
155 |
if( mCubeEffectNumber==0 && mNodeEffectNumber==0 ) |
|
138 | 156 |
{ |
139 |
throw new RuntimeException("Disappear Cube Effects not created!");
|
|
157 |
throw new RuntimeException("Cube and Node Effects both not created!");
|
|
140 | 158 |
} |
141 | 159 |
|
142 | 160 |
for(int i=0; i<mCubeEffectNumber; i++) |
... | ... | |
145 | 163 |
mCubeEffects[i].notifyWhenFinished(this); |
146 | 164 |
} |
147 | 165 |
|
166 |
DistortedEffects nodeEffects = mCube.getEffects(); |
|
167 |
|
|
168 |
for(int i=0; i<mNodeEffectNumber; i++) |
|
169 |
{ |
|
170 |
nodeEffects.apply(mNodeEffects[i],mNodeEffectPosition[i]); |
|
171 |
mNodeEffects[i].notifyWhenFinished(this); |
|
172 |
} |
|
173 |
|
|
148 | 174 |
return FAKE_EFFECT_ID; |
149 | 175 |
} |
150 | 176 |
|
src/main/java/org/distorted/effect/DisappearEffectMove.java | ||
---|---|---|
24 | 24 |
import org.distorted.library.type.Dynamic3D; |
25 | 25 |
import org.distorted.library.type.Static3D; |
26 | 26 |
|
27 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
28 |
|
|
29 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 28 |
|
31 | 29 |
class DisappearEffectMove extends DisappearEffect |
32 | 30 |
{ |
33 | 31 |
public int createEffects(int duration) |
34 | 32 |
{ |
35 |
mCubeEffectPosition = new int[] {6}; |
|
36 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
|
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]; |
|
37 | 39 |
|
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);
|
|
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);
|
|
42 | 44 |
|
43 | 45 |
return 1; |
44 | 46 |
} |
src/main/java/org/distorted/effect/DisappearEffectNone.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {-1}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 35 |
|
36 |
Dynamic3D oldCube0 = new Dynamic3D(1,0.5f);
|
|
37 |
oldCube0.add(new Static3D(0,0,0));
|
|
38 |
mCubeEffects[0] = new MatrixEffectMove(oldCube0);
|
|
36 |
Dynamic3D d0 = new Dynamic3D(1,0.5f);
|
|
37 |
d0.add(new Static3D(0,0,0));
|
|
38 |
mCubeEffects[0] = new MatrixEffectMove(d0);
|
|
39 | 39 |
|
40 | 40 |
return 1; |
41 | 41 |
} |
src/main/java/org/distorted/effect/DisappearEffectScale.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {6}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 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);
|
|
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 | 40 |
|
41 | 41 |
return 1; |
42 | 42 |
} |
src/main/java/org/distorted/effect/DisappearEffectTransparency.java | ||
---|---|---|
33 | 33 |
mCubeEffectPosition = new int[] {-1}; |
34 | 34 |
mCubeEffects = new Effect[mCubeEffectPosition.length]; |
35 | 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);
|
|
36 |
Dynamic1D d0 = new Dynamic1D(duration, 0.5f);
|
|
37 |
d0.add(new Static1D(1.0f));
|
|
38 |
d0.add(new Static1D(0.0f));
|
|
39 |
mCubeEffects[0] = new FragmentEffectAlpha(d0);
|
|
40 | 40 |
|
41 | 41 |
return 1; |
42 | 42 |
} |
Also available in: Unified diff
Add support for separate Cube and Node effects.