Ejemplo n.º 1
0
        public static void showPoint(SGWorld66 sgworld, double cx, double cy, double cz, double cdir)
        {
            if (mPresentation == null)
            {
                mPresentationGroupID = sgworld.ProjectTree.FindItem("Presentation");
                if (string.IsNullOrEmpty(mPresentationGroupID))
                {
                    mPresentationGroupID = sgworld.ProjectTree.CreateGroup("Presentation");
                }
                mPresentation = sgworld.Creator.CreatePresentation(mPresentationGroupID, "PointNav");
                sgworld.OnPresentationFlyToReachedDestination += Sgworld_OnPresentationFlyToReachedDestination;
            }
            mPresentation = sgworld.Creator.CreatePresentation(mPresentationGroupID, "Navigating");

            mPresentation.PlayAlgorithm = PresentationPlayAlgorithm.PPA_SPLINE;
            if (CGisDataSettings.AppSpeed <= 2)
            {
                mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_VERYSLOW;
            }
            else if (CGisDataSettings.AppSpeed < 5)
            {
                mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_SLOW;
            }
            else if (CGisDataSettings.AppSpeed < 7)
            {
                mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_NORMAL;
            }
            else if (CGisDataSettings.AppSpeed < 9)
            {
                mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_FAST;
            }
            else
            {
                mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_VERYFAST;
            }
            mPresentation.PlaySpeedFactor = PresentationPlaySpeed.PPS_NORMAL;

            mPresentation.PlayMode  = PresentationPlayMode.PPM_AUTOMATIC;
            mPresentation.LoopRoute = true;


            double[] x   = { 1, -1, 0, 0 };
            double[] y   = { 0, 0, 1, -1 };
            Random   ran = new Random();

            //double[] z = { cz, cz, cz, cz };
            //double[] d = { cdir, cdir, cdir, cdir };
            if (mPointNear[0] == null)
            {
                //* (1 + ran.NextDouble())
                //mPointNav = sgworld.Creator.CreatePosition(x, y, z, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, dir, 0, 0, 350);
                for (int i = 0; i < x.Length; i++)
                {
                    mPointNear[i] = sgworld.Creator.CreatePosition(cx + x[i] * 0.005,
                                                                   cy + y[i] * 0.005, 350 + ran.Next(1, 100), AltitudeTypeCode.ATC_TERRAIN_RELATIVE, -i * 90, -60, 0, 1300);
                }
            }
            else
            {
                for (int i = 0; i < x.Length; i++)
                {
                    mPointNear[i].X        = cx + x[i] * 0.005;
                    mPointNear[i].Y        = cy + y[i] * 0.005;
                    mPointNear[i].Altitude = 350 + ran.Next(1, 100);
                }
            }
            for (int i = mPresentation.Steps.Count - 1; i >= 0; i--)
            {
                mPresentation.DeleteStep(i);
            }

            for (int i = 0; i < mPointNear.Length; i++)
            {
                mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 0, "Starting", mPointNear[i]);
            }
            mPresentation.CreateLocationStep(PresentationStepContinue.PSC_WAIT, 0, "Ended", mPointNear[0]);
            mPresentation.Play(0);
        }
Ejemplo n.º 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);
        }