World Wind Java Development 12-load coarse three-dimensional model (Extrudedpolygon)

Source: Internet
Author: User

WW can generate false three-dimensional models in batches based on Dlg diagrams, which is very useful for building models with similar characteristics to the community. Here's how to implement the load of a fake three-dimensional model step-by-step:

1, SHP file production first digitized several buildings under ArcMap, and the new height field stores the height of the building.

2. Code implementation
/** * @ Method Name: Init3dmodel; * @ Method Description: Import simple three-dimensional model; * @ parameter: @param filepath:shp file path * @ return type: void; * @ Creator: Liu Shuo; * @ Created: February 3, 2015 PM 6:10:22; * @throws */private void Init3dmodel (String filePath) {shapefile shapefile = new Shapefile (fil Epath); Renderablelayer layer = new Renderablelayer (), Layer.setname ("simple three-dimensional model"); layer.setpickenabled (true); Try{while ( Shapefile.hasnext ()) {Shapefilerecord record = Shapefile.nextrecord (); Layer.addrenderable (Makeshape (Record));} Wwpanel.getworldwindowglcanvas (). Getmodel (). Getlayers (). Add (layer);} Finally{shapefile.close ();}} /** * @ Method Name: makeshape; * @ Method Description: Create a model from each record of shp file; * @ parameter: @param record * @ parameter: @return * @ return type: extrudedpolygon; * @ Creator: Liu Shuo; * @ creation Time: February 3, 2015 PM 6:11:08; * @throws */private Extrudedpolygon makeshape (Shapefilerecord record) {String image_path = "F : \\data\\wwj\\build123sm.jpg ";D ouble height = null; string[] Heightkeys = new string[]{"height", "height", "height"};for (String key:heightkeys) {Object o = record.getattr Ibutes (). GetValue (key);F (o! = null) {height = double.parsedouble (o.tostring ());}} Top properties Shapeattributes capattrs = new Basicshapeattributes (); capattrs.setoutlinematerial (Material.gray); Capattrs.setinteriormaterial (Material.cyan);//Edge property shapeattributes sideattributes = new Basicshapeattributes (); Sideattributes.setinteriormaterial (Material.light_gray); sideattributes.setoutlinematerial (Material.DARK_GRAY); Sideattributes.setimagesource (image_path);//Create stretched polygon Vecbuffer vb = record.getpointbuffer (0); Polygon pgonairspace = new Polygon (Vb.getlocations ()); Build polygon//texture arraylist<string> textures = new arraylist<string> () based on Dot 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);p olygon.setsideattributes (sideattributes);p Olygon.setaltitudemode ( Worldwind.clamp_to_ground); return polygon;}

The effect is as follows:
3, the problem found that the model can not load the texture Ah, check a few times do not know where the problem, I hope to understand the friends to see the message to the guide under Ah, greatly appreciated.

World Wind Java Development 12-load coarse three-dimensional model (Extrudedpolygon)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.