Exemple #1
0
        // 沿线运动对象
        private void btn_MoveObj_Click(object sender, EventArgs e)
        {
            //创建路线(也可以通过获取)
            GSOGeoPolyline3D polyLine = new GSOGeoPolyline3D();
            GSOPoint3ds      pnts     = new GSOPoint3ds(); //创建节点对象

            //把各节点添加到节点对象上
            pnts.Add(new GSOPoint3d(120.4, 31.3, 0));
            pnts.Add(new GSOPoint3d(120.41, 31.31, 0));
            pnts.Add(new GSOPoint3d(120.42, 31.32, 0));
            pnts.Add(new GSOPoint3d(120.43, 31.30, 0));
            pnts.Add(new GSOPoint3d(120.44, 31.34, 0));
            polyLine.AddPart(pnts);

            GSORoute route = new GSORoute(); //创建路径

            for (int i = 0; i < polyLine[0].Count; i++)
            {
                route.Add(polyLine[0][i]);
            }
            // 设置路径属性
            route.CircleRoute       = true; //路径是否闭合
            route.Speed             = 10;   //沿线运动速度
            route.SpeedAcceleration = 1;    //加速度
            route.RotateSpeed       = 10;   //拐弯速度

            //加载模型
            GSOGeoModel model = new GSOGeoModel();

            model.FilePath = _modelPath;  //3D模型路径

            //创建沿线运动模型要素
            GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute();

            dynamicRoute.ActorGeometry = model; //添加模型到沿线运动模型上

            dynamicRoute.Route = route;         //赋路线
            dynamicRoute.Play();                //播放运动
            dynamicRoute.TimerInterval = 20;    //播放时间间隔

            GSOFeature feature = new GSOFeature();

            feature.Geometry = dynamicRoute;
            GSOFeature polylineFeature = new GSOFeature();

            polylineFeature.Geometry = polyLine;
            _glbControl.Globe.MemoryLayer.AddFeature(feature);
            _glbControl.Globe.MemoryLayer.AddFeature(polylineFeature);
            _glbControl.Globe.FlyToFeature(polylineFeature);
        }
