Revision 45850cce
Added by Leszek Koltunski 12 days ago
src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.effect.MatrixEffectMove; |
29 | 29 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
30 | 30 |
import org.distorted.library.effect.MatrixEffectScale; |
31 |
import org.distorted.library.effect.PostprocessEffectGlow; |
|
31 | 32 |
import org.distorted.library.effect.VertexEffectDeform; |
32 | 33 |
import org.distorted.library.effect.VertexEffectDisappear; |
33 | 34 |
import org.distorted.library.effect.VertexEffectMove; |
... | ... | |
43 | 44 |
import org.distorted.library.type.Dynamic1D; |
44 | 45 |
import org.distorted.library.type.DynamicQuat; |
45 | 46 |
import org.distorted.library.type.Static1D; |
47 |
import org.distorted.library.type.Static2D; |
|
46 | 48 |
import org.distorted.library.type.Static3D; |
47 | 49 |
import org.distorted.library.type.Static4D; |
48 | 50 |
|
... | ... | |
104 | 106 |
new Static3D(+DIST,+DIST,-DIST), |
105 | 107 |
new Static3D(+DIST,+DIST,+DIST), |
106 | 108 |
}; |
109 |
private static final int NUM_CUBITS = CUBIT_MOVES.length; |
|
107 | 110 |
|
108 | 111 |
private final Resources mResources; |
109 | 112 |
private final DistortedScreen mScreen; |
... | ... | |
111 | 114 |
private final Static3D mScale; |
112 | 115 |
private final VertexEffectRotate mRotate; |
113 | 116 |
private final VertexEffectDisappear mDisappear; |
117 |
private final PostprocessEffectGlow mGlow; |
|
114 | 118 |
private final Dynamic1D mAngleDyn; |
115 | 119 |
private final Static1D mAngle; |
116 | 120 |
private final Static3D mAxis; |
... | ... | |
127 | 131 |
|
128 | 132 |
SingleMeshRenderer(GLSurfaceView v) |
129 | 133 |
{ |
130 |
mInvisible = new boolean[CUBIT_MOVES.length];
|
|
134 |
mInvisible = new boolean[NUM_CUBITS];
|
|
131 | 135 |
mResources = v.getResources(); |
132 | 136 |
|
133 | 137 |
mScreen = new DistortedScreen(); |
... | ... | |
154 | 158 |
mDisappear = new VertexEffectDisappear(); |
155 | 159 |
mDisappear.setMeshAssociation(0,-1); |
156 | 160 |
|
161 |
final float HALO_TO_RADIUS = 0.2f; |
|
162 |
Static2D haloRadius= new Static2D(25*HALO_TO_RADIUS,25); |
|
163 |
Static4D color = new Static4D(1.0f,0.0f,0.0f,0.5f); // half-transparent red |
|
164 |
mGlow = new PostprocessEffectGlow(haloRadius,color); |
|
165 |
|
|
157 | 166 |
mEffects = new DistortedEffects(); |
158 | 167 |
mEffects.apply( mRotate ); |
159 | 168 |
mEffects.apply( mDisappear ); |
160 | 169 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) ); |
161 | 170 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) ); |
162 | 171 |
mEffects.apply( new MatrixEffectScale(mScale)); |
172 |
mEffects.apply( mGlow ); |
|
163 | 173 |
|
164 | 174 |
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
165 | 175 |
} |
... | ... | |
395 | 405 |
|
396 | 406 |
private MeshBase createMesh() |
397 | 407 |
{ |
398 |
final int NUM_CUBITS = CUBIT_MOVES.length; |
|
399 | 408 |
MeshBase[] cubits = new MeshBase[NUM_CUBITS]; |
400 | 409 |
|
401 | 410 |
cubits[NUM_CUBITS-1] = createCubitMesh(); // NUM_CUBITS-1 (or anything non-zero!) |
402 | 411 |
|
403 |
for(int i=0; i<NUM_CUBITS-1; i++) cubits[i] = cubits[NUM_CUBITS-1].copy(true); |
|
404 |
|
|
405 | 412 |
for(int i=0; i<NUM_CUBITS; i++) |
406 | 413 |
{ |
414 |
cubits[i] = cubits[NUM_CUBITS-1].copy(true); |
|
407 | 415 |
cubits[i].apply( new MatrixEffectMove(CUBIT_MOVES[i]), 1,0); |
408 | 416 |
cubits[i].setTextureMap(TEXTURE_MAP[i],0); |
409 | 417 |
} |
410 | 418 |
|
411 | 419 |
MeshBase result = new MeshJoined(cubits); |
412 |
for(int i=0; i<CUBIT_MOVES.length; i++) result.setEffectAssociation( i, (1<<i), 0);
|
|
420 |
for(int i=0; i<NUM_CUBITS; i++) result.setEffectAssociation( i, (1<<i), 0);
|
|
413 | 421 |
|
414 | 422 |
return result; |
415 | 423 |
} |
Also available in: Unified diff
SingleMeshCube: add Glow