Example #1
0
        /// <summary>
        /// 创建图元
        /// </summary>
        /// <param name="kml">模型的kml</param>
        /// <param name="layer">模型所在的图层</param>
        /// <returns></returns>
        public IMFElement CreateElement(Kml kml, ILayer layer)
        {
            KmlModel3d modelkml = kml.Placemark.Graph as KmlModel3d;

            if (modelkml == null)
            {
                return(null);
            }
            if (modelkml.Position == null)
            {
                return(null);
            }
            if (!File.Exists(modelkml.ModelFilePath))
            {
                return(null);
            }
            int index = -1;

            //图层
            IGlobeGraphicsLayer graphicLayer = layer as IGlobeGraphicsLayer;

            if (graphicLayer == null)
            {
                return(null);
            }

            //实例化图元
            Model3d_ArcGlobe modelElement = null;

            //添加图元
            this.Dosomething((Action) delegate()
            {
                IImport3DFile import3Dfile = null;
                if (!filePathDic.ContainsKey(modelkml.ModelFilePath))
                {
                    import3Dfile = new Import3DFileClass();
                    import3Dfile.CreateFromFile(modelkml.ModelFilePath);
                    filePathDic.Add(modelkml.ModelFilePath, import3Dfile);
                }
                else//模型已创建
                {
                    import3Dfile = filePathDic[modelkml.ModelFilePath];
                }

                modelElement = new Model3d_ArcGlobe(graphicLayer, modelkml, import3Dfile);

                //设置属性
                GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass();
                properties.Rasterize = modelkml.Rasterize;

                graphicLayer.AddElement(modelElement, properties, out index);
                modelElement.Index       = index;
                modelElement.ElementName = kml.Placemark.Name;
            }, true);

            return(modelElement);
        }
Example #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_graphcisLayer">图层</param>
        /// <param name="modelKml">模型kml</param>
        public Model3d_ArcGlobe(IGlobeGraphicsLayer _graphicLayer, KmlModel3d modelKml, IImport3DFile import3Dfile)
        {
            graphicLayer = _graphicLayer;

            this.ElementType = ElementTypeEnum.Model3D;   // 图元类型
            this.Description = modelKml.Description;      // 图元描述

            #region  符号

            IGeometry geometry = import3Dfile.Geometry;
            //将模型转为3D符号
            marker3DSymbol       = new Marker3DSymbolClass();
            marker3DSymbol.Shape = geometry;
            markerSymbol         = marker3DSymbol as IMarkerSymbol;
            markerSymbol.Size    = modelKml.Scale;
            markerSymbol.Angle   = modelKml.Azimuth;


            IRgbColor c = new RgbColorClass();
            c.Transparency     = modelKml.Color.A;
            c.Red              = modelKml.Color.R;
            c.Green            = modelKml.Color.G;
            c.Blue             = modelKml.Color.B;
            markerSymbol.Color = c;

            this.scale = modelKml.Scale;
            this.color = modelKml.Color;

            #endregion

            #region  位置

            IPoint p = new PointClass();
            p.PutCoords(modelKml.Position.Lng, modelKml.Position.Lat);
            p.Z = modelKml.Position.Alt;
            (p as IZAware).ZAware = true;
            #endregion
            lngLat = modelKml.Position;

            base.Geometry = p;                                  //指定位置
            base.Symbol   = markerSymbol;                       //指定符号

            flashTimer          = new Timer();
            flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed);
            flashTimer.Interval = 500;
        }