1

I am using this neat trick from another Stack Overflow question: True Isometric Projection with OpenGL to setup an isometric projection. If I draw just outline with lines everything is fine 1 but if I draw polygons they get clipped and so lines 2.

       Correct      Clipped

Code to setup projection:

    pmv.glMatrixMode(PMVMatrix.GL_PROJECTION);
    pmv.glLoadIdentity();
    float dist = (float)Math.sqrt(1 / 3.0f);
    pmv.gluLookAt(dist, dist, dist,
              0.0f,  0.0f,  0.0f,
              0.0f,  1.0f,  0.0f);

NOTE: I am using JOGL, so it might be a possible bug there; other than that, no culling, depth test enabled and depthrange for offsetting lines/polys.

4

1 に答える 1

2

フラスタムのニアプレーンとファープレーンを詳しく見ると、それらが正しく設定されていないことがわかります

    N: Plane[ [ 0.57735026, 0.57735026, 0.57735026 ], 0.0], 
    F: Plane[ [ -0.57735026, -0.57735026, -0.57735026 ], 1.9999998]], 

解決策は簡単で、最初に正しい近/遠値でオルソ投影を設定し、次にルックアット関数行列で乗算します

    pmv.glMatrixMode(PMVMatrix.GL_PROJECTION);
    pmv.glLoadIdentity();
    pmv.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
    float dist = (float)Math.sqrt(1 / 3.0f);
    pmv.gluLookAt(dist, dist, dist,
              0.0f,  0.0f,  0.0f,
              0.0f,  1.0f,  0.0f);

結果:

    N: Plane[ [ -0.57735026, -0.57735026, -0.57735026 ], 1.9999998], 
    F: Plane[ [ 0.57735026, 0.57735026, 0.57735026 ], 0.0]],
于 2013-09-20T19:45:05.290 に答える