⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 surfaceconcaveshape.java

📁 world wind java sdk 源码
💻 JAVA
字号:
/* Copyright (C) 2001, 2009 United States Government as represented bythe Administrator of the National Aeronautics and Space Administration.All Rights Reserved.*/package gov.nasa.worldwind.render;import gov.nasa.worldwind.geom.*;import gov.nasa.worldwind.util.Logging;import javax.media.opengl.GL;import javax.media.opengl.glu.*;/** * @author dcollins * @version $Id: SurfaceConcaveShape.java 10634 2009-04-29 03:52:29Z dcollins $ */public abstract class SurfaceConcaveShape extends AbstractSurfaceShape{    protected static GLU glu;    protected static GLUtessellator tess;    protected SurfaceConcaveShape(ShapeAttributes attributes)    {        super(attributes);    }    protected SurfaceConcaveShape()    {    }    @SuppressWarnings({"UnusedDeclaration"})    protected void doRenderInteriorToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)    {        // Concave shape makes no assumptions about the nature or structure of the shape's vertices. The interior is        // treated as a potentially complex polygon, and this code will do its best to rasterize that polygoin. The        // outline is treated as a simple line loop, regardless of whether the shape's vertices actually define a        // closed path.        ShapeAttributes attributes = this.getAttributes();        SurfaceShapeSupport shapeSupport = getSurfaceShapeSupport();        shapeSupport.applyInteriorState(dc, attributes);        this.drawArraysAsPolygon(dc, this.vertices);    }    @SuppressWarnings({"UnusedDeclaration"})    protected void doRenderOutlineToRegion(DrawContext dc, Sector sector, int x, int y, int width, int height)    {        ShapeAttributes attributes = this.getAttributes();        SurfaceShapeSupport shapeSupport = getSurfaceShapeSupport();        shapeSupport.applyOutlineState(dc, attributes);        shapeSupport.drawArrays(dc, GL.GL_LINE_LOOP, 0, this.vertices.size());    }    protected void drawArraysAsPolygon(DrawContext dc, java.util.List<? extends Vec4> vertices)    {        if (dc == null)        {            String message = Logging.getMessage("nullValue.DrawContextIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        if (vertices == null)        {            String message = Logging.getMessage("nullValue.VertexListIsNull");            Logging.logger().severe(message);            throw new IllegalArgumentException(message);        }        GLU glu = getGLU();        GLUtessellator tess = getGLUTessellator();        GLUtessellatorCallback tessCallback = this.getTessellatorCallback(dc);        this.beginTessellation(dc, glu, tess, tessCallback);        for (int i = 0; i < vertices.size(); i++)        {            double[] compArray = new double[3];            vertices.get(i).toArray3(compArray, 0);            glu.gluTessVertex(tess, compArray, 0, i);        }        this.endTessellation(dc, glu, tess);    }    //**************************************************************//    //********************  Polygon Tessellation  ******************//    //**************************************************************//    protected GLUtessellatorCallback getTessellatorCallback(DrawContext dc)    {        return new ImmediateDrawTessellatorCallback(dc.getGL());    }    @SuppressWarnings({"UnusedDeclaration"})    protected void beginTessellation(DrawContext dc, GLU glu, GLUtessellator tess, GLUtessellatorCallback tessCallback)    {        glu.gluTessNormal(tess, 0.0, 0.0, 1.0);        glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, tessCallback);        glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, tessCallback);        glu.gluTessCallback(tess, GLU.GLU_TESS_END, tessCallback);        glu.gluTessBeginPolygon(tess, null);        glu.gluTessBeginContour(tess);    }    @SuppressWarnings({"UnusedDeclaration"})    protected void endTessellation(DrawContext dc, GLU glu, GLUtessellator tess)    {        glu.gluTessEndContour(tess);        glu.gluTessEndPolygon(tess);        glu.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, null);        glu.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, null);        glu.gluTessCallback(tess, GLU.GLU_TESS_END, null);    }    //**************************************************************//    //********************  Utilities  *****************************//    //**************************************************************//    protected static GLU getGLU()    {        if (glu == null)        {            glu = new GLU();        }        return glu;    }    protected static GLUtessellator getGLUTessellator()    {        if (tess == null)        {            tess = glu.gluNewTess();            glu.gluTessNormal(tess, 0.0, 0.0, 1.0);        }        return tess;    }    protected static class ImmediateDrawTessellatorCallback extends GLUtessellatorCallbackAdapter    {        private final GL gl;        public ImmediateDrawTessellatorCallback(GL gl)        {            if (gl == null)            {                String message = Logging.getMessage("nullValue.GLIsNull");                Logging.logger().severe(message);                throw new IllegalArgumentException(message);            }            this.gl = gl;        }        public void begin(int type)        {            this.gl.glBegin(type);        }        public void vertex(Object vertexData)        {            int index = (Integer) vertexData;            this.gl.glArrayElement(index);        }        public void end()        {            this.gl.glEnd();        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -