Revision ac2ee4b3
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/control/RubikControlWhole.java | ||
---|---|---|
29 | 29 |
import org.distorted.library.main.DistortedScreen; |
30 | 30 |
import org.distorted.library.main.DistortedTexture; |
31 | 31 |
import org.distorted.library.mesh.MeshQuad; |
32 |
import org.distorted.library.message.EffectListener; |
|
32 | 33 |
import org.distorted.library.type.Dynamic; |
33 | 34 |
import org.distorted.library.type.Dynamic3D; |
34 | 35 |
import org.distorted.library.type.Static3D; |
... | ... | |
40 | 41 |
|
41 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 43 |
|
43 |
class RubikControlWhole |
|
44 |
class RubikControlWhole implements EffectListener
|
|
44 | 45 |
{ |
45 | 46 |
private static final int NUM_NODE = 4; |
46 | 47 |
private static final int NUM_EFFE = 4; |
... | ... | |
49 | 50 |
private DistortedEffects[] mEffects; |
50 | 51 |
private DistortedNode[] mNodes; |
51 | 52 |
private long mEffectID; |
53 |
private int mStageFinished, mWidth, mHeight; |
|
54 |
|
|
52 | 55 |
private MeshQuad mQuad; |
56 |
private DistortedTexture mTextureHand, mTextureShad, mTextureCirc; |
|
53 | 57 |
|
54 |
private Dynamic3D mDynamicHand1; |
|
55 |
private MatrixEffectMove mMoveHand1; |
|
58 |
private Dynamic3D mDynMoveHand1, mDynMoveShad1; |
|
59 |
private Dynamic3D mDynScaleHand1, mDynScaleShad1; |
|
60 |
private MatrixEffectMove mMoveHand1, mMoveShad1; |
|
61 |
private MatrixEffectScale mScaleHand1, mScaleShad1; |
|
56 | 62 |
|
57 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
58 | 64 |
|
... | ... | |
70 | 76 |
return null; |
71 | 77 |
} |
72 | 78 |
|
79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
80 |
|
|
81 |
private void createEffectsStage1() |
|
82 |
{ |
|
83 |
float x0 = mWidth*0.55f; |
|
84 |
float x1 = mWidth*0.45f; |
|
85 |
float x2 = mWidth*0.35f; |
|
86 |
float y1 = mHeight*0.28f; |
|
87 |
float z = 0; |
|
88 |
float d = mWidth*0.01f; |
|
89 |
float s = mWidth*0.33f; |
|
90 |
|
|
91 |
Static3D point0h = new Static3D(-x0 ,-y1 , z); |
|
92 |
Static3D point1h = new Static3D(-x1 ,-y1 , z); |
|
93 |
Static3D point2h = new Static3D(-x2 ,-y1 , z); |
|
94 |
Static3D point3h = new Static3D(-x2 +d,-y1 +d, z); |
|
95 |
Static3D point0s = new Static3D(-x0+2*d,-y1+2*d, z); |
|
96 |
Static3D point1s = new Static3D(-x1+2*d,-y1+2*d, z); |
|
97 |
Static3D point2s = new Static3D(-x2+2*d,-y1+2*d, z); |
|
98 |
Static3D point3s = new Static3D(-x2 +d,-y1 +d, z); |
|
99 |
|
|
100 |
Static3D pointSc = new Static3D(s,s,s); |
|
101 |
|
|
102 |
mDynMoveHand1.add(point0h); |
|
103 |
mDynMoveHand1.add(point1h); |
|
104 |
mDynMoveHand1.add(point2h); |
|
105 |
mDynMoveHand1.add(point2h); |
|
106 |
mDynMoveHand1.add(point3h); |
|
107 |
mDynMoveShad1.add(point0s); |
|
108 |
mDynMoveShad1.add(point1s); |
|
109 |
mDynMoveShad1.add(point2s); |
|
110 |
mDynMoveShad1.add(point2s); |
|
111 |
mDynMoveShad1.add(point3s); |
|
112 |
mDynScaleHand1.add(pointSc); |
|
113 |
mDynScaleShad1.add(pointSc); |
|
114 |
|
|
115 |
mStageFinished = 1; |
|
116 |
} |
|
117 |
|
|
118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
119 |
|
|
120 |
private void createEffectsStage2() |
|
121 |
{ |
|
122 |
float x2 = mWidth*0.35f; |
|
123 |
float y1 = mHeight*0.28f; |
|
124 |
float z = 0; |
|
125 |
float d = mWidth*0.01f; |
|
126 |
float sS = mWidth*0.0001f; |
|
127 |
float sF = mWidth*0.16f; |
|
128 |
|
|
129 |
Static3D point3h = new Static3D(-x2 +d,-y1 +d, z); |
|
130 |
Static3D scaleS = new Static3D(sS,sS,sS); |
|
131 |
Static3D scaleF = new Static3D(sF,sF,sF); |
|
132 |
|
|
133 |
mDynMoveHand1.removeAll(); |
|
134 |
mDynMoveHand1.add(point3h); |
|
135 |
mDynMoveShad1.removeAll(); |
|
136 |
mDynMoveShad1.add(point3h); |
|
137 |
mDynScaleShad1.removeAll(); |
|
138 |
mDynScaleShad1.add(scaleS); |
|
139 |
mDynScaleShad1.add(scaleF); |
|
140 |
mDynScaleShad1.resetToBeginning(); |
|
141 |
|
|
142 |
mNodes[0].changeInputSurface(mTextureCirc); |
|
143 |
|
|
144 |
mStageFinished = 2; |
|
145 |
} |
|
146 |
|
|
147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
148 |
|
|
149 |
private void reloadEffectsStage1() |
|
150 |
{ |
|
151 |
mDynMoveHand1.resetToBeginning(); |
|
152 |
mDynMoveShad1.resetToBeginning(); |
|
153 |
mMoveHand1.notifyWhenFinished(this); |
|
154 |
} |
|
155 |
|
|
73 | 156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 157 |
|
75 | 158 |
private void createEffects() |
... | ... | |
79 | 162 |
mEffects = new DistortedEffects[NUM_EFFE]; |
80 | 163 |
for(int i=0; i<NUM_EFFE; i++) mEffects[i]= new DistortedEffects(); |
81 | 164 |
|
82 |
DistortedScreen screen = mControl.getScreen(); |
|
83 |
int wid = screen.getWidth(); |
|
84 |
int hei = screen.getHeight(); |
|
85 |
|
|
86 |
float x1 = wid*0.35f; |
|
87 |
float y1 = hei*0.28f; |
|
88 |
float z = 0; |
|
89 |
float handScale = wid*0.33f; |
|
90 |
float circScale = handScale*0.5f; |
|
91 |
|
|
92 |
Static3D point0 = new Static3D(-x1,-y1,z); |
|
93 |
Static3D point1 = new Static3D( 0,-y1,z); |
|
94 |
Static3D point2 = new Static3D(+x1,-y1,z); |
|
95 |
Static3D point3 = new Static3D(+x1, 0,z); |
|
96 |
Static3D point4 = new Static3D(+x1,+y1,z); |
|
97 |
Static3D point5 = new Static3D( 0, 0,z); |
|
98 |
|
|
99 |
mDynamicHand1 = new Dynamic3D(15000,0.5f); |
|
100 |
mDynamicHand1.add(point0); |
|
101 |
mDynamicHand1.add(point0); |
|
102 |
mDynamicHand1.add(point1); |
|
103 |
mDynamicHand1.add(point2); |
|
104 |
mDynamicHand1.add(point2); |
|
105 |
mDynamicHand1.add(point3); |
|
106 |
mDynamicHand1.add(point4); |
|
107 |
mDynamicHand1.add(point4); |
|
108 |
mDynamicHand1.add(point5); |
|
109 |
mDynamicHand1.add(point0); |
|
110 |
mDynamicHand1.add(point0); |
|
111 |
mDynamicHand1.setMode(Dynamic.MODE_PATH); |
|
112 |
mDynamicHand1.setConvexity(0.0f); |
|
113 |
|
|
114 |
mMoveHand1 = new MatrixEffectMove(mDynamicHand1); |
|
115 |
mMoveHand1.notifyWhenFinished(mControl); |
|
116 |
mEffectID = mMoveHand1.getID(); |
|
117 |
|
|
118 |
mEffects[0].apply( new MatrixEffectScale(circScale)); |
|
119 |
mEffects[0].apply(mMoveHand1); |
|
120 |
mEffects[2].apply( new MatrixEffectScale(handScale)); |
|
165 |
int time = 3000; |
|
166 |
|
|
167 |
mDynMoveHand1 = new Dynamic3D(time,0.5f); |
|
168 |
mDynMoveHand1.setMode(Dynamic.MODE_PATH); |
|
169 |
mDynMoveHand1.setConvexity(0.0f); |
|
170 |
mDynMoveShad1 = new Dynamic3D(time,0.5f); |
|
171 |
mDynMoveShad1.setMode(Dynamic.MODE_PATH); |
|
172 |
mDynMoveShad1.setConvexity(0.0f); |
|
173 |
mDynScaleHand1 = new Dynamic3D(time,0.5f); |
|
174 |
mDynScaleHand1.setMode(Dynamic.MODE_PATH); |
|
175 |
mDynScaleHand1.setConvexity(0.0f); |
|
176 |
mDynScaleShad1 = new Dynamic3D(time,0.5f); |
|
177 |
mDynScaleShad1.setMode(Dynamic.MODE_PATH); |
|
178 |
mDynScaleShad1.setConvexity(0.0f); |
|
179 |
|
|
180 |
mMoveHand1 = new MatrixEffectMove(mDynMoveHand1); |
|
181 |
mMoveShad1 = new MatrixEffectMove(mDynMoveShad1); |
|
182 |
mScaleHand1= new MatrixEffectScale(mDynScaleHand1); |
|
183 |
mScaleShad1= new MatrixEffectScale(mDynScaleShad1); |
|
184 |
|
|
185 |
mMoveHand1.notifyWhenFinished(this); |
|
186 |
|
|
187 |
mEffects[0].apply(mScaleShad1); |
|
188 |
mEffects[0].apply(mMoveShad1); |
|
189 |
mEffects[2].apply(mScaleHand1); |
|
121 | 190 |
mEffects[2].apply(mMoveHand1); |
191 |
|
|
192 |
DistortedScreen screen = mControl.getScreen(); |
|
193 |
mWidth = screen.getWidth(); |
|
194 |
mHeight= screen.getHeight(); |
|
195 |
|
|
196 |
createEffectsStage1(); |
|
122 | 197 |
} |
123 |
else |
|
124 |
{ |
|
125 |
mDynamicHand1.resetToBeginning(); |
|
126 |
mMoveHand1.notifyWhenFinished(mControl); |
|
127 |
} |
|
198 |
else reloadEffectsStage1(); |
|
128 | 199 |
} |
129 | 200 |
|
130 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
142 | 213 |
if( act!=null ) |
143 | 214 |
{ |
144 | 215 |
Bitmap bmpCirc = openBitmap(act, R.drawable.ui_fading_circle); |
145 |
DistortedTexture textureCirc = new DistortedTexture(); |
|
146 |
textureCirc.setTexture(bmpCirc); |
|
147 |
mNodes[0]= new DistortedNode(textureCirc,mEffects[0],mQuad); |
|
148 |
mNodes[1]= new DistortedNode(textureCirc,mEffects[1],mQuad); |
|
149 |
|
|
216 |
Bitmap bmpShad = openBitmap(act, R.drawable.ui_hand_shadow); |
|
150 | 217 |
Bitmap bmpHand = openBitmap(act, R.drawable.ui_hand_pointer); |
151 |
DistortedTexture textureHand = new DistortedTexture(); |
|
152 |
textureHand.setTexture(bmpHand); |
|
153 |
mNodes[2]= new DistortedNode(textureHand,mEffects[2],mQuad); |
|
154 |
mNodes[3]= new DistortedNode(textureHand,mEffects[3],mQuad); |
|
218 |
|
|
219 |
mTextureCirc = new DistortedTexture(); |
|
220 |
mTextureCirc.setTexture(bmpCirc); |
|
221 |
mTextureShad = new DistortedTexture(); |
|
222 |
mTextureShad.setTexture(bmpShad); |
|
223 |
mTextureHand = new DistortedTexture(); |
|
224 |
mTextureHand.setTexture(bmpHand); |
|
225 |
|
|
226 |
mNodes[0]= new DistortedNode(mTextureShad,mEffects[0],mQuad); |
|
227 |
mNodes[1]= new DistortedNode(mTextureShad,mEffects[1],mQuad); |
|
228 |
mNodes[2]= new DistortedNode(mTextureHand,mEffects[2],mQuad); |
|
229 |
mNodes[3]= new DistortedNode(mTextureHand,mEffects[3],mQuad); |
|
155 | 230 |
} |
156 | 231 |
else |
157 | 232 |
{ |
... | ... | |
189 | 264 |
{ |
190 | 265 |
mControl = control; |
191 | 266 |
} |
267 |
|
|
268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
269 |
// PUBLIC |
|
270 |
|
|
271 |
public void effectFinished(long effectID) |
|
272 |
{ |
|
273 |
switch( mStageFinished ) |
|
274 |
{ |
|
275 |
case 1: createEffectsStage2(); |
|
276 |
break; |
|
277 |
case 2: mEffectID = -1; |
|
278 |
mControl.effectFinished(mEffectID); |
|
279 |
break; |
|
280 |
} |
|
281 |
} |
|
192 | 282 |
} |
Also available in: Unified diff
Progress with RubikControl - sub-stages 1 and 2 of the 'whole' stage finished.