本文整理匯總了Java中java.nio.FloatBuffer.flip方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatBuffer.flip方法的具體用法?Java FloatBuffer.flip怎麽用?Java FloatBuffer.flip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.FloatBuffer
的用法示例。
在下文中一共展示了FloatBuffer.flip方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Generate a new FloatBuffer using the given array of Quaternion objects.
* The FloatBuffer will be 4 * data.length long and contain the vector data.
*
* @param data array of Quaternion objects to place into a new FloatBuffer
*/
public static FloatBuffer createFloatBuffer(Quaternion... data) {
if (data == null) {
return null;
}
FloatBuffer buff = createFloatBuffer(4 * data.length);
for (Quaternion element : data) {
if (element != null) {
buff.put(element.getX()).put(element.getY()).put(element.getZ()).put(element.getW());
} else {
buff.put(0).put(0).put(0).put(0);
}
}
buff.flip();
return buff;
}
示例2: Mesh
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Create a mesh with the specified vertices and indices and whether the normals should be calculated
* @param vertices
* @param indices
* @param calculateNormals
*/
public Mesh(Vertex[] vertices, int[] indices, boolean calculateNormals) {
modelMatrix = new Matrix4f();
// Automatically calculate normals for the mesh
if(calculateNormals) {
calculateNormals(vertices, indices);
}
// Create a FloatBuffer to hold Vertex data
FloatBuffer data = BufferUtils.createFloatBuffer(vertices.length * Vertex.SIZE);
for(int i = 0; i < vertices.length; i++) {
// Store the position
data.put(vertices[i].getPos().x);
data.put(vertices[i].getPos().y);
data.put(vertices[i].getPos().z);
// Store the texture coordinates
data.put(vertices[i].getTexCoords().x);
data.put(vertices[i].getTexCoords().y);
// Store the normal
data.put(vertices[i].getNormal().x);
data.put(vertices[i].getNormal().y);
data.put(vertices[i].getNormal().z);
// Store the color
data.put(vertices[i].getColor().x);
data.put(vertices[i].getColor().y);
data.put(vertices[i].getColor().z);
}
// Prepare the buffer for get() operations
data.flip();
// Create the VAO using the vertices and indices
vao = new IndexedVAO(data, indices, Vertex.DIMENSIONS);
}
示例3: toBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Stores the specified data into a FloatBuffer
* @param data The array of float data
* @return The generated FloatBuffer
*/
public static FloatBuffer toBuffer(float[] data) {
// Create an empty FloatBuffer with the correct size
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
// Store all the data in the buffer
for(int i = 0; i < data.length; i++) {
buffer.put(data[i]);
}
// Prepares the buffer for get() operations
buffer.flip();
return buffer;
}
示例4: createFlippedBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer createFlippedBuffer(float... values)
{
FloatBuffer buffer = createFloatBuffer(values.length);
buffer.put(values);
buffer.flip();
return buffer;
}
示例5: createFlippedBufferAOS
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static FloatBuffer createFlippedBufferAOS(Vertex[] vertices)
{
FloatBuffer buffer = createFloatBuffer(vertices.length * Vertex.FLOATS);
for(int i = 0; i < vertices.length; i++)
{
buffer.put(vertices[i].getPos().getX());
buffer.put(vertices[i].getPos().getY());
buffer.put(vertices[i].getPos().getZ());
buffer.put(vertices[i].getNormal().getX());
buffer.put(vertices[i].getNormal().getY());
buffer.put(vertices[i].getNormal().getZ());
buffer.put(vertices[i].getTextureCoord().getX());
buffer.put(vertices[i].getTextureCoord().getY());
if (vertices[i].getTangent() != null && vertices[i].getBitangent() != null){
buffer.put(vertices[i].getTangent().getX());
buffer.put(vertices[i].getTangent().getY());
buffer.put(vertices[i].getTangent().getZ());
buffer.put(vertices[i].getBitangent().getX());
buffer.put(vertices[i].getBitangent().getY());
buffer.put(vertices[i].getBitangent().getZ());
}
}
buffer.flip();
return buffer;
}
示例6: calcWelzl
import java.nio.FloatBuffer; //導入方法依賴的package包/類
/**
* Calculates a minimum bounding sphere for the copyTo of points. The algorithm
* was originally found in C++ at
* <p><a href="http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1">
* http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1</a><br><strong>broken link</strong></p>
* <p>and translated to java by Cep21</p>
*
* @param points
* The points to calculate the minimum bounds from.
*/
public void calcWelzl(FloatBuffer points) {
if (center == null) {
center = new Vector3f();
}
FloatBuffer buf = BufferUtils.createFloatBuffer(points.limit());
points.rewind();
buf.put(points);
buf.flip();
recurseMini(buf, buf.limit() / 3, 0, 0);
}
示例7: storeDataInFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
private FloatBuffer storeDataInFloatBuffer(float[] data) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
示例8: createBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
private FloatBuffer createBuffer(float[] data) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
return buffer;
}
示例9: storeData
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void storeData(float[] data){
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
buffer.put(data);
buffer.flip();
storeData(buffer);
}
示例10: getAsFloatBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public FloatBuffer getAsFloatBuffer() {
FloatBuffer buffer = BufferUtils.createFloatBuffer(4);
buffer.put(new float[] { col.x, col.y, col.z, a });
buffer.flip();
return buffer;
}
示例11: storeDataInBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static void storeDataInBuffer(FloatBuffer buffer, int vertexCount, float[]... data) {
float[] interleavedData = interleaveFloatData(vertexCount, data);
buffer.clear();
buffer.put(interleavedData);
buffer.flip();
}
示例12: storeDataInBuffer
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public static void storeDataInBuffer(FloatBuffer buffer, int vertexCount, float[]... data) {
float[] interleavedData = interleaveFloatData(vertexCount, data);
buffer.clear();
buffer.put(interleavedData);
buffer.flip();
}
示例13: print
import java.nio.FloatBuffer; //導入方法依賴的package包/類
public void print(float x, float y, String text){
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
FloatBuffer xbuf = BufferUtils.createFloatBuffer(1);
FloatBuffer ybuf = BufferUtils.createFloatBuffer(1);
xbuf.put(x);
ybuf.put(Window.instance.getHeight() - y);
xbuf.flip();
ybuf.flip();
STBTTAlignedQuad q = STBTTAlignedQuad.malloc();
GL11.glBegin(GL11.GL_QUADS);
for(char c : text.toCharArray()){
if(c == '\n'){
ybuf.put(0, ybuf.get(0) + fontHeight);
xbuf.put(0, x);
continue;
}else if(c < 32 || c > 128){
continue;
}
STBTruetype.stbtt_GetBakedQuad(cdata, 512, 512, (int)(c - 32), xbuf, ybuf, q, true);
GL11.glTexCoord2f(q.s0(), q.t0());
GL11.glVertex2f(q.x0(), q.y0());
GL11.glTexCoord2f(q.s1(), q.t0());
GL11.glVertex2f(q.x1(), q.y0());
GL11.glTexCoord2f(q.s1(), q.t1());
GL11.glVertex2f(q.x1(), q.y1());
GL11.glTexCoord2f(q.s0(), q.t1());
GL11.glVertex2f(q.x0(), q.y1());
}
GL11.glEnd();
}