Search in sources :

Example 31 with FloatBuffer

use of java.nio.FloatBuffer in project jmonkeyengine by jMonkeyEngine.

the class MikkTSpaceImpl method getNormal.

@Override
public void getNormal(float[] normOut, int face, int vert) {
    int vertIndex = getIndex(face, vert);
    VertexBuffer normal = mesh.getBuffer(VertexBuffer.Type.Normal);
    FloatBuffer norm = (FloatBuffer) normal.getData();
    norm.position(vertIndex * 3);
    normOut[0] = norm.get();
    normOut[1] = norm.get();
    normOut[2] = norm.get();
}
Also used : VertexBuffer(com.jme3.scene.VertexBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 32 with FloatBuffer

use of java.nio.FloatBuffer in project jmonkeyengine by jMonkeyEngine.

the class MikkTSpaceImpl method setTSpaceBasic.

@Override
public void setTSpaceBasic(float[] tangent, float sign, int face, int vert) {
    int vertIndex = getIndex(face, vert);
    VertexBuffer tangentBuffer = mesh.getBuffer(VertexBuffer.Type.Tangent);
    FloatBuffer tan = (FloatBuffer) tangentBuffer.getData();
    tan.position(vertIndex * 4);
    tan.put(tangent);
    tan.put(sign);
    tan.rewind();
    tangentBuffer.setUpdateNeeded();
}
Also used : VertexBuffer(com.jme3.scene.VertexBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 33 with FloatBuffer

use of java.nio.FloatBuffer in project jmonkeyengine by jMonkeyEngine.

the class MikkTSpaceImpl method getPosition.

@Override
public void getPosition(float[] posOut, int face, int vert) {
    int vertIndex = getIndex(face, vert);
    VertexBuffer position = mesh.getBuffer(VertexBuffer.Type.Position);
    FloatBuffer pos = (FloatBuffer) position.getData();
    pos.position(vertIndex * 3);
    posOut[0] = pos.get();
    posOut[1] = pos.get();
    posOut[2] = pos.get();
}
Also used : VertexBuffer(com.jme3.scene.VertexBuffer) FloatBuffer(java.nio.FloatBuffer)

Example 34 with FloatBuffer

use of java.nio.FloatBuffer in project jmonkeyengine by jMonkeyEngine.

the class BufferUtils method createFloatBuffer.

//// -- GENERAL FLOAT ROUTINES -- ////
/**
     * Create a new FloatBuffer of the specified size.
     * 
     * @param size
     *            required number of floats to store.
     * @return the new FloatBuffer
     */
public static FloatBuffer createFloatBuffer(int size) {
    FloatBuffer buf = allocator.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
    buf.clear();
    onBufferAllocated(buf);
    return buf;
}
Also used : FloatBuffer(java.nio.FloatBuffer)

Example 35 with FloatBuffer

use of java.nio.FloatBuffer in project jmonkeyengine by jMonkeyEngine.

the class BufferUtils method createFloatBuffer.

/**
     * Generate a new FloatBuffer using the given array of ColorRGBA objects.
     * The FloatBuffer will be 4 * data.length long and contain the color data.
     *
     * @param data
     *            array of ColorRGBA objects to place into a new FloatBuffer
     */
public static FloatBuffer createFloatBuffer(ColorRGBA... data) {
    if (data == null) {
        return null;
    }
    FloatBuffer buff = createFloatBuffer(4 * data.length);
    for (int x = 0; x < data.length; x++) {
        if (data[x] != null) {
            buff.put(data[x].getRed()).put(data[x].getGreen()).put(data[x].getBlue()).put(data[x].getAlpha());
        } else {
            buff.put(0).put(0).put(0).put(0);
        }
    }
    buff.flip();
    return buff;
}
Also used : FloatBuffer(java.nio.FloatBuffer)

Aggregations

FloatBuffer (java.nio.FloatBuffer)291 ByteBuffer (java.nio.ByteBuffer)82 IntBuffer (java.nio.IntBuffer)43 ShortBuffer (java.nio.ShortBuffer)39 Vector3f (com.jme3.math.Vector3f)27 VertexBuffer (com.jme3.scene.VertexBuffer)27 DoubleBuffer (java.nio.DoubleBuffer)17 IndexBuffer (com.jme3.scene.mesh.IndexBuffer)16 LongBuffer (java.nio.LongBuffer)10 Mesh (com.jme3.scene.Mesh)9 CharBuffer (java.nio.CharBuffer)9 FrameBuffer2D (androidx.media.filterfw.FrameBuffer2D)8 OutputPort (androidx.media.filterfw.OutputPort)7 Matrix4f (com.jme3.math.Matrix4f)7 Buffer (java.nio.Buffer)7 TempVars (com.jme3.util.TempVars)6 IOException (java.io.IOException)6 BufferOverflowException (java.nio.BufferOverflowException)6 BufferUnderflowException (java.nio.BufferUnderflowException)6 ArrayList (java.util.ArrayList)6