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 } }
public FlightControls( GLCanvas master, ViewParams viewParams ) { this.master = master; this.vf = viewParams.getViewFrustum(); }
@Override public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { float aspect = (float) width / (float) height; LOG.info( "reshape( GLAutoDrawable, " + x + ", " + y + ", " + width + ", " + height + " ) called, aspect: " + aspect ); params.setProjectionPlaneDimensions( width, height ); GL gl = drawable.getGL(); gl.glViewport( x, y, width, height ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); glu.gluPerspective( params.getViewFrustum().getFOVY(), aspect, params.getViewFrustum().getZNear(), params.getViewFrustum().getZFar() ); // glu.gluPerspective( params.getViewFrustum().getFOVY(), aspect, 0.01, 1000 ); gl.glMatrixMode( GL.GL_MODELVIEW ); }
private void getObjects( ViewParams viewParams, float[] eye, Set<T> result ) { if ( viewParams.getViewFrustum().intersects( getEnvelope() ) ) { if ( hasCoveringObjects() ) { for ( Entry<T> obj : objectsCoveringEnv ) { double distance = VectorUtils.getDistance( envelope, eye ); double estimatePixel = viewParams.estimatePixelSizeForSpaceUnit( distance ); double estError = estimatePixel * maxError; if ( distance <= 1E-10 || ( estError > maxPixelError ) ) { for ( Entry<T> obj : leafObjects ) { distance = Vectors3f.distance( eye, 0, obj.entryEnv, 0 ); double estPixelSize = viewParams.estimatePixelSizeForSpaceUnit( distance ); boolean noPixelError = ( obj.entryValue.getErrorScalar() * estPixelSize ) > maxPixelError; boolean intersects = viewParams.getViewFrustum().intersects( obj.entryEnv ); if ( noPixelError && intersects ) { result.add( obj.entryValue );
ViewFrustum vf = new ViewFrustum( newEyeP, center, up, fov, (double) width / height, nearClippingPlane, farClippingPlane ); ViewParams params = new ViewParams( vf, width, height ); RenderContext context = new RenderContext( params ); context.setContext( gl );
GL gl = glRenderContext.getContext(); int x = vp.getScreenPixelsX() - 120; gl.glDisable( GL.GL_TEXTURE_2D ); gl.glColor3f( 1.0f, 1.0f, 1.0f );
private boolean isTexturable( MeshFragment fragment ) { float[][] scaledBBox = new float[2][3]; scaledBBox[0] = Arrays.copyOf( fragment.bbox[0], 3 ); scaledBBox[1] = Arrays.copyOf( fragment.bbox[1], 3 ); scaledBBox[0][2] *= zScale; scaledBBox[1][2] *= zScale; float[] eyePos = new float[3]; eyePos[0] = (float) viewRegion.getEyePos().x; eyePos[1] = (float) viewRegion.getEyePos().y; eyePos[2] = (float) viewRegion.getEyePos().z; float dist = VectorUtils.getDistance( scaledBBox, eyePos ); double pixelSize = viewParams.estimatePixelSizeForSpaceUnit( dist ); double metersPerPixel = maxProjectedTexelSize / pixelSize; double resolution = getFinestTextureResolution( metersPerPixel ); if ( resolution <= 0.00001 ) { resolution = 0.00001; } double textureSize = getMaxSideLen( fragment ) / resolution; LOG.debug( "Side len: " + getMaxSideLen( fragment ) + ", resolution: " + resolution + ", texture size: " + textureSize ); if ( textureSize > maxTextureSize ) { LOG.debug( "Side len: " + getMaxSideLen( fragment ) + ", resolution: " + resolution + ", texture size: " + textureSize ); } else { LOG.debug( "No refinement needed, Side len: " + getMaxSideLen( fragment ) + ", resolution: " + resolution + ", texture size: " + textureSize ); } return textureSize <= maxTextureSize; }
ViewFrustum vf = params.getViewFrustum(); Point3d eyePosPoint = vf.getEyePos(); float[] eyePos = new float[] { (float) eyePosPoint.x, (float) eyePosPoint.y, (float) eyePosPoint.z }; double pixelSize = params.estimatePixelSizeForSpaceUnit( dist ); double requiredUnitsPerPixel = maxProjectedTexelSize / pixelSize;
return new ViewParams( eye, lookingAt, viewerUp, fovy, zNear, zFar );
/** * Checks whether the screen-space error (after perspective projection) introduced by the fragments of the * {@link Arc} is acceptable. * * @param arc * @return true, if all fragments are fine */ private boolean isScreenSpaceErrorAcceptable( Arc arc ) { float[][] scaledBBox = arc.getBBox(); scaledBBox[0][2] *= zScale; scaledBBox[1][2] *= zScale; float[] eyePos = new float[3]; eyePos[0] = (float) viewRegion.getEyePos().x; eyePos[1] = (float) viewRegion.getEyePos().y; eyePos[2] = (float) viewRegion.getEyePos().z; float dist = VectorUtils.getDistance( scaledBBox, eyePos ); double projectionFactor = viewParams.estimatePixelSizeForSpaceUnit( dist ); double screenError = projectionFactor * arc.geometricError; // System.out.println ("error: " + arc.geometryError); // System.out.println ("screen error: " + screenError); return screenError <= maxPixelError; }
private void setBackground() { Texture skyImage = TexturePool.getTexture( glRenderContext, skyImageID ); if ( skyImage != null ) { draw2D( 0, 0, params.getScreenPixelsX(), params.getScreenPixelsY(), skyImage, false ); } }
/** * Creates a new {@link ViewFrustumCrit} instance. * * @param viewParams * specifies the visible space volume (viewer position, view direction, etc.) * @param maxPixelError * maximum tolerable screen space error in pixels (in the rendered image) * @param zScale * scaling factor applied to z values of the mesh geometry (and bounding boxes) * @param maxTextureSize * maximum texture size (all fragments of the extracted LOD must have a size that is small enough, so * they can be textured regarding this value and the <code>finestTextureResolution</code> parameter * @param textureManagers * texture managers that will be used to provide the textures * @param maxProjectedTexelSize */ public ViewFrustumCrit( ViewParams viewParams, float maxPixelError, float zScale, int maxTextureSize, TextureManager[] textureManagers, float maxProjectedTexelSize ) { this.maxPixelError = maxPixelError; this.viewParams = viewParams; this.viewRegion = viewParams.getViewFrustum(); this.zScale = zScale; this.maxTextureSize = maxTextureSize; this.textureManagers = textureManagers; this.maxProjectedTexelSize = maxProjectedTexelSize; }
ViewParams viewParams = glRenderContext.getViewParams(); Point3d e = viewParams.getViewFrustum().getEyePos(); float[] eye = new float[] { (float) e.x, (float) e.y, (float) e.z }; double distance = Vectors3f.distance( eye, position ); double worldSize = viewParams.estimatePixelSizeForSpaceUnit( distance ); for ( ; level >= 0 && result == -1; --level ) { if ( worldSize >= max( level ) ) {
width / (double) height, configuredNearClippingPlane, farClippingPlane ); return new ViewParams( vf, width, height );
/** * Update the width and height to the configured ones. * * @param viewParams * @throws OWSException */ private void updateMaxWidthAndHeight( ViewParams viewParams ) throws OWSException { int width = viewParams.getScreenPixelsX(); int height = viewParams.getScreenPixelsY(); if ( width > this.maxRequestWidth || height > this.maxRequestHeight ) { StringBuilder errorMessage = new StringBuilder( "Requested" ); if ( width > this.maxRequestWidth ) { errorMessage.append( " width: " ).append( width ).append( " exceeds maximum request width: " ).append( maxRequestWidth ); } if ( height > this.maxRequestHeight ) { if ( width > this.maxRequestWidth ) { errorMessage.append( "," ); } errorMessage.append( " height: " ).append( height ).append( " exceeds maximum request height: " ).append( maxRequestHeight ); } throw new OWSException( errorMessage.toString(), OWSException.INVALID_PARAMETER_VALUE ); // double scale = ( width > height ) ? ( ( (double) this.maxRequestWidth ) / width ) // : ( ( (double) this.maxRequestHeight ) / height ); // viewParams.setScreenDimensions( (int) Math.floor( width * scale ), (int) Math.floor( height * scale ) ); } }
/** * @param viewParams * to get the objects for. * @return the objects which intersect with the given view parameters and or it's children, or the empty list. */ public Set<T> getObjects( ViewParams viewParams ) { Set<T> result = new HashSet<T>(); Point3d e = viewParams.getViewFrustum().getEyePos(); float[] eye = new float[] { (float) e.x, (float) e.y, (float) e.z }; getObjects( viewParams, eye, result ); return result; }
this.request = request; this.viewParams = request.getViewParameters(); this.width = viewParams.getScreenPixelsX(); this.height = viewParams.getScreenPixelsY(); this.context = glRenderContext; this.colormap = colormap;
/** * @param gl */ private void reshape( GL gl ) { float aspect = (float) width / (float) height; LOG.trace( "reshape( GLAutoDrawable, " + 0 + ", " + 0 + ", " + width + ", " + height + " ) called, aspect: " + aspect ); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); gl.glViewport( 0, 0, width, height ); glu.gluPerspective( viewParams.getViewFrustum().getFOVY(), aspect, viewParams.getViewFrustum().getZNear(), viewParams.getViewFrustum().getZFar() ); gl.glMatrixMode( GL.GL_MODELVIEW ); }
gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluOrtho2D( 0, params.getScreenPixelsX(), 0, params.getScreenPixelsY() );
ViewParams params = glRenderContext.getViewParams(); GL context = glRenderContext.getContext(); params.getViewFrustum().getEyePos(); Set<WorldRenderableObject> buildings = getObjects( params ); if ( !buildings.isEmpty() ) {