Revision 16b22aab
Added by Leszek Koltunski about 5 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, mScale;
|
|
59 |
private Static3D mScale; |
|
60 | 60 |
private Static1D mRadius; |
61 | 61 |
|
62 | 62 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
79 | 79 |
mLeaf = new DistortedTexture(LEAF_SIZE,LEAF_SIZE); |
80 | 80 |
|
81 | 81 |
MeshFlat mesh = new MeshFlat(1,1); |
82 |
mMove = new Static3D(0,0,0); |
|
83 | 82 |
mScale= new Static3D(1,1,1); |
84 | 83 |
|
85 | 84 |
DistortedEffects rootEffects = new DistortedEffects(); |
... | ... | |
89 | 88 |
|
90 | 89 |
DistortedNode root = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), rootEffects, mesh); |
91 | 90 |
|
92 |
rootEffects.apply(new MatrixEffectMove(mMove)); |
|
93 | 91 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
94 | 92 |
rootEffects.apply(blurEffect); |
95 | 93 |
|
... | ... | |
98 | 96 |
rotate.add(new Static1D( 0)); |
99 | 97 |
rotate.add(new Static1D(360)); |
100 | 98 |
|
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); |
|
103 |
|
|
99 |
Static3D center = new Static3D(0,0,0); |
|
104 | 100 |
Static3D axis = new Static3D(0,0,1); |
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);
|
|
101 |
Static3D innerMoveVector = new Static3D( (1-INNER)*LEAF_SIZE/2, 0, 0);
|
|
102 |
Static3D outerMoveVector = new Static3D( (4-OUTER)*LEAF_SIZE/2, 0, 0);
|
|
107 | 103 |
|
108 | 104 |
for(int j=0; j<NUM_LEAVES; j++) |
109 | 105 |
{ |
110 | 106 |
outerLeafEffects[j] = new DistortedEffects(); |
111 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, outerCenter) );
|
|
107 |
outerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
|
|
112 | 108 |
outerLeafEffects[j].apply(new MatrixEffectMove(outerMoveVector)); |
113 | 109 |
|
114 | 110 |
root.attach(mLeaf, outerLeafEffects[j], mesh); |
115 | 111 |
} |
116 | 112 |
|
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) ); |
|
113 |
innerEffects.apply( new MatrixEffectRotate(rotate, axis, center) ); |
|
119 | 114 |
innerEffects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0) ) ); |
120 | 115 |
innerEffects.apply(blurEffect); |
121 | 116 |
|
... | ... | |
125 | 120 |
for(int j=0; j<NUM_LEAVES; j++) |
126 | 121 |
{ |
127 | 122 |
innerLeafEffects[j] = new DistortedEffects(); |
128 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, innerCenter) );
|
|
123 |
innerLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
|
|
129 | 124 |
innerLeafEffects[j].apply(new MatrixEffectMove(innerMoveVector)); |
130 | 125 |
|
131 | 126 |
innerNode.attach( mLeaf, innerLeafEffects[j], mesh ); |
... | ... | |
155 | 150 |
|
156 | 151 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
157 | 152 |
{ |
158 |
float factor; |
|
159 |
|
|
160 |
if( (float)mScreenH/mScreenW > (float)height/width ) |
|
161 |
{ |
|
162 |
int w = (height*mScreenW)/mScreenH; |
|
163 |
factor = (float)height/mScreenH; |
|
164 |
mMove.set((width-w)/2 ,0, 0); |
|
165 |
} |
|
166 |
else |
|
167 |
{ |
|
168 |
int h = (width*mScreenH)/mScreenW; |
|
169 |
factor = (float)width/mScreenW; |
|
170 |
mMove.set(0,(height-h)/2,0); |
|
171 |
} |
|
153 |
float horiRatio = (float)width / mScreenW; |
|
154 |
float vertRatio = (float)height/ mScreenH; |
|
155 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio; |
|
172 | 156 |
|
173 | 157 |
mScale.set(factor,factor,factor); |
174 |
|
|
175 | 158 |
mScreen.resize(width, height); |
176 | 159 |
} |
177 | 160 |
|
Also available in: Unified diff
Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.