2010-12-01 150 views
1

我一直在玩Android的动画框架,我发现下面的3D旋转示例代码:3D旋转被翻译

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Transition3d.html

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html

它确实几乎我想要什么,但我希望ImageView在从A点转换到B点时旋转,并且它应该沿着它自己的中心(它正在移动)旋转,而不是屏幕容器的中心。

有谁知道该怎么做?

-Rachel

回答

0

那么这是非常接近你发布。本质上,你将旋转矩阵乘以平移矩阵。这基本上是在封面下发生的。 Android通过它的API隐藏了您的细节:

Matrix matrix = transformation.getMatrix(); 
matrix.rotate(rotateX, rotateY); 
matrix.postTranslate(transX, transY); 

先旋转然后翻译将在翻译它之前围绕它自己的轴旋转图像。

+0

您是不是指matrix.setRotate(rotateX,rotateY)?我认为这是2D旋转寿命。我们不得不使用camera.rotateY来实现3D旋转效果吗? – 2010-12-01 17:45:44