相关疑难解决方法(0)

使用glFrustum进行轴外投影

我正在尝试使用OpenGL对场景进行离轴投影,并且我将文档读取到了Robert Kooima的离轴投影,现在对于实际需要做的事情有了更好的想法,但仍然有一些部分我觉得这里很棘手.我知道OpenGL的离轴投影代码有点如下:

代码1:

glMatrixMode(GL_PROJECTION);  
    glLoadIdentity();            
    glFrustum(fNear*(-fFov * ratio + headX),  
              fNear*(fFov * ratio + headX),  
              fNear*(-fFov + headY),  
              fNear*(fFov + headY),  
              fNear, fFar);  
          
    glMatrixMode(GL_MODELVIEW);  
    glLoadIdentity();  
    gluLookAt(headX*headZ, headY*headZ, 0, headX*headZ, headY*headZ, -1, 0, 1, 0);
    glTranslatef(0.0,0.0,headZ);
Run Code Online (Sandbox Code Playgroud)

如果这是用户位于屏幕中心的正常透视投影,那么我理解的内容相当容易理解.

               Screen  
                   |
                   |  h = H/2
                   |  
x----- n -----------
                   |
                   |  h = H/2
                   |
Run Code Online (Sandbox Code Playgroud)

当用户在x处并且距离屏幕的距离为n时,glFrustum的顶部,底部坐标将被计算为:(假设theta是视野(fov),我认为假设为30度)

h = n * tan (theta/2);
tanValue = DEG_TO_RAD * theta/2;
[EDIT Line additon here>>]: fFov = tan(tanValue);
h …
Run Code Online (Sandbox Code Playgroud)

c++ opengl algorithm 3d openframeworks

5
推荐指数
1
解决办法
1890
查看次数

标签 统计

3d ×1

algorithm ×1

c++ ×1

openframeworks ×1

opengl ×1