当前位置: 首页>>代码示例>>Java>>正文


Java GL2.glTexCoord2d方法代码示例

本文整理汇总了Java中javax.media.opengl.GL2.glTexCoord2d方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glTexCoord2d方法的具体用法?Java GL2.glTexCoord2d怎么用?Java GL2.glTexCoord2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.opengl.GL2的用法示例。


在下文中一共展示了GL2.glTexCoord2d方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawCorners

import javax.media.opengl.GL2; //导入方法依赖的package包/类
private void drawCorners(GL2 gl, Map<String, Vertex> map) {
  Vertex rightBottom = map.get("rightBottom");
  Vertex leftBottom = map.get("leftBottom");
  Vertex rightTop = map.get("rightTop");
  Vertex leftTop = map.get("leftTop");
  TextureCoords textureCoords = texture.getImageTexCoords();

  float leftTex = textureCoords.left();
  float rightTex = textureCoords.right();
  float topTex = textureCoords.top();
  float bottomTex = textureCoords.bottom();

  gl.glPushMatrix();
  gl.glBegin(GL_TRIANGLE_STRIP);
  gl.glTexCoord2d(rightTex, bottomTex);
  gl.glVertex3f(rightBottom.getPositionX(), rightBottom.getPositionY(),
      rightBottom.getPositionZ());

  gl.glTexCoord2d(rightTex, topTex);
  gl.glVertex3f(rightTop.getPositionX(), rightTop.getPositionY(), rightTop.getPositionZ());

  gl.glTexCoord2d(leftTex, bottomTex);
  gl.glVertex3f(leftBottom.getPositionX(), leftBottom.getPositionY(), leftBottom.getPositionZ());

  gl.glTexCoord2d(leftTex, topTex);
  gl.glVertex3f(leftTop.getPositionX(), leftTop.getPositionY(), leftTop.getPositionZ());
  gl.glEnd();
  gl.glPopMatrix();
}
 
开发者ID:StefanoaicaLucian,项目名称:ParticleEffectsAPI,代码行数:30,代码来源:Particle.java

示例2: renderFace

import javax.media.opengl.GL2; //导入方法依赖的package包/类
/**
 * Renter face
 *
 * @param i index of face
 * @param flipTexCoords true if the tex coords need flipping
 * @param gl
 */
public void renderFace(int i, boolean flipTexCoords, GL2 gl) /* Render the ith face by getting the vertex, normal, and tex
 coord indicies for face i. Use those indicies to access the
 actual vertex, normal, and tex coord data, and render the face.

 Each face uses 3 array of indicies; one for the vertex
 indicies, one for the normal indicies, and one for the tex
 coord indicies.

 If the model doesn't use normals or tex coords then the indicies
 arrays will contain 0's.

 If the tex coords need flipping then the t-values are changed.
 */ {
    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);
    int[] texIdxs = facesTexIdxs.get(i);

    /* render the normals, tex coords, and vertices for face i
     by accessing them using their indicies */
    Vector3f vert, norm, texCoord;
    double yTC;
    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());
        }

        if (texIdxs[f] != 0) {
            // if there are tex coords, render them
            texCoord = texCoords.get(texIdxs[f] - 1);
            yTC = texCoord.getY();
            if (flipTexCoords) {
                yTC = 1.0f - yTC;
            }

            if (texCoord.getZ() == DUMMY_Z_TC) {
                gl.glTexCoord2d(texCoord.getX(), yTC);
            } else {
                gl.glTexCoord3d(texCoord.getX(), yTC, texCoord.getZ());
            }
            /*
             System.out.print("Tex index: " + (texIdxs[f]) + ": ");
             System.out.println("Tex coord: " + df.format(texCoord.getX()) + ", " +
             df.format( yTC ) + ", " +
             df.format( texCoord.getZ() ));
             */
        }

        vert = verts.get(vertIdxs[f] - 1);  // render the vertices
        //     System.out.println(vertIdxs[f] - 1 + " " + verts.get(vertIdxs[f] - 1).length());
        gl.glVertex3d(vert.getX(), vert.getY(), vert.getZ());

    }

    gl.glEnd();
}
 
开发者ID:Fidentis,项目名称:Analyst,代码行数:82,代码来源:Faces.java


注:本文中的javax.media.opengl.GL2.glTexCoord2d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。