/** * Add the given {@link FloatBuffer} to the direct coordinates buffer, if the direct coordinate buffer does not have * the capacity this method will return -1; * * @param coordBuffer * to add to the coordinates direct buffer. * @return the position of the copy in the coordinate buffer or -1 if the given buffer could not be copied in the * direct buffer. */ public synchronized int addCoordinates( FloatBuffer coordBuffer ) { return addBuffer( this.coordBuffer, coordBuffer ); }
/** * Add the floats read from the given {@link ObjectInputStream} to the direct texture {@link FloatBuffer}, if the * direct texture buffer does not have the capacity this method will return -1. This method assumes that the stream * is positioned so, that the next value is an int, declaring the size of the number of floats to be read. * * @param in * the stream to get the floats from. * @return the position of the copy in the texture buffer or -1 if the given buffer could not be copied in the * direct buffer. * @throws IOException * if the stream throws this exception while reading. */ public synchronized int readTexCoordsFromStream( ObjectInputStream in ) throws IOException { return addFromStream( textureBuffer, in ); }
/** * Read the floats from the given {@link DataInputStream} to the direct coordinates buffer, if the direct coordinate * buffer does not have the capacity this method will return -1,-1; * * @param in * the stream to add to the coordinates from. * @return the position [0] of the copy in the coordinate buffer and the number of ordinates [1] inserted. Both will * have -1 if the given ordinates could not be copied in the direct buffer. * @throws IOException */ public synchronized int[] readCoordinates( DataInputStream in ) throws IOException { return readFromStreamBuffer( this.coordBuffer, in ); }
coordBuffer = geomBuffer.getCoords( coordPosition, numberOfOrdinates ); if ( coordBuffer != null ) { coordPosition = -1; LOG.trace( "Loading normal buffer" ); if ( normalPosition >= 0 && ( normalBuffer == null ) && ( geomBuffer != null ) ) { normalBuffer = geomBuffer.getNormals( normalPosition, numberOfOrdinates ); hasNormals = ( normalBuffer != null );
int[] coordPositions = new int[2]; if ( geometryBuffer != null ) { coordPositions = geometryBuffer.readCoordinates( in ); } else { coordBuffer = readFloatBuffer( in ); int[] normalPositions = new int[2]; if ( geometryBuffer != null ) { normalPositions = geometryBuffer.readNormals( in ); } else { normalBuffer = readFloatBuffer( in ); String textureID = in.readUTF(); if ( geometryBuffer != null ) { int[] texPos = geometryBuffer.readTextureOrdinates( in ); result = new RenderableTexturedGeometry( coordPositions[0], ( coordPositions[1] / 3 ), glType, normalPositions[0], style, textureID, texPos[0] );
private FloatBuffer getBuffer( FloatBuffer buffer, int position, int limit, VertexType type ) { if ( buffer == null ) { if ( geometryBuffer == null ) { LOG.warn( "The given buffer is null and the geometry buffer was not set; the geometry has no " + type ); } else { if ( position == -1 ) { LOG.warn( "The given geometry does not have a direct buffer position and no buffer; the geometry has no " + type ); } else { buffer = geometryBuffer.getCoords( position, limit ); } } } return buffer; }
@Override protected void enableArrays( RenderContext glRenderContext, DirectGeometryBuffer geomBuffer ) { super.enableArrays( glRenderContext, geomBuffer ); if ( texturePosition >= 0 && textureBuffer == null && geomBuffer != null ) { textureBuffer = geomBuffer.getTextureCoordinates( texturePosition, textureOrdinatesCount ); if ( textureBuffer == null ) { texturePosition = -1; } } if ( textureBuffer != null ) { glRenderContext.getContext().glEnable( GL.GL_TEXTURE_2D ); TexturePool.loadTexture( glRenderContext, texture ); glRenderContext.getContext().glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); glRenderContext.getContext().glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureBuffer ); } }
DirectGeometryBuffer geometryBuffer = new DirectGeometryBuffer( info.getOrdinateCount(), info.getTextureOrdinateCount() );
/** * Add the given {@link FloatBuffer} to the direct coordinates buffer, if the direct normal buffer does not have the * capacity this method will return -1; * * @param normalBuffer * to add to the normal direct buffer. * @return the position of the copy in the coordinate buffer or -1 if the given buffer could not be copied in the * direct buffer. */ public synchronized int addNormals( FloatBuffer normalBuffer ) { return addBuffer( this.normalBuffer, normalBuffer ); }
/** * Read the floats from the given {@link DataInputStream} to the direct normal buffer, if the direct normal buffer * does not have the capacity this method will return -1,-1; * * @param in * the stream to add to the coordinates from. * @return the position [0] of the copy in the normal buffer and the number of ordinates [1] inserted. Both will * have -1 if the given ordinates could not be copied in the direct buffer. * @throws IOException */ public synchronized int[] readNormals( DataInputStream in ) throws IOException { return readFromStreamBuffer( this.normalBuffer, in ); }
/** * Add the given {@link FloatBuffer} to the direct texture buffer, if the direct texture buffer does not have the * capacity this method will return -1; * * @param textureBuffer * to add to the texture direct buffer. * @return the position of the copy in the texture buffer or -1 if the given buffer could not be copied in the * direct buffer. */ public synchronized int addTexture( FloatBuffer textureBuffer ) { return addBuffer( this.textureBuffer, textureBuffer ); }
/** * Read the floats from the given {@link DataInputStream} to the direct texture buffer, if the direct texture buffer * does not have the capacity this method will return -1,-1; * * @param in * the stream to add to the coordinates from. * @return the position [0] of the copy in the texture buffer and the number of ordinates [1] inserted. Both will * have -1 if the given ordinates could not be copied in the direct buffer. * @throws IOException */ public synchronized int[] readTextureOrdinates( DataInputStream in ) throws IOException { return readFromStreamBuffer( this.textureBuffer, in ); }