Ejemplo n.º 1
0
        /// <summary>
        /// 创建模型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddModel_Click(object sender, EventArgs e)
        {
            GSOGeoModel model = new GSOGeoModel(); //创建模型
            GSOPoint3d  pt    = new GSOPoint3d();  //创建点

            pt.X = 116.6;
            pt.Y = 39.9;
            pt.Z = 0;

            GSOModelPointStyle3D style = new GSOModelPointStyle3D();  //创建模型的风格

            model.Style = style;

            //模型可以是3ds、obj、gse、gsez格式的三维模型
            //模型所在路径,用户可根据实际情况进行设置
            string filepath = Application.StartupPath + "\\Model\\坦克.3ds";

            //设置模型
            model.FilePath = filepath;
            model.Position = pt;

            model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上

            GSOFeature f = new GSOFeature();                     //创建几何要素

            f.Geometry    = model;
            f.Name        = "模型 01";
            f.Description = "模型 01";  //设置feature description的值,这个值将在tooltip上显示

            //把几何要素添加到内存图层中
            globeControl1.Globe.MemoryLayer.AddFeature(f);

            //飞行到模型所在的位置
            globeControl1.Globe.FlyToFeature(f);
        }
        private void btn_Model_Click(object sender, EventArgs e)
        {
            GSOGeoModel model = new GSOGeoModel(); //创建模型
            GSOPoint3d  pt    = new GSOPoint3d();  //创建点

            pt.X = 120;
            pt.Y = 30;
            pt.Z = 0;

            GSOModelPointStyle3D style = new GSOModelPointStyle3D();  //创建模型的风格

            model.Style = style;

            //设置模型
            model.FilePath = _modelPath;
            model.Position = pt;

            model.AltitudeMode = EnumAltitudeMode.ClampToGround; //把几何体放到地面上

            GSOFeature f = new GSOFeature();                     //创建几何要素

            f.Geometry    = model;
            f.Name        = "模型 01";
            f.Description = "模型 01";  //设置feature description的值,这个值将在tooltip上显示

            //把几何要素添加到内存图层中
            GSOFeature newFeature = _glbControl.Globe.MemoryLayer.AddFeature(f);

            _glbControl.Globe.FlyToFeature(f); //飞行到模型所在的位置
            _glbControl.Refresh();             //刷新场景
        }