android 3d 旋转
2010-10-12 02:45:00 来源:本站整理35. final float centerY = mCenterY;
36. final Matrix matrix = t.getMatrix();
37.
38. if (degrees < = -76.0f) {
39. degrees = -90.0f;
40. mCamera.save();
41. mCamera.rotateY(degrees);
42. mCamera.getMatrix(matrix);
43. mCamera.restore();
44. } else if(degrees >=76.0f){
45. degrees = 90.0f;
46. mCamera.save();
47. mCamera.rotateY(degrees);
48. mCamera.getMatrix(matrix);
49. mCamera.restore();
50. }else{
51. mCamera.save();
52. //这里很重要哦。
53. mCamera.translate(0, 0, centerX);
54. mCamera.rotateY(degrees);
55. mCamera.translate(0, 0, -centerX);
56. mCamera.getMatrix(matrix);
57. mCamera.restore();
58. }
59.
60. matrix.preTranslate(-centerX, -centerY);
61. matrix.postTranslate(centerX, centerY);
62. }
63. }
public class Rotate3d extends Animation {
private float mFromDegree;
private float mToDegree;
private float mCenterX;
private float mCenterY;
private float mLeft;
private float mTop;
private Camera mCamera;
private static final String TAG = "Rotate3d";
public Rotate3d(float fromDegree, float toDegree, float left, float top,
float centerX, float centerY) {
this.mFromDegree = fromDegree;
this.mToDegree = toDegree;
this.mLeft = left;
this.mTop = top;
this.mCenterX = centerX;
this.mCenterY = centerY;
}
@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
mCamera = new Camera();
更多精彩
赞助商链接