Пример #1
0
        public void roamingAuto()
        {
            //var sgworld = new SGWorld66();
            mDynamicTrain = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                fileName, 0.25, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, string.Empty, "Train");//创建对象

            double[] x, y, z, d;
            int      n;

            count = 0;
            //for (int count = 0; count < gRWScene.mProjectList.Count - 1; count++)//暂时以这个list代替
            //{
            n = gRWScene.mMiddleLines.getSubLineByDKCode(gRWScene.mProjectList[0].Mileage_Start_Discription, gRWScene.mProjectList[1].Mileage_Start_Discription, 70, out x, out y, out z, out d);
            if (n > 0)
            {
                for (int i = 0; i < 200; i++)     //CRailwayScene.mMiddleLine.mPointNum 将一个工点上所有点addWaypoint
                {
                    if (d[i] > 180)
                    {
                        d[i] = d[i] - 180;
                    }
                    mDynamicTrain.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(x[i], y[i], z[i], 300, d[i]));
                }
                //曾经加过一些动作或状态..
                mDynamicTrain.CircularRoute = false;
                //Console.WriteLine(count + "," + DateTime.Now.ToString("HH:mm:ss"));//看下运行时的机制
                //}
                sgworld.Navigate.FlyTo(mDynamicTrain);
            }
        }
Пример #2
0
        public void Starting(int hotSpotIndex)
        {
            if (hotSpotIndex < 0 || hotSpotIndex + 1 >= mSceneData.mHotSpotList.Count)
            {
                return;
            }
            double[] mx, my, mz, md;
            if (string.IsNullOrEmpty(mGroupID))
            {
                mGroupID = sgworld.ProjectTree.CreateGroup("Train");
            }
            else
            {
                Console.WriteLine("clear train for restart");
                sgworld.ProjectTree.DeleteItem(mGroupID);
                mGroupID = sgworld.ProjectTree.CreateGroup("Train");
            }
            mDynamicTrain = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                mModelName, 0.25, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mGroupID, "Train");
            mCount = mSceneData.mMiddleLines.getSubLineByDKCode(mSceneData.mHotSpotList[hotSpotIndex].DKCode, mSceneData.mHotSpotList[hotSpotIndex].CenterMileage,
                                                                mSceneData.mHotSpotList[hotSpotIndex + 1].DKCode, mSceneData.mHotSpotList[hotSpotIndex + 1].CenterMileage, 70, out mx, out my, out mz, out md);
            for (int i = 0; i < mCount; i++)
            {
                mDynamicTrain.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(mx[i], my[i], mz[i], 100, md[i]));
            }
            Console.WriteLine("starting new journey from " + hotSpotIndex + "\t" + mSceneData.mHotSpotList[hotSpotIndex].DKCode + mSceneData.mHotSpotList[hotSpotIndex].CenterMileage + " to "
                              + mSceneData.mHotSpotList[hotSpotIndex + 1].DKCode + mSceneData.mHotSpotList[hotSpotIndex + 1].CenterMileage);
            mDynamicTrain.Pause = false;
            sgworld.Navigate.FlyTo(mDynamicTrain);

            //mDynamicTrain.PlayRouteOnStartup = false;
        }
Пример #3
0
        private void createNavTrain()
        {
            var    sgworld  = new SGWorld66();
            string fileName = GlobalVar.gDataPath + @"Common\Models\train.3ds";

            //mTrain = sgworld.Creator.CreateModel(sgworld.Creator.CreatePosition(),fileName,0.25,ModelTypeCode.MT_NORMAL,string.Empty,"Train");
            //mTrain.Position.X = 50;


            mDynamicTrain = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                fileName, 0.25, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, string.Empty, "Train");
            for (int i = 6000; i < 36000; i += 5) //CRailwayScene.mMiddleLine.mPointNum
            {
                mDynamicTrain.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(
                                                        CRailwayScene.mMiddleLine.longitude[i],
                                                        CRailwayScene.mMiddleLine.latitude[i],
                                                        CRailwayScene.mMiddleLine.altitude[i],
                                                        300, CRailwayScene.mMiddleLine.heading[i]));
                //Console.WriteLine(CRailwayScene.mMiddleLine.longitude[i] + "\t" + CRailwayScene.mMiddleLine.latitude[i]);
            }
            mDynamicTrain.PlayRouteOnStartup = false;
            //mDynamicTrain.Pause = true;
            //mDynamicTrain.s
            //mDynamicTrain.
        }
