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

The following examples show how to use java.nio.FloatBuffer#put() . 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: BufferUtils.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Creates a new FloatBuffer with the same contents as the given
 * FloatBuffer. The new FloatBuffer is seperate from the old one and changes
 * are not reflected across. If you want to reflect changes, consider using
 * Buffer.duplicate().
 *
 * @param buf
 *            the FloatBuffer to copy
 * @return the copy
 */
public static FloatBuffer clone(FloatBuffer buf) {
    if (buf == null) {
        return null;
    }
    buf.rewind();

    FloatBuffer copy;
    if (buf.isDirect()) {
        copy = createFloatBuffer(buf.limit());
    } else {
        copy = FloatBuffer.allocate(buf.limit());
    }
    copy.put(buf);

    return copy;
}
 
Example 2
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateVertices(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float x = 0;
	final float y = 0;
	final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
	final float y2 = pSprite.getHeight(); // TODO Optimize with field access?

	final float xCenter = (x + x2) * 0.5f;
	final float yCenter = (y + y2) * 0.5f;

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);

	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);

	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);

	this.setDirtyOnHardware();
}
 
Example 3
Source File: MDDome3D.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void uploadTexCoordinateBufferIfNeed(MD360Program program, int index) {
    if (super.getTexCoordinateBuffer(index) == null){
        return;
    }

    if (index == 0){
        float ratio = mTextureSize.width() / mTextureSize.height();
        if (ratio != mPrevRatio){
            int size = texCoordinates.length;
            float[] tmp = new float[size];
            for (int i = 0; i < size; i += 2){
                tmp[i] = (texCoordinates[i]- 0.5f)/ratio + 0.5f;
                tmp[i+1] = texCoordinates[i+1];
            }

            ByteBuffer cc = ByteBuffer.allocateDirect(
                    tmp.length * 4);
            cc.order(ByteOrder.nativeOrder());
            FloatBuffer buffer = cc.asFloatBuffer();
            buffer.put(tmp);
            buffer.position(0);
            setTexCoordinateBuffer(0,buffer);
            setTexCoordinateBuffer(1,buffer);
            mPrevRatio = ratio;
        }
    }

    super.uploadTexCoordinateBufferIfNeed(program, index);
}
 
Example 4
Source File: GPUImageTwoInputFilter.java    From SimpleVideoEditor with Apache License 2.0 5 votes vote down vote up
public void setRotation(final Rotation rotation, final boolean flipHorizontal, final boolean flipVertical) {
    float[] buffer = TextureRotationUtil.getRotation(rotation, flipHorizontal, flipVertical);

    ByteBuffer bBuffer = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder());
    FloatBuffer fBuffer = bBuffer.asFloatBuffer();
    fBuffer.put(buffer);
    fBuffer.flip();

    mTexture2CoordinatesBuffer = bBuffer;
}
 
Example 5
Source File: BufferUtil.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public static FloatBuffer createFlippedBuffer(Vec3f[] vector)
{
	FloatBuffer buffer = createFloatBuffer(vector.length * Float.BYTES * 3);
	
	for (int i = 0; i < vector.length; i++)
	{
		buffer.put(vector[i].getX());
		buffer.put(vector[i].getY());
		buffer.put(vector[i].getZ());
	}
	
	buffer.flip();
	
	return buffer;
}
 
Example 6
Source File: GlUtils.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public static FloatBuffer toFloatBufferPositionZero(float[] values) {
	ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 4);
	vbb.order(ByteOrder.nativeOrder());
	FloatBuffer buffer = vbb.asFloatBuffer();
	buffer.put(values);
	buffer.position(0);
	return buffer;
}
 
Example 7
Source File: OfflineGeometryGenerator.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private byte[] floatArrayToByteArray(float[] vertices) {
	if (vertices == null) {
		return null;
	}
	ByteBuffer buffer = ByteBuffer.wrap(new byte[vertices.length * 4]);
	buffer.order(ByteOrder.LITTLE_ENDIAN);
	FloatBuffer asFloatBuffer = buffer.asFloatBuffer();
	for (float f : vertices) {
		asFloatBuffer.put(f);
	}
	return buffer.array();
}
 
