Login  Register

contour lines disappeared when zoom in 3D earth coordinates

Posted by yaqiang on Dec 21, 2021; 10:37am
URL: https://forum.jogamp.org/contour-lines-disappeared-when-zoom-in-3D-earth-coordinates-tp4041550.html

Earth 3D coordinates was implemented in MeteoInfo through converting longitude, latitude and altitude coordinates to flat 3D coordinates. It's ok when plotting surface earth image and contour lines in default extent. But some contour lines disappeared when zoom in the extent. Also the legend was covered by earth image. I tested orthographic and perspective projections both have same problem.

The reshape function code is pasted below:

public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        this.width = width;
        this.height = height;
        this.positionArea = this.getPositionArea(new Rectangle2D.Double(0, 0, width, height));

        final GL2 gl = drawable.getGL().getGL2();
        if (height <= 0) {
            height = 1;
        }

        final float h = (float) width / (float) height;
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();

        if (this.orthographic) {
            float v = 2.0f;
            switch (this.aspectType) {
                case EQUAL:
                    gl.glOrthof(-v * h, v * h, -v, v, -distance, distance);
                    break;
                default:
                    gl.glOrthof(-v, v, -v, v, -distance, distance);
                    break;
            }
        } else {
            switch (this.aspectType) {
                case EQUAL:
                    glu.gluPerspective(45.0f, h, 1.0, 20.0);
                    break;
                default:
                    glu.gluPerspective(45.0f, 1.0f, 1.0, 20.0);
                    break;
            }
            glu.gluLookAt(0.0f, 0.0f, distance, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
        }
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

The related code can be found in Plot3DGL class (https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/Plot3DGL.java).

Plot earth image and contour lines:


After zoom in the extent:


Any suggestion is appreciated!
www.meteothink.org