Project

General

Profile

« Previous | Next » 

Revision 0fb42347

Added by Leszek Koltunski over 7 years ago

Revert "Convert a few more APPs to the new resolution-independent Matrix Effects."

This reverts commit 19938eb7e76e004b164589f0ca6eec2894935e08.

View differences:

src/main/java/org/distorted/examples/mirror/MirrorRenderer.java
46 46
class MirrorRenderer implements GLSurfaceView.Renderer
47 47
{
48 48
   private static final float MIRROR_SCALE     =0.70f;  // each next mirror will be 70% of the size or the previous
49
   private static final float HEAD_SCALE       =0.40f;  // Head's height will be 30% of the height of the mirror
49
   private static final float HEAD_SCALE       =0.30f;  // Head's height will be 30% of the height of the mirror
50 50
   private static final float MIRROR_BRIGHTNESS=0.70f;  // Each next mirror 30% darker
51
   private static final float MIRROR_MARGIN    =0.09f;  // The frame of the mirror takes up 9% of its width
51
   private static final float MIRROR_MARGIN    =0.11f;  // The frame of the mirror takes up 11% of its width
52 52
   private static final float MIRROR_MOVE      =0.12f;  // Each next mirror is moved to the right by 12% of
53 53
                                                        // the length of the previous one
54 54

  
55 55
   private GLSurfaceView mView;
56
   private DistortedEffects mEffectsHead, mEffectsNull, mEffectsOffscreen1, mEffectsOffscreen2;
56
   private DistortedEffects mEffectsMirror, mEffectsHead, mEffectsNull;
57
   private DistortedEffects mEffectsOffscreen1, mEffectsOffscreen2;
57 58
   private DistortedTexture mTextureMirror, mTextureHead;
58 59
   private DistortedFramebuffer mOffScreen1, mOffScreen2;
59 60
   private DistortedScreen mScreen;
......
62 63
   private Dynamic3D mHeadDyn;
63 64
   private int mX;
64 65

  
65
   private int mHeadW, mHeadH;
66
   private int mMirrorW, mMirrorH, mHeadW, mHeadH;
66 67
   private int mScreenW, mScreenH;
67 68

  
68 69
///////////////////////////////////////////////////////////////////////////////////////////////////
......
73 74
      mQuad    = new MeshFlat(1,1);
74 75
      mScreen  = new DistortedScreen();
75 76

  
76
      mEffectsHead       = new DistortedEffects();
77
      mEffectsOffscreen1 = new DistortedEffects();
78
      mEffectsOffscreen2 = new DistortedEffects();
79
      mEffectsNull       = new DistortedEffects();
77
      mEffectsMirror    = new DistortedEffects();
78
      mEffectsHead      = new DistortedEffects();
79
      mEffectsOffscreen1= new DistortedEffects();
80
      mEffectsOffscreen2= new DistortedEffects();
81
      mEffectsNull      = new DistortedEffects();
80 82

  
81 83
      mX = MirrorActivity.INIT_POSITION;
82 84

  
......
90 92
   void setPosition(int pos)
91 93
      {
92 94
      mX = pos;
93
      mHeadPosition.set1( (mX/50.0f-1)*(0.5f-MIRROR_MARGIN-HEAD_SCALE/2) );
95

  
96
      float headW = (HEAD_SCALE *mScreenH* mHeadW) / (mScreenW* mHeadH);
97

  
98
      mHeadPosition.set1(mX*(1.0f-2*MIRROR_MARGIN-headW)*mScreenW / 100.0f + MIRROR_MARGIN*mScreenW);
94 99
      }
95 100
   
96 101
///////////////////////////////////////////////////////////////////////////////////////////////////
......
128 133
        mOffScreen2 = new DistortedFramebuffer( (int)(MIRROR_SCALE*mScreenW), (int)(MIRROR_SCALE*mScreenH) );
129 134

  
130 135
        mEffectsHead.abortAllEffects();
136
        mEffectsMirror.abortAllEffects();
131 137
        mEffectsOffscreen1.abortAllEffects();
132 138
        mEffectsOffscreen2.abortAllEffects();
133 139

  
140
        mEffectsMirror.scale( new Static3D( (float)mScreenW/mMirrorW, (float)mScreenH/mMirrorH, 1.0f) );
141
        mEffectsOffscreen1.scale(MIRROR_SCALE);
134 142
        mEffectsOffscreen1.brightness(new Static1D(MIRROR_BRIGHTNESS));
135
        mEffectsOffscreen2.move( new Static3D( MIRROR_MOVE-0.5f+MIRROR_SCALE/2, MIRROR_MOVE-0.5f+MIRROR_SCALE/2, 0) );
136
        mEffectsOffscreen2.scale( new Static3D( MIRROR_SCALE, MIRROR_SCALE, 1) );
143
        mEffectsOffscreen2.move( new Static3D( MIRROR_MOVE*mScreenW, MIRROR_MOVE*mScreenH*mMirrorW/mMirrorH, 0) );
137 144

  
138 145
        mEffectsHead.move(mHeadDyn);
139
        float qx = mScreenW/ mHeadW;
140
        float qy = mScreenH/ mHeadH;
141

  
142
        if( qx<qy )
143
          {
144
          mEffectsHead.scale(new Static3D(HEAD_SCALE, HEAD_SCALE*qx/qy, 1) );
145
          mHeadPosition.set2(0.5f-MIRROR_MARGIN-(HEAD_SCALE/2)*qx/qy);
146
          }
147
        else
148
          {
149
          mEffectsHead.scale( new Static3D(HEAD_SCALE*qy/qx, HEAD_SCALE, 1) );
150
          mHeadPosition.set2(0.5f-MIRROR_MARGIN-HEAD_SCALE/2);
151
          }
152

  
146
        float headScale = HEAD_SCALE *mScreenH/ mHeadH;
147
        mEffectsHead.scale(headScale);
148
        mHeadPosition.set2( mScreenH*(1.0f-MIRROR_MARGIN*mMirrorW/mMirrorH) - headScale* mHeadH);
153 149
        setPosition(mX);
154 150

  
155
        mOffScreen1.attach( mTextureMirror, mEffectsNull      , mQuad );
151
        mOffScreen1.attach( mTextureMirror, mEffectsMirror    , mQuad );
156 152
        mOffScreen1.attach( mOffScreen2   , mEffectsOffscreen2, mQuad );
157 153
        mOffScreen1.attach( mTextureHead  , mEffectsHead      , mQuad );
158 154
        mOffScreen2.attach( mOffScreen1   , mEffectsOffscreen1, mQuad );
159 155

  
160 156
        mScreen.detachAll();
161
        mScreen.attach    ( mOffScreen1   , mEffectsNull     , mQuad );
157
        mScreen.attach    ( mOffScreen1   , mEffectsNull      , mQuad );
162 158
        mScreen.resize(mScreenW,mScreenH);
163 159
        }