Exemple #2
0
        //沿线运动对象
        private void addRouteObjectMenuItem_Click(object sender, EventArgs e)
        {
            if (globeControl1.Globe.SelectedObject==null)
            {
                MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            GSOFeature lineFeature=globeControl1.Globe.SelectedObject;
            if(lineFeature.Geometry==null || lineFeature.Geometry.Type!=EnumGeometryType.GeoPolyline3D)
            {
                MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "*.3ds|*.3ds|*.gcm|*.gcm|*.gse|*.gse|*.obj|*.obj||";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                GSOGeoModel model=new GSOGeoModel();
                model.FilePath = dlg.FileName;

                GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute();
                dynamicRoute.ActorGeometry = model;

                GSORoute route = new GSORoute();
                GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry;
                for (int i = 0; i < geoline[0].Count; i++)
                {
                    route.Add(geoline[0][i]);
                }
                route.CircleRoute = false;
                route.Speed = 30;
                route.RotateSpeed = 50;
                route.AltitudeMode = geoline.AltitudeMode;
                dynamicRoute.Route = route;

                GSOFeature feature = new GSOFeature();

                dynamicRoute.Play();
                feature.Geometry = dynamicRoute;

                GSOLabel gsoLabel = new GSOLabel();
                gsoLabel.Text = "模型测试";
                feature.Label = gsoLabel;
                globeControl1.Globe.MinModelVisibleSize = 0;

                globeControl1.Globe.MemoryLayer.AddFeature(feature);
                globeControl1.Globe.Refresh();
            }
        }
Exemple #3
0
        private void DynamicCarMenuItem_Click(object sender, EventArgs e)
        {
            GSORoute route = new GSORoute();
            route.Add(116.601, 39.901, 0);
            route.Add(116.602, 39.901, 0);
            route.Add(116.603, 39.901, 0);
            route.Add(116.603, 39.902, 0);
            route.Add(116.603, 39.903, 0);
            route.Add(116.603, 39.904, 0);
            route.Speed = 50;
            route.RotateSpeed = 50;
            route.AltitudeMode = EnumAltitudeMode.ClampToGround;

            GSOGeoModel geoModel = new GSOGeoModel();
            geoModel.FilePath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/model/tank.3ds";

            GSOGeoDynamicRoute geoDynamicRoute = new GSOGeoDynamicRoute();
            geoDynamicRoute.TimerInterval = 20;
            geoDynamicRoute.Route = route;
            geoDynamicRoute.ActorGeometry = geoModel;
            geoDynamicRoute.Play();

            GSOFeature feature = new GSOFeature();
            feature.Geometry = geoDynamicRoute;

            GSOLabel gsoLabel = new GSOLabel();
            gsoLabel.Text = "中-59";

            feature.Label = gsoLabel;

            globeControl1.Globe.MemoryLayer.AddFeature(feature);
            GSOCameraState cameraState = new GSOCameraState();
            cameraState.Longitude = 116.601;
            cameraState.Latitude = 39.901;
            cameraState.Altitude = 900;
            cameraState.Tilt = 0;
            cameraState.Heading = 0;
            globeControl1.Globe.FlyToCameraState(cameraState);
        }
Exemple #4
0
        private void MissileMenuItem_Click(object sender, EventArgs e)
        {
            GSORoute route = new GSORoute();

            route.Add(116.601, 39.902, 100);
            route.Add(116.602, 39.902, 150);
            route.Add(116.603, 39.902, 200);
            route.Add(116.603, 39.902, 200);
            route.Add(116.603, 39.902, 200);
            route.Add(116.603, 39.902, 200);
            route.Add(116.604, 39.902, 250);
            route.Add(116.605, 39.902, 300);
            route.Add(116.606, 39.902, 250);
            route.Add(116.607, 39.902, 200);
            route.Add(116.608, 39.902, 150);
            route.Add(116.609, 39.902, 100);
            route.Speed = 500;
            route.RotateSpeed = 200;
            route.AltitudeMode = EnumAltitudeMode.Absolute;
            route.CircleRoute=false;

            GSOGeoModel geoModel = new GSOGeoModel();
            geoModel.FilePath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/model/aim9.3ds";
            geoModel.SetScale(30, 30, 30);

            GSOGeoDynamicRoute geoDynamicRoute = new GSOGeoDynamicRoute();
            geoDynamicRoute.TimerInterval = 20;
            geoDynamicRoute.Route = route;
            geoDynamicRoute.ActorGeometry = geoModel;
            geoDynamicRoute.Play();

            GSOFeature feature = new GSOFeature();
            feature.Geometry = geoDynamicRoute;
            GSOLabel gsoLabel = new GSOLabel();
            gsoLabel.Text = "爱国者";
            feature.Label = gsoLabel;

            globeControl1.Globe.MemoryLayer.AddFeature(feature);

            GSOCameraState cameraState = new GSOCameraState();
            cameraState.Longitude = 116.605;
            cameraState.Latitude = 39.902;
            cameraState.Altitude = 100;
            cameraState.Tilt = 85;
            cameraState.Heading = 0;
            globeControl1.Globe.FlyToCameraState(cameraState);
        }
Exemple #5
0
        private void CopterMenuItem_Click(object sender, EventArgs e)
        {
            GSORoute route = new GSORoute();
            route.Add(116.601, 39.901, 1000);
            route.Add(116.603, 39.901, 1000);
            route.Add(116.605, 39.901, 1000);
            route.Add(116.605, 39.901, 1000);
            route.Add(116.605, 39.901, 1000);
            route.Add(116.605, 39.901, 1000);
            route.Add(116.605, 39.903, 1000);
            route.Add(116.605, 39.905, 1000);
            route.Add(116.605, 39.907, 1000);
            route.Speed = 200;
            route.RotateSpeed = 50;
            route.AltitudeMode = EnumAltitudeMode.Absolute;
            route.CircleRoute = true;

            GSOGeoModel geoModel = new GSOGeoModel();
            geoModel.FilePath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/model/客机.3ds";
            geoModel.RotateZ = -90;
            geoModel.SetScale(0.1, 0.1, 0.1);
            GSOGeoDynamicRoute geoDynamicRoute = new GSOGeoDynamicRoute();
            geoDynamicRoute.TimerInterval = 20;
            geoDynamicRoute.Route = route;
            geoDynamicRoute.ActorGeometry = geoModel;
            geoDynamicRoute.Play();

            GSOFeature feature = new GSOFeature();
            feature.Geometry = geoDynamicRoute;
            GSOLabel gsoLabel = new GSOLabel();
            gsoLabel.Text = "国航A9";
            feature.Label = gsoLabel;

            globeControl1.Globe.MemoryLayer.AddFeature(feature);

            GSOCameraState cameraState = new GSOCameraState();
            cameraState.Longitude = 116.601;
            cameraState.Latitude = 39.901;
            cameraState.Altitude = 2500;
            cameraState.Tilt = 0;
            cameraState.Heading = 0;
            globeControl1.Globe.FlyToCameraState(cameraState);
        }