Java Code Examples for java.nio.FloatBuffer#position()

The following examples show how to use java.nio.FloatBuffer#position() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Object3DBuilder.java    From react-native-3d-model-view with MIT License 6 votes vote down vote up
public FloatBuffer getVertexArray() {
	// initialize vertex byte buffer for shape coordinates
	ByteBuffer bb = ByteBuffer.allocateDirect(
			// (number of coordinate values * 4 bytes per float)
			drawOrder.capacity() * COORDS_PER_VERTEX * 4);
	// use the device hardware's native byte order
	bb.order(ByteOrder.nativeOrder());
	FloatBuffer ret = bb.asFloatBuffer();
	ret.position(0);
	for (int i = 0; i < drawOrder.capacity(); i++) {
		ret.put(vertices.get(drawOrder.get(i) * 3)); // x
		ret.put(vertices.get(drawOrder.get(i) * 3 + 1)); // y
		ret.put(vertices.get(drawOrder.get(i) * 3 + 2)); // z
	}
	return ret;
}
 
Example 2
Source File: ShaderColorLights.java    From smartGL with Apache License 2.0 6 votes vote down vote up
@Override
public void onPreRender(OpenGLRenderer renderer, RenderObject object, Face3D face3D) {

    float[] modelMatrix = object.getMatrix();
    GLES20.glUniformMatrix4fv(mModelMatrixId, 1, false, modelMatrix, 0);

    float[] lightDirection = renderer.getLightDirection();
    GLES20.glUniform3fv(mParallelLightDirectionId, 1, lightDirection, 0);

    float[] lightColor = renderer.getLightColor();
    GLES20.glUniform4fv(mParallelLightColorId, 1, lightColor, 0);

    float[] ambiant = renderer.getLightAmbiant();
    GLES20.glUniform4fv(mLightAmbiantId, 1, ambiant, 0);

    GLES20.glEnableVertexAttribArray(mNormalsId);
    NormalList normalList = face3D.getNormalList();
    FloatBuffer vertexBuffer = normalList.getFloatBuffer();
    vertexBuffer.position(0);
    GLES20.glVertexAttribPointer(mNormalsId, 3, GLES20.GL_FLOAT, false, 0, vertexBuffer);
}
 
Example 3
Source File: TestPointerToBuffer.java    From jcuda with MIT License 6 votes vote down vote up
@Test
public void testWithPosition2()
{
    float array[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
    FloatBuffer arrayBuffer = FloatBuffer.wrap(array);
    FloatBuffer directBuffer = 
        ByteBuffer.allocateDirect(array.length * Sizeof.FLOAT).
            order(ByteOrder.nativeOrder()).asFloatBuffer();
    directBuffer.put(array);
    directBuffer.rewind();
    
    arrayBuffer.position(2);
    directBuffer.position(2);
    
    assertTrue(copyWithTo      (arrayBuffer,  4, new float[] {0, 1, 2, 3}));
    assertTrue(copyWithToBuffer(arrayBuffer,  4, new float[] {2, 3, 4, 5}));
    assertTrue(copyWithTo      (directBuffer, 4, new float[] {0, 1, 2, 3}));
    assertTrue(copyWithToBuffer(directBuffer, 4, new float[] {2, 3, 4, 5}));
}
 
Example 4
Source File: DrawerImpl.java    From android-3D-model-viewer with GNU Lesser General Public License v3.0 6 votes vote down vote up
private int setPosition(Object3DData obj) {

        // get handle to vertex shader's a_Position member
        int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position");
        GLUtil.checkGlError("glGetAttribLocation");

        // Enable a handle to the triangle vertices
        GLES20.glEnableVertexAttribArray(mPositionHandle);
        GLUtil.checkGlError("glEnableVertexAttribArray");

        FloatBuffer vertexBuffer = obj.getVertexArrayBuffer() != null ? obj.getVertexArrayBuffer()
                : obj.getVertexBuffer();
        vertexBuffer.position(0);
        GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, VERTEX_STRIDE,
                vertexBuffer);
        GLUtil.checkGlError("glVertexAttribPointer");

        return mPositionHandle;
    }
 
Example 5
Source File: Utils.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a point.
 * @param gl  The GL10 object for drawing
 * @param x The point's x coordinate
 * @param y The point's y coordinate
 * @param color The color in the form 0xAARRGGBB
 */