Example 8
Source File: GLUtil.java    From OpenGLESRecorder with Apache License 2.0 5 votes vote down vote up
public static FloatBuffer createFloatBuffer(float[] array) {
    ByteBuffer bb = ByteBuffer.allocateDirect(array.length * SIZE_OF_FLOAT);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer fb = bb.asFloatBuffer();
    fb.put(array);
    fb.position(0);
    return fb;
}
 
Example 9
Source File: LowMemorySpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdateColor(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float packedColor = pSprite.getColor().getABGRPackedFloat();

	bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor);
	bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor);
	bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor);
	bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.COLOR_INDEX, packedColor);

	this.setDirtyOnHardware();
}
 
Example 10
Source File: GpuFloatBuffer.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
void ensureCapacity(int size)
{
	while (buffer.remaining() < size)
	{
		FloatBuffer newB = allocateDirect(buffer.capacity() * 2);
		buffer.flip();
		newB.put(buffer);
		buffer = newB;
	}
}
 
Example 11
Source File: BufferUtil.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public static ByteBuffer createByteBuffer(Vec3f vector){
	
	ByteBuffer byteBuffer = memAlloc(Float.BYTES * 3);
	FloatBuffer floatBuffer = byteBuffer.asFloatBuffer();
	floatBuffer.put(BufferUtil.createFlippedBuffer(vector));
	
	return byteBuffer;
}
 
Example 12
Source File: ScaledDrawable2d.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the array of texture coordinates.  The first time this is called, we generate
 * a modified version of the array from the parent class.
 * <p>
 * To avoid allocations, this returns internal state.  The caller must not modify it.
 */
@Override
public FloatBuffer getTexCoordArray() {
    if (mRecalculate) {
        //Log.v(TAG, "Scaling to " + mScale);
        FloatBuffer parentBuf = super.getTexCoordArray();
        int count = parentBuf.capacity();

        if (mTweakedTexCoordArray == null) {
            ByteBuffer bb = ByteBuffer.allocateDirect(count * SIZEOF_FLOAT);
            bb.order(ByteOrder.nativeOrder());
            mTweakedTexCoordArray = bb.asFloatBuffer();
        }

        // Texture coordinates range from 0.0 to 1.0, inclusive.  We do a simple scale
        // here, but we could get much fancier if we wanted to (say) zoom in and pan
        // around.
        FloatBuffer fb = mTweakedTexCoordArray;
        float scale = mScale;
        for (int i = 0; i < count; i++) {
            float fl = parentBuf.get(i);
            fl = ((fl - 0.5f) * scale) + 0.5f;
            fb.put(i, fl);
        }

        mRecalculate = false;
    }

    return mTweakedTexCoordArray;
}
 
Example 13
Source File: BufferUtil.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public static FloatBuffer createFlippedBuffer(Matrix4f matrix)
{
	FloatBuffer buffer = createFloatBuffer(4 * 4);
	
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 4; j++)
			buffer.put(matrix.get(i, j));
	
	buffer.flip();
	
	return buffer;
}
 
Example 14
Source File: PMDSkinMesh.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
    public synchronized PMDSkinMesh clone() {
        PMDSkinMesh newMesh = (PMDSkinMesh)super.clone();
//        newMesh.boneMatrixArray = new Matrix4f[boneMatrixArray.length];
        newMesh.skinvb2 = new VertexBuffer(VertexBuffer.Type.Position);
        FloatBuffer skinvfb2 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
        newMesh.skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2);
        
//        newMesh.skinnb2 = new VertexBuffer(VertexBuffer.Type.Normal);
//        FloatBuffer skinnfb2 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
//        newMesh.skinnb2.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinnfb2);
        
        VertexBuffer skinvb1 = new VertexBuffer(VertexBuffer.Type.Position);
//        FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
        FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.getBuffer(VertexBuffer.Type.Position).getData());
        skinvb1.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb1);
        newMesh.clearBuffer(VertexBuffer.Type.Position);
        newMesh.setBuffer(skinvb1);
        
