8 |
8 |
import org.distorted.library.main.DistortedNode;
|
9 |
9 |
import org.distorted.library.main.DistortedScreen;
|
10 |
10 |
import org.distorted.library.main.DistortedTexture;
|
11 |
|
import org.distorted.library.main.InternalOutputSurface;
|
12 |
11 |
import org.distorted.library.mesh.MeshQuad;
|
13 |
12 |
import org.distorted.library.message.EffectListener;
|
14 |
|
import org.distorted.library.type.Dynamic;
|
15 |
13 |
import org.distorted.library.type.Dynamic2D;
|
16 |
|
import org.distorted.library.type.Dynamic3D;
|
17 |
14 |
import org.distorted.library.type.Dynamic4D;
|
18 |
15 |
import org.distorted.library.type.Static2D;
|
19 |
|
import org.distorted.library.type.Static3D;
|
20 |
16 |
import org.distorted.library.type.Static4D;
|
21 |
17 |
|
22 |
18 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
19 |
|
24 |
20 |
public class OverlayStars implements EffectListener
|
25 |
21 |
{
|
26 |
|
private static final int DUR_MOV = 4000;
|
27 |
22 |
private static final int DUR_GLO = 2000;
|
28 |
23 |
|
29 |
24 |
private static final int[] colors = new int[] {0,0,1, 1,0,1, 1,0,0, 1,1,0, 0,1,0, 1,1,1}; // blue, pink, red, yellow, green, white
|
... | ... | |
32 |
27 |
private DistortedNode mNode1, mNode2;
|
33 |
28 |
private DistortedScreen mScreen;
|
34 |
29 |
|
35 |
|
private float mWidth;
|
36 |
|
private long mMoveID, mGlowID;
|
37 |
|
|
38 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
40 |
|
private Dynamic3D createRandomMove()
|
41 |
|
{
|
42 |
|
Dynamic3D move = new Dynamic3D();
|
43 |
|
move.setMode(Dynamic.MODE_PATH);
|
44 |
|
move.setDuration(DUR_MOV);
|
45 |
|
move.setCount(0.5f);
|
46 |
|
|
47 |
|
Static3D pointS = new Static3D(0,-500,0);
|
48 |
|
Static3D pointE = new Static3D(0,0,0);
|
49 |
|
|
50 |
|
move.add(pointS);
|
51 |
|
move.add(pointE);
|
52 |
|
|
53 |
|
return move;
|
54 |
|
}
|
|
30 |
private long mGlowID;
|
55 |
31 |
|
56 |
32 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
57 |
33 |
|
... | ... | |
59 |
35 |
{
|
60 |
36 |
DistortedTexture texture = new DistortedTexture();
|
61 |
37 |
texture.setColorARGB(0xffff0000);
|
62 |
|
|
63 |
38 |
MeshQuad mesh = new MeshQuad();
|
64 |
|
|
65 |
39 |
DistortedEffects effects = new DistortedEffects();
|
66 |
40 |
|
67 |
|
float scaleP = mWidth*0.15f;
|
68 |
|
VertexEffectScale scaleE = new VertexEffectScale(scaleP);
|
69 |
|
scaleE.setMeshAssociation(1,-1);
|
70 |
|
effects.apply(scaleE);
|
71 |
|
|
72 |
|
Dynamic3D moveP = createRandomMove();
|
73 |
|
VertexEffectMove moveE= new VertexEffectMove(moveP);
|
74 |
|
moveE.setMeshAssociation(0,0);
|
75 |
|
effects.apply(moveE);
|
76 |
|
|
77 |
|
mMoveID = moveE.getID();
|
78 |
|
moveE.notifyWhenFinished(this);
|
79 |
|
|
80 |
41 |
return new DistortedNode(texture,effects,mesh);
|
81 |
42 |
}
|
82 |
43 |
|
... | ... | |
86 |
47 |
{
|
87 |
48 |
DistortedTexture texture = new DistortedTexture();
|
88 |
49 |
texture.setColorARGB(0xffff0000);
|
89 |
|
|
90 |
50 |
MeshQuad mesh = new MeshQuad();
|
91 |
|
|
92 |
51 |
DistortedEffects effects = new DistortedEffects();
|
93 |
|
|
94 |
|
float scaleM = mWidth*0.40f;
|
95 |
|
Static3D moveM= new Static3D(0,0,1);
|
96 |
|
|
97 |
|
VertexEffectMove mainMove = new VertexEffectMove(moveM);
|
98 |
|
VertexEffectScale mainScale= new VertexEffectScale(scaleM);
|
99 |
|
|
100 |
|
effects.apply(mainMove);
|
|
52 |
VertexEffectScale mainScale= new VertexEffectScale(200);
|
101 |
53 |
effects.apply(mainScale);
|
102 |
54 |
|
103 |
55 |
return new DistortedNode(texture,effects,mesh);
|
... | ... | |
108 |
60 |
public void startOverlay(DistortedScreen screen)
|
109 |
61 |
{
|
110 |
62 |
mScreen = screen;
|
111 |
|
mWidth = mScreen.getWidth();
|
112 |
|
|
113 |
63 |
mNode1 = createNode1();
|
114 |
|
mNode1.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
|
115 |
64 |
mScreen.attach(mNode1);
|
116 |
|
|
117 |
65 |
mNode2 = createNode2();
|
118 |
|
mNode2.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
|
119 |
66 |
mScreen.attach(mNode2);
|
120 |
67 |
}
|
121 |
68 |
|
... | ... | |
123 |
70 |
|
124 |
71 |
public void effectFinished(long id)
|
125 |
72 |
{
|
126 |
|
if( id==mMoveID )
|
127 |
|
{
|
128 |
|
Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
|
129 |
|
haloRadius.add(new Static2D( 0, 0));
|
130 |
|
haloRadius.add(new Static2D(15,50));
|
131 |
|
haloRadius.add(new Static2D( 0, 0));
|
132 |
|
|
133 |
|
Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
|
134 |
|
Static4D P1 = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
|
135 |
|
Static4D P2 = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
|
136 |
|
color.add(P1);
|
137 |
|
color.add(P2);
|
138 |
|
color.add(P1);
|
139 |
|
|
140 |
|
PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
|
141 |
|
glow.setQuality(EffectQuality.MEDIUM);
|
142 |
|
mGlowID = glow.getID();
|
143 |
|
glow.notifyWhenFinished(this);
|
144 |
|
DistortedEffects effects = mNode1.getEffects();
|
145 |
|
effects.apply(glow);
|
146 |
|
}
|
147 |
73 |
if( id==mGlowID )
|
148 |
74 |
{
|
149 |
75 |
mScreen.detach(mNode1);
|
... | ... | |
155 |
81 |
}
|
156 |
82 |
}
|
157 |
83 |
|
|
84 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
85 |
|
|
86 |
public void button2()
|
|
87 |
{
|
|
88 |
Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
|
|
89 |
haloRadius.add(new Static2D( 0, 0));
|
|
90 |
haloRadius.add(new Static2D(15,50));
|
|
91 |
haloRadius.add(new Static2D( 0, 0));
|
|
92 |
|
|
93 |
Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
|
|
94 |
Static4D P1 = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
|
|
95 |
Static4D P2 = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
|
|
96 |
color.add(P1);
|
|
97 |
color.add(P2);
|
|
98 |
color.add(P1);
|
|
99 |
|
|
100 |
PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
|
|
101 |
glow.setQuality(EffectQuality.MEDIUM);
|
|
102 |
mGlowID = glow.getID();
|
|
103 |
glow.notifyWhenFinished(this);
|
|
104 |
DistortedEffects effects = mNode1.getEffects();
|
|
105 |
effects.apply(glow);
|
|
106 |
}
|
|
107 |
|
158 |
108 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
159 |
109 |
|
160 |
110 |
@SuppressWarnings("unused")
|
simplify the crash app.