public static void drawPoint(GL10 gl, float x, float y, float size, int color) {

    fb.rewind();

    fb.put(x); // x
    fb.put(y); // y
    fb.put(0.0f); // z

    fb.put(Color.red(color) / 255.0f);   // r
    fb.put(Color.green(color) / 255.0f); // g
    fb.put(Color.blue(color) / 255.0f);  // b
    fb.put(Color.alpha(color) / 255.0f); // a

    fb.rewind();

    gl.glPointSize(size);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

    gl.glVertexPointer(3, GL10.GL_FLOAT, (3 + 4) * 4, fb);

    FloatBuffer colors = fb.duplicate();
    colors.position(3);
    gl.glColorPointer(4, GL10.GL_FLOAT, (3 + 4) * 4, colors);

    gl.glDrawArrays(GL10.GL_POINTS, 0, 1);

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
}
 
Example 6
Source File: Plane.java    From Pano360 with MIT License 5 votes vote down vote up
public void uploadTexCoordinateBuffer(int textureCoordinateHandle){
    FloatBuffer textureBuffer = getTexCoordinateBuffer();
    if (textureBuffer == null) return;
    textureBuffer.position(0);

    GLES20.glVertexAttribPointer(textureCoordinateHandle, 2, GLES20.GL_FLOAT, false, 0, textureBuffer);
    ShaderUtils.checkGlError("glVertexAttribPointer maTextureHandle");
    GLES20.glEnableVertexAttribArray(textureCoordinateHandle);
    ShaderUtils.checkGlError("glEnableVertexAttribArray maTextureHandle");
}
 
Example 7
Source File: BufferUtils.java    From In77Camera with MIT License 5 votes vote down vote up
public static FloatBuffer getFloatBuffer(final float[] array, int offset){
    FloatBuffer bb= ByteBuffer.allocateDirect(
            array.length * FLOAT_SIZE_BYTES)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(array);
    bb.position(offset);
    return bb;
}
 
Example 8
Source File: MDAbsObject3D.java    From MD360Player4Android with Apache License 2.0 5 votes vote down vote up
public void uploadTexCoordinateBufferIfNeed(MD360Program program, int index){
    FloatBuffer textureBuffer = getTexCoordinateBuffer(index);
    if (textureBuffer == null) return;

    textureBuffer.position(0);

    // set data to OpenGL
    int textureCoordinateHandle = program.getTextureCoordinateHandle();
    GLES20.glVertexAttribPointer(textureCoordinateHandle, sTextureCoordinateDataSize, GLES20.GL_FLOAT, false, 0, textureBuffer);
    GLES20.glEnableVertexAttribArray(textureCoordinateHandle);

}
 
Example 9
Source File: GLMatrixStack.java    From ldparteditor with MIT License 5 votes vote down vote up
public void glLoadIdentity() {
    final Matrix4f ID = new Matrix4f();
    Matrix4f.setIdentity(ID);
    final FloatBuffer ID_buf = BufferUtils.createFloatBuffer(16);
    ID.store(ID_buf);
    ID_buf.position(0);
    currentMatrix = ID;

    int model = shader.getUniformLocation("model" ); //$NON-NLS-1$
    GL20.glUniformMatrix4fv(model, false, ID_buf);

    int view = shader.getUniformLocation("view" ); //$NON-NLS-1$
    GL20.glUniformMatrix4fv(view, false, ID_buf);
}
 
Example 10
Source File: LessonOneRenderer.java    From opengl with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a triangle from the given vertex data.
 * 
 * @param aTriangleBuffer The buffer containing the vertex data.
 */
private void drawTriangle(final FloatBuffer aTriangleBuffer)
{		
	// Pass in the position information
	aTriangleBuffer.position(mPositionOffset);
       GLES30.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES30.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
               
       GLES30.glEnableVertexAttribArray(mPositionHandle);        
       
       // Pass in the color information
       aTriangleBuffer.position(mColorOffset);
       GLES30.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES30.GL_FLOAT, false,
       		mStrideBytes, aTriangleBuffer);        
       
       GLES30.glEnableVertexAttribArray(mColorHandle);
       
	// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
       // (which currently contains model * view).
       Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
       
       // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
       // (which now contains model * view * projection).
       Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);

       GLES30.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
       GLES30.glDrawArrays(GLES30.GL_TRIANGLES, 0, 3);                               
}
 
Example 11
Source File: GlUtil.java    From LiveVideoBroadcaster with Apache License 2.0 5 votes vote down vote up
/**
 * Allocates a direct float buffer, and populates it with the float array data.
 */
