//**************************************************************//
        //********************  Diagnostic Support  ********************//
        //**************************************************************//

        /**
         * Causes this SurfaceObject to render its bounding sectors to the specified region in geographic coordinates. The
         * specified viewport denotes the geographic region and its corresponding screen viewport.
         * <p/>
         * The bounding sectors are rendered as a 1 pixel wide green outline.
         *
         * @param dc  the current DrawContext.
         * @param sdc the context containing a geographic region and screen viewport corresponding to a surface tile.
         *
         * @see #getSectors(DrawContext)
         */
        protected void drawBoundingSectors(DrawContext dc, SurfaceTileDrawContext sdc)
        {
            List <Sector> sectors = this.getSectors(dc);

            if (sectors == null)
            {
                return;
            }

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            int attributeMask =
                GL2.GL_COLOR_BUFFER_BIT // For alpha test enable, blend enable, alpha func, blend func.
                | GL2.GL_CURRENT_BIT    // For current color.
                | GL2.GL_LINE_BIT;      // For line smooth, line width.

            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushAttrib(gl, attributeMask);
            ogsh.pushModelview(gl);
            try
            {
                gl.glEnable(GL.GL_BLEND);
                OGLUtil.applyBlending(gl, false);

                gl.glDisable(GL.GL_LINE_SMOOTH);
                gl.glLineWidth(1f);

                gl.glColor4f(1f, 1f, 1f, 0.5f);

                // Set the model-view matrix to transform from geographic coordinates to viewport coordinates.
                Matrix matrix = sdc.getModelviewMatrix();
                gl.glMultMatrixd(matrix.toArray(new double[16], 0, false), 0);

                foreach (Sector s in sectors)
                {
                    LatLon[] corners = s.getCorners();
                    gl.glBegin(GL2.GL_LINE_LOOP);
                    gl.glVertex2f((float)corners[0].getLongitude().degrees, (float)corners[0].getLatitude().degrees);
                    gl.glVertex2f((float)corners[1].getLongitude().degrees, (float)corners[1].getLatitude().degrees);
                    gl.glVertex2f((float)corners[2].getLongitude().degrees, (float)corners[2].getLatitude().degrees);
                    gl.glVertex2f((float)corners[3].getLongitude().degrees, (float)corners[3].getLatitude().degrees);
                    gl.glEnd();
                }
            }
            finally
            {
                ogsh.pop(gl);
            }
        }
Ejemplo n.º 2
0
        protected void drawBox(DrawContext dc, Vec4 a, Vec4 b, Vec4 c, Vec4 d)
        {
            Vec4 e  = a.add3(this.r);
            Vec4 f  = d.add3(this.r);
            GL2  gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            dc.getView().pushReferenceCenter(dc, this.bottomCenter);
            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushModelview(gl);
            try
            {
                // Draw parallel lines in R direction
                int  n  = 20;
                Vec4 dr = this.r.multiply3(1d / (double)n);

                this.drawOutline(dc, a, b, c, d);
                for (int i = 1; i < n; i++)
                {
                    gl.glTranslated(dr.x, dr.y, dr.z);
                    this.drawOutline(dc, a, b, c, d);
                }

                // Draw parallel lines in S direction
                n = 20;
                Vec4 ds = this.s.multiply3(1d / (double)n);

                gl.glPopMatrix();
                gl.glPushMatrix();
                this.drawOutline(dc, a, e, f, d);
                for (int i = 1; i < n; i++)
                {
                    gl.glTranslated(ds.x, ds.y, ds.z);
                    this.drawOutline(dc, a, e, f, d);
                }
            }
            finally
            {
                ogsh.pop(gl);
                dc.getView().popReferenceCenter(dc);
            }
        }
Ejemplo n.º 3
0
        /**
         * Display the cylinder.
         *
         * @param dc the current draw context.
         *
         * @throws ArgumentException if the draw context is null.
         */
        public void render(DrawContext dc)
        {
            if (dc == null)
            {
                String msg = Logging.getMessage("nullValue.DrawContextIsNull");
                Logging.logger().severe(msg);
                throw new ArgumentException(msg);
            }

            // Compute a matrix that will transform world coordinates to cylinder coordinates. The negative z-axis
            // will point from the cylinder's bottomCenter to its topCenter. The y-axis will be a vector that is
            // perpendicular to the cylinder's axisUnitDirection. Because the cylinder is symmetric, it does not matter
            // in what direction the y-axis points, as long as it is perpendicular to the z-axis.
            double tolerance = 1e-6;
            Vec4   upVector  = (this.axisUnitDirection.cross3(Vec4.UNIT_Y).getLength3() <= tolerance) ?
                               Vec4.UNIT_NEGATIVE_Z : Vec4.UNIT_Y;
            Matrix transformMatrix = Matrix.fromModelLookAt(this.bottomCenter, this.topCenter, upVector);

            double[] matrixArray = new double[16];
            transformMatrix.toArray(matrixArray, 0, false);

            GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

            OGLStackHandler ogsh = new OGLStackHandler();

            ogsh.pushAttrib(gl, GL2.GL_CURRENT_BIT | GL2.GL_ENABLE_BIT | GL2.GL_TRANSFORM_BIT | GL2.GL_DEPTH_BUFFER_BIT);
            try
            {
                // The cylinder is drawn with as a wireframe plus a center axis. It's drawn in two passes in order to
                // visualize the portions of the cylinder above and below an intersecting surface.

                gl.glEnable(GL.GL_BLEND);
                OGLUtil.applyBlending(gl, false);
                gl.glEnable(GL.GL_DEPTH_TEST);

                // Draw the axis
                gl.glDepthFunc(GL.GL_LEQUAL); // draw the part that would normally be visible
                gl.glColor4f(1f, 1f, 1f, 0.4f);
                gl.glBegin(GL2.GL_LINES);
                gl.glVertex3d(this.bottomCenter.x, this.bottomCenter.y, this.bottomCenter.z);
                gl.glVertex3d(this.topCenter.x, this.topCenter.y, this.topCenter.z);
                gl.glEnd();

                gl.glDepthFunc(GL.GL_GREATER); // draw the part that is behind an intersecting surface
                gl.glColor4f(1f, 0f, 1f, 0.4f);
                gl.glBegin(GL2.GL_LINES);
                gl.glVertex3d(this.bottomCenter.x, this.bottomCenter.y, this.bottomCenter.z);
                gl.glVertex3d(this.topCenter.x, this.topCenter.y, this.topCenter.z);
                gl.glEnd();

                // Draw the exterior wireframe
                ogsh.pushModelview(gl);
                gl.glMultMatrixd(matrixArray, 0);

                GLUquadric quadric = dc.getGLU().gluNewQuadric();
                dc.getGLU().gluQuadricDrawStyle(quadric, GLU.GLU_LINE);

                gl.glDepthFunc(GL.GL_LEQUAL);
                gl.glColor4f(1f, 1f, 1f, 0.5f);
                dc.getGLU().gluCylinder(quadric, this.cylinderRadius, this.cylinderRadius, this.cylinderHeight, 30, 30);

                gl.glDepthFunc(GL.GL_GREATER);
                gl.glColor4f(1f, 0f, 1f, 0.4f);
                dc.getGLU().gluCylinder(quadric, this.cylinderRadius, this.cylinderRadius, this.cylinderHeight, 30, 30);

                dc.getGLU().gluDeleteQuadric(quadric);
            }
            finally
            {
                ogsh.pop(gl);
            }
        }