首页 / 浏览问题 / 组件GIS / 问题详情
sun类初始化,代码添加Sun类对象之后没有效果
35EXP 2018年07月27日


namespace Import_TO_3DMode
{
    public partial class MainForm : Form
    {
        //显示三维场景控件
        public SceneControl m_sceneControl;
        //Public/private区别??
        private Workspace m_workspace;
        private Library m_library;
        private GeoModel geoModel = new GeoModel();
        private GeoModel animationModel = null;
        private NodeAnimation ani = null;
        private Layer3DKML layerKML = null;
        private GeoLine3D geoLine = null;
        public Sun sun;
        public MainForm()
        {
            InitializeComponent();
            //System.Timers.Timer t = new System.Timers.Timer(1000);//实例化Timer类,设置间隔时间为10000毫秒; 
            //t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件; 
            //t.AutoReset = false;//设置是执行一次(false)还是一直执行(true); 
            //t.Start();
            //t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
            
            //sun.IsVisible = true;//(太阳可见可产生阴影)
           // sun.SunDateTime = new DateTime(2018, 7, 26, 21, 50, 30);
           // sun.IsTimeSliderVisible = true;
           
        }
      
    
       
        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
        //在主窗体加载时,初始化Library类型,来完成功能的展现
        private void MainForm_Load(object sender, EventArgs e)
        {
            
            
            //初始化
            this.m_workspace = new SuperMap.Data.Workspace(this.components);
            m_sceneControl = new SuperMap.UI.SceneControl();
            //控件随父级调整大小
            m_sceneControl.Dock = DockStyle.Fill;
            panel1.Dock = DockStyle.Fill;
            //m_sceneControl放置在panel1上
            panel1.Controls.Add(m_sceneControl);
            m_library = new Library(m_workspace, m_sceneControl);
            geoModel.Position = new Point3D(116.381155556, 39.989522222, 0);
            geoModel.FromFile(@"F:\B16_GIS_1Class\test Model\test3\Box001.SGM");
            //将模型添加到KML图层中
            Scene scene = m_sceneControl.Scene;
            //具体步骤:在超图桌面软件新建一个KML图层文件(test7),然后在KML图层添加三维模型。
            Layer3D layer = scene.Layers["test8"];
            layerKML = layer as Layer3DKML;
            //问题3:三维要素作用:Feature3D是三维要素类,只对KML图层有效。您要在KML图层中添加模型geoModel,就必须用Feature3D。
            Feature3D feature = layerKML.Features.Add(geoModel);
            //设置添加到KML图层中的模型的节点动画信息
            animationModel = feature.Geometry as GeoModel;
           //windows的timer时间间隔偏差较大
              timer1.Interval =1000;
              timer1.Enabled = true;
            
             timer2.Interval = 15000;
             timer2.Enabled = true;
            //timer2.Interval = 2000;
            //timer2.Enabled = true;
            
              //timer1.Stop();超图软件可设置 
             //(太阳可见可产生阴影)
            sun.IsVisible = true;
            sun.SunDateTime = new DateTime(2018, 7, 26, 21, 50, 30);
            sun.IsTimeSliderVisible = true;
             
        }

1个回答

您好!这个功能我还没做过,我这边实现了再给您回复哈。
3,352EXP 2018年07月27日
好的,谢谢
您好!您要先获取场景中的Sun,用sun = sceneControl.Scene.Sun;
...