Exemple #1
0
        private void CreateDynamicFly(List <IRouteWaypoint66> _lr, List <double> _lineArray)
        {
            string tAppRoot   = Path.GetDirectoryName(Application.ExecutablePath);
            string _modelFile = Path.Combine(tAppRoot, @"XPL\111.xpl2");
            var    _routeLine = sgworld.Creator.CreatePolylineFromArray(_lineArray.ToArray(), -1000000, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, flyGroupID, "实际航线");

            _route = sgworld.Creator.CreateDynamicObject(_lr.ToArray(), DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_3D_MODEL, _modelFile, 0.05, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, flyGroupID, "模拟飞行");
            _route.CircularRoute     = false;
            _route.TurnSpeed         = 0;
            _route.Acceleration      = 0;
            _route.Position.Distance = 5;
            _route.RestartRoute();
            sgworld.Navigate.FlyTo(_route);
            //fpCurrent.ShowPopup();
        }
Exemple #2
0
        public bool startNextPresentation()
        {
            bool fromCurrent = true;

            if (mNavigationList == null || mNavigationList.Count == 0)
            {
                return(false);
            }

            readyForNext = false;

            // 屏幕中心坐标
            IPosition66 cp = sgworld.Window.CenterPixelToWorld().Position;
            // 视点坐标
            IPosition66 viewp = sgworld.Navigate.GetPosition(AltitudeTypeCode.ATC_TERRAIN_RELATIVE);

            //起点与目标点距离
            double len1 = mNavigationList[mNavIndex].getUTMDistance(cp.X, cp.Y) + viewp.Altitude;

            //如果漫游起点距离屏幕中心过远,从当前点漫游到起点
            double fromX, fromY, fromZ;

            //if (mRan.Next(1,20) == 10)
            //{
            //    fromX = 118.6;
            //    fromY = 36.6;
            //    fromZ = 400000;
            //    fromCurrent = false;

            //}
            //else
            if (len1 > 5000)
            {
                fromX       = cp.X;
                fromY       = cp.Y;
                fromZ       = viewp.Altitude;
                fromCurrent = false;
            }
            else  //否则从极点到下一点
            {
                fromX = mNavigationList[mNavIndex].Longitude;
                fromY = mNavigationList[mNavIndex].Latitude;
                fromZ = mNavigationList[mNavIndex].Altitude;
            }

            double length = mNavigationList[mNavNextIndex].getUTMDistance(fromX, fromY);

#if DEBUG
            Console.WriteLine(mNavNextIndex + " 目的地 " + mNavigationList[mNavNextIndex].ToString());
#endif
            if (length < 50)
            {
                ReachOnePlace();
                return(true);
            }

            mTopSpeed = Math.Max(0, Math.Min(Math.Pow(2, CGisDataSettings.AppSpeed) * 20, 350));
            double speed = Math.Min(length / 3.5, mTopSpeed);

            clearTrain();

            isOnOneWay   = true;
            mVirtualOnly = false;

            if (!fromCurrent || length > 30000)
            {
                double x, y;

                x = (fromX + mNavigationList[mNavNextIndex].Longitude) / 2;
                y = (fromY + mNavigationList[mNavNextIndex].Latitude) / 2;
                for (int i = mPresentation.Steps.Count - 1; i >= 0; i--)
                {
                    mPresentation.DeleteStep(i);
                }

                mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 1, "Starting",
                                                 sgworld.Creator.CreatePosition(fromX, fromY, 0, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, -89, 0, Math.Max(350, fromZ)));

                // 如果距离过长,先到世界中心,再到当前工点
                mPresentation.CreateCaptionStep(PresentationStepContinue.PSC_WAIT, 0, "Txt", "开始漫游", 3);
                if (length > 60000)
                {
                    mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 1, "Ending",
                                                     sgworld.Creator.CreatePosition(118.6, 36.6, 0, AltitudeTypeCode.ATC_TERRAIN_RELATIVE,
                                                                                    341, -90.0, 0, 445000));
                }
                else
                {
                    mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 1, "Ending",
                                                     sgworld.Creator.CreatePosition(x, y, 0, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, -89, 0, Math.Max(length, 5000)));
                }
                mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 1, "Ended",
                                                 sgworld.Creator.CreatePosition(mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude, 350, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 0, -89, 0, 0));

                updatePresentationSpeed(mPresentation);

                mPresentation.Play(0);
                //mVirtualObj.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(mPlaceList[nextIndex].Longitude, mPlaceList[nextIndex].Latitude, mPlaceList[nextIndex].Altitude + 150));

                return(true);
            }
            //isPresentation = true;

            //sgworld.OnObjectAction += Sgworld_OnObjectAction;

            mStepm   = length < 250 ? length / 5 : speed;
            mNavPath = new CSubPath(CRailwayLineList.gRealConnection, mNavigationList[mNavIndex].DKCode, mNavigationList[mNavIndex].Mileage,
                                    mNavigationList[mNavNextIndex].DKCode, mNavigationList[mNavNextIndex].Mileage, 10);

            if (!mNavPath.hasPath)
            {
                // 如果没有路径,直接飞过去
                double midx, midy, midz;
                midx = (fromX + mNavigationList[mNavNextIndex].Longitude) / 2;
                midy = (fromY + mNavigationList[mNavNextIndex].Latitude) / 2;
                midz = (fromZ + mNavigationList[mNavNextIndex].Altitude) / 2;
                mVirtualWayPointCount = 3;
                mVirtualObj.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(fromX, fromY, fromZ + 150, speed));
                mVirtualObj.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(midx, midy, midz + 150, speed));
                mVirtualObj.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude, mNavigationList[mNavNextIndex].Altitude + 150, speed));
