Java 类javax.vecmath.Tuple2f 实例源码

项目: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 Tuple2f> float[] toFloatArray2(Collection<T> tuples, float[] buffer) {
    if (buffer == null) {
        buffer = new float[tuples.size() * 2];
    }
    int d = 0;
    for (final T tuple : tuples) {
        buffer[d++] = tuple.x;
        buffer[d++] = tuple.y;
    }
    return buffer;
}
项目:breakout    文件:VecmathUtils.java   
public static <T extends Tuple2f> float[] toFloatArray2(T[] tuples, float[] buffer) {
    if (buffer == null) {
        buffer = new float[tuples.length * 2];
    }
    int d = 0;
    for (final T tuple : tuples) {
        buffer[d++] = tuple.x;
        buffer[d++] = tuple.y;
    }
    return buffer;
}
项目:ChessMaster    文件:RenderUtil.java   
static float[] toFloatArray(Tuple2f tuple) {
    return new float[]{tuple.getX(), tuple.getY()};
}
项目:Analyst    文件:TextureFP.java   
public TextureFP(FacialPointType type, Tuple2f point) {
    this.type = type;
    this.x = point.x;
    this.y = point.y;
}
项目: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 uv coordinates in the target.
 */
public void getUV(Tuple2f trgt) {
    trgt.set(this.uv);
}
项目:java-3d-utils4gl    文件:VertexBuffer.java   
/**
 * Adds a new 2D texture coordinate tuple to the buffer
 * 
 * @param _tuple Tuple2f object to add to the vertex buffer
 */
public void addTexCoord(Tuple2f _tuple) {
    int nIdx = getTextureOffset(m_nVertexCount);
    m_textureCoords.put(nIdx + 0, _tuple.x);
    m_textureCoords.put(nIdx + 1, _tuple.y);
}
项目:java-3d-utils4gl    文件:VertexBuffer.java   
/**
 * Gets the specified texture coordinate tuple from the buffer
 * 
 * @param _nIndex The index of the texture coordinates to change
 * @param _tuple Tuple2f object where the texture coordinates will be stored
 */
public void getTexCoord(int _nIndex, Tuple2f _tuple) {
    int nIdx = getTextureOffset(_nIndex);
    _tuple.x = m_textureCoords.get(nIdx + 0);
    _tuple.y = m_textureCoords.get(nIdx + 1);
}
项目:java-3d-utils4gl    文件:VertexBuffer.java   
/**
 * Changes the specified vertex in the buffer
 * 
 * @param _nIndex The index of the texture coordinates to change
 * @param _tuple Tuple2f object to use to change the vertex buffer
 */
public void setTexCoord(int _nIndex, Tuple2f _tuple) {
    int nIdx = getTextureOffset(_nIndex);
    m_textureCoords.put(nIdx + 0, _tuple.x);
    m_textureCoords.put(nIdx + 1, _tuple.y);
}
项目: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(Tuple2f tuple) {
    this(2);
    set(tuple);
}
项目: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(Tuple2f tuple) {
    elementData[0] = (float) tuple.x;
    elementData[1] = (float) tuple.y;
}