Revision 5a683295
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/movingglow/MovingGlowRenderer.java | ||
---|---|---|
62 | 62 |
private DistortedScreen mScreen; |
63 | 63 |
private DistortedEffects[] mLeafEffects = new DistortedEffects[NUM_LEAVES]; |
64 | 64 |
private PostprocessEffectGlow[] mGlow = new PostprocessEffectGlow[NUM_LEAVES]; |
65 |
private int mRootW, mRootH; |
|
66 | 65 |
private int mGlowing; |
67 | 66 |
private Static3D mScale; |
68 | 67 |
|
... | ... | |
72 | 71 |
{ |
73 | 72 |
mView = v; |
74 | 73 |
|
75 |
mRootW = 5*LEAF_SIZE; |
|
76 |
mRootH = 5*LEAF_SIZE; |
|
77 |
|
|
74 |
MeshQuad mesh = new MeshQuad(); |
|
75 |
mScale= new Static3D(1,1,1); |
|
78 | 76 |
mLeaf = new DistortedTexture(); |
79 | 77 |
DistortedTexture surface = new DistortedTexture(); |
80 | 78 |
|
81 |
MeshQuad rootMesh = new MeshQuad(); |
|
82 |
rootMesh.setStretch(mRootW,mRootH,0); |
|
83 |
MeshQuad leafMesh = new MeshQuad(); |
|
84 |
leafMesh.setStretch(LEAF_SIZE,LEAF_SIZE,0); |
|
85 |
|
|
86 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
87 |
DistortedNode root = new DistortedNode(surface, rootEffects, rootMesh); |
|
88 |
|
|
89 | 79 |
Static3D moveVector = new Static3D(-1.45f*LEAF_SIZE, 0, 0); |
90 | 80 |
Static1D chromaLevel= new Static1D(0.5f); |
91 | 81 |
Static3D center = new Static3D(0,0,0); |
92 | 82 |
Static3D axis = new Static3D(0,0,1); |
93 | 83 |
|
84 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
|
85 |
rot.setMode(Dynamic1D.MODE_JUMP); |
|
86 |
rot.add(new Static1D( 0)); |
|
87 |
rot.add(new Static1D(360)); |
|
88 |
|
|
89 |
DistortedEffects rootEffects = new DistortedEffects(); |
|
90 |
rootEffects.apply(new MatrixEffectRotate(rot, axis, center) ); |
|
91 |
rootEffects.apply(new MatrixEffectScale(mScale)); |
|
92 |
|
|
93 |
DistortedNode root = new DistortedNode(surface, rootEffects, mesh); |
|
94 |
root.resizeFBO(5*LEAF_SIZE,5*LEAF_SIZE); |
|
95 |
|
|
94 | 96 |
MatrixEffectMove leafMove = new MatrixEffectMove(moveVector); |
95 | 97 |
|
96 | 98 |
for(int j=0; j<NUM_LEAVES; j++) |
97 | 99 |
{ |
98 | 100 |
mLeafEffects[j] = new DistortedEffects(); |
101 |
mLeafEffects[j].apply( new MatrixEffectScale(LEAF_SIZE) ); |
|
99 | 102 |
mLeafEffects[j].apply(leafMove); |
100 | 103 |
mLeafEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) ); |
101 | 104 |
mLeafEffects[j].apply( new FragmentEffectChroma(chromaLevel, new Static3D(colors[3*j],colors[3*j+1], colors[3*j+2])) ); |
102 |
DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], leafMesh);
|
|
105 |
DistortedNode node = new DistortedNode( mLeaf, mLeafEffects[j], mesh);
|
|
103 | 106 |
root.attach(node); |
104 | 107 |
} |
105 | 108 |
|
106 |
mScale= new Static3D(1,1,1); |
|
107 |
|
|
108 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
|
109 |
rot.setMode(Dynamic1D.MODE_JUMP); |
|
110 |
rot.add(new Static1D( 0)); |
|
111 |
rot.add(new Static1D(360)); |
|
112 |
|
|
113 |
DistortedEffects effects = root.getEffects(); |
|
114 |
effects.apply(new MatrixEffectRotate(rot, axis, center) ); |
|
115 |
effects.apply(new MatrixEffectScale(mScale)); |
|
116 |
|
|
117 | 109 |
Dynamic1D radiusDyn = new Dynamic1D(FLASH_TIME,1.0f); |
118 | 110 |
radiusDyn.add(new Static1D( 0)); |
119 | 111 |
radiusDyn.add(new Static1D(50)); |
... | ... | |
167 | 159 |
|
168 | 160 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
169 | 161 |
{ |
170 |
float qw = (float)width /mRootW;
|
|
171 |
float qh = (float)height/mRootH;
|
|
162 |
float qw = (float)width ; |
|
163 |
float qh = (float)height; |
|
172 | 164 |
float factor = 0.9f* (qw<qh ? qw:qh); |
173 | 165 |
|
174 | 166 |
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() )