我在網上衝浪尋找在Android上翻頁的好效果,但似乎並沒有一個。因爲我正在學習平臺,所以能夠做到這一點似乎是件好事。在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
也許有人可以幫助我在一個公式來簡單地摺疊在頁面右上角診斷內部創建一個類似的效果,我可以稍後應用陰影來更深入地展示它?
非常酷,繼續,我認爲你可以做得更好 – pengwang 2011-03-03 06:06:45
我將盡快提交一個新的版本,作爲一個ListView,所以你將能夠添加任何種類的視圖! – Moss 2011-04-06 09:01:36
有趣但仍需要是獨立的觀點。 – Hamid 2011-04-12 08:07:13