Ham*_*mid 40 math android transition
我在网上冲浪寻找一个很好的效果,在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));
}
}
Run Code Online (Sandbox Code Playgroud)
给出了一个示例(上面)的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
也许有人可以帮我解决一个方程式,只是简单地向内折叠右上角,在页面上进行诊断,以创建一个类似的效果,我可以在以后使用阴影来更深入地进行测量?
har*_*ism 31
我正在使用OpenGL ES对Android上的页面卷曲效果进行一些实验.它实际上是一个草图,但可能会给出一些如何根据您的需求实现页面卷曲的想法.如果您对3D页面翻转实现感兴趣,那就是.
至于你所指的公式 - 我尝试了它并且不太喜欢结果.我会说它根本不适合小屏幕而且开始破解更简单的解决方案.
代码可以在这里找到:https: //github.com/harism/android_page_curl/
在写这篇文章的时候,我正在决定如何实现"假"软阴影 - 以及是否创建一个合适的应用程序来炫耀这个页面的卷曲效果.这也是我做过的极少数OpenGL实现中的一个,不应该作为一个正确的例子.
Mos*_*oss 29
我刚刚创建了一个开源项目,它使用原生画布在2D中进行页面卷曲模拟:https://github.com/moritz-wundke/android-page-curl 我还在努力添加适配器等等使其可用作独立视图.
| 归档时间: |
|
| 查看次数: |
42694 次 |
| 最近记录: |