Java 类javax.vecmath.Tuple4f 实例源码

项目:ChessMaster    文件:RenderUtil.java   
static short createVertexBuffer(ByteBuffer buffer, BGFXVertexDecl decl, Object[]... vertices) {
    for (Object[] objects : vertices) {
        for (Object object : objects) {
            if (object instanceof Tuple2f)
                buffer.putFloat(((Tuple2f) object).getX()).putFloat(((Tuple2f) object).getY());
            else if (object instanceof Tuple3f)
                buffer.putFloat(((Tuple3f) object).getX()).putFloat(((Tuple3f) object).getY()).putFloat(((Tuple3f) object).getZ());
            else if (object instanceof Tuple4f)
                buffer.putFloat(((Tuple4f) object).getX()).putFloat(((Tuple4f) object).getY()).putFloat(((Tuple4f) object).getZ()).putFloat(((Tuple4f) object).getW());
            else if (object instanceof Integer)
                buffer.putInt(((int) object));
            else
                throw new IllegalArgumentException("Unknown type of vertex: " + object.getClass().getName() + ", valid type are:" +
                    "javax.vecmath.Tuple2f/3f/4f & java.lang.Integer");
        }
    }

    if (buffer.remaining() != 0) {
        throw new RuntimeException("ByteBuffer size and number of arguments do not match");
    }

    buffer.flip();

    return createVertexBuffer(buffer, decl);
}
项目:MCAnm    文件:Point.java   
public void putIntoBakedQuadBuilder(UnpackedBakedQuad.Builder builder, TextureAtlasSprite sprite) {
    Vertex transformed = getTransformedVertex();
    Tuple4f positionBuffer = new Vector4f();
    transformed.getPosition(positionBuffer);
    Tuple3f normalBuffer = new Vector3f();
    transformed.getNormal(normalBuffer);
    Tuple2f uvBuffer = new Vector2f();
    transformed.getUV(uvBuffer);

    VertexFormat vertexFormat = builder.getVertexFormat();
    int elementCount = vertexFormat.getElementCount();
    for (int e = 0; e < elementCount; e++) {
        VertexFormatElement element = vertexFormat.getElement(e);
        switch (element.getUsage()) {
        case POSITION:
            builder.put(e, positionBuffer.x, positionBuffer.z, -positionBuffer.y, positionBuffer.w);
            break;
        case NORMAL:
            builder.put(e, normalBuffer.x, normalBuffer.z, -normalBuffer.y, 0);
            break;
        case UV:
            if (element.getIndex() != 0)
                break;
            builder.put(
                    e,
                    sprite.getInterpolatedU(uvBuffer.x * 16),
                    sprite.getInterpolatedV(uvBuffer.y * 16),
                    0,
                    1);
            break;
        case COLOR:
            builder.put(e, 1, 1, 1, 1);
            break;
        default:
            builder.put(e);
        }
    }
}
项目:breakout    文件:VecmathUtils.java   
public static <T extends Tuple4f> float[] toFloatArray4(Collection<T> tuples, float[] buffer) {
    if (buffer == null) {
        buffer = new float[tuples.size() * 4];
    }
    int d = 0;
    for (final T tuple : tuples) {
        buffer[d++] = tuple.x;
        buffer[d++] = tuple.y;
        buffer[d++] = tuple.z;
        buffer[d++] = tuple.w;
    }
    return buffer;
}
项目:breakout    文件:VecmathUtils.java   
public static <T extends Tuple4f> float[] toFloatArray4(T[] tuples, float[] buffer) {
    if (buffer == null) {
        buffer = new float[tuples.length * 4];
    }
    int d = 0;
    for (final T tuple : tuples) {
        buffer[d++] = tuple.x;
        buffer[d++] = tuple.y;
        buffer[d++] = tuple.z;
        buffer[d++] = tuple.w;
    }
    return buffer;
}
项目:Mineworld    文件:TeraAssert.java   
public static void assertEquals(Tuple4f expected, Tuple4f actual, float error) {
    if (expected == null) {
        assertNull(actual);
    } else {
        assertNotNull(actual);
        String errorMessage = "Expected " + expected + ", actual" + actual;
        org.junit.Assert.assertEquals(errorMessage, expected.x, actual.x, error);
        org.junit.Assert.assertEquals(errorMessage, expected.y, actual.y, error);
        org.junit.Assert.assertEquals(errorMessage, expected.z, actual.z, error);
        org.junit.Assert.assertEquals(errorMessage, expected.w, actual.w, error);
    }
}
项目:asura-j    文件:GfVector.java   
/**
 * Sets the value of this vector to the values in tuple.
 *
 * @param tuple
 *            the source for the new GVector's new values
 */
public final void set(Tuple4f tuple) {
    elementData[0] = (float) tuple.x;
    elementData[1] = (float) tuple.y;
    elementData[2] = (float) tuple.z;
    elementData[3] = (float) tuple.w;
}
项目:ChessMaster    文件:RenderUtil.java   
static float[] toFloatArray(Tuple4f tuple4f) {
    return new float[]{tuple4f.getX(), tuple4f.getY(), tuple4f.getZ(), tuple4f.getW()};
}
项目:CustomWorldGen    文件:TRSRTransformation.java   
public static Vector4f lerp(Tuple4f from, Tuple4f to, float progress)
{
    Vector4f res = new Vector4f(from);
    res.interpolate(from, to, progress);
    return res;
}
项目:MCAnm    文件:Vertex.java   
public Vertex(Tuple4f pos, Tuple3f norm, Tuple2f uv) {
    this.pos = new Point4f(pos);
    this.norm = new Vector3f(norm);
    this.uv = new Point2f(uv);
}
项目:MCAnm    文件:Vertex.java   
/**
 * Stores this vertex's position in the target.
 */
public void getPosition(Tuple4f trgt) {
    trgt.set(this.pos);
}
项目:asura-j    文件:GfVector.java   
/**
 * Constructs a new GVector and copies the initial values from the Tuple
 *
 * @param vector
 *            the source for the new GVector's initial values
 */
public GfVector(Tuple4f tuple) {
    this(4);
    set(tuple);
}