本文整理汇总了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();
}
示例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;
}
示例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;
}