#if DEBUG
                ModelInfo.Helper.LogHelper.WriteLog(mNavIndex + "\t" + midx + "\t" + midy + "\t" + midz);
#endif
                mVirtualOnly = true;
                mVirtualObj.CircularRoute = false;
                mVirtualObj.Pause         = false;
                mVirtualObj.RestartRoute();
                sgworld.Navigate.FlyTo(mVirtualObj, ActionCode.AC_FOLLOWABOVE);
                // ReachOnePlace();
                return(true);
            }

            panelInfo.Visible = true;
            prepareTrain(mNavPath, 0);
//            double[][] mm,mx, my, mz, md;
//            mx = new double[5][];
//            my = new double[5][];
//            mz = new double[5][];
//            md = new double[5][];
//            mm = new double[5][];
//            double[] ms = { 0, 37, 86, 135, 172 };
//            //mx[0] = mNavPath.mx;
//            //my[0] = mNavPath.my;
//            //mz[0] = mNavPath.mz;
//            //md[0] = mNavPath.md;
//            mTrainWayPointTotal = mTrainWayPointCount = mNavPath.mPointCount;
//            mDistoNext = mNavPath.mLength;
//            for (int i = 0; i< 5; i++)
//            {
//                ModelInfo.Helper.CSubLine.getSubLineByMileage(-ms[i], mNavPath.mLength-ms[i], mStepm, mNavPath.mm, mNavPath.mx, mNavPath.my, mNavPath.mz, mNavPath.md,
//                    out mm[i], out mx[i], out my[i], out mz[i], out md[i], true);

//            }

//            //mDynamicTrain.Acceleration = 1;
//            double localspeed;
//            for (int j = 0; j < 5; j++)
//            {
//                for (int i = 0; i < mTrainWayPointCount; i++)
//                {
//                    // 逐渐加速,减速
//                    localspeed = Math.Min(5 + (mTrainWayPointCount - Math.Abs(mTrainWayPointCount - i / 2)) * 10, speed);
//#if DEBUG
//                    //Console.WriteLine(curIndex + "\t" + mx[i] + "\t" + my[i] + "\t" + mz[i] + "\t" + md[i]);
//                    //ModelInfo.Helper.LogHelper.WriteLog(curIndex + "\t" + mx[i] + "\t" + my[i] + "\t" + mz[i] + "\t" + md[i]);
//                    mDynamicTrain[j].Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(mx[j][i], my[j][i], mz[j][i], speed, md[j][i]));
//#else
//                mDynamicTrain.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(mx[j][i], my[j][i], mz[j][i], localspeed, md[j][i]));
//#endif
//                }

//                mDynamicTrain[j].CircularRoute = false;
//                mDynamicTrain[j].Pause = false;
//                mDynamicTrain[j].RestartRoute();
//            }
//            if (mTrainWayPointTotal < 15)
//            {
//                sgworld.Navigate.FlyTo(mDynamicTrain[0], ActionCode.AC_FOLLOWBEHINDANDABOVE);
//            }
//            else
//                sgworld.Navigate.FlyTo(mDynamicTrain[0], ActionCode.AC_FOLLOWCOCKPIT);


            return(true);
        }
Exemple #3
0
 private void bbiRouteRestart_ItemClick(object sender, ItemClickEventArgs e)
 {
     _route.RestartRoute();
 }