當前位置: 首頁>>代碼示例>>Java>>正文


Java GL2.GL_POLYGON屬性代碼示例

本文整理匯總了Java中javax.media.opengl.GL2.GL_POLYGON屬性的典型用法代碼示例。如果您正苦於以下問題:Java GL2.GL_POLYGON屬性的具體用法?Java GL2.GL_POLYGON怎麽用?Java GL2.GL_POLYGON使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.GL_POLYGON屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderFace

void renderFace(int i, GL2 gl, int curDistanceAttrib, List<Float> dist) {
    if (i >= facesVertIdxs.size()) {
        return;
    }

    int[] vertIdxs = facesVertIdxs.get(i);
    // get the vertex indicies for face i

    int polytype;
    if (vertIdxs.length == 3) {
        polytype = GL2.GL_TRIANGLES;
    } else if (vertIdxs.length == 4) {
        polytype = GL2.GL_QUADS;
    } else {
        polytype = GL2.GL_POLYGON;
    }
    
  
   
    gl.glBegin(polytype);
    // get the normal and tex coords indicies for face i
    int[] normIdxs = facesNormIdxs.get(i);

    Vector3f vert, norm;
    for (int f = 0; f < vertIdxs.length; f++) {
        if (normIdxs[f] != 0) {  // if there are normals, render them
            norm = normals.get(normIdxs[f] - 1);
            gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ());
        }

         gl.glVertexAttrib1f(curDistanceAttrib,dist.get(vertIdxs[f] - 1));

        vert = verts.get(vertIdxs[f] - 1);  // render the vertices

        gl.glVertex3d(vert.getX(), vert.getY(), vert.getZ());

    }

    gl.glEnd();
}
 
開發者ID:Fidentis,項目名稱:Analyst,代碼行數:40,代碼來源:Faces.java

示例2: build

/**
 * Create a SimpleBody from the previously given definition.
 *
 * @return A new SimpleBody.
 */
public SimpleBody build() {
    /**
     * Tell Assembler to compile all the surfaces and then retrieve the
     * necessary values.
     */
    assembler.compileSurfaceCompilation();
    //Buffer containing all Vertextdata off all previously added shapes.
    //The data in in the format: vertexX, vertexY, vertexZ, normalX, normalY, normalZ.
    final FloatBuffer dataBuffer = assembler.getDataBuffer();
    /**
     * List of index buffers. Each index buffer belongs to a shape and
     * consists of pointers to vertices in the data buffer.
     */
    final List<IntBuffer> indicesBufferList = assembler.getIndicesBuffers();
    /**
     * List of boolean flags. Runs parallel to the indicesBufferList and is
     * true if the shape is a polygon, false if it's a QuadStrip.
     */
    final List<Boolean> surfaceTypeList = assembler.getSurfaceTypeList();
    final List<ImplementedTexture> textureList = assembler.getTextureList();
    final int[] indexBufferNames = bmInitialiser.addData(dataBuffer, indicesBufferList);
    final SimpleBody simpleBody = new SimpleBody();
    for (int i = 0; i < indexBufferNames.length; i++) {
        final int shapeMode = surfaceTypeList.get(i) ? GL2.GL_POLYGON : GL2.GL_QUAD_STRIP;
        final ImplementedTexture texture = textureList.get(i);
        final Shape shape = new Shape(indexBufferNames[i], indicesBufferList.get(i).capacity(), shapeMode).setTexture(texture);
        if (texture != null) {
            texturedShapes.add(shape);
        }
        simpleBody.addShape(shape);
    }
    return simpleBody;
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:38,代碼來源:StackBuilder.java

示例3: build

public SimpleBody build(List<Vertex> trackDescription) {
    assembler.calculateTrack(trackDescription, laneWidth, laneCount, trackHeight, closedTrack, textureTop, textureBottom, textureSide);
    /**
     * Buffer containing all vertex data from all previously added shapes.
     * The data in in the format: vertexX, vertexY, vertexZ, normalX,
     * normalY, normalZ.
     */
    final FloatBuffer dataBuffer = assembler.getDataBuffer();
    /**
     * List of index buffers. Each index buffer belongs to a shape and
     * consists of pointers to vertices in the data buffer.
     */
    final List<IntBuffer> indicesBufferList = assembler.getIndicesBuffers();
    /**
     * List of boolean flags. Runs parallel to the indicesBufferList and is
     * true if the shape is a polygon, false if it's a QuadStrip.
     */
    final List<Boolean> surfaceTypeList = assembler.getSurfaceTypeList();
    final List<ImplementedTexture> textureList = assembler.getTextureList();
    final int[] indexBufferNames = bmInitialiser.addData(dataBuffer, indicesBufferList);
    /**
     * Create the SimpleBody that represents this RaceTrack.
     */
    final SimpleBody simpleBody = new SimpleBody();
    for (int i = 0; i < indexBufferNames.length; i++) {
        final int shapeMode = surfaceTypeList.get(i) ? GL2.GL_POLYGON : GL2.GL_QUAD_STRIP;
        final ImplementedTexture texture = textureList.get(i);
        simpleBody.addShape(new Shape(indexBufferNames[i], indicesBufferList.get(i).capacity(), shapeMode).setTexture(texture));
    }
    return simpleBody;
}
 
開發者ID:ABoschman,項目名稱:2IV60_RobotRace,代碼行數:31,代碼來源:TrackBuilder.java


注:本文中的javax.media.opengl.GL2.GL_POLYGON屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。