/** * Returns a new direct float buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static FloatBuffer newFloatBuffer(float[] a) { FloatBuffer b = newFloatBuffer(a.length); b.put(a); b.flip(); return b; }
/** * Returns a new direct long buffer. * @param capacity the buffer capacity. * @return the new buffer. */ public static LongBuffer newLongBuffer(int capacity) { return newByteBuffer(8*capacity).asLongBuffer(); }
/** * Returns a new direct int buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static IntBuffer newIntBuffer(int[] a) { IntBuffer b = newIntBuffer(a.length); b.put(a); b.flip(); return b; }
/** * Returns a new direct short buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static ShortBuffer newShortBuffer(short[] a) { ShortBuffer b = newShortBuffer(a.length); b.put(a); b.flip(); return b; } }
/** * Returns a new direct double buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static DoubleBuffer newDoubleBuffer(double[] a) { DoubleBuffer b = newDoubleBuffer(a.length); b.put(a); b.flip(); return b; }
/** * Returns a new direct long buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static LongBuffer newLongBuffer(long[] a) { LongBuffer b = newLongBuffer(a.length); b.put(a); b.flip(); return b; }
public LineNode(float[] xyz, float[] rgb) { BoundingBox bb = new BoundingBox(xyz); _bs = new BoundingSphere(bb); _np = xyz.length/3; int np = _np; int nv = np; int nc = np; _vb = Direct.newFloatBuffer(3*nv); _cb = (rgb!=null)?Direct.newFloatBuffer(3*nc):null; for (int ip=0,iv=0,ic=0; ip<np; ++ip) { int i = 3*ip; _vb.put(iv++,xyz[i+X]); _vb.put(iv++,xyz[i+Y]); _vb.put(iv++,xyz[i+Z]); if (_cb!=null) { _cb.put(ic++,rgb[i+R]); _cb.put(ic++,rgb[i+G]); _cb.put(ic++,rgb[i+B]); } } }
/** * Returns a new direct float buffer. * @param capacity the buffer capacity. * @return the new buffer. */ public static FloatBuffer newFloatBuffer(int capacity) { return newByteBuffer(4*capacity).asFloatBuffer(); }
_jsmin = 0; _jsmax = -1; _jtmin = 0; _jtmax = -1; _pixels = Direct.newIntBuffer(_ls*_lt); _floats = new float[_ls][_lt];
public PointNode( BoundingBoxTree.Node bbtNode, float[] xyz, float[] rgb) { BoundingBox bb = bbtNode.getBoundingBox(); _bs = new BoundingSphere(bb); _np = bbtNode.getSize(); int np = _np; int nv = np; int nc = np; int[] index = bbtNode.getIndices(); _vb = Direct.newFloatBuffer(3*nv); _cb = (rgb!=null)?Direct.newFloatBuffer(3*nc):null; for (int ip=0,iv=0,ic=0; ip<np; ++ip) { int i = 3*index[ip]; _vb.put(iv++,xyz[i+X]); _vb.put(iv++,xyz[i+Y]); _vb.put(iv++,xyz[i+Z]); if (_cb!=null) { _cb.put(ic++,rgb[i+R]); _cb.put(ic++,rgb[i+G]); _cb.put(ic++,rgb[i+B]); } } }
/** * Returns a new direct int buffer. * @param capacity the buffer capacity. * @return the new buffer. */ public static IntBuffer newIntBuffer(int capacity) { return newByteBuffer(4*capacity).asIntBuffer(); }
int nc = 3*nt; int[] index = bbtNode.getIndices(); _vb = Direct.newFloatBuffer(3*nv); _nb = (uvw!=null)?Direct.newFloatBuffer(3*nn):null; _cb = (rgb!=null)?Direct.newFloatBuffer(3*nc):null; for (int it=0,iv=0,in=0,ic=0; it<nt; ++it) { int jt = 3*index[it];
/** * Returns a new direct short buffer. * @param capacity the buffer capacity. * @return the new buffer. */ public static ShortBuffer newShortBuffer(int capacity) { return newByteBuffer(2*capacity).asShortBuffer(); }
/** * Gets the pixel z coordinate at the specified pixel x and y coordinates. * Reads the front depth buffer of this canvas at the specified pixel * coordinates (xp,yp) to compute (approximately) the pixel z coordinate zp. * <p> * The pixel z coordinate is a floating point number between 0.0 and 1.0. * The value zp = 0.0 corresponds to the near clipping plane, and the value * zp = 1.0 corresponds to the far clipping plane. * @param xp the pixel x coordinate. * @param yp the pixel y coordinate. * @return the pixel z coordinate. */ public double getPixelZ(final int xp, final int yp) { final int hp = getHeight(); final FloatBuffer pixels = Direct.newFloatBuffer(1); runWithContext(new Runnable() { public void run() { glPushAttrib(GL_PIXEL_MODE_BIT); glReadBuffer(GL_FRONT); glReadPixels(xp,hp-1-yp,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,pixels); glPopAttrib(); } }); return pixels.get(0); }
/** * Returns a new direct double buffer. * @param capacity the buffer capacity. * @return the new buffer. */ public static DoubleBuffer newDoubleBuffer(int capacity) { return newByteBuffer(8*capacity).asDoubleBuffer(); }
int nc = 4*nq; int[] index = bbtNode.getIndices(); _vb = Direct.newFloatBuffer(3*nv); _nb = (uvw!=null)?Direct.newFloatBuffer(3*nn):null; _cb = (rgb!=null)?Direct.newFloatBuffer(3*nc):null; for (int iq=0,iv=0,in=0,ic=0; iq<nq; ++iq) { int jq = 4*index[iq];
/** * Returns a new direct byte buffer. Allocates the buffer with capacity * equal to the length of the specified array, and copies all array * elements to the buffer. * @param a the array. * @return the new buffer. */ public static ByteBuffer newByteBuffer(byte[] a) { ByteBuffer b = newByteBuffer(a.length); b.put(a); b.flip(); return b; }
int nc = np; int[] index = bbtNode.getIndices(); _vb = Direct.newFloatBuffer(3*4*6*nv); _nb = Direct.newFloatBuffer(3*4*6*nn); _cb = (rgb!=null)?Direct.newFloatBuffer(3*4*6*nc):null; float d = 0.5f*size; for (int ip=0,iv=0,in=0,ic=0; ip<np; ++ip) {
int nc = 4*nq; Random random = new Random(); _vb = Direct.newFloatBuffer(3*nv); _nb = Direct.newFloatBuffer(3*nn); _cb = Direct.newFloatBuffer(3*nc); float e = 0.01f; for (int iq=0,iv=0,in=0,ic=0; iq<nq; ++iq) {
/** * 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()); }