Changeset 207

Show
Ignore:
Timestamp:
12/31/09 06:32:55 (7 months ago)
Author:
jerome
Message:

Building area visibility

Location:
pTolemy3DViewer/branches/refactor-0.1.1/src/org/ptolemy3d
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pTolemy3DViewer/branches/refactor-0.1.1/src/org/ptolemy3d/plugin/CityGmlBuildingArea.java

    r203 r207  
    1111import org.ptolemy3d.math.Math3D; 
    1212import org.ptolemy3d.math.Vector3d; 
     13import org.ptolemy3d.scene.Landscape; 
    1314import org.ptolemy3d.view.Camera; 
    1415 
     
    7475        } 
    7576         
     77        public boolean isVisible(Camera camera) { 
     78                if((lod1Triangles == null) && (lod2Triangles == null)) { 
     79                        return true; //Always visible if not initialized 
     80                } 
     81                return camera.isTileInView( 
     82                                getMinLon(), getMaxLon(), 
     83                                getMinLat(), getMaxLat(), 
     84                                getMaxAlt(), getMaxAlt(), getMaxAlt(), getMaxAlt()); 
     85        } 
     86         
     87        public double getMinLat() { return minLat; } 
     88        public double getMaxLat() { return maxLat; } 
     89 
     90        public double getMinLon() { return minLon; } 
     91        public double getMaxLon() { return maxLon; } 
     92 
     93        public double getMinAlt() { return minAlt; } 
     94        public double getMaxAlt() { return maxAlt; } 
     95 
    7696        /** 
    7797         * Convert all building surfaces into vertex that can be rendered by the 
  • pTolemy3DViewer/branches/refactor-0.1.1/src/org/ptolemy3d/plugin/CityGmlPlugin.java

    r203 r207  
    201201                // altitude parameter. 
    202202                for (CityGmlBuildingArea buildingArea : buildingAreas) { 
     203                        if (!buildingArea.isVisible(camera)) { 
     204                                continue; 
     205                        } 
     206                         
     207                        double camAltitude = camera.getPosition().getAltitudeDD(); 
     208                         
     209                        // Decide if show LOD1 or LOD2 depending on the altitude 
    203210                        TriangleList cityTriangles = null; 
    204                         // Decide if show LOD1 or LOD2 depending on the altitude 
    205                         double camAltitude = camera.getPosition().getAltitudeDD(); 
    206211                        if (camAltitude < altitude) { 
    207212                                cityTriangles = buildingArea.getLod1Geometry(); 
  • pTolemy3DViewer/branches/refactor-0.1.1/src/org/ptolemy3d/view/Camera.java

    r174 r207  
    516516        } 
    517517 
     518        public boolean isTileInView(double leftLon, double rightLon, double upLat, double botLat, 
     519                        double upLeftHeight, double botLeftHeight, double botRightHeight, double upRightHeight) { 
     520                /* 
     521                 * FIXME At north pose for close view, the visibility goes wrong 
     522                 */ 
     523                 
     524                // Tile corners 
     525                Math3D.setSphericalCoord(leftLon, upLat, Unit.EARTH_RADIUS + upLeftHeight, _point1_); 
     526                Math3D.setSphericalCoord(leftLon, botLat, Unit.EARTH_RADIUS + botLeftHeight, _point2_); 
     527                Math3D.setSphericalCoord(rightLon, botLat, Unit.EARTH_RADIUS + botRightHeight, _point3_); 
     528                Math3D.setSphericalCoord(rightLon, upLat, Unit.EARTH_RADIUS + upRightHeight, _point4_); 
     529 
     530                if (isCartesianPointInVisibleSide(_point1_) || isCartesianPointInVisibleSide(_point2_) 
     531                 || isCartesianPointInVisibleSide(_point3_) || isCartesianPointInVisibleSide(_point4_)) { 
     532                        return frustum.insideFrustum(_point1_, _point2_, _point3_, _point4_); 
     533                } else { 
     534                        return false; 
     535                } 
     536        } 
     537         
    518538        public boolean realPointInView(double lon, double alt, double lat, int MAXANGLE) { 
    519539                final Vector3d coord = new Vector3d();