Project

General

Profile

« Previous | Next » 

Revision 16b22aab

Added by Leszek Koltunski about 5 years ago

Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.

View differences:

src/main/java/org/distorted/examples/inflate/InflateRenderer.java
23 23
import javax.microedition.khronos.opengles.GL10;
24 24

  
25 25
import org.distorted.library.effect.FragmentEffectAlpha;
26
import org.distorted.library.effect.MatrixEffectMove;
27 26
import org.distorted.library.effect.MatrixEffectQuaternion;
28 27
import org.distorted.library.effect.MatrixEffectScale;
29 28
import org.distorted.library.main.DistortedEffects;
......
50 49
    private DistortedEffects mEffects;
51 50
    private MeshBase mMesh;
52 51
    private DistortedScreen mScreen;
53
    private int mObjWidth, mObjHeight, mObjDepth;
54
    private Static3D mMove, mScale, mCenter;
52
    private int mObjWidth, mObjHeight;
53
    private Static3D mScale;
55 54
    private Static1D mAlpha;
56 55

  
57 56
    Static4D mQuat1, mQuat2;
......
65 64

  
66 65
      mAlpha = new Static1D(1.0f);
67 66

  
68
      mMove = new Static3D(0,0,0);
69 67
      mScale= new Static3D(1,1,1);
70
      mCenter=new Static3D(0,0,0);
68

  
69
      Static3D center=new Static3D(0,0,0);
71 70

  
72 71
      InflateActivity2 act = (InflateActivity2)v.getContext();
73 72

  
......
76 75

  
77 76
      mObjWidth = mTexture.getWidth();
78 77
      mObjHeight= mTexture.getHeight();
79
      mObjDepth = mTexture.getDepth(mMesh);
80 78

  
81 79
      mQuat1 = new Static4D(0,0,0,1);  // unity
82 80
      mQuat2 = new Static4D(0,0,0,1);  // quaternions
......
88 86
      quatInt2.add(mQuat2);
89 87

  
90 88
      mEffects = new DistortedEffects();
91
      mEffects.apply( new MatrixEffectMove(mMove) );
92 89
      mEffects.apply( new MatrixEffectScale(mScale));
93
      mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) );
94
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) );
90
      mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
91
      mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
95 92
      mEffects.apply( new FragmentEffectAlpha(mAlpha));
96 93

  
97 94
      mScreen = new DistortedScreen();
......
114 111

  
115 112
      mScreenMin = width<height ? width:height;
116 113
      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
117
      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , -factor*mObjDepth/2 );
118 114
      mScale.set(factor,factor,factor);
119
      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
120 115
      mScreen.resize(width, height);
121 116
      }
122 117

  

Also available in: Unified diff