Пример #4
0
        private void timerSyncronize_Tick(object sender, EventArgs e)
        {
            try
            {
                IPosition66          wp     = sgworld.Window.CenterPixelToWorld().Position;
                GMap.NET.PointLatLng LatLng = marker.Position;
                LatLng.Lat      = wp.Y;
                LatLng.Lng      = wp.X;
                marker.Position = LatLng;

                //LatLng = markerTrain.Position;
                //LatLng.Lat = GlobalVar.gScene.mDynamicTrain.Position.Y;
                //LatLng.Lng = GlobalVar.gScene.mDynamicTrain.Position.X;
                //markerTrain.Position = LatLng;
                //if (isFlying)
                //{
                //    flyingTick++;
                //    if (flyingTick % 100 == 0)
                //sgworld.Navigate.FlyTo(GlobalVar.gScene.mDynamicTrain, nextFLyCode());
                //}


                if (trainBack)
                {
                    sgworld.Creator.DeleteObject(mDynamicTrain.ID);
                    mDynamicTrain = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                        fileName, 0.25, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, string.Empty, "Train");//创建对象

                    double[] x, y, z, d;
                    int      n;

                    n = gRWScene.mMiddleLines.getSubLineByDKCode(gRWScene.mProjectList[0].Mileage_Start_Discription, gRWScene.mProjectList[1].Mileage_Start_Discription, 70, out x, out y, out z, out d);
                    if (n > 0)
                    {
                        for (int i = 200; i < 500; i++) //CRailwayScene.mMiddleLine.mPointNum 将一个工点上所有点addWaypoint
                        {
                            if (d[i] > 180)
                            {
                                d[i] = d[i] - 180;
                            }
                            mDynamicTrain.Waypoints.AddWaypoint(sgworld.Creator.CreateRouteWaypoint(x[i], y[i], z[i], 300, d[i]));
                        }
                    }
                    mDynamicTrain.CircularRoute = false;
                    sgworld.Navigate.FlyTo(mDynamicTrain);
                    trainBack = false;
                    //trainFly = true;
                }

                if (trainFly)
                {
                    trainFly = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Train is not ready");
            }
        }
Пример #5
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();
        }
Пример #6
0
        public CTEPresentation(CRailwayScene s, CTEScene tes, PanelProgress2D p2, PanelInfo p3, Timer timer, List <CHotSpot> hp = null)//
        {
            mSceneData      = s;
            mTEScene        = tes;
            mNavigationList = hp;
            panel2D         = p2;
            panelInfo       = p3;
            if (mNavigationList == null || mNavigationList.Count <= 1)
            {
                return;
            }
            mNavIndex = mNavigationList.Count - 1;
            //mNavIndex = Math.Max(0, mNavIndex);
            mNavNextIndex = (mNavIndex + 1) % mNavigationList.Count;

            sgworld = new SGWorld66();

            timerWaitingForNext       = timer;
            timerWaitingForNext.Tick += TimerWaitingForNext_Tick;

            if (string.IsNullOrEmpty(mNavObjGroupID))
            {
                mNavObjGroupID = sgworld.ProjectTree.CreateGroup("TrainGroup");
            }
            else
            {
                sgworld.ProjectTree.DeleteItem(mNavObjGroupID);
                mNavObjGroupID = sgworld.ProjectTree.CreateGroup("TrainGroup");
            }

            mPresentationGroupID = sgworld.ProjectTree.FindItem("Presentation");
            if (string.IsNullOrEmpty(mPresentationGroupID))
            {
                mPresentationGroupID = sgworld.ProjectTree.CreateGroup("Presentation");
            }

            mPresentation = sgworld.Creator.CreatePresentation(mPresentationGroupID, "Navigating");

            mPresentation.PlayAlgorithm = PresentationPlayAlgorithm.PPA_SPLINE;
            mPresentation.PlayMode      = PresentationPlayMode.PPM_AUTOMATIC;
            mPresentation.LoopRoute     = true;

            //mPresentation.CaptionHeight = 50;

            //mWorker = (ITerrainModel66)(sgworld.ProjectTree.GetObject(sgworld.ProjectTree.FindItem("worker")));
            //mDynamicWorker =(ITerrainDynamicObject66)(sgworld.ProjectTree.GetObject(sgworld.ProjectTree.FindItem("dynamicCamera")));
            mDynamicTrain[0] = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                   mModelName[0], 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "TrainObj0");
            mDynamicTrain[1] = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                   mModelName[1], 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "TrainObj1");
            mDynamicTrain[2] = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                   mModelName[1], 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "TrainObj2");
            mDynamicTrain[3] = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                   mModelName[1], 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "TrainObj3");
            mDynamicTrain[4] = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_AIRPLANE, DynamicObjectType.DYNAMIC_3D_MODEL,
                                                                   mModelName[2], 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "TrainObj4");
            //mDynamicTrain.Acceleration =
            mVirtualObj = sgworld.Creator.CreateDynamicObject(0, DynamicMotionStyle.MOTION_MANUAL, DynamicObjectType.DYNAMIC_VIRTUAL,
                                                              "", 1, AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE, mNavObjGroupID, "VirtualObj");

            if (!isTEEventRegistered)
            {
                sgworld.OnObjectAction += Sgworld_OnObjectAction;
                sgworld.OnPresentationFlyToReachedDestination += Sgworld_OnPresentationFlyToReachedDestination;
                isTEEventRegistered = true;
            }
        }