//        VertexBuffer skinnb1 = new VertexBuffer(VertexBuffer.Type.Normal);
//        FloatBuffer skinnfb1 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
//        FloatBuffer skinnfb1 = BufferUtils.clone((FloatBuffer)this.getBuffer(VertexBuffer.Type.Normal).getData());
//        skinnb1.setupData(VertexBuffer.Usage.Stream, 3, VertexBuffer.Format.Float, skinnfb1);
//        newMesh.clearBuffer(VertexBuffer.Type.Normal);
//        newMesh.setBuffer(skinnb1);
        FloatBuffer newBoneMatrixBuffer = BufferUtils.createFloatBuffer(boneMatrixBuffer.capacity());
        boneMatrixBuffer.position(0);
        newBoneMatrixBuffer.put(boneMatrixBuffer);
        newBoneMatrixBuffer.position(0);
        newMesh.setBoneMatrixBuffer(newBoneMatrixBuffer);
        return newMesh;
    }
 
Example 15
Source File: BufferUtil.java    From oreon-engine with GNU General Public License v3.0 5 votes vote down vote up
public static FloatBuffer createFlippedBuffer(List<Vec2f> vector)
{
	FloatBuffer buffer = createFloatBuffer(vector.size() * Float.BYTES * 2);
	
	for (Vec2f v : vector)
	{
		buffer.put(v.getX());
		buffer.put(v.getY());	
	}
	
	buffer.flip();
	
	return buffer;
}
 
Example 16
Source File: VectorSet.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Access the buffer containing all the Vector3f values in this set. No
 * further add() is allowed.
 *
 * @return a new buffer, flipped
 */
public FloatBuffer toBuffer() {
    int numFloats = 3 * set.size();
    FloatBuffer buffer = BufferUtils.createFloatBuffer(numFloats);
    for (Vector3f tempVector : set) {
        buffer.put(tempVector.x);
        buffer.put(tempVector.y);
        buffer.put(tempVector.z);
    }
    buffer.flip();

    return buffer;
}
 
Example 17
Source File: GeoWorldLoader.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("resource")
public static Map<String, Spatial> loadMeshs(String fileName) throws IOException {
	Map<String, Spatial> geoms = new HashMap<String, Spatial>();
	File geoFile = new File(fileName);
	FileChannel roChannel = null;
	MappedByteBuffer geo = null;
	roChannel = new RandomAccessFile(geoFile, "r").getChannel();
	int size = (int) roChannel.size();
	geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, size).load();
	geo.order(ByteOrder.LITTLE_ENDIAN);
	while (geo.hasRemaining()) {
		short namelenght = geo.getShort();
		byte[] nameByte = new byte[namelenght];
		geo.get(nameByte);
		String name = new String(nameByte).intern();
		Node node = new Node(DEBUG ? name : null);
		byte intentions = 0;
		byte singleChildMaterialId = -1;
		int modelCount = geo.getShort();
		for (int c = 0; c < modelCount; c++) {
			Mesh m = new Mesh();

			int vectorCount = (geo.getInt()) * 3;
			ByteBuffer floatBuffer = ByteBuffer.allocateDirect(vectorCount * 4);
			FloatBuffer vertices = floatBuffer.asFloatBuffer();
			for (int x = 0; x < vectorCount; x++) {
				vertices.put(geo.getFloat());
			}

			int triangles = geo.getInt();
			ByteBuffer shortBuffer = ByteBuffer.allocateDirect(triangles * 2);
			ShortBuffer indexes = shortBuffer.asShortBuffer();
			for (int x = 0; x < triangles; x++) {
				indexes.put(geo.getShort());
			}

			Geometry geom = null;
			m.setCollisionFlags(geo.getShort());
			if ((m.getIntentions() & CollisionIntention.MOVEABLE.getId()) != 0) {
				// TODO: skip moveable collisions (ships, shugo boxes), not handled yet
				continue;
			}
			intentions |= m.getIntentions();
			m.setBuffer(VertexBuffer.Type.Position, 3, vertices);
			m.setBuffer(VertexBuffer.Type.Index, 3, indexes);
			m.createCollisionData();

			if ((intentions & CollisionIntention.DOOR.getId()) != 0 && (intentions & CollisionIntention.PHYSICAL.getId()) != 0) {
				if (!GeoDataConfig.GEO_DOORS_ENABLE) {
					continue;
				}
				geom = new DoorGeometry(name, m);
				// what if doors have few models ?
			}
			else {
				MaterialTemplate mtl = DataManager.MATERIAL_DATA.getTemplate(m.getMaterialId());
				geom = new Geometry(null, m);
				if (mtl != null || m.getMaterialId() == 11) {
					node.setName(name);
				}
				if (modelCount == 1) {
					geom.setName(name);
					singleChildMaterialId = geom.getMaterialId();
				}
				else {
					geom.setName(("child" + c + "_" + name).intern());
				}
				node.attachChild(geom);
			}
			geoms.put(geom.getName(), geom);
		}
		node.setCollisionFlags((short) (intentions << 8 | singleChildMaterialId & 0xFF));
		if (!node.getChildren().isEmpty()) {
			geoms.put(name, node);
		}
	}
	destroyDirectByteBuffer(geo);
	return geoms;

}
 
