當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。