加载粗制三维模型(ExtrudedPolygon)

/** ** @方法名称: init3DModel ; * @方法描述: 导入简易三维模型 ; * @参数 :@param filePath :shp文件路径 * @返回类型: void ; * @创建人:刘硕; * @创建时间:2015年2月3日 下午6:10:22; * @throws */private void init3DModel(String filePath){Shapefile shapefile = new Shapefile(filePath);RenderableLayer layer = new RenderableLayer();layer.setName("简易三维模型");layer.setPickEnabled(true);try{while (shapefile.hasNext()){ShapefileRecord record = shapefile.nextRecord();layer.addRenderable(makeShape(record));}wwPanel.getWorldWindowGLCanvas().getModel().getLayers().add(layer);}finally{shapefile.close();}}/** ** @方法名称: makeShape ; * @方法描述: 根据shp文件每条记录创建模型 ; * @参数 :@param record * @参数 :@return* @返回类型: ExtrudedPolygon ; * @创建人:刘硕; * @创建时间:2015年2月3日 下午6:11:08; * @throws */private ExtrudedPolygon makeShape(ShapefileRecord record){String IMAGE_PATH = "F:\\data\\wwj\\build123sm.jpg";Double height = null;String[] heightKeys = new String[]{ "height", "Height", "HEIGHT" };for (String key : heightKeys){Object o = record.getAttributes().getValue(key);if (o != null){height = Double.parseDouble(o.toString());}}// 顶部属性ShapeAttributes capAttrs = new BasicShapeAttributes();capAttrs.setOutlineMaterial(Material.GRAY);capAttrs.setInteriorMaterial(Material.CYAN);// 边属性ShapeAttributes sideAttributes = new BasicShapeAttributes();sideAttributes.setInteriorMaterial(Material.LIGHT_GRAY);sideAttributes.setOutlineMaterial(Material.DARK_GRAY);sideAttributes.setImageSource(IMAGE_PATH);// 创建拉伸多边形VecBuffer vb = record.getPointBuffer(0);Polygon pgonAirspace = new Polygon(vb.getLocations()); // 根据点串构建多边形//纹理ArrayList<String> textures = new ArrayList<String>();for (int i = 0; i < pgonAirspace.getLocations().size(); i++){textures.add(IMAGE_PATH);}ExtrudedPolygon polygon = new ExtrudedPolygon(pgonAirspace.getLocations(), height, textures);polygon.setCapAttributes(capAttrs);polygon.setSideAttributes(sideAttributes);polygon.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);return polygon;}效果如下图所示:

,只做第一个我,不做第二个谁。

加载粗制三维模型(ExtrudedPolygon)

相关文章:

你感兴趣的文章:

标签云: