3D旋转立方体两侧可点击区域立方体、区域

2023-09-08 00:53:15 作者:一往痴心

我想做到的是一个iPad应用程序与3D可旋转的立方体,并在魔方的每一面我想定义,即一旦点击会采取另一种观点认为,或显示一个弹出多个领域。

What I want to accomplish is an iPad Application with a 3D rotatable cube, and on each side of the cube I want to define multiple areas where once clicked would take to another view or display a popup.

这可以用从无到有使用OpenGL ES以x code一些努力来实现,或者我应该使用3D架构,如果是的话,这将是最简单的框架? (我只听到统一和pretty的昂贵)

Can this be achieved with some effort using OpenGL ES in Xcode from scratch, or should I use a 3D framework, if so what would be the easiest framework? (I have only heard of Unity and its pretty expensive)

有没有人有一个很好的教程我学习如何做到这一点?

Does anyone have a good tutorial for me to learn how to do this?

我已经尝试过3D CSS3转换,但我想保留,作为最后的手段。

I already tried 3D CSS3 Transformation but I want to keep that as the last resort.

推荐答案

如果你想要的是一个文字3D魔方,你可以使用核心动画这一点。看看 CATransformLayer 。您可以撰写真正的3D分层pretty的轻松使用 CATransformLayer 。乔Ricioppo有这个一个很酷的文章,随着一些样品code和视频。它类似于3D CSS3转换,但它是一个更容易操作的重新presents单独将每个子层的3D分层结构,而不是单层。只需旋转你所有的立方体表面开始,所以他们组成一个立方体定位​​。然后,你可以应用转换到转换层本身,它会做所有花哨的数学自动改变你的子层。

If all you want is a literal 3D cube, you can use Core Animation for this. Check out CATransformLayer. You can compose true 3D hierarchies pretty easily using CATransformLayer. Joe Ricioppo has a cool article about this, along with some sample code and a video. It's similar to 3D CSS3 transforms, except it's a lot easier to manipulate a single layer that represents a 3D hierarchy instead of individually transforming each sublayer. Just rotate all your cube faces initially and position them so they form a cube. Then you can apply transforms to the transform layer itself, and it will do all the fancy math to transform your sublayers automatically.

的大问题,这是触摸操作是如何工作的。您的不能的使用 -hitTest: CATransformLayer ,因为它是无法映射2D触控自己的3D层次。你也许可以操纵自己的则hitTest:实施摸不着头脑,但它几乎感觉比它的价值更多的工作。我不知道有什么规定的OpenGL提供了2D到3D触控翻译,但是这可能是你唯一的选择。

The big problem with this is how touch handling will work. You cannot use -hitTest: on CATransformLayer as it is unable to map 2D touches to its own 3D hierarchy. You might be able to rig your own hitTest: implementation to figure this out, but it almost feels like more work than its worth. I'm unaware of what provisions OpenGL offers for 2D-to-3D touch translation, but this may be your only option.