private void setInBuffer(Mesh mesh, int index, Vector3f normal, Vector3f tangent, Vector3f binormal) { VertexBuffer NB = mesh.getBuffer(Type.Normal); VertexBuffer TB = mesh.getBuffer(Type.Tangent); VertexBuffer BB = mesh.getBuffer(Type.Binormal); BufferUtils.setInBuffer(normal, (FloatBuffer)NB.getData(), index); BufferUtils.setInBuffer(tangent, (FloatBuffer)TB.getData(), index); BufferUtils.setInBuffer(binormal, (FloatBuffer)BB.getData(), index); NB.setUpdateNeeded(); TB.setUpdateNeeded(); BB.setUpdateNeeded(); }
/** * Normalize a Vector2f in-buffer. * * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector2(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.normalizeLocal(); setInBuffer(tempVec2, buf, index); vars.release(); }
/** * Normalize a Vector3f in-buffer. * * @param buf * the buffer to find the Vector3f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector3(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); tempVec3.normalizeLocal(); setInBuffer(tempVec3, buf, index); vars.release(); }
/** * Multiply and store a Vector2f in-buffer. * * @param toMult * the vector to multiply against * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to multiply */ public static void multInBuffer(Vector2f toMult, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.multLocal(toMult); setInBuffer(tempVec2, buf, index); vars.release(); }
/** * Applies the offsets of this pose to the vertex buffer given by the blend factor. * * @param blend Blend factor, 0 = no change to vertex buffer, 1 = apply full offsets * @param vertbuf Vertex buffer to apply this pose to */ public void apply(float blend, FloatBuffer vertbuf){ for (int i = 0; i < indices.length; i++){ Vector3f offset = offsets[i]; int vertIndex = indices[i]; tempVec.set(offset).multLocal(blend); // acquire vertex BufferUtils.populateFromBuffer(tempVec2, vertbuf, vertIndex); // add offset multiplied by factor tempVec2.addLocal(tempVec); // write modified vertex BufferUtils.setInBuffer(tempVec2, vertbuf, vertIndex); } }
/** * Add to a Vector3f in-buffer. * * @param toAdd * the vector to add from * @param buf * the buffer to find the Vector3f within * @param index * the position (in terms of vectors, not floats) of the vector * to add to */ public static void addInBuffer(Vector3f toAdd, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); tempVec3.addLocal(toAdd); setInBuffer(tempVec3, buf, index); vars.release(); }
/** * Multiply and store a Vector3f in-buffer. * * @param toMult * the vector to multiply against * @param buf * the buffer to find the Vector3f within * @param index * the position (in terms of vectors, not floats) of the vector * to multiply */ public static void multInBuffer(Vector3f toMult, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); tempVec3.multLocal(toMult); setInBuffer(tempVec3, buf, index); vars.release(); }
/** * Add to a Vector2f in-buffer. * * @param toAdd * the vector to add from * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to add to */ public static void addInBuffer(Vector2f toAdd, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.addLocal(toAdd); setInBuffer(tempVec2, buf, index); vars.release(); }
setInBuffer(origin, lineVertex, index); setInBuffer(originColor, lineColor, index); setInBuffer(point, lineVertex, index + 1); setInBuffer(normalColor, lineColor, index + 1);
lineIndex.put(id + 5, index + 3); setInBuffer(origin, lineVertex, index); setInBuffer(originColor, lineColor, index); setInBuffer(point, lineVertex, index + 1); setInBuffer(tangentColor, lineColor, index + 1); setInBuffer(point, lineVertex, index + 2); setInBuffer(binormalColor, lineColor, index + 2); setInBuffer(point, lineVertex, index + 3); setInBuffer(normalColor, lineColor, index + 3);
BufferUtils.setInBuffer(v2a[i], multiData, i); BufferUtils.setInBuffer(v3a[i], multiData, i); BufferUtils.setInBuffer(v4a[i], multiData, i);
binormal.set(new Vector3f(1,0,0).cross(normal)); BufferUtils.setInBuffer(tangent.normalizeLocal(), tangentStore, (r * getWidth() + c)); // save the tangent BufferUtils.setInBuffer(binormal.normalizeLocal(), binormalStore, (r * getWidth() + c)); // save the binormal
BufferUtils.populateFromBuffer(tempB, points, j + ap); BufferUtils.populateFromBuffer(tempC, points, j - 1 + ap); BufferUtils.setInBuffer(tempC, points, j + ap); BufferUtils.setInBuffer(tempB, points, j - 1 + ap);
tempNorm.multLocal(scale).normalizeLocal(); BufferUtils.setInBuffer(tempNorm, store, normalIndex); normalIndex++;
BufferUtils.setInBuffer(normal, store, (r * getWidth() + c)); // save the normal
private void setInBuffer(Mesh mesh, int index, Vector3f normal, Vector3f tangent, Vector3f binormal) { VertexBuffer NB = mesh.getBuffer(Type.Normal); VertexBuffer TB = mesh.getBuffer(Type.Tangent); VertexBuffer BB = mesh.getBuffer(Type.Binormal); BufferUtils.setInBuffer(normal, (FloatBuffer)NB.getData(), index); BufferUtils.setInBuffer(tangent, (FloatBuffer)TB.getData(), index); BufferUtils.setInBuffer(binormal, (FloatBuffer)BB.getData(), index); NB.setUpdateNeeded(); TB.setUpdateNeeded(); BB.setUpdateNeeded(); }
/** * Normalize a Vector3f in-buffer. * * @param buf * the buffer to find the Vector3f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector3(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); tempVec3.normalizeLocal(); setInBuffer(tempVec3, buf, index); vars.release(); }
/** * Normalize a Vector3f in-buffer. * * @param buf * the buffer to find the Vector3f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector3(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); tempVec3.normalizeLocal(); setInBuffer(tempVec3, buf, index); vars.release(); }
/** * Normalize a Vector2f in-buffer. * * @param buf * the buffer to find the Vector2f within * @param index * the position (in terms of vectors, not floats) of the vector * to normalize */ public static void normalizeVector2(FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); tempVec2.normalizeLocal(); setInBuffer(tempVec2, buf, index); vars.release(); }
/** * Applies the offsets of this pose to the vertex buffer given by the blend factor. * * @param blend Blend factor, 0 = no change to vertex buffer, 1 = apply full offsets * @param vertbuf Vertex buffer to apply this pose to */ public void apply(float blend, FloatBuffer vertbuf){ for (int i = 0; i < indices.length; i++){ Vector3f offset = offsets[i]; int vertIndex = indices[i]; tempVec.set(offset).multLocal(blend); // acquire vertex BufferUtils.populateFromBuffer(tempVec2, vertbuf, vertIndex); // add offset multiplied by factor tempVec2.addLocal(tempVec); // write modified vertex BufferUtils.setInBuffer(tempVec2, vertbuf, vertIndex); } }