本文整理汇总了Java中java.nio.FloatBuffer.rewind方法的典型用法代码示例。如果您正苦于以下问题:Java FloatBuffer.rewind方法的具体用法?Java FloatBuffer.rewind怎么用?Java FloatBuffer.rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.FloatBuffer
的用法示例。
在下文中一共展示了FloatBuffer.rewind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Draws a unit sphere centered at the origin.
*/
public void draw() {
if (_displayList==null) {
FloatBuffer xyz = Direct.newFloatBuffer(3*_nv);
xyz.put(_xyz); xyz.rewind();
_displayList = new GlDisplayList();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glNewList(_displayList.list(),GL_COMPILE);
glVertexPointer(3,GL_FLOAT,0,xyz);
glNormalPointer(GL_FLOAT,0,xyz);
glDrawArrays(GL_TRIANGLES,0,_nv);
glEndList();
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
glCallList(_displayList.list());
}
示例2: fillFloatBuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* <code>fillFloatBuffer</code> fills a FloatBuffer object with the matrix
* data.
*
* @param fb
* the buffer to fill, starting at current position. Must have
* room for 16 more floats.
* @param columnMajor
* if true, this buffer should be filled with column major data,
* otherwise it will be filled row major.
* @return matrix data as a FloatBuffer. (position is advanced by 16 and any
* limit set is not changed).
*/
public FloatBuffer fillFloatBuffer(FloatBuffer fb, boolean columnMajor) {
// if (columnMajor) {
// fb.put(m00).put(m10).put(m20).put(m30);
// fb.put(m01).put(m11).put(m21).put(m31);
// fb.put(m02).put(m12).put(m22).put(m32);
// fb.put(m03).put(m13).put(m23).put(m33);
// } else {
// fb.put(m00).put(m01).put(m02).put(m03);
// fb.put(m10).put(m11).put(m12).put(m13);
// fb.put(m20).put(m21).put(m22).put(m23);
// fb.put(m30).put(m31).put(m32).put(m33);
// }
TempVars vars = TempVars.get();
fillFloatArray(vars.matrixWrite, columnMajor);
fb.put(vars.matrixWrite, 0, 16);
vars.release();
fb.rewind();
return fb;
}
示例3: bindUniforms
import java.nio.FloatBuffer; //导入方法依赖的package包/类
void bindUniforms(GL2 gl, Scene scene,Renderer renderer, Simulation s, MeshEntity me,
Matrix4f projectionViewModel, Matrix4f viewModel, Matrix4f model,
FloatBuffer fb) {
fb.rewind();
gl.glUniformMatrix4fv(mvpMatrixHandle, 1, false, projectionViewModel.fillFloatBuffer(fb, true));
gl.glUniformMatrix4fv(mvMatrixHandle, 1, false, viewModel.fillFloatBuffer(fb, true));
gl.glUniformMatrix4fv(mMatrixHandle, 1, false, model.fillFloatBuffer(fb, true));
Vector3f lightPos = scene.getLight().getTransform().getTranslation();
Vector3f eyePos = scene.getCamera().getTransform().getTranslation();
gl.glUniform4f(lightPosHandle, lightPos.x, lightPos.y, lightPos.z, 1);
gl.glUniform4f(eyePosHandle, eyePos.x, eyePos.y, eyePos.z, 1);
float r = Color.red(me.getColor()) / 255.0f;
float g = Color.green(me.getColor()) / 255.0f;
float b = Color.blue(me.getColor()) / 255.0f;
float a = Color.alpha(me.getColor()) / 255.0f;
gl.glUniform4f(colorHandle, r, g, b, a);
gl.glUniform1f(ambient, me.getMaterial().getAmbient());
gl.glUniform1f(diffuse, me.getMaterial().getDiffuse());
gl.glUniform1f(specular, me.getMaterial().getSpecular());
gl.glUniform1f(shininess, me.getMaterial().getShininess());
}
示例4: clone
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* 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 (isDirect(buf)) {
copy = createFloatBuffer(buf.limit());
} else {
copy = FloatBuffer.allocate(buf.limit());
}
copy.put(buf);
return copy;
}
示例5: toBuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Stores the specified 4x4 matrix into a float buffer
* @param data The 4x4 matrix
* @return The generated FloatBuffer
*/
public static FloatBuffer toBuffer(Matrix4f data) {
// Create an empty FloatBuffer with the correct size (4x4)
FloatBuffer buffer = BufferUtils.createFloatBuffer(4 * 4);
// Store the matrix into the buffer
data.store(buffer);
// Prepare the buffer for get() operations
buffer.rewind();
return buffer;
}
示例6: lwjglBody
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public void lwjglBody(int gl_format, Texture tx, Texel ir, int mipmap, int slice, Map<String,String> options, DDS_HEADER header, DDS_BODY body) throws Exception {
IntBuffer intBuf1=BufferUtils.createIntBuffer(1);
glGenTextures(intBuf1);
int id=intBuf1.get(0);
glBindTexture(GL_TEXTURE_2D,id);
Vector4f pixels[][]=ir.getPixels(PixelFormat.FLOAT_NORMALIZED_RGBA);
FloatBuffer bbf=BufferUtils.createFloatBuffer(pixels.length*pixels[0].length*4);
for(int y=0;y<pixels[0].length;y++){
for(int x=0;x<pixels.length;x++){
bbf.put(pixels[x][y].x);
bbf.put(pixels[x][y].y);
bbf.put(pixels[x][y].z);
bbf.put(pixels[x][y].w);
}
}
bbf.rewind();
glTexImage2D(GL_TEXTURE_2D,0,gl_format,pixels.length,pixels[0].length,0,GL_RGBA,GL_FLOAT,bbf);
int out_size=glGetTexLevelParameteri(GL_TEXTURE_2D,0,GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB);
ByteBuffer out=BufferUtils.createByteBuffer(out_size);
// glGetCompressedTexImageARB(GL_TEXTURE_2D,0,out);
glGetCompressedTexImage(GL_TEXTURE_2D,0,out);
byte bytes[]=new byte[out_size];
out.rewind();
out.get(bytes);
body.write(bytes);
BufferUtils.destroyDirectBuffer(out);
BufferUtils.destroyDirectBuffer(bbf);
glBindTexture(GL_TEXTURE_2D,0);
glDeleteTextures(id);
}
示例7: toFloatBuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* <code>toFloatBuffer</code> returns a FloatBuffer object that contains
* the matrix data.
*
* @return matrix data as a FloatBuffer.
*/
public FloatBuffer toFloatBuffer() {
FloatBuffer fb = BufferUtils.createFloatBuffer(9);
fb.put(m00).put(m01).put(m02);
fb.put(m10).put(m11).put(m12);
fb.put(m20).put(m21).put(m22);
fb.rewind();
return fb;
}
示例8: 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);
}
示例9: quatToGlMatrix
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public static FloatBuffer quatToGlMatrix(FloatBuffer p_187418_0_, Quaternion p_187418_1_)
{
p_187418_0_.clear();
float f = p_187418_1_.x * p_187418_1_.x;
float f1 = p_187418_1_.x * p_187418_1_.y;
float f2 = p_187418_1_.x * p_187418_1_.z;
float f3 = p_187418_1_.x * p_187418_1_.w;
float f4 = p_187418_1_.y * p_187418_1_.y;
float f5 = p_187418_1_.y * p_187418_1_.z;
float f6 = p_187418_1_.y * p_187418_1_.w;
float f7 = p_187418_1_.z * p_187418_1_.z;
float f8 = p_187418_1_.z * p_187418_1_.w;
p_187418_0_.put(1.0F - 2.0F * (f4 + f7));
p_187418_0_.put(2.0F * (f1 + f8));
p_187418_0_.put(2.0F * (f2 - f6));
p_187418_0_.put(0.0F);
p_187418_0_.put(2.0F * (f1 - f8));
p_187418_0_.put(1.0F - 2.0F * (f + f7));
p_187418_0_.put(2.0F * (f5 + f3));
p_187418_0_.put(0.0F);
p_187418_0_.put(2.0F * (f2 + f6));
p_187418_0_.put(2.0F * (f5 - f3));
p_187418_0_.put(1.0F - 2.0F * (f + f4));
p_187418_0_.put(0.0F);
p_187418_0_.put(0.0F);
p_187418_0_.put(0.0F);
p_187418_0_.put(0.0F);
p_187418_0_.put(1.0F);
p_187418_0_.rewind();
return p_187418_0_;
}
示例10: processAPSFrame
import java.nio.FloatBuffer; //导入方法依赖的package包/类
@Override
public float[] processAPSFrame(AEFrameChipRenderer frame) {
final int numChannels = processor.isMakeRGBFrames() ? 3 : 1;
float mean = processor.getImageMean(), scale = processor.getImageScale();
int width = processor.getImageWidth(), height = processor.getImageHeight();
if (inputNormalizationGraph == null) {
Graph g = new Graph();
GraphBuilder b = new GraphBuilder(g);
// see https://github.com/tensorflow/tensorflow/issues/6781
final Output<Float> imagePH = g.opBuilder("Placeholder", "input").setAttr("dtype", DataType.FLOAT).build().output(0);
final Output<Float> meanPH = g.opBuilder("Placeholder", "mean").setAttr("dtype", DataType.FLOAT).build().output(0);
final Output<Float> scalePH = g.opBuilder("Placeholder", "scale").setAttr("dtype", DataType.FLOAT).build().output(0);
// final Output<Integer> widthPH = g.opBuilder("Placeholder", "width").setAttr("dtype", DataType.INT32).build().output(0);
// final Output<Integer> heightPH = g.opBuilder("Placeholder", "height").setAttr("dtype", DataType.INT32).build().output(0);
final Output<Integer> sizePH = g.opBuilder("Placeholder", "size").setAttr("dtype", DataType.INT32).build().output(0);
normalizedImageOutput
= b.div(
b.sub(
b.resizeBilinear(
imagePH,
sizePH),
meanPH),
scalePH);
inputNormalizationGraph = g;
}
final int sx = frame.getWidthInPixels(), sy = frame.getHeightInPixels();
FloatBuffer fb = FloatBuffer.allocate(sx * sy * numChannels);
float[] rgb = null;
if (processor.isMakeRGBFrames()) {
rgb = new float[]{1, 1, 1};
} else {
rgb = new float[]{1};
}
for (int y = 0; y < sy; y++) {
for (int x = 0; x < sx; x++) {
for (int c = 0; c < numChannels; c++) {
final int newIdx = c + numChannels * (x + (sx * (sy - y - 1)));
fb.put(newIdx, rgb[c] * frame.getApsGrayValueAtPixel(x, y));
}
}
}
fb.rewind();
Tensor<Float> inputImageTensor = Tensor.create(new long[]{1, sy, sx, numChannels}, fb);
Tensor meanT = Tensor.create(mean);
Tensor scaleT = Tensor.create(scale);
Tensor sizeT = Tensor.create(new int[]{height, width});
Tensor<Float> normalizedImage = new Session(inputNormalizationGraph)
.runner()
.feed("input", inputImageTensor)
.feed("mean", meanT)
.feed("scale", scaleT)
.feed("size", sizeT)
.fetch(normalizedImageOutput.op().name())
.run()
.get(0).expect(Float.class);
float[] results = TensorFlow.executeGraph(executionGraph, normalizedImage, processor.getInputLayerName(), processor.getOutputLayerName());
outputLayer = new OutputLayer(results);
getSupport().firePropertyChange(EVENT_MADE_DECISION, null, this);
return results;
}
示例11: createFloatBuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
public static FloatBuffer createFloatBuffer(float[] floats) {
FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
buffer.put(floats);
buffer.rewind();
return buffer;
}
示例12: containAABB
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* <code>containAABB</code> creates a minimum-volume axis-aligned bounding
* box of the points, then selects the smallest enclosing sphere of the box
* with the sphere centered at the boxes center.
*
* @param points
* the list of points.
*/
public void containAABB(FloatBuffer points) {
if (points == null) {
return;
}
points.rewind();
if (points.remaining() <= 2) // we need at least a 3 float vector
{
return;
}
TempVars vars = TempVars.get();
float[] tmpArray = vars.skinPositions;
float minX = Float.POSITIVE_INFINITY, minY = Float.POSITIVE_INFINITY, minZ = Float.POSITIVE_INFINITY;
float maxX = Float.NEGATIVE_INFINITY, maxY = Float.NEGATIVE_INFINITY, maxZ = Float.NEGATIVE_INFINITY;
int iterations = (int) M.ceil(points.limit() / ((float) tmpArray.length));
for (int i = iterations - 1; i >= 0; i--) {
int bufLength = Math.min(tmpArray.length, points.remaining());
points.get(tmpArray, 0, bufLength);
for (int j = 0; j < bufLength; j += 3) {
vars.vect1.x = tmpArray[j];
vars.vect1.y = tmpArray[j+1];
vars.vect1.z = tmpArray[j+2];
if (vars.vect1.x < minX) {
minX = vars.vect1.x;
}
if (vars.vect1.x > maxX) {
maxX = vars.vect1.x;
}
if (vars.vect1.y < minY) {
minY = vars.vect1.y;
}
if (vars.vect1.y > maxY) {
maxY = vars.vect1.y;
}
if (vars.vect1.z < minZ) {
minZ = vars.vect1.z;
}
if (vars.vect1.z > maxZ) {
maxZ = vars.vect1.z;
}
}
}
vars.release();
center.set(minX + maxX, minY + maxY, minZ + maxZ);
center.multLocal(0.5f);
xExtent = maxX - center.x;
yExtent = maxY - center.y;
zExtent = maxZ - center.z;
}
示例13: toFloatBuffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* <code>toFloatBuffer</code> returns a FloatBuffer object that contains the
* matrix data.
*
* @param columnMajor
* if true, this buffer should be filled with column major data,
* otherwise it will be filled row major.
* @return matrix data as a FloatBuffer. The position is set to 0 for
* convenience.
*/
public FloatBuffer toFloatBuffer(boolean columnMajor) {
FloatBuffer fb = BufferUtils.createFloatBuffer(16);
fillFloatBuffer(fb, columnMajor);
fb.rewind();
return fb;
}
示例14: createVector3Buffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector3f object data only if the given buffer if not already
* the right size.
*
* @param buf
* the buffer to first check and rewind
* @param vertices
* number of vertices that need to be held by the newly created
* buffer
* @return the requested new FloatBuffer
*/
public static FloatBuffer createVector3Buffer(FloatBuffer buf, int vertices) {
if (buf != null && buf.limit() == 3 * vertices) {
buf.rewind();
return buf;
}
return createFloatBuffer(3 * vertices);
}
示例15: createVector2Buffer
import java.nio.FloatBuffer; //导入方法依赖的package包/类
/**
* Create a new FloatBuffer of an appropriate size to hold the specified
* number of Vector2f object data only if the given buffer if not already
* the right size.
*
* @param buf
* the buffer to first check and rewind
* @param vertices
* number of vertices that need to be held by the newly created
* buffer
* @return the requested new FloatBuffer
*/
public static FloatBuffer createVector2Buffer(FloatBuffer buf, int vertices) {
if (buf != null && buf.limit() == 2 * vertices) {
buf.rewind();
return buf;
}
return createFloatBuffer(2 * vertices);
}