public static FloatBuffer createFloatBuffer(float[] coords) {
    // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * SIZEOF_FLOAT);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer fb = bb.asFloatBuffer();
    fb.put(coords);
    fb.position(0);
    return fb;
}
 
Example 12
Source File: GlUtil.java    From IjkVRPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * Allocates a direct float buffer, and populates it with the float array data.
 */
public static FloatBuffer createFloatBuffer(float[] coords) {
    // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * SIZEOF_FLOAT);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer fb = bb.asFloatBuffer();
    fb.put(coords);
    fb.position(0);
    return fb;
}
 
Example 13
Source File: FloatVBO.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void putSubData(int index, FloatBuffer buffer) {
	if (!use_vbo) {
		saved_buffer.position(index);
		saved_buffer.put(buffer);
	} else {
		makeCurrent();
		ARBBufferObject.glBufferSubDataARB(getTarget(), index<<2, buffer);
		buffer.position(buffer.limit());
	}
}
 
Example 14
Source File: TextureUtils.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public static FloatBuffer toFloatBuffer(float[] v) {
  ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 4);
  buf.order(ByteOrder.nativeOrder());
  FloatBuffer buffer = buf.asFloatBuffer();
  buffer.put(v);
  buffer.position(0);
  return buffer;
}
 
Example 15
Source File: EglElement.java    From Lassi-Android with MIT License 5 votes vote down vote up
protected static FloatBuffer floatBuffer(float[] coords) {
    // Allocate a direct ByteBuffer, using 4 bytes per float, and copy coords into it.
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer fb = bb.asFloatBuffer();
    fb.put(coords);
    fb.position(0);
    return fb;
}
 
Example 16
Source File: CameraViewModel.java    From VIA-AI with MIT License 5 votes vote down vote up
private void checkDataUpdate()
{
    if(mNeedUpdate) {
        // VBO update vertex coordinate
        ByteBuffer bb = ByteBuffer.allocateDirect(mPosition.length * 4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer vertexBuffer = bb.asFloatBuffer();
        vertexBuffer.put(mPosition);
        vertexBuffer.position(0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mPositionVBO[0]);
        GLUtility.checkGlError("glBindBuffer");

        GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mPosition.length * 4, vertexBuffer, GLES20.GL_STATIC_DRAW);
        GLUtility.checkGlError("glBufferData");


        // VBO update texture coordinate
        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mTextureCoordinateVBO[0]);
        GLUtility.checkGlError("glBindBuffer");

        bb = ByteBuffer.allocateDirect(mTextureCoordinate.length * 4);
        bb.order(ByteOrder.nativeOrder());
        FloatBuffer textureCoordinateBuffer = bb.asFloatBuffer();
        textureCoordinateBuffer.put(mTextureCoordinate);
        textureCoordinateBuffer.position(0);

        GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mTextureCoordinate.length * 4, textureCoordinateBuffer, GLES20.GL_STATIC_DRAW);
        GLUtility.checkGlError("glBufferData");

        mNeedUpdate = false;
    }
}
 
