Revision 5a683295
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
58 | 58 |
private DistortedTexture mLeaf; |
59 | 59 |
private DistortedScreen mScreen; |
60 | 60 |
private MeshQuad mLeafMesh; |
61 |
private int mScreenW, mScreenH; |
|
62 | 61 |
private int mPrevRendered, mCurrRendered; |
63 | 62 |
private Static3D mScale; |
64 | 63 |
|
... | ... | |
93 | 92 |
mPrevRendered = -1; |
94 | 93 |
mCurrRendered = -1; |
95 | 94 |
|
96 |
mScreenW = 9*LEAF_SIZE; |
|
97 |
mScreenH = 9*LEAF_SIZE; |
|
98 |
|
|
99 | 95 |
mLeaf = new DistortedTexture(); |
100 | 96 |
DistortedTexture surface = new DistortedTexture(); |
101 | 97 |
|
102 | 98 |
mLeafMesh = new MeshQuad(); |
103 |
mLeafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0); |
|
104 |
MeshQuad circleMesh = new MeshQuad(); |
|
105 |
circleMesh.setStretch(3*LEAF_SIZE,3*LEAF_SIZE,0); |
|
106 |
MeshQuad rootMesh = new MeshQuad(); |
|
107 |
rootMesh.setStretch(mScreenW,mScreenH,0); |
|
99 |
MeshQuad quad = new MeshQuad(); |
|
108 | 100 |
|
109 | 101 |
mScale= new Static3D(1,1,1); |
110 | 102 |
|
111 | 103 |
DistortedEffects rootEffects = new DistortedEffects(); |
112 | 104 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
113 | 105 |
|
114 |
mRoot = new DistortedNode(new DistortedTexture(), rootEffects, rootMesh); |
|
115 |
|
|
106 |
mRoot = new DistortedNode(new DistortedTexture(), rootEffects, quad); |
|
107 |
mRoot.resizeFBO(9*LEAF_SIZE,9*LEAF_SIZE); |
|
108 |
|
|
116 | 109 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
117 | 110 |
rot.setMode(Dynamic1D.MODE_JUMP); |
118 | 111 |
rot.add(new Static1D( 0)); |
... | ... | |
132 | 125 |
for(int j=0; j<NUM_LEAVES; j++) |
133 | 126 |
{ |
134 | 127 |
mEffects[j] = new DistortedEffects(); |
135 |
mEffects[j].apply(new MatrixEffectMove(moveVector)); |
|
128 |
mEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) ); |
|
129 |
mEffects[j].apply( new MatrixEffectMove(moveVector)); |
|
136 | 130 |
mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
137 | 131 |
} |
138 | 132 |
|
139 | 133 |
for(int i=0; i<NUM_CIRCLES; i++) |
140 | 134 |
{ |
141 | 135 |
DistortedEffects effects = new DistortedEffects(); |
136 |
effects.apply( new MatrixEffectScale(3*LEAF_SIZE) ); |
|
142 | 137 |
effects.apply( new MatrixEffectRotate(rot, axis, center) ); |
143 | 138 |
effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) ); |
144 | 139 |
effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) ); |
145 | 140 |
|
146 |
mCircleNode[i] = new DistortedNode( surface, effects, circleMesh); |
|
141 |
mCircleNode[i] = new DistortedNode( surface, effects, quad); |
|
142 |
mCircleNode[i].resizeFBO(3*LEAF_SIZE, 3*LEAF_SIZE); |
|
147 | 143 |
mRoot.attach(mCircleNode[i]); |
148 | 144 |
|
149 | 145 |
for(int j=0; j<NUM_LEAVES; j++) mCircleNode[i].attach(mLeaf, mEffects[j], mLeafMesh); |
... | ... | |
179 | 175 |
|
180 | 176 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
181 | 177 |
{ |
182 |
float horiRatio = (float)width / mScreenW;
|
|
183 |
float vertRatio = (float)height/ mScreenH;
|
|
178 |
float horiRatio = (float)width ; |
|
179 |
float vertRatio = (float)height; |
|
184 | 180 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio; |
185 | 181 |
|
186 | 182 |
mScale.set(factor,factor,factor); |
Also available in: Unified diff
Size of the FBO internal to Nodes is now NO MORE taken from the Mesh's stretch values.
Instead, the size is copied from child's FBO size (if there is one) or if the child is a leaf with texture in it (which is sizeless) then we get the default 100x100 ( which means we probably have to explicitly call Node.resizeFBO() )