Revision c8ecd3ac
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/examples/mirror/MirrorRenderer.java | ||
|---|---|---|
| 25 | 25 |
|
| 26 | 26 |
import org.distorted.examples.R; |
| 27 | 27 |
import org.distorted.library.effect.EffectName; |
| 28 |
import org.distorted.library.effect.FragmentEffectBrightness; |
|
| 29 |
import org.distorted.library.effect.MatrixEffectMove; |
|
| 30 |
import org.distorted.library.effect.MatrixEffectScale; |
|
| 28 | 31 |
import org.distorted.library.main.Distorted; |
| 29 | 32 |
import org.distorted.library.main.DistortedEffects; |
| 30 | 33 |
import org.distorted.library.main.DistortedFramebuffer; |
| 31 | 34 |
import org.distorted.library.main.DistortedScreen; |
| 32 | 35 |
import org.distorted.library.main.DistortedTexture; |
| 33 | 36 |
import org.distorted.library.main.MeshFlat; |
| 34 |
import org.distorted.library.type.Dynamic3D; |
|
| 35 | 37 |
import org.distorted.library.type.Static1D; |
| 36 | 38 |
import org.distorted.library.type.Static3D; |
| 37 | 39 |
|
| ... | ... | |
| 59 | 61 |
private DistortedFramebuffer mOffScreen1, mOffScreen2; |
| 60 | 62 |
private DistortedScreen mScreen; |
| 61 | 63 |
private MeshFlat mQuad; |
| 62 |
private Static3D mHeadPosition; |
|
| 63 |
private Dynamic3D mHeadDyn; |
|
| 64 |
private int mX; |
|
| 64 |
private Static3D mHeadPosition, mScaleMirror, mMoveOffscreen2, mScaleHead; |
|
| 65 | 65 |
|
| 66 |
private int mX; |
|
| 66 | 67 |
private int mMirrorW, mMirrorH, mHeadW, mHeadH; |
| 67 | 68 |
private int mScreenW, mScreenH; |
| 68 | 69 |
|
| ... | ... | |
| 82 | 83 |
|
| 83 | 84 |
mX = MirrorActivity.INIT_POSITION; |
| 84 | 85 |
|
| 85 |
mHeadPosition = new Static3D(0,0,0); |
|
| 86 |
mHeadDyn = new Dynamic3D(); |
|
| 87 |
mHeadDyn.add(mHeadPosition); |
|
| 86 |
mHeadPosition = new Static3D(0,0,0); |
|
| 87 |
mScaleMirror = new Static3D(1,1,1); |
|
| 88 |
mMoveOffscreen2 = new Static3D(0,0,0); |
|
| 89 |
mScaleHead = new Static3D(1,1,1); |
|
| 90 |
|
|
| 91 |
mEffectsMirror.apply( new MatrixEffectScale(mScaleMirror)); |
|
| 92 |
mEffectsOffscreen1.apply( new MatrixEffectScale( new Static3D(MIRROR_SCALE,MIRROR_SCALE,MIRROR_SCALE))); |
|
| 93 |
mEffectsOffscreen2.apply( new MatrixEffectMove(mMoveOffscreen2) ); |
|
| 94 |
mEffectsHead.apply( new MatrixEffectMove(mHeadPosition) ); |
|
| 95 |
mEffectsHead.apply( new MatrixEffectScale(mScaleHead) ); |
|
| 96 |
mEffectsOffscreen1.apply(new FragmentEffectBrightness(new Static1D(MIRROR_BRIGHTNESS))); |
|
| 88 | 97 |
} |
| 89 | 98 |
|
| 90 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 132 | 141 |
mOffScreen1 = new DistortedFramebuffer(mScreenW,mScreenH); |
| 133 | 142 |
mOffScreen2 = new DistortedFramebuffer( (int)(MIRROR_SCALE*mScreenW), (int)(MIRROR_SCALE*mScreenH) ); |
| 134 | 143 |
|
| 135 |
mEffectsHead.abortAllEffects(); |
|
| 136 |
mEffectsMirror.abortAllEffects(); |
|
| 137 |
mEffectsOffscreen1.abortAllEffects(); |
|
| 138 |
mEffectsOffscreen2.abortAllEffects(); |
|
| 139 |
|
|
| 140 |
mEffectsMirror.scale( new Static3D( (float)mScreenW/mMirrorW, (float)mScreenH/mMirrorH, 1.0f) ); |
|
| 141 |
mEffectsOffscreen1.scale(MIRROR_SCALE); |
|
| 142 |
mEffectsOffscreen1.brightness(new Static1D(MIRROR_BRIGHTNESS)); |
|
| 143 |
mEffectsOffscreen2.move( new Static3D( MIRROR_MOVE*mScreenW, MIRROR_MOVE*mScreenH*mMirrorW/mMirrorH, 0) ); |
|
| 144 |
mScaleMirror.set( (float)mScreenW/mMirrorW, (float)mScreenH/mMirrorH, 1.0f); |
|
| 145 |
mMoveOffscreen2.set( MIRROR_MOVE*mScreenW, MIRROR_MOVE*mScreenH*mMirrorW/mMirrorH, 0); |
|
| 144 | 146 |
|
| 145 |
mEffectsHead.move(mHeadDyn); |
|
| 146 | 147 |
float headScale = HEAD_SCALE *mScreenH/ mHeadH; |
| 147 |
mEffectsHead.scale(headScale);
|
|
| 148 |
mScaleHead.set(headScale,headScale,headScale);
|
|
| 148 | 149 |
mHeadPosition.set2( mScreenH*(1.0f-MIRROR_MARGIN*mMirrorW/mMirrorH) - headScale* mHeadH); |
| 149 | 150 |
setPosition(mX); |
| 150 | 151 |
|
Also available in: Unified diff
Further progress with Apps: 26 (out of 31) compile now.