Example 17
Source File: SurfaceTextureRenderer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void drawFrame(SurfaceTexture st, int width, int height, int flipType)
        throws LegacyExceptionUtils.BufferQueueAbandonedException {
    checkGlError("onDrawFrame start");
    st.getTransformMatrix(mSTMatrix);

    Matrix.setIdentityM(mMVPMatrix, /*smOffset*/0);

    // Find intermediate buffer dimensions
    Size dimens;
    try {
        dimens = LegacyCameraDevice.getTextureSize(st);
    } catch (LegacyExceptionUtils.BufferQueueAbandonedException e) {
        // Should never hit this.
        throw new IllegalStateException("Surface abandoned, skipping drawFrame...", e);
    }
    float texWidth = dimens.getWidth();
    float texHeight = dimens.getHeight();

    if (texWidth <= 0 || texHeight <= 0) {
        throw new IllegalStateException("Illegal intermediate texture with dimension of 0");
    }

    // Letterbox or pillar-box output dimensions into intermediate dimensions.
    RectF intermediate = new RectF(/*left*/0, /*top*/0, /*right*/texWidth, /*bottom*/texHeight);
    RectF output = new RectF(/*left*/0, /*top*/0, /*right*/width, /*bottom*/height);
    android.graphics.Matrix boxingXform = new android.graphics.Matrix();
    boxingXform.setRectToRect(output, intermediate, android.graphics.Matrix.ScaleToFit.CENTER);
    boxingXform.mapRect(output);

    // Find scaling factor from pillar-boxed/letter-boxed output dimensions to intermediate
    // buffer dimensions.
    float scaleX = intermediate.width() / output.width();
    float scaleY = intermediate.height() / output.height();

    // Intermediate texture is implicitly scaled to 'fill' the output dimensions in clip space
    // coordinates in the shader.  To avoid stretching, we need to scale the larger dimension
    // of the intermediate buffer so that the output buffer is actually letter-boxed
    // or pillar-boxed into the intermediate buffer after clipping.
    Matrix.scaleM(mMVPMatrix, /*offset*/0, /*x*/scaleX, /*y*/scaleY, /*z*/1);

    if (DEBUG) {
        Log.d(TAG, "Scaling factors (S_x = " + scaleX + ",S_y = " + scaleY + ") used for " +
                width + "x" + height + " surface, intermediate buffer size is " + texWidth +
                "x" + texHeight);
    }

    // Set viewport to be output buffer dimensions
    GLES20.glViewport(0, 0, width, height);

    if (DEBUG) {
        GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    }

    GLES20.glUseProgram(mProgram);
    checkGlError("glUseProgram");

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

    FloatBuffer triangleVertices;
    switch(flipType) {
        case FLIP_TYPE_HORIZONTAL:
            triangleVertices = mHorizontalFlipTriangleVertices;
            break;
        case FLIP_TYPE_VERTICAL:
            triangleVertices = mVerticalFlipTriangleVertices;
            break;
        case FLIP_TYPE_BOTH:
            triangleVertices = mBothFlipTriangleVertices;
            break;
        default:
            triangleVertices = mRegularTriangleVertices;
            break;
    }

    triangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
    GLES20.glVertexAttribPointer(maPositionHandle, VERTEX_POS_SIZE, GLES20.GL_FLOAT,
            /*normalized*/ false, TRIANGLE_VERTICES_DATA_STRIDE_BYTES, triangleVertices);
    checkGlError("glVertexAttribPointer maPosition");
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    checkGlError("glEnableVertexAttribArray maPositionHandle");

    triangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
    GLES20.glVertexAttribPointer(maTextureHandle, VERTEX_UV_SIZE, GLES20.GL_FLOAT,
            /*normalized*/ false, TRIANGLE_VERTICES_DATA_STRIDE_BYTES, triangleVertices);
    checkGlError("glVertexAttribPointer maTextureHandle");
    GLES20.glEnableVertexAttribArray(maTextureHandle);
    checkGlError("glEnableVertexAttribArray maTextureHandle");

    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, /*count*/ 1, /*transpose*/ false, mMVPMatrix,
            /*offset*/ 0);
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, /*count*/ 1, /*transpose*/ false, mSTMatrix,
            /*offset*/ 0);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /*offset*/ 0, /*count*/ 4);
    checkGlDrawError("glDrawArrays");
}
 
Example 18
Source File: BatchNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doTransformsTangents(FloatBuffer bindBufPos, FloatBuffer bindBufNorm, FloatBuffer bindBufTangents,FloatBuffer bufPos, FloatBuffer bufNorm, FloatBuffer bufTangents, int start, int end, Matrix4f transform) {
    TempVars vars = TempVars.get();
    Vector3f pos = vars.vect1;
    Vector3f norm = vars.vect2;
    Vector3f tan = vars.vect3;

    int length = (end - start) * 3;
    int tanLength = (end - start) * 4;

    // offset is given in element units
    // convert to be in component units
    int offset = start * 3;
    int tanOffset = start * 4;

    
    bindBufPos.rewind();
    bindBufNorm.rewind();
    bindBufTangents.rewind();
    bindBufPos.get(tmpFloat, 0, length);
    bindBufNorm.get(tmpFloatN, 0, length);
    bindBufTangents.get(tmpFloatT, 0, tanLength);

    int index = 0;
    int tanIndex = 0;
    while (index < length) {
        pos.x = tmpFloat[index];
        norm.x = tmpFloatN[index++];
        pos.y = tmpFloat[index];
        norm.y = tmpFloatN[index++];
        pos.z = tmpFloat[index];
        norm.z = tmpFloatN[index];

        tan.x = tmpFloatT[tanIndex++];
        tan.y = tmpFloatT[tanIndex++];
        tan.z = tmpFloatT[tanIndex++];

        transform.mult(pos, pos);
        transform.multNormal(norm, norm);
        transform.multNormal(tan, tan);

        index -= 2;
        tanIndex -= 3;

        tmpFloat[index] = pos.x;
        tmpFloatN[index++] = norm.x;
        tmpFloat[index] = pos.y;
        tmpFloatN[index++] = norm.y;
        tmpFloat[index] = pos.z;
        tmpFloatN[index++] = norm.z;

        tmpFloatT[tanIndex++] = tan.x;
        tmpFloatT[tanIndex++] = tan.y;
        tmpFloatT[tanIndex++] = tan.z;

        //Skipping 4th element of tangent buffer (handedness)
        tanIndex++;

    }
    vars.release();
    bufPos.position(offset);
    //using bulk put as it's faster
    bufPos.put(tmpFloat, 0, length);
    bufNorm.position(offset);
    //using bulk put as it's faster
    bufNorm.put(tmpFloatN, 0, length);
    bufTangents.position(tanOffset);
    //using bulk put as it's faster
    bufTangents.put(tmpFloatT, 0, tanLength);
}
 