Example 18
Source File: RawDataFileImpl.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public synchronized int storeDataPoints(DataPoint dataPoints[]) throws IOException {

    if (dataPointsFile == null) {
      File newFile = RawDataFileImpl.createNewDataPointsFile();
      openDataPointsFile(newFile);
    }

    final long currentOffset = dataPointsFile.length();

    final int currentID;
    if (!dataPointsOffsets.isEmpty())
      currentID = dataPointsOffsets.lastKey() + 1;
    else
      currentID = 1;

    final int numOfDataPoints = dataPoints.length;

    // Convert the dataPoints into a byte array. Each float takes 4 bytes,
    // so we get the current float offset by dividing the size of the file
    // by 4
    final int numOfBytes = numOfDataPoints * 2 * 4;

    if (buffer.capacity() < numOfBytes) {
      buffer = ByteBuffer.allocate(numOfBytes * 2);
    } else {
      // JDK 9 breaks compatibility with JRE8: need to cast
      // https://stackoverflow.com/questions/48693695/java-nio-buffer-not-loading-clear-method-on-runtime
      ((Buffer) buffer).clear();
    }

    FloatBuffer floatBuffer = buffer.asFloatBuffer();
    for (DataPoint dp : dataPoints) {
      floatBuffer.put((float) dp.getMZ());
      floatBuffer.put((float) dp.getIntensity());
    }

    dataPointsFile.seek(currentOffset);
    dataPointsFile.write(buffer.array(), 0, numOfBytes);

    dataPointsOffsets.put(currentID, currentOffset);
    dataPointsLengths.put(currentID, numOfDataPoints);

    return currentID;

  }
 
