public FlightControls( GLCanvas master, ViewParams viewParams ) { this.master = master; this.vf = viewParams.getViewFrustum(); }
/** * 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; }
/** * @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; }
/** * @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 ); }
@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 ); }
ViewParams params = glRenderContext.getViewParams(); GL context = glRenderContext.getContext(); params.getViewFrustum().getEyePos(); Set<WorldRenderableObject> buildings = getObjects( params ); if ( !buildings.isEmpty() ) {
/** * The new LOD is based on the current viewfrustum and the maximum size of any textures. * * @param glRenderContext * @param zScale * @param textureManagers */ private Set<RenderMeshFragment> getNewLOD( RenderContext glRenderContext, float zScale, TextureManager[] textureManagers ) { ViewParams params = glRenderContext.getViewParams(); ViewFrustum frustum = params.getViewFrustum(); ViewFrustumCrit crit = new ViewFrustumCrit( params, (float) maxPixelError, zScale, glRenderContext.getMaxTextureSize(), textureManagers, (float) maxProjectedTexelSize ); SpatialSelection lodAdaptor = new SpatialSelection( fragmentManager.getMultiresolutionMesh(), crit, frustum, zScale ); List<MeshFragment> fragments = lodAdaptor.determineLODFragment(); Set<RenderMeshFragment> fragmentIds = new HashSet<RenderMeshFragment>( fragments.size() ); for ( MeshFragment fragment : fragments ) { fragmentIds.add( fragmentManager.renderFragments[fragment.id] ); } return fragmentIds; }
ViewFrustum vf = params.getViewFrustum(); Point3d eyePosPoint = vf.getEyePos(); float[] eyePos = new float[] { (float) eyePosPoint.x, (float) eyePosPoint.y, (float) eyePosPoint.z };
Point3d eyePos = viewParams.getViewFrustum().getEyePos(); Point3d lookingAt = viewParams.getViewFrustum().getLookingAt(); Vector3d viewerUp = viewParams.getViewFrustum().getUp(); glu.gluLookAt( eyePos.x, eyePos.y, eyePos.z, lookingAt.x, lookingAt.y, lookingAt.z, viewerUp.x, viewerUp.y, viewerUp.z );
private void getObjects( ViewParams viewParams, float[] eye, Set<T> result ) { if ( viewParams.getViewFrustum().intersects( getEnvelope() ) ) { if ( hasCoveringObjects() ) { for ( Entry<T> obj : objectsCoveringEnv ) { 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 );
Point3d eyePos = params.getViewFrustum().getEyePos(); Point3d lookingAt = params.getViewFrustum().getLookingAt(); Vector3d viewerUp = params.getViewFrustum().getUp(); glu.gluLookAt( eyePos.x, eyePos.y, eyePos.z, lookingAt.x, lookingAt.y, lookingAt.z, viewerUp.x, viewerUp.y, viewerUp.z ); lodAnalyzer.updateParameters( demRenderer.getCurrentLOD(), params.getViewFrustum() ); lodAnalyzer.repaint();
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 );
GL context = glRenderContext.getContext(); long begin = System.currentTimeMillis(); Point3d eye = params.getViewFrustum().getEyePos(); float[] eye2 = new float[] { (float) eye.x, (float) eye.y, (float) eye.z }; Set<BillBoard> boards = getObjects( params );
@Override public void render( RenderContext glRenderContext ) { Point3d eye = glRenderContext.getViewParams().getViewFrustum().getEyePos(); GL context = glRenderContext.getContext(); context.glPushMatrix(); context.glDepthMask( false ); context.glEnable( GL.GL_TEXTURE_2D ); context.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); // the translation context.glTranslatef( location[0], location[1], location[2] ); // the rotation calculateAndSetRotation( context, new float[] { (float) eye.x, (float) eye.y, (float) eye.z } ); context.glScalef( width, 1, height ); TexturePool.loadTexture( glRenderContext, textureID ); // context.glMaterialfv( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, new float[] { 1, 1, 1, .1f }, 0 ); context.glVertexPointer( 3, GL.GL_FLOAT, 0, coordBuffer ); context.glTexCoordPointer( 2, GL.GL_FLOAT, 0, textureBuffer ); // context.glDisableClientState( GL.GL_NORMAL_ARRAY ); context.glDrawArrays( GL.GL_QUADS, 0, 4 ); context.glDisableClientState( GL.GL_TEXTURE_COORD_ARRAY ); context.glDisable( GL.GL_TEXTURE_2D ); context.glDepthMask( true ); context.glMatrixMode( GL.GL_MODELVIEW ); context.glPopMatrix(); }