private void paint3D(int n1, int w2) {
        int[] xPol = new int[3];
        int[] yPol = new int[3];

        Graphics2D g = image.createGraphics();

        int ib = 0, ie = n1, sti = 1, jb = 0, je = n1, stj = 1;

        if(m20 < 0) {
            ib = n1;
            ie = -1;
            sti = -1;
        }

        if(m22 < 0) {
            jb = n1;
            je = -1;
            stj = -1;
        }

        double second_color = 1 - color_3d_blending;

        double red, green, blue;

        for(int i = ib; i != ie; i += sti) {
            for(int j = jb; j != je; j += stj) {

                red = ((((int)vert[i][j][0]) >> 16) & 0xff);
                green = ((((int)vert[i][j][0]) >> 8) & 0xff);
                blue = (((int)vert[i][j][0]) & 0xff);

                if(Norm1z[i][j][0] > 0) {
                    xPol[0] = w2 + (int)vert1[i][j][0];
                    xPol[1] = w2 + (int)vert1[i + 1][j][0];
                    xPol[2] = w2 + (int)vert1[i + 1][j + 1][0];
                    yPol[0] = w2 - (int)vert1[i][j][1];
                    yPol[1] = w2 - (int)vert1[i + 1][j][1];
                    yPol[2] = w2 - (int)vert1[i + 1][j + 1][1];

                    g.setColor(new Color((int)(red * color_3d_blending + ((colors_3d[(int)Norm1z[i][j][0]] >> 16) & 0xff) * second_color + 0.5), (int)(green * color_3d_blending + ((colors_3d[(int)Norm1z[i][j][0]] >> 8) & 0xff) * second_color + 0.5), (int)(blue * color_3d_blending + (colors_3d[(int)Norm1z[i][j][0]] & 0xff) * second_color + 0.5)));

                    if(filters[MainWindow.ANTIALIASING]) {
                        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
                        g.fillPolygon(xPol, yPol, 3);
                        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                        g.fillPolygon(xPol, yPol, 3);
                    }
                    else {
                        g.fillPolygon(xPol, yPol, 3);
                    }

                }

                if(Norm1z[i][j][1] > 0) {
                    xPol[0] = w2 + (int)vert1[i][j][0];
                    xPol[1] = w2 + (int)vert1[i][j + 1][0];
                    xPol[2] = w2 + (int)vert1[i + 1][j + 1][0];
                    yPol[0] = w2 - (int)vert1[i][j][1];
                    yPol[1] = w2 - (int)vert1[i][j + 1][1];
                    yPol[2] = w2 - (int)vert1[i + 1][j + 1][1];

                    g.setColor(new Color((int)(red * color_3d_blending + ((colors_3d[(int)Norm1z[i][j][1]] >> 16) & 0xff) * second_color + 0.5), (int)(green * color_3d_blending + ((colors_3d[(int)Norm1z[i][j][1]] >> 8) & 0xff) * second_color + 0.5), (int)(blue * color_3d_blending + (colors_3d[(int)Norm1z[i][j][1]] & 0xff) * second_color + 0.5)));

                    if(filters[MainWindow.ANTIALIASING]) {
                        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
                        g.fillPolygon(xPol, yPol, 3);
                        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                        g.fillPolygon(xPol, yPol, 3);
                    }
                    else {
                        g.fillPolygon(xPol, yPol, 3);
                    }

                }
            }
        }

    }