imageBuffer = getFrameBufferRGB( glContext, imageBuffer, viewPortX, viewPortY, width, height ); if ( resultImage == null || resultImage.getWidth() < width || resultImage.getHeight() < height ) { resultImage = new BufferedImage( width, height, BufferedImage.TYPE_3BYTE_BGR ); for ( int x = 0; x < width; x++ ) { imageBuffer.get( color ); resultImage.setRGB( x, y, convertBytesToRGBInt( color ) );
/** * Create an a float array from the given color object, which can be used for rendering with jogl. * * @param color * to be converted. * @return the color as an float array holding rgba. */ public static float[] convertColorFloats( Color color ) { int c = convertColorGLColor( color ); return convertColorIntAsFloats( c ); }
@Override public void init( GLAutoDrawable glpBuffer ) { GL context = glpBuffer.getGL(); glTextureSize = JOGLUtils.getMaxTextureSize( context ); }
imageBuffer = getFrameBufferRGBA( glContext, imageBuffer, viewPortX, viewPortY, width, height ); if ( resultImage == null || resultImage.getWidth() < width || resultImage.getHeight() < height ) { resultImage = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB ); for ( int x = 0; x < width; x++ ) { imageBuffer.get( color ); resultImage.setRGB( x, y, convertBytesToARGBInt( color ) );
private void writeResult( GL gl ) { ByteBuffer buffer = imageBuffer.getBuffer(); int limit = buffer.limit(); buffer.limit( width * height * 3 ); resultImage = getFrameBufferRGB( gl, buffer, 0, 0, width, height, null ); buffer.limit( limit ); }
/** * @param f * @return * @throws IOException */ private List<WorldRenderableObject> readGML( String fileName, CommandLine commandLine ) throws IOException { LOG.debug( "Reading buildings from file: " + fileName ); String schemaLocation = commandLine.getOptionValue( DataManager.OPT_CITY_GML_SCHEMA ); String color = commandLine.getOptionValue( DataManager.OPT_CITY_GML_COLOR ); SimpleGeometryStyle style = new SimpleGeometryStyle(); if ( color != null ) { try { int i = Integer.decode( color ); int diffuseColor = JOGLUtils.convertColorGLColor( new Color( i ) ); style.setDiffuseColor( diffuseColor ); style.setAmbientColor( diffuseColor ); style.setSpecularColor( diffuseColor ); } catch ( NumberFormatException e ) { LOG.warn( "Could not decode color into an integer: " + color + " using white instead." ); } } boolean useOpengis = commandLine.hasOption( DataManager.OPT_USE_OPENGIS ); CityGMLImporter importer = new CityGMLImporter( schemaLocation, new float[] { (float) wpvsTranslationVector[0], (float) wpvsTranslationVector[1], 0 }, style, useOpengis ); return importer.importFromFile( fileName, numberOfqualityLevels, qualityLevel ); }
float[] newEye = JOGLUtils.getEyeFromModelView( context ); float[] viewVec = Vectors3f.sub( worldTranslation, newEye ); Vectors3f.normalizeInPlace( viewVec );
/** * Create an int value ([a]rgb) from the given color array (rgb[a]), the result can be used for buffered images. * * @param color * to be converted may be of length 3 or 4, not <code>null</code>. * @return the color as an int holding argb. */ public static int convertBytesToARGBInt( byte[] color ) { int result = convertBytesToRGBInt( color ); if ( color.length == 4 ) { result = color[3] & 0x000000FF; result <<= 8; } return result; }
/** * Create float arrays of the int colors. */ private void createColors() { // ambientColor = new float[] { 0.6f, 0.6f, 0.6f, 1 };// convertColorIntAsFloats( style.getAmbientColor() ); emmisiveColor = convertColorIntAsFloats( style.getEmmisiveColor() ); specularColor = convertColorIntAsFloats( style.getSpecularColor() ); diffuseColor = convertColorIntAsFloats( style.getDiffuseColor() ); }
private void init( GL gl ) { float[] cc = JOGLUtils.convertColorFloats( request.getBackgroundColor() ); gl.glClearColor( cc[0], cc[1], cc[2], 0.0f ); SunInfo pos = request.getSceneParameters().getSunPosition(); float[] light_position = pos.getEucledianPosition( sceneLatitude ); Vectors3f.scale( -1, light_position ); float[] ambientAndDiffuse = pos.calculateSunlight( sceneLatitude ); // float intens = pos.calcSunlightIntensity( ambientAndDiffuse, 0.5f ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_POSITION, new float[] { light_position[0], light_position[1], light_position[2], 0 }, 0 ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); gl.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); gl.glLightfv( GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[] { ambientAndDiffuse[0], ambientAndDiffuse[1], ambientAndDiffuse[2], 1 }, 0 ); }
private void writeResult( GL gl ) { int width = params.getScreenPixelsX(); int height = params.getScreenPixelsY(); BufferedImage resultImage = JOGLUtils.getFrameBufferRGB( gl, null, 0, 0, width, height, null ); try { File f = File.createTempFile( "wpvs_", ".jpg" ); ImageIO.write( resultImage, "jpg", f ); System.out.println( "Wrote file to: " + f.getAbsolutePath() ); } catch ( IOException e ) { // nottin } }
SimpleGeometryStyle style = new SimpleGeometryStyle( convertColorGLColor( specular.get() ), convertColorGLColor( ambient.get() ), convertColorGLColor( diffuse.get() ), convertColorGLColor( emmisive.get() ), shininess ); if ( bb == null ) {
glu.gluLookAt( eye[0], eye[1], eye[2], lookAt[0], lookAt[1], lookAt[2], 0, 1, 0 ); trackBall.multModelMatrix( gl, centroid ); float[] newEye = JOGLUtils.getEyeFromModelView( gl ); if ( LOG.isDebugEnabled() ) { LOG.debug( "farClippingPlane:" + farClippingPlane );
this.glRenderContext = new RenderContext( params, zScale, JOGLUtils.getMaxTextureSize( gl ), initValues.getCompositingTextureShaderPrograms() );