我怎么计算使用glUnProject openGL的触摸我怎么、glUnProject、openGL

2023-09-08 10:53:02 作者:愉悦混乱

我发现高达近计划和远计划..然后如何识别使用这个我感动的对象..任何人都可以请帮助我。这是我的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 flew flgw flut 环境配置 绘制出Hello World

现在,你已经确定的演员阵容到场景中的鼠标位置的射线,你要测试,如果射线相交的任何对象。 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.