/** * @param renderableTexturedGeometry * @param out * @throws IOException */ private void writeTexturedGeometry( RenderableTexturedGeometry renderableTexturedGeometry, DataOutputStream out ) throws IOException { writePlainGeometry( renderableTexturedGeometry, out ); out.writeUTF( renderableTexturedGeometry.getTexture() ); FloatBuffer fb = getBuffer( renderableTexturedGeometry.getTextureCoordinates(), renderableTexturedGeometry.getTexturePosition(), renderableTexturedGeometry.getTextureOrdinateCount(), VertexType.TextureCoordinates ); writeFloatBuffer( fb, out, VertexType.TextureCoordinates ); }
/** * @param textureCoordinates * the textureCoordinates to set */ public final void setTextureCoordinates( float[] textureCoordinates ) { loadTextureCoordinates( textureCoordinates ); }
if ( geometryBuffer != null ) { int[] texPos = geometryBuffer.readTextureOrdinates( in ); result = new RenderableTexturedGeometry( coordPositions[0], ( coordPositions[1] / 3 ), glType, normalPositions[0], style, textureID, texPos[0] ); } else { FloatBuffer textureBuffer = readFloatBuffer( in ); result = new RenderableTexturedGeometry( coordBuffer, glType, normalBuffer, style, textureID, textureBuffer );
/** * Load the texture coordinates from given float array * * @param textureCoordinates */ private void loadTextureCoordinates( float[] textureCoordinates ) { if ( textureCoordinates == null || textureCoordinates.length == 0 ) { throw new IllegalArgumentException( "A Renderable Textured Geometry must have texture coordinates to work with (the textureCoordinates array may not be null or empty). " ); } if ( textureCoordinates.length / 2 != getVertexCount() ) { throw new IllegalArgumentException( "The number of texture coordinates (" + ( textureCoordinates.length / 2 ) + ") must equal the number of vertices (" + getVertexCount() + ")." ); } if ( super.useDirectBuffers() ) { textureBuffer = BufferUtil.copyFloatBuffer( FloatBuffer.wrap( textureCoordinates ) ); } else { textureBuffer = FloatBuffer.wrap( textureCoordinates ); } textureOrdinatesCount = textureCoordinates.length; }
@Override public RenderableGeometry createRenderableGeometry( boolean useDirectBuffers ) { return new RenderableTexturedGeometry( getTesselatedCoordinates(), getOpenGLType(), calculateNormals(), getGeometry().getStyle(), ( (TexturedGeometry) getGeometry() ).getTexture(), getTesselatedTextureCoordinates(), useDirectBuffers ); }
geometries.add( new RenderableGeometry( coords, glType, normals, style, false ) ); } else { geometries.add( new RenderableTexturedGeometry( coords, glType, normals, style, texCoordID.first, texCoordID.second, false ) );
/** * * @param vertices * @param openGLType * @param vertexNormals * @param texture * @param textureCoordinates * @param useDirectBuffers * to use direct buffers instead of heap buffers. */ public RenderableTexturedGeometry( float[] vertices, int openGLType, float[] vertexNormals, String texture, float[] textureCoordinates, boolean useDirectBuffers ) { super( vertices, openGLType, vertexNormals, useDirectBuffers ); this.texture = texture; loadTextureCoordinates( textureCoordinates ); }
/** * @param vertices * @param openGLType * @param vertexNormals * @param style * @param texture * to use * @param textureCoordinates * of this data * @param useDirectBuffers * to use direct buffers instead of heap buffers. */ public RenderableTexturedGeometry( float[] vertices, int openGLType, float[] vertexNormals, SimpleGeometryStyle style, String texture, float[] textureCoordinates, boolean useDirectBuffers ) { super( vertices, openGLType, vertexNormals, style, useDirectBuffers ); this.texture = texture; loadTextureCoordinates( textureCoordinates ); }