侧面有可点击区域的 3D 可旋转立方体 [英] 3D rotatable cube with clickable areas on sides

查看:18
本文介绍了侧面有可点击区域的 3D 可旋转立方体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要完成的是一个带有 3D 可旋转立方体的 iPad 应用程序,我想在立方体的每一侧定义多个区域,一旦点击这些区域就会进入另一个视图或显示一个弹出窗口.

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.

  1. 这是否可以通过在 Xcode 中从头开始使用 OpenGL ES 的一些努力来实现,或者我应该使用 3D 框架,如果是这样,最简单的框架是什么?(我只听说过 Unity 并且它相当昂贵)

  1. 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 立方体,你可以使用 Core Animation 来实现.查看 CATransformLayer.您可以使用 CATransformLayer 轻松构建真正的 3D 层次结构.Joe Ricioppo 有一篇关于此的很酷的文章,以及一些示例代码和视频.它类似于 3D CSS3 变换,但操作代表 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.

最大的问题是触摸处理的工作方式.您不能CATransformLayer 上使用 -hitTest:,因为它无法将 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.

这篇关于侧面有可点击区域的 3D 可旋转立方体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