在 iOS 纵向:
“许多其他教程和示例代码都无法生成可信的 3D 翻转。在 y 轴上的简单旋转不是 iOS 中所做的。”
在寻找样品将近 30 小时后,我不得不同意。
我有一部电影,我可以在中间截屏。
视图的右侧有:
- 向左移动并缩小到 95%。
视图的左侧有:
- 向右移动并缩小到 80%。
在 Android Full(初始状态):
Android 中:
安卓代码:
// @param interpolatedTime The value of the normalized time (0.0 to 1.0)
// @param t The Transformation object to fill in with the current transforms.
protected void applyTransformation(float interpolatedTime, Transformation t){
float degrees = toDegree*interpolatedTime;
//float rad = (float) (degrees * Math.PI / 180.0f);
Matrix matrix = t.getMatrix();
camera.save();
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);// M' = M * T(dx, dy)
matrix.postTranslate(centerX, centerY); // M' = T(dx, dy) * M
}
代码的改进版本可以在大多数示例中找到:
// @param interpolatedTime The value of the normalized time (0.0 to 1.0)
// @param t The Transformation object to fill in with the current transforms.
protected void applyTransformation(float interpolatedTime, Transformation t){
float degrees = toDegree*interpolatedTime;
//float rad = (float) (degrees * Math.PI / 180.0f);
Matrix matrix = t.getMatrix();
camera.save();
camera.translate(0.0f, 0.0f, mDepthZ * interpolatedTime);
camera.rotateY(degrees);
camera.getMatrix(matrix);
camera.restore();
matrix.preTranslate(-centerX, -centerY);// M' = M * T(dx, dy)
matrix.postTranslate(centerX, centerY); // M' = T(dx, dy) * M
}
一些区别是:
- 视图的右侧不会像 iOS 那样移动。
这是 Android 相机轴:
我确实相信 Z 轴上的平移无法解决此问题。也许也需要收缩。
float dz = (float) (centerX * Math.sin(rad));
camera.translate(0f, 0f, -dz);
还是不够。左侧缩小太多了。