Java Cube cubeTextureArray(float x0, float y0, float x1, float y1)

Here you can find the source of cubeTextureArray(float x0, float y0, float x1, float y1)

Description

A GL_QUAD compatible array of texture coordinates.

License

Open Source License

Parameter

Parameter Description
x0 The x-value of the top-left texture coordinate.
y0 The y-value of the top-left texture coordinate.
x1 The x-value of the bottom-right texture coordinate.
y1 The y-value of the bottom-right texture coordinate.

Return

An array of coordinates that should be rendered 4 values at a time to form a cube with given texture coordinates.

Declaration

public static float[] cubeTextureArray(float x0, float y0, float x1, float y1) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w  w  w  . j ava  2s  . c  om*/
     * A GL_QUAD compatible array of texture coordinates.
     * 
     * @param x0
     *            The x-value of the top-left texture coordinate.
     * @param y0
     *            The y-value of the top-left texture coordinate.
     * @param x1
     *            The x-value of the bottom-right texture coordinate.
     * @param y1
     *            The y-value of the bottom-right texture coordinate.
     * @return An array of coordinates that should be rendered 4 values at a
     *         time to form a cube with given texture coordinates.
     */
    public static float[] cubeTextureArray(float x0, float y0, float x1, float y1) {
        float[] tex = new float[] { x0, y0, x1, y0, x1, y1, x0, y1 };

        return makeBigArray(tex, 6);
    }

    public static float[] makeBigArray(float[] array, int number) {
        float[] result = new float[array.length * number];

        for (int i = 0; i < number; i++) {
            for (int j = 0; j < array.length; j++) {
                result[i * array.length + j] = array[j];
            }
        }

        return result;
    }
}

Related

  1. cube(int a)
  2. cube(int value)
  3. cube2rect(byte[][][] cube)
  4. cubed(final int input)
  5. cubeIntersectsSphere(int x1, int y1, int z1, int x2, int y2, int z2, int sX, int sY, int sZ, int radius)
  6. cubeTextureFace(float x0, float y0, float x1, float y1)
  7. cubeToBounds(float[] target, float x, float y, float z, float w, float d, float h)
  8. cubeVertexArray(float x, float y, float z, float size)