Revision 0a098d35
Added by Leszek Koltunski about 6 years ago
src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java | ||
---|---|---|
56 | 56 |
private DistortedTexture mLeaf; |
57 | 57 |
private DistortedScreen mScreen; |
58 | 58 |
private int mScreenW, mScreenH; |
59 |
private Static3D mMove, mInnerScale, mOuterScale;
|
|
60 |
private Static1D mRadiusSta;
|
|
59 |
private Static3D mMove, mScale; |
|
60 |
private Static1D mRadius; |
|
61 | 61 |
|
62 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 63 |
|
... | ... | |
65 | 65 |
{ |
66 | 66 |
mView = v; |
67 | 67 |
|
68 |
mScreenW = 9*LEAF_SIZE;
|
|
69 |
mScreenH = 9*LEAF_SIZE;
|
|
68 |
final int OUTER = 9;
|
|
69 |
final int INNER = 4;
|
|
70 | 70 |
|
71 |
mRadiusSta = new Static1D(5); |
|
71 |
mScreenW = OUTER*LEAF_SIZE; |
|
72 |
mScreenH = OUTER*LEAF_SIZE; |
|
73 |
|
|
74 |
mRadius = new Static1D(5); |
|
72 | 75 |
Dynamic1D radiusDyn = new Dynamic1D(); |
73 |
radiusDyn.add(mRadiusSta); |
|
76 |
radiusDyn.add(mRadius); |
|
77 |
PostprocessEffectBlur blurEffect = new PostprocessEffectBlur(radiusDyn); |
|
74 | 78 |
|
75 | 79 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE); |
76 | 80 |
|
77 | 81 |
MeshFlat mesh = new MeshFlat(1,1); |
78 | 82 |
mMove = new Static3D(0,0,0); |
79 |
|
|
80 |
mInnerScale= new Static3D(1,1,1); |
|
81 |
mOuterScale= new Static3D(1,1,1); |
|
83 |
mScale= new Static3D(1,1,1); |
|
82 | 84 |
|
83 | 85 |
DistortedEffects rootEffects = new DistortedEffects(); |
84 | 86 |
DistortedEffects innerEffects = new DistortedEffects(); |
... | ... | |
87 | 89 |
|
88 | 90 |
DistortedNode root = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), rootEffects, mesh); |
89 | 91 |
|
90 |
DistortedNode[] innerLeafNodes = new DistortedNode[NUM_LEAVES]; |
|
91 |
DistortedNode[] outerLeafNodes = new DistortedNode[NUM_LEAVES]; |
|
92 |
|
|
93 | 92 |
rootEffects.apply(new MatrixEffectMove(mMove)); |
94 |
rootEffects.apply(new MatrixEffectScale(mOuterScale)); |
|
93 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
|
94 |
//rootEffects.apply(blurEffect); |
|
95 |
|
|
96 |
Dynamic1D rotate = new Dynamic1D(5000,0.0f); |
|
97 |
rotate.setMode(Dynamic1D.MODE_JUMP); |
|
98 |
rotate.add(new Static1D( 0)); |
|
99 |
rotate.add(new Static1D(360)); |
|
95 | 100 |
|
96 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
|
97 |
rot.setMode(Dynamic1D.MODE_JUMP); |
|
98 |
rot.add(new Static1D( 0)); |
|
99 |
rot.add(new Static1D(360)); |
|
101 |
Static3D outerCenter = new Static3D(OUTER*LEAF_SIZE/2, OUTER*LEAF_SIZE/2, 0); |
|
102 |
Static3D innerCenter = new Static3D(INNER*LEAF_SIZE/2, INNER*LEAF_SIZE/2, 0); |
|
100 | 103 |
|
101 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0); |
|
102 | 104 |
Static3D axis = new Static3D(0,0,1); |
103 |
Static3D innerMoveVector = new Static3D(0, LEAF_SIZE,0);
|
|
104 |
Static3D outerMoveVector = new Static3D(0,3*LEAF_SIZE,0);
|
|
105 |
Static3D innerMoveVector = new Static3D( 0, (INNER-1)*LEAF_SIZE/2, 0);
|
|
106 |
Static3D outerMoveVector = new Static3D(3*LEAF_SIZE/2, (OUTER-1)*LEAF_SIZE/2, 0);
|
|
105 | 107 |
|
106 | 108 |
for(int j=0; j<NUM_LEAVES; j++) |
107 | 109 |
{ |
108 | 110 |
outerLeafEffects[j] = new DistortedEffects(); |
109 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
|
|
111 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, outerCenter) );
|
|
110 | 112 |
outerLeafEffects[j].apply(new MatrixEffectMove(outerMoveVector)); |
111 |
outerLeafNodes[j] = new DistortedNode( mLeaf, outerLeafEffects[j], mesh); |
|
112 | 113 |
|
113 |
root.attach(outerLeafNodes[j]);
|
|
114 |
root.attach(mLeaf, outerLeafEffects[j], mesh);
|
|
114 | 115 |
} |
115 | 116 |
|
116 |
innerEffects.apply( new MatrixEffectMove(new Static3D( mScreenW/2, mScreenH/2, 0)) ); |
|
117 |
innerEffects.apply( new MatrixEffectRotate(rot, axis, center) ); |
|
118 |
rootEffects.apply(new MatrixEffectScale(mInnerScale)); |
|
117 |
innerEffects.apply( new MatrixEffectMove(new Static3D( (OUTER-INNER)*LEAF_SIZE/2,(OUTER-INNER)*LEAF_SIZE/2, 0)) ); |
|
118 |
innerEffects.apply( new MatrixEffectRotate(rotate, axis, innerCenter) ); |
|
119 | 119 |
innerEffects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0) ) ); |
120 |
innerEffects.apply(blurEffect); |
|
120 | 121 |
|
121 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(3*LEAF_SIZE,3*LEAF_SIZE), innerEffects, mesh);
|
|
122 |
DistortedNode innerNode = new DistortedNode( new DistortedTexture(INNER*LEAF_SIZE,INNER*LEAF_SIZE), innerEffects, mesh);
|
|
122 | 123 |
root.attach(innerNode); |
123 | 124 |
|
124 | 125 |
for(int j=0; j<NUM_LEAVES; j++) |
125 | 126 |
{ |
126 | 127 |
innerLeafEffects[j] = new DistortedEffects(); |
127 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
|
|
128 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, innerCenter) );
|
|
128 | 129 |
innerLeafEffects[j].apply(new MatrixEffectMove(innerMoveVector)); |
129 |
innerLeafNodes[j] = new DistortedNode( mLeaf, innerLeafEffects[j], mesh); |
|
130 | 130 |
|
131 |
innerNode.attach(innerLeafNodes[j]);
|
|
131 |
innerNode.attach( mLeaf, innerLeafEffects[j], mesh );
|
|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
mScreen = new DistortedScreen(); |
... | ... | |
140 | 140 |
int setBlur(int blur) |
141 | 141 |
{ |
142 | 142 |
int radius = blur/2; |
143 |
mRadiusSta.set(radius);
|
|
143 |
mRadius.set(radius); |
|
144 | 144 |
return radius; |
145 | 145 |
} |
146 | 146 |
|
... | ... | |
155 | 155 |
|
156 | 156 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
157 | 157 |
{ |
158 |
float iFactor, oFactor;
|
|
158 |
float factor;
|
|
159 | 159 |
|
160 | 160 |
if( (float)mScreenH/mScreenW > (float)height/width ) |
161 | 161 |
{ |
162 | 162 |
int w = (height*mScreenW)/mScreenH; |
163 |
oFactor = (float)height/mScreenH; |
|
164 |
iFactor = 0.3f*oFactor; |
|
163 |
factor = (float)height/mScreenH; |
|
165 | 164 |
mMove.set((width-w)/2 ,0, 0); |
166 | 165 |
} |
167 | 166 |
else |
168 | 167 |
{ |
169 | 168 |
int h = (width*mScreenH)/mScreenW; |
170 |
oFactor = (float)width/mScreenW; |
|
171 |
iFactor = 0.3f*oFactor; |
|
169 |
factor = (float)width/mScreenW; |
|
172 | 170 |
mMove.set(0,(height-h)/2,0); |
173 | 171 |
} |
174 | 172 |
|
175 |
mOuterScale.set(oFactor,oFactor,oFactor); |
|
176 |
mInnerScale.set(iFactor,iFactor,iFactor); |
|
173 |
mScale.set(factor,factor,factor); |
|
177 | 174 |
|
178 | 175 |
mScreen.resize(width, height); |
179 | 176 |
} |
Also available in: Unified diff
Improve the 'PostprocessTree' app. Shows bugs in postprocessing.