Example 19
Source File: PMDLoaderGLSLSkinning2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
PMDMesh createMesh_old(MeshData md) {
        boolean textureFlag = true;
        if (md.getMaterial().getTextureFileName().length() == 0) {
            textureFlag = false;
        }
        PMDMesh mesh = new PMDMesh();
        mesh.setMode(Mesh.Mode.Triangles);
        VertexBuffer vb = new VertexBuffer(VertexBuffer.Type.Position);
        VertexBuffer nb = new VertexBuffer(VertexBuffer.Type.Normal);

        VertexBuffer tb = new VertexBuffer(VertexBuffer.Type.TexCoord);

        VertexBuffer wb = new VertexBuffer(VertexBuffer.Type.BoneWeight);
        VertexBuffer ib = new VertexBuffer(VertexBuffer.Type.Index);
        VertexBuffer bib = new VertexBuffer(VertexBuffer.Type.BoneIndex);
        PMDVertex v = new PMDVertex();
//        System.out.println("isb.capacity() = " + isb.capacity());
//        System.out.println("isb.capacity() = " + md.getIndexList().size());
        vb.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, md.vfb);
        nb.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, md.nfb);

//        bvb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bvfb);
//        bnb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bnfb);
        if (textureFlag) {
            tb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, md.tfb);
        }
        wb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, md.wfb);
        ib.setupData(VertexBuffer.Usage.Static, 1, VertexBuffer.Format.UnsignedShort, md.isb);
        bib.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.UnsignedShort, md.bisb);
        mesh.setBuffer(vb);
        mesh.setBuffer(nb);
        
        mesh.setVbBackup(vb);
        mesh.setNbBackup(nb);

//        mesh.setBuffer(bvb);
//        mesh.setBuffer(bnb);
        if (textureFlag) {
            mesh.setBuffer(tb);
        }
        mesh.setBuffer(wb);
        mesh.setBuffer(ib);
        mesh.setBuffer(bib);
        int[] indexArray = md.indexArray;
        mesh.setBoneIndexArray(indexArray);
        mesh.setBoneIndexBuffer(md.indexBuffer);
        FloatBuffer boneMatrixBuffer = BufferUtils.createFloatBuffer(16 * indexArray.length);
        mesh.setBoneMatrixArray(new Matrix4f[indexArray.length]);
        mesh.setBoneMatrixBuffer(boneMatrixBuffer);
        for (int i = 0; i < mesh.getBoneMatrixArray().length; i++) {
            mesh.getBoneMatrixArray()[i] = new Matrix4f();
            mesh.getBoneMatrixArray()[i].loadIdentity();
            mesh.getBoneMatrixArray()[i].fillFloatBuffer(boneMatrixBuffer, true);
        }
        boneMatrixBuffer.position(0);
        return mesh;
    }
 
Example 20
Source File: NoosaScript.java    From PD-classes with GNU General Public License v3.0 3 votes vote down vote up
public void drawElements( FloatBuffer vertices, ShortBuffer indices, int size ) {
	
	vertices.position( 0 );
	aXY.vertexPointer( 2, 4, vertices );
	
	vertices.position( 2 );
	aUV.vertexPointer( 2, 4, vertices );
	
	GLES20.glDrawElements( GLES20.GL_TRIANGLES, size, GLES20.GL_UNSIGNED_SHORT, indices );
	
}