@@ -24,7 +24,8 @@ public class MD360Director {
2424
2525 private float mEyeZ = 0f ;
2626 private float mEyeX = 0f ;
27- private float mAngle = 0f ;
27+ private float mAngleX = 0f ;
28+ private float mAngleY = 0f ;
2829 private float mRatio = 0f ;
2930 private float mNearScale = 0f ;
3031 private float mLookX = 0f ;
@@ -44,7 +45,8 @@ private MD360Director(Builder builder) {
4445 this .mEyeZ = builder .mEyeZ ;
4546 this .mRatio = builder .mRatio ;
4647 this .mNearScale = builder .mNearScale ;
47- this .mAngle = builder .mAngle ;
48+ this .mAngleX = builder .mAngleX ;
49+ this .mAngleY = builder .mAngleY ;
4850 this .mEyeX = builder .mEyeX ;
4951 this .mLookX = builder .mLookX ;
5052 initCamera ();
@@ -92,16 +94,17 @@ private void initModel(){
9294 Matrix .setIdentityM (mAccumulatedRotation , 0 );
9395 Matrix .setIdentityM (mSensorMatrix , 0 );
9496 // Model Matrix
95- updateModelRotate (mAngle );
97+ updateModelRotateX (mAngleX );
98+ updateModelRotateY (mAngleY );
9699 }
97100
98101 public void shot (MD360Program program ) {
99102
100103 Matrix .setIdentityM (mModelMatrix , 0 );
101104
102105 Matrix .setIdentityM (mCurrentRotation , 0 );
103- Matrix .rotateM (mCurrentRotation , 0 , -mDeltaY , 1.0f , 0.0f , 0.0f );
104- Matrix .rotateM (mCurrentRotation , 0 , -mDeltaX + mAngle , 0.0f , 1.0f , 0.0f );
106+ Matrix .rotateM (mCurrentRotation , 0 , -mDeltaY + mAngleY , 1.0f , 0.0f , 0.0f );
107+ Matrix .rotateM (mCurrentRotation , 0 , -mDeltaX + mAngleX , 0.0f , 1.0f , 0.0f );
105108 Matrix .multiplyMM (mCurrentRotation , 0 , mSensorMatrix , 0 , mCurrentRotation , 0 );
106109
107110 // set the accumulated rotation to the result.
@@ -146,8 +149,12 @@ private void updateViewMatrix() {
146149 Matrix .setLookAtM (mViewMatrix , 0 , eyeX , eyeY , eyeZ , lookX , lookY , lookZ , upX , upY , upZ );
147150 }
148151
149- protected void updateModelRotate (float a ) {
150- mAngle = a ;
152+ protected void updateModelRotateX (float a ) {
153+ mAngleX = a ;
154+ }
155+
156+ protected void updateModelRotateY (float a ) {
157+ mAngleY = a ;
151158 }
152159
153160 protected void updateProjectionNearScale (float scale ){
@@ -175,11 +182,12 @@ public static Builder builder(){
175182
176183 public static class Builder {
177184 private float mEyeZ = 0f ;
178- private float mAngle = 0 ;
185+ private float mAngleX = 0 ;
179186 private float mRatio = 1.5f ;
180187 private float mNearScale = 1 ;
181188 private float mEyeX = 0f ;
182189 private float mLookX = 0f ;
190+ private float mAngleY = 0 ;
183191
184192 public Builder setLookX (float mLookX ) {
185193 this .mLookX = mLookX ;
@@ -196,8 +204,24 @@ public Builder setEyeZ(float mEyeZ) {
196204 return this ;
197205 }
198206
199- public Builder setAngle (float mAngle ) {
200- this .mAngle = mAngle ;
207+
208+ /**
209+ * Deprecated since 1.4.0, please use {@link #setAngleX(float)}
210+ * @param a
211+ * @return
212+ */
213+ @ Deprecated
214+ public Builder setAngle (float a ) {
215+ return setAngleX (a );
216+ }
217+
218+ public Builder setAngleX (float mAngle ) {
219+ this .mAngleX = mAngle ;
220+ return this ;
221+ }
222+
223+ public Builder setAngleY (float mAngle ) {
224+ this .mAngleY = mAngle ;
201225 return this ;
202226 }
203227
0 commit comments