首页 > 代码库 > [原][osgearth]earth文件加载道路一初步看见模型道路

[原][osgearth]earth文件加载道路一初步看见模型道路

时间是2017年2月5日17:16:32

由于OE2.9还没有发布,但是我又急于使用OE的道路。

所以,我先编译了正在github上调试中的OE2.9

github网址是:https://github.com/gwaldron/osgearth

 

但是由于,它是调试中的版本,很多例子还不能跑。

不过,经过一番摸索,我还是调通了一个使用model建立道路的earth

<map>
    <options>
    <!--添加缓存机制-->
        <cache path="../cache" type="filesystem" />
        <terrain driver="rex">
            <lods>
                <lod lod="13" priority_offset="7"/>
                <lod lod="16" priority_offset="3"/>
            </lods>
        </terrain>
    </options>
    
    <image name="readymap_imagery" driver="tms" opacity="0.9" enabled="true">
        <url>http://readymap.org/readymap/tiles/1.0.0/7/</url>
    </image>
    
    <elevation name="readymap_elevation" driver="tms" enabled="true">
        <url>http://readymap.org/readymap/tiles/1.0.0/116/</url>
    </elevation>  
            
       
    <!--测试地图-->
    <image driver="debug"/>     
    
    <!--平整路-->
    <flattened_elevation name="road flattener" min_level="12" max_level="16">
        <cache_policy usage="none"/>
        <base_layer>readymap_elevation</base_layer>
        <features name="roads" driver="ogr">
                    <!--url>H:/data/fhwa/nhpn2005_08/NHPNLine-mercator.shp</url-->
            <url>../data/flatten_mt_rainier.shp</url>
            <build_spatial_index>true</build_spatial_index>
        </features>
        <line_width>50m</line_width>
        <buffer_width>50m</buffer_width>
    </flattened_elevation>
    
    <!--线框模型-->
    <model name="boundaries" driver="feature_geom">
        <features name="world" driver="ogr">
            <url>../data/flatten_mt_rainier.shp</url>
        </features>        
        <styles>
            <style type="text/css">
                states {
                   stroke:            #ffff00;
                   render-depth-test: false;
                   render-clip-plane: 0;
                   render-order:      1;
                }                    
            </style>
        </styles>        
    </model>
 
    <!--贴图路面
    <road_surface min_level="13">
        <cache_policy usage="none"/>
        <features name="roads" driver="ogr">
            <url>../data/flatten_mt_rainier.shp</url>
            <build_spatial_index>true</build_spatial_index>
        </features>
        <style type="text/css">
            default {
               stroke: #ffffff;
               stroke-width: 25m;
               stroke-image: "../data/road.png";
            }                    
        </style>
        <outer_width>100</outer_width>
    </road_surface>
    -->
    
    <model name="points" driver="feature_geom">
        <features name="points" driver="ogr">
            <url>../data/flatten_mt_rainier.shp</url>
            <build_spatial_index>true</build_spatial_index>
        </features>
                
        <styles>
            <style type="text/css">
                points {
                   model:               "../data/red_flag.osg.10.scale";
                   altitude-clamping:   terrain;
                }                                            
            </style>
        </styles>   
        
    </model>
    
    <!--路模型<layout tile_size="2000">
            <level class="default" max_range="10000"/>
        </layout>-->
    <model name="roadssss" driver="feature_geom">
        <features name="roadssss" driver="ogr">
            <url>../data/flatten_mt_rainier.shp</url>
            <build_spatial_index>true</build_spatial_index>
        </features>
        <styles>
            <style type="text/css">
                default {
                   stroke: #ff0000;
                   stroke-width: 25m;
                   stroke-tessellation-size: 50m;
                   stroke-image: "../data/road.png";
                   altitude-clamping: terrain;
                   altitude-resolution: 0.0001;
                   altitude-binding: vertex;
                   render-order: 1;
                   render-transparent: true;
                   render-decal: true;
                   altitude-offset: 0.05;
                }                    
            </style>
        </styles>
    </model>
    

    
    <!--线框模型
    <model driver="feature_geom" min_level="13">
    <cache_policy usage="none"/>
    <features name="roads" driver="ogr">
      <url>../data/flatten_mt_rainier.shp</url>
      <build_spatial_index>true</build_spatial_index>
    </features>
    <layout tile_size="2000">
      <level class="default" max_range="10000"/>
    </layout>
    <styles>
      <style type="text/css">
        default {
        stroke: #ffffff;
        stroke-width: 25m;
        stroke-tessellation-size: 50m;
        stroke-image: "../data/road.png";
        altitude-clamping: terrain;
        altitude-resolution: 0.00001;
        altitude-binding: vertex;
        render-order: 1;
        render-transparent: true;
        render-decal: true;
        altitude-offset: 0.05;
        }
      </style>
    </styles>
  </model>
  -->
    
  
    
    
    <bumpmap>
        <image>../data/rock_hard.jpg</image>
        <octaves>8</octaves>
        <intensity>8.2</intensity>
    </bumpmap>     
    
    <xi:include href="viewpoints.xml"/>

  <libraries>osgearthsplat</libraries>
</map>

 

 

这个例子包含了:

1.压路机,就是把地形给压平了

2.模型线框,我用来标识shp文件所在位置的

3.添加4个小旗子模型,也是用来表示shp中的点的

4.重点就是这“道路”模型,我先解决了有的问题,之后我再把他变成真正可行的道路

PS:我之后会使用road_surface来调试,这个出来就差不多了

[原][osgearth]earth文件加载道路一初步看见模型道路