Example 19
Source File: MDStereoSphere3D.java    From MD360Player4Android with Apache License 2.0 4 votes vote down vote up
private static void generateSphere(float radius, int rings, int sectors, MDAbsObject3D object3D, MDDirection direction) {
    final float PI = (float) Math.PI;
    final float PI_2 = (float) (Math.PI / 2);

    float R = 1f/(float)rings;
    float S = 1f/(float)sectors;
    short r, s;
    float x, y, z;

    int numPoint = (rings + 1) * (sectors + 1);
    float[] vertexs = new float[numPoint * 3];
    float[] texcoords = new float[numPoint * 2];
    float[] texcoords2 = new float[numPoint * 2];
    short[] indices = new short[numPoint * 6];

    int t = 0, v = 0;
    for(r = 0; r < rings + 1; r++) {
        for(s = 0; s < sectors + 1; s++) {
            x = (float) (Math.cos(2*PI * s * S) * Math.sin( PI * r * R ));
            y = - (float) Math.sin( -PI_2 + PI * r * R );
            z = (float) (Math.sin(2*PI * s * S) * Math.sin( PI * r * R ));

            if (MDDirection.VERTICAL == direction){
                texcoords[t] = s*S;
                texcoords2[t] = s*S;
                t++;

                texcoords[t] = 1 - r*R/2;
                texcoords2[t] = 0.5f - r*R/2;
                t++;
            } else {
                texcoords[t] = s*S/2;
                texcoords2[t] = s*S/2 + 0.5f;
                t++;

                texcoords[t] = 1 - r*R;
                texcoords2[t] = 1 - r*R;
                t++;
            }

            vertexs[v++] = x * radius;
            vertexs[v++] = y * radius;
            vertexs[v++] = z * radius;
        }
    }

    int counter = 0;
    int sectorsPlusOne = sectors + 1;
    for(r = 0; r < rings; r++){
        for(s = 0; s < sectors; s++) {
            indices[counter++] = (short) (r * sectorsPlusOne + s);       //(a)
            indices[counter++] = (short) ((r+1) * sectorsPlusOne + (s));    //(b)
            indices[counter++] = (short) ((r) * sectorsPlusOne + (s+1));  // (c)
            indices[counter++] = (short) ((r) * sectorsPlusOne + (s+1));  // (c)
            indices[counter++] = (short) ((r+1) * sectorsPlusOne + (s));    //(b)
            indices[counter++] = (short) ((r+1) * sectorsPlusOne + (s+1));  // (d)
        }
    }

    // initialize vertex byte buffer for shape coordinates
    ByteBuffer bb = ByteBuffer.allocateDirect(
            // (# of coordinate values * 4 bytes per float)
            vertexs.length * 4);
    bb.order(ByteOrder.nativeOrder());
    FloatBuffer vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(vertexs);
    vertexBuffer.position(0);

    // initialize vertex byte buffer for shape coordinates
    ByteBuffer cc = ByteBuffer.allocateDirect(
            texcoords.length * 4);
    cc.order(ByteOrder.nativeOrder());
    FloatBuffer texBuffer = cc.asFloatBuffer();
    texBuffer.put(texcoords);
    texBuffer.position(0);

    // initialize vertex2 byte buffer for shape coordinates
    ByteBuffer cc2 = ByteBuffer.allocateDirect(
            texcoords.length * 4);
    cc2.order(ByteOrder.nativeOrder());
    FloatBuffer texBuffer2 = cc2.asFloatBuffer();
    texBuffer2.put(texcoords2);
    texBuffer2.position(0);

    // initialize byte buffer for the draw list
    ByteBuffer dlb = ByteBuffer.allocateDirect(
            // (# of coordinate values * 2 bytes per short)
            indices.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    ShortBuffer indexBuffer = dlb.asShortBuffer();
    indexBuffer.put(indices);
    indexBuffer.position(0);

    object3D.setIndicesBuffer(indexBuffer);
    object3D.setTexCoordinateBuffer(0,texBuffer);
    object3D.setTexCoordinateBuffer(1,texBuffer2);
    object3D.setVerticesBuffer(0,vertexBuffer);
    object3D.setVerticesBuffer(1,vertexBuffer);
    object3D.setNumIndices(indices.length);
}
 
Example 20
Source File: BatchNode.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void doTransforms(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();
    bindBufPos.get(tmpFloat, 0, length);

    if (bindBufNorm != null) {
        bindBufNorm.rewind();
        bindBufNorm.get(tmpFloatN, 0, length);
    }

    if (bindBufTangents != null) {
        bindBufTangents.rewind();
        bindBufTangents.get(tmpFloatT, 0, tanLength);
    }

    int index = 0;
    int tanIndex = 0;
    int index1, index2, tanIndex1, tanIndex2;

    while (index < length) {
        index1 = index + 1;
        index2 = index + 2;

        pos.x = tmpFloat[index];
        pos.y = tmpFloat[index1];
        pos.z = tmpFloat[index2];
        transform.mult(pos, pos);
        tmpFloat[index] = pos.x;
        tmpFloat[index1] = pos.y;
        tmpFloat[index2] = pos.z;

        if (bindBufNorm != null) {
            norm.x = tmpFloatN[index];
            norm.y = tmpFloatN[index1];
            norm.z = tmpFloatN[index2];
            transform.multNormal(norm, norm);
            tmpFloatN[index] = norm.x;
            tmpFloatN[index1] = norm.y;
            tmpFloatN[index2] = norm.z;
        }

        index += 3;

        if (bindBufTangents != null) {
            tanIndex1 = tanIndex + 1;
            tanIndex2 = tanIndex + 2;
            tan.x = tmpFloatT[tanIndex];
            tan.y = tmpFloatT[tanIndex1];
            tan.z = tmpFloatT[tanIndex2];
            transform.multNormal(tan, tan);
            tmpFloatT[tanIndex] = tan.x;
            tmpFloatT[tanIndex1] = tan.y;
            tmpFloatT[tanIndex2] = tan.z;
            tanIndex += 4;
        }

    }
    vars.release();

    //using bulk put as it's faster
    bufPos.position(offset);
    bufPos.put(tmpFloat, 0, length);

    if (bindBufNorm != null) {
        bufNorm.position(offset);
        bufNorm.put(tmpFloatN, 0, length);
    }

    if (bindBufTangents != null) {
        bufTangents.position(tanOffset);
        bufTangents.put(tmpFloatT, 0, tanLength);
    }
}