我在浏览网页,寻找一种在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示例中找到了一个位图网格示例:http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.html
也许有人可以帮我设计一个方程,将右上角的纸角斜向折叠到页面上,从而创建类似的效果,我稍后可以应用阴影来增加深度?