【发布时间】:2011-04-24 04:38:58
【问题描述】:
我正在网上冲浪,寻找在 Android 上翻页的好效果,但似乎没有。由于我正在学习该平台,因此能够做到这一点似乎是一件好事。
我在这里找到了一个页面:http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html
- (void)deform
{
Vertex2f vi; // Current input vertex
Vertex3f v1; // First stage of the deformation
Vertex3f *vo; // Pointer to the finished vertex
CGFloat R, r, beta;
for (ushort ii = 0; ii < numVertices_; ii++)
{
// Get the current input vertex.
vi = inputMesh_[ii];
// Radius of the circle circumscribed by vertex (vi.x, vi.y) around A on the x-y plane
R = sqrt(vi.x * vi.x + pow(vi.y - A, 2));
// Now get the radius of the cone cross section intersected by our vertex in 3D space.
r = R * sin(theta);
// Angle subtended by arc |ST| on the cone cross section.
beta = asin(vi.x / R) / sin(theta);
// *** MAGIC!!! ***
v1.x = r * sin(beta);
v1.y = R + A - r * (1 - cos(beta)) * sin(theta);
v1.z = r * (1 - cos(beta)) * cos(theta);
// Apply a basic rotation transform around the y axis to rotate the curled page.
// These two steps could be combined through simple substitution, but are left
// separate to keep the math simple for debugging and illustrative purposes.
vo = &outputMesh_[ii];
vo->x = (v1.x * cos(rho) - v1.z * sin(rho));
vo->y = v1.y;
vo->z = (v1.x * sin(rho) + v1.z * cos(rho));
}
}
给出了 iPhone 的示例(上面)代码,但我不知道如何在 android 上实现它。有哪位数学大神可以帮助我了解如何在 Android Java 中实现这一点。
是否可以使用本机绘图 API,我是否必须使用 openGL?我可以以某种方式模仿这种行为吗?
任何帮助将不胜感激。谢谢。
****************编辑****************************** ******************
我在 Android API 演示中找到了一个 Bitmap Mesh 示例:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.html
也许有人可以帮助我解决一个方程式,只需将右上角向内折叠穿过页面以创建类似的效果,然后我可以应用阴影以使其更深入?
【问题讨论】:
标签: android math transition