164 160
      }
......
187 183
        catch(IOException e) { }
188 184
        }
189 185

  
190
      mHeadW = bitmapH.getWidth();
191
      mHeadH = bitmapH.getHeight();
186
      mMirrorW = bitmapM.getWidth();
187
      mMirrorH = bitmapM.getHeight();
188
      mHeadW   = bitmapH.getWidth();
189
      mHeadH   = bitmapH.getHeight();
192 190

  
193
      if( mTextureMirror==null ) mTextureMirror = new DistortedTexture(bitmapM.getWidth(),bitmapM.getHeight());
191
      if( mTextureMirror==null ) mTextureMirror = new DistortedTexture(mMirrorW,mMirrorH);
194 192
      if( mTextureHead  ==null ) mTextureHead   = new DistortedTexture(mHeadW, mHeadH);
195 193

  
196 194
      mTextureMirror.setTexture(bitmapM);
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
41 41

  
42 42
import android.graphics.Bitmap;
43 43
import android.graphics.BitmapFactory;
44
import android.opengl.GLES30;
44 45
import android.opengl.GLSurfaceView;
45 46

  
46 47
///////////////////////////////////////////////////////////////////////////////////////////////////
......
98 99
    
99 100
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
100 101
    {
101
    float qx = (float)width ;
102
    float qy = (float)height;
103
    float scale = 0.5f;
102
    float scaleFactor = width>height ? height/3:width/3;
104 103

  
105 104
    mEffects.abortEffects(EffectTypes.MATRIX);
106
    mEffects.quaternion( mRot, new Static3D(0,0,0) );
107
    mEffects.scale(  qx<qy ? (new Static3D(scale,scale*qx/qy,scale)) : (new Static3D(scale*qy/qx,scale,scale)) );
108

  
105
    mEffects.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
106
    mEffects.scale(scaleFactor);
107
    mEffects.quaternion( mRot, new Static3D( (float)mTexture.getWidth()/2, (float)mTexture.getHeight()/2 , 0) );
108
       
109 109
    mScreen.resize(width, height);
110 110
    }
111 111

  

Also available in: Unified diff