Iphone OpengGL ES:检测对原语的点击 [英] Iphone OpengGL ES: detecting clicks on a primitive

查看:104
本文介绍了Iphone OpengGL ES:检测对原语的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个充满3D多维数据集的3d环境,没有人知道您将如何检测到其中一个多维数据集上的触摸.我在想,如果我能得到多维数据集的屏幕位置(坐标从左下角开始),那将很容易

I have created a 3d environment full of 3D cubes, does anyone have any idea how you would detect a touch on one of these Cubes. I thinking if I could get the cubes screen position (coords start from bottom left) then it would be pretty easy

更新:

我添加了-(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D函数,该函数似乎使我的物品在世界上排名靠前,但我现在遇到的问题是:

I added the function -(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D which seems to give me my items position in the world but the bit I am now stuck on is:

  • 我有一个有位置的对象

  • I have objects that have a position

我在世界上的位置(gluLookAt eye [0],eye [1],eye [2])

I have my position in the world (gluLookAt eye[0], eye[1], eye[2])

然后在屏幕上点击我的位置

and then I have where I tapped on the screen

我如何将所有这些结合起来,这是我归档伟大作品的最后一件事!!!

How do I join all this up, its the last thing in my way to archiving greatness!!!!

推荐答案

查找

Look up OpenGL picking on Google. There are two main methods to accomplish this, I recommend you use the second one described at OpenGL.org as it does not involve rendering anything offscreen:

[…]涉及通过鼠标位置拍摄拾取光线并测试与当前显示的对象的相交. OpenGL不会测试射线的相交,但是您需要与OpenGL交互以生成拾取射线.

[…] involves shooting a pick ray through the mouse location and testing for intersections with the currently displayed objects. OpenGL doesn't test for ray intersections, but you'll need to interact with OpenGL to generate the pick ray.

有关此问题的一些讨论,也请参见此问题: 在OpenGLES中进行屏幕到世界的坐标转换是一项简单的任务?

Also see this question for some discussion on the matter: Screen-to-World coordinate conversion in OpenGLES an easy task?

这篇关于Iphone OpengGL ES:检测对原语的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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