如何从屏幕确定 3D 空间中触摸的内容? [英] How do I determine what is touched in 3D space from the screen?

查看:12
本文介绍了如何从屏幕确定 3D 空间中触摸的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的 OpenGL ES 1.1 android 应用程序中使用 gl.gluUnproject 来确定用户触摸屏幕时选择了什么?

How do I use gl.gluUnproject in my OpenGL ES 1.1 android app to determine what is selected when the user touches the screen?

我的理解是触摸事件产生一条线,我必须找到它相交的第一个东西".

My understanding is that the touch event results in a line and I have to find the first "thing" it intersects with.

有没有关于如何做到这一点的教程?

Are there any tutorials on how to do this?

推荐答案

我的一个想法是缓存调用 gluProject 的结果.这可能仅在您处理固定相机时才实用.在相机视角发生任何变化后,我可以重新生成这个可触摸"缓存.

One thought I had was to cache the results of calling gluProject. This might only be practical when you are dealing with a fixed camera. At the end of any change in camera perspective, I can regenerate this cache of "touchables".

这还有一个额外的好处,即确保我只针对会响应被触摸的事物测试输入.

This also has the added benefit of ensuring that I'm only testing input against things that will respond to being touched.

如果对这种方法有任何想法,我将不胜感激!

I'd appreciate any thoughts on this approach!

这篇关于如何从屏幕确定 3D 空间中触摸的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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