Skip to content

Commit

Permalink
增加一个3D旋转控制的View
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoqp2010 committed Dec 11, 2013
1 parent 47033c0 commit 9572217
Show file tree
Hide file tree
Showing 148 changed files with 1,323 additions and 642 deletions.
Binary file modified AndBase/bin/andbase.jar
Binary file not shown.
Binary file not shown.
78 changes: 78 additions & 0 deletions AndBase/src/com/ab/view/app/AbRotate3dAnimation2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.ab.view.app;

import android.graphics.Camera;
import android.graphics.Matrix;
import android.view.animation.Animation;
import android.view.animation.Transformation;
/**
*
* Copyright (c) 2012 All rights reserved
* 名称:AbRotate3dAnimation2.java
* 描述:TODO
* @author 原作者 QQ:250333410
* @date:2013-12-11 上午11:36:37
* @version v1.0
*/
public class AbRotate3dAnimation2 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 AbRotate3dAnimation2(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();
}

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float FromDegree = mFromDegree;
float degrees = FromDegree + (mToDegree - mFromDegree)
* interpolatedTime;
final float centerX = mCenterX;
final float centerY = mCenterY;
final Matrix matrix = t.getMatrix();

if (degrees <= -76.0f) {
degrees = -90.0f;
mCamera.save();
mCamera.rotateY(degrees);
mCamera.getMatrix(matrix);
mCamera.restore();
} else if (degrees >= 76.0f) {
degrees = 90.0f;
mCamera.save();
mCamera.rotateY(degrees);
mCamera.getMatrix(matrix);
mCamera.restore();
} else {
mCamera.save();
mCamera.translate(0, 0, centerX);
mCamera.rotateY(degrees);
mCamera.translate(0, 0, -centerX);
mCamera.getMatrix(matrix);
mCamera.restore();
}

matrix.preTranslate(-centerX, -centerY);
matrix.postTranslate(centerX, centerY);
}

}
10 changes: 10 additions & 0 deletions AndBaseDemo/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.Rotate3DActivity1"
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.Rotate3DActivity2"
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.HttpActivity"
android:configChanges="keyboardHidden|orientation" >
Expand Down
Binary file modified AndBaseDemo/bin/AndBaseDemo.apk
Binary file not shown.
10 changes: 10 additions & 0 deletions AndBaseDemo/bin/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.Rotate3DActivity1"
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.Rotate3DActivity2"
android:configChanges="keyboardHidden|orientation" >
</activity>

<activity
android:name=".demo.activity.HttpActivity"
android:configChanges="keyboardHidden|orientation" >
Expand Down
Loading

0 comments on commit 9572217

Please sign in to comment.