我怎么计算使用glUnProject openGL的触摸 [英] how do i calculate the Touch on openGL using glUnProject

查看:661
本文介绍了我怎么计算使用glUnProject openGL的触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现高达近计划和远计划..然后如何识别使用这个我感动的对象..任何人都可以请帮助我。这是我的code ..

   - (布尔)checkCollission:(CGPoint)也是如此winpos
{
    winPos.y =(浮点)__视[3]  -  winPos.y;

    三维点NearPoint的;
    三维点公司Farpoint;
    三维点rayVector;

    在检索//位置投射在附近计划
    gluUnProject(winPos.x,winPos.y,0,__modelview,__projection,__viewport,&安培; nearPoint.x,&安培; nearPoint.y,&安培; nearPoint.z);

    在检索//位置投射在远处计划
    gluUnProject(winPos.x,winPos.y,1,__modelview,__projection,__viewport,和放大器; farPoint.x,和放大器; farPoint.y,和放大器; farPoint.z);
}
 

解决方案

  rayVector.x = farPoint.x  -  nearPoint.x
rayVector.y = farPoint.y  -  nearPoint.y
rayVector.z = farPoint.z  -  nearPoint.z
 

现在,你已经确定的演员阵容到场景中的鼠标位置的射线,你要测试,如果射线相交的任何对象。 OpenGL的帮不了你那里,因为所有的OpenGL是大约是借鉴的东西在屏幕上。

采摘的,这就是你问的这个问题,是OpenGL之外的问题。在采线相交测试项A互联网搜索应该给你足够的结果。

Hi i found upto near plan and far plan.. then how to identify using this i touched on the object.. could anyone pls help me.. Here is My code..

-(Boolean) checkCollission:(CGPoint)winPos
{   
    winPos.y = (float)__viewport[3] - winPos.y;

    Point3D nearPoint;
    Point3D farPoint;
    Point3D rayVector;

    //Retreiving position projected on near plan
    gluUnProject( winPos.x, winPos.y , 0, __modelview, __projection, __viewport, &nearPoint.x, &nearPoint.y, &nearPoint.z);

    //Retreiving position projected on far plan
    gluUnProject( winPos.x, winPos.y,  1, __modelview, __projection, __viewport, &farPoint.x, &farPoint.y, &farPoint.z);
}

解决方案

and…

rayVector.x = farPoint.x - nearPoint.x
rayVector.y = farPoint.y - nearPoint.y
rayVector.z = farPoint.z - nearPoint.z

Now that you've determined the ray that's cast into the scene by the mouse position, you have to test if the ray intersects with any of the objects. OpenGL can not help you there, since all that OpenGL is about is drawing things on the screen.

Picking, that's the problem you're asking about, is a problem outside of OpenGL. A internet search on the terms "Picking ray intersection test" should give you plenty of results.

这篇关于我怎么计算使用glUnProject openGL的触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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