case 1: this.radius = 1f - RADIUS_EPSILON; BufferUtils.populateFromBuffer(center, points, ap - 1); break; case 2: BufferUtils.populateFromBuffer(tempA, points, ap - 1); BufferUtils.populateFromBuffer(tempB, points, ap - 2); setSphere(tempA, tempB); break; case 3: BufferUtils.populateFromBuffer(tempA, points, ap - 1); BufferUtils.populateFromBuffer(tempB, points, ap - 2); BufferUtils.populateFromBuffer(tempC, points, ap - 3); setSphere(tempA, tempB, tempC); break; case 4: BufferUtils.populateFromBuffer(tempA, points, ap - 1); BufferUtils.populateFromBuffer(tempB, points, ap - 2); BufferUtils.populateFromBuffer(tempC, points, ap - 3); BufferUtils.populateFromBuffer(tempD, points, ap - 4); setSphere(tempA, tempB, tempC, tempD); BufferUtils.populateFromBuffer(tempA, points, i + ap); if (tempA.distanceSquared(center) - (radius * radius) > RADIUS_EPSILON - 1f) { for (int j = i; j > 0; j--) { 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);
index[1] = indexBuffer.get(1); populateFromBuffer(v[0], vertexBuffer, index[0]); populateFromBuffer(v[1], vertexBuffer, index[1]); populateFromBuffer(t[0], textureBuffer, index[0]); populateFromBuffer(t[1], textureBuffer, index[1]); populateFromBuffer(v[2], vertexBuffer, index[2]); populateFromBuffer(t[2], textureBuffer, index[2]);
index[1] = indexBuffer.get(1); populateFromBuffer(v[0], vertexBuffer, index[0]); populateFromBuffer(v[1], vertexBuffer, index[1]); populateFromBuffer(t[0], textureBuffer, index[0]); populateFromBuffer(t[1], textureBuffer, index[1]); BufferUtils.populateFromBuffer(v[2], vertexBuffer, index[2]); BufferUtils.populateFromBuffer(t[2], textureBuffer, index[2]);
/** * Gets the triangle vertex positions at the given triangle index * and stores them into the v1, v2, v3 arguments. * * @param index The index of the triangle. * Should be between 0 and {@link #getTriangleCount()}. * * @param v1 Vector to contain first vertex position * @param v2 Vector to contain second vertex position * @param v3 Vector to contain third vertex position */ public void getTriangle(int index, Vector3f v1, Vector3f v2, Vector3f v3){ VertexBuffer pb = getBuffer(Type.Position); IndexBuffer ib = getIndicesAsList(); if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3){ FloatBuffer fpb = (FloatBuffer) pb.getData(); // aquire triangle's vertex indices int vertIndex = index * 3; int vert1 = ib.get(vertIndex); int vert2 = ib.get(vertIndex+1); int vert3 = ib.get(vertIndex+2); BufferUtils.populateFromBuffer(v1, fpb, vert1); BufferUtils.populateFromBuffer(v2, fpb, vert2); BufferUtils.populateFromBuffer(v3, fpb, vert3); }else{ throw new UnsupportedOperationException("Position buffer not set or " + " has incompatible format"); } }
/** * Checks to see if the given Vector3f is equals to the data stored in the * buffer at the given data index. * * @param check * the vector to check against - null will return false. * @param buf * the buffer to compare data with * @param index * the position (in terms of vectors, not floats) of the vector * in the buffer to check against * @return true if the data is equivalent, otherwise false. */ public static boolean equals(Vector3f check, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector3f tempVec3 = vars.vect1; populateFromBuffer(tempVec3, buf, index); boolean eq = tempVec3.equals(check); vars.release(); return eq; }
/** * Checks to see if the given Vector2f is equals to the data stored in the * buffer at the given data index. * * @param check * the vector to check against - null will return false. * @param buf * the buffer to compare data with * @param index * the position (in terms of vectors, not floats) of the vector * in the buffer to check against * @return true if the data is equivalent, otherwise false. */ public static boolean equals(Vector2f check, FloatBuffer buf, int index) { TempVars vars = TempVars.get(); Vector2f tempVec2 = vars.vect2d; populateFromBuffer(tempVec2, buf, index); boolean eq = tempVec2.equals(check); vars.release(); return eq; }
for (int j = 0; j < 3; j++) { index[j] = indexBuffer.get(i * 3 + j); populateFromBuffer(v[j], vertexBuffer, index[j]); populateFromBuffer(t[j], textureBuffer, index[j]);
/** * 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(); }
for (int i = 0; i < size; i++) { populateFromBuffer(position, vertexBuffer, i); populateFromBuffer(normal, normalBuffer, i); populateFromBuffer(texCoord, texcoordBuffer, i);
/** * 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(); }
ArrayList<TriangleData> triangles = vertexData.get(i).triangles; Vector3f givenNormal = new Vector3f(); populateFromBuffer(givenNormal, normalBuffer, i);
BufferUtils.populateFromBuffer(origin, points, 0); for (int i = 1; i < length; i++) { BufferUtils.populateFromBuffer(compVec1, points, i); origin.addLocal(compVec1); BufferUtils.populateFromBuffer(compVec1, points, i); compVec1.subtract(origin, compVec2); sumXX += compVec2.x * compVec2.x;
populateFromBuffer(origin, vertexBuffer, i); populateFromBuffer(normal, normalBuffer, i); tangentW = tangentBuffer.get(i * 4 + 3); } else { populateFromBuffer(tangent, tangentBuffer, i); point.normalizeLocal(); } else { populateFromBuffer(point, binormalBuffer, i);
populateFromBuffer(origin, vertexBuffer, i); populateFromBuffer(point, normalBuffer, i);
BufferUtils.populateFromBuffer(pos, positions, i);