public ScriptPlayer(String scriptFile, IGlobe globe) { System.Diagnostics.Debug.Assert(globe != null); System.Diagnostics.Debug.Assert(scriptFile != null); System.Diagnostics.Debug.Assert(!scriptFile.Equals(String.Empty)); System.IO.FileInfo fi = new System.IO.FileInfo(scriptFile); if (!fi.Exists) throw new TimelineException("Specified script does not exist."); Script script = new Script(fi); System.Collections.IList atElements = script.AtElements; if (atElements == null || atElements.Count < 1) throw new TimelineException("Script file " + scriptFile + " has no At elements."); this.globe = globe; this.timesToRepeat = script.RepeatCount; this.timelines = new Timelines(atElements); this.timer = new System.Timers.Timer(15); this.timer.AutoReset = true; this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timerTickHandler); this.createPlayers(); }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { //Instantiate the hook helper if (null == m_globeHookHelper) { m_globeHookHelper = new GlobeHookHelperClass(); } //set the hook m_globeHookHelper.Hook = hook; //get the relevant members IGlobe globe = m_globeHookHelper.Globe; m_scene = globe as IScene; m_globeDsp = m_globeHookHelper.GlobeDisplay; m_globeViewUtil = m_globeHookHelper.Camera as IGlobeViewUtil; //connect to the ZipCodes featureclass string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); path = System.IO.Path.Combine(path, @"ArcGIS\data\USZipCodeData"); if (!Directory.Exists(path)) { throw new Exception(string.Format("Fix code to point to your sample data: {0} was not found", path)); } IWorkspaceFactory wf = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory; IWorkspace ws = wf.OpenFromFile(path, 0); IFeatureWorkspace fw = ws as IFeatureWorkspace; m_featureClass = fw.OpenFeatureClass("US_ZipCodes"); }
public Task InitActorTransitionAsync(IGlobe globe, ISector sector, IActor actor, SectorTransition transition) { if (globe is null) { throw new ArgumentNullException(nameof(globe)); } if (sector is null) { throw new ArgumentNullException(nameof(sector)); } if (actor is null) { throw new ArgumentNullException(nameof(actor)); } if (transition is null) { throw new ArgumentNullException(nameof(transition)); } return(ProcessInternalAsync(globe, sector, actor, transition)); }
private static async Task RunGlobeIteration(IGlobe globe) { for (var i = 0; i < GlobeMetrics.OneIterationLength; i++) { await globe.UpdateAsync().ConfigureAwait(false); } }
private static bool PlayerPersonIsNotInTransitionPool(IGlobe globe, IPerson person) { var globeNodeWithPerson = GetSectorNode(globe, person); var isPlayerPersonInGlobe = globeNodeWithPerson != null; return(isPlayerPersonInGlobe); }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { //Instantiate the hook helper if (null == m_globeHookHelper) { m_globeHookHelper = new GlobeHookHelperClass(); } //set the hook m_globeHookHelper.Hook = hook; //get the relevant members IGlobe globe = m_globeHookHelper.Globe; m_scene = globe as IScene; m_globeDsp = m_globeHookHelper.GlobeDisplay; m_globeViewUtil = m_globeHookHelper.Camera as IGlobeViewUtil; //connect to the ZipCodes featureclass //get the ArcGIS path from the registry String versionNumber = RuntimeManager.ActiveRuntime.Version; RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcObjectsSdk" + versionNumber); string path = Convert.ToString(key.GetValue("InstallDir")); path = System.IO.Path.Combine(path, @"Samples\data\USZipCodeData"); IWorkspaceFactory wf = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory; IWorkspace ws = wf.OpenFromFile(path, 0); IFeatureWorkspace fw = ws as IFeatureWorkspace; m_featureClass = fw.OpenFeatureClass("US_ZipCodes"); }
public static double ReturnProjectDistance(IGlobe pGlobe, double dFromX, double dFromY, double dFromZ, double dToX, double dToY, double dToZ) { IPoint pPnt1 = new Point(); IPoint pPnt2 = new Point(); pPnt1.X = dFromX; pPnt1.Y = dFromY; MakeZAware(pPnt1); pPnt1.Z = dFromZ * 1000; pPnt1.SpatialReference = pGlobe.GlobeDisplay.Scene.SpatialReference; if (pPnt1.SpatialReference is IGeographicCoordinateSystem) { pPnt1 = ProjectGeometry(pPnt1) as IPoint; } pPnt2.X = dToX; pPnt2.Y = dToY; MakeZAware(pPnt2); pPnt2.Z = dToZ * 1000; pPnt2.SpatialReference = pGlobe.GlobeDisplay.Scene.SpatialReference; if (pPnt2.SpatialReference is IGeographicCoordinateSystem) { pPnt2 = ProjectGeometry(pPnt2) as IPoint; } IProximityOperator3D pProximityOperator3D = pPnt1 as IProximityOperator3D; return(pProximityOperator3D.ReturnDistance3D(pPnt2)); }
private void Form1_Load(object sender, System.EventArgs e) { //check and load if the animation file is present... m_AnimFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); m_AnimFilePath = Path.Combine(m_AnimFilePath, @"ArcGIS\data\Globe\AnimationSample.aga"); var filePath = new DirectoryInfo(m_AnimFilePath); System.Diagnostics.Debug.WriteLine(string.Format("File path for data root: {0} [{1}]", filePath.FullName, Directory.GetCurrentDirectory())); if (!File.Exists(m_AnimFilePath)) { throw new Exception(string.Format("Fix code to point to your sample data: {0} [{1}] was not found", filePath.FullName, Directory.GetCurrentDirectory())); } if (System.IO.File.Exists(m_AnimFilePath)) { //Load the sample animation file into the animation file into the doc... IGlobe globe = axGlobeControl1.Globe; IBasicScene basicScene = (IBasicScene)globe; basicScene.LoadAnimation(m_AnimFilePath); } else { //Disable Animation Player controls... OptDuration.Enabled = false; OptIteration.Enabled = false; txtDuration.Enabled = false; TxtFrequency.Enabled = false; TxtFrequency.Enabled = false; CmdPlay.Enabled = false; } Icon = null; }
public Task <IEnumerable <IPerson> > CreateStartPersonsAsync(IGlobe globe) { var person = CreateStartPerson(PERSON_SCHEME_SID, _personFactory, Fractions.MainPersonFraction); _player.BindPerson(globe, person); return(Task.FromResult(new[] { person }.AsEnumerable())); }
/// <summary> /// 内插中间贞函数,只需给出第一帧和最后一帧的状态信息,即可内插出中间帧状态 /// </summary> /// <param name="pGlobe"></param> /// <param name="doubleX1_Tar">第一帧目标点X坐标</param> /// <param name="doubleY1_Tar">第一帧目标点Y坐标</param> /// <param name="doubleZ1_Tar">第一帧目标点Z坐标</param> /// <param name="doubleX1_Obs">第一帧观察点X坐标</param> /// <param name="doubleY1_Obs">第一帧观察点Y坐标</param> /// <param name="doubleZ1_Obs">第一帧观察点Z坐标</param> /// <param name="doubleX2_Tar">第二帧目标点X坐标</param> /// <param name="doubleY2_Tar">第二帧目标点Y坐标</param> /// <param name="doubleZ2_Tar">第二帧目标点Z坐标</param> /// <param name="doubleX2_Obs">第二帧观察点X坐标</param> /// <param name="doubleY2_Obs">第二帧观察点Y坐标</param> /// <param name="doubleZ2_Obs">第二帧观察点Z坐标</param> /// <returns></returns> private static IKeyframe CreateMiddleKeyframe(IGlobe pGlobe, double doubleX1_Tar, double doubleY1_Tar, double doubleZ1_Tar, double doubleX1_Obs, double doubleY1_Obs, double doubleZ1_Obs, double doubleX2_Tar, double doubleY2_Tar, double doubleZ2_Tar, double doubleX2_Obs, double doubleY2_Obs, double doubleZ2_Obs) { IUnitConverter unitConverter = new UnitConverterClass(); IGlobeDisplayRendering globeDisplayRendering = (IGlobeDisplayRendering)pGlobe.GlobeDisplay; IKeyframe pMidKeyframe = new GlobeCameraKeyframeClass(); try { pMidKeyframe.set_PropertyValueInt(0, 0); pMidKeyframe.set_PropertyValueDouble(1, (doubleY1_Tar + doubleY2_Tar) / 2); //doubleY_mid); pMidKeyframe.set_PropertyValueDouble(2, (doubleX1_Tar + doubleX2_Tar) / 2); //doubleX_mid); pMidKeyframe.set_PropertyValueDouble(3, (doubleZ1_Tar + doubleZ2_Tar) / 2); //doubleZ1_Tar/2);//// (globeDisplayRendering.GlobeRadius / -1000)); pMidKeyframe.set_PropertyValueDouble(4, (doubleY1_Obs + doubleY2_Obs) / 2); //doubleY_mid); pMidKeyframe.set_PropertyValueDouble(5, (doubleX1_Obs + doubleX2_Obs) / 2); //doubleX_mid); //改善中间过程用户体验,增加中间点Observer的高度,让高度约等于两点间距离+海拔高度 double doubleAltitide_mid = ReturnProjectDistance(pGlobe, doubleX1_Obs, doubleY1_Obs, doubleZ1_Obs, doubleX2_Obs, doubleY2_Obs, doubleZ2_Obs) / 1000; //KM //加入地表高程 doubleAltitide_mid += GetGlobeElevation(pGlobe.GlobeDisplay, (doubleX1_Obs + doubleX2_Obs) / 2, (doubleY1_Obs + doubleY2_Obs) / 2, true); pMidKeyframe.set_PropertyValueDouble(6, doubleAltitide_mid); pMidKeyframe.set_PropertyValueDouble(7, 30); pMidKeyframe.set_PropertyValueDouble(8, 0); } catch { } return(pMidKeyframe); }
public ScriptPlayer(String scriptFile, IGlobe globe) { System.Diagnostics.Debug.Assert(globe != null); System.Diagnostics.Debug.Assert(scriptFile != null); System.Diagnostics.Debug.Assert(!scriptFile.Equals(String.Empty)); System.IO.FileInfo fi = new System.IO.FileInfo(scriptFile); if (!fi.Exists) { throw new TimelineException("Specified script does not exist."); } Script script = new Script(fi); System.Collections.IList atElements = script.AtElements; if (atElements == null || atElements.Count < 1) { throw new TimelineException("Script file " + scriptFile + " has no At elements."); } this.globe = globe; this.timesToRepeat = script.RepeatCount; this.timelines = new Timelines(atElements); this.timer = new System.Timers.Timer(15); this.timer.AutoReset = true; this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timerTickHandler); this.createPlayers(); }
private static ISectorNode GetPlayerSectorNode(IPlayer player, IGlobe globe) { return((from sectorNode in globe.SectorNodes from actor in sectorNode.Sector.ActorManager.Items where actor.Person == player.MainPerson select sectorNode).SingleOrDefault()); }
public void ZoomToGeometry(IGlobe pGlobe, IGeometry pGeo, double doubleDuration, string name) { pGeo = ProjectGeometryGeo(pGeo); IEnvelope pEnvelope = null; pEnvelope = pGeo.Envelope; ZoomToSelectedGlobeFeatures(pGlobe, pEnvelope, name); }
private IScene GetScene(IGlobe globe) { IScene scene; scene = globe as IScene; return(scene); }
private async Task ExpandGlobeInternalAsync(IGlobe globe, ISectorNode sectorNode) { await _biomeInitializer.MaterializeLevelAsync(sectorNode).ConfigureAwait(false); // Фиксируем новый узел, как известную, материализованную часть мира. // Далее этот узел будет обрабатываться при каждом изменении мира. globe.AddSectorNode(sectorNode); }
private IScene GetScene(IGlobe globe) { IScene scene; scene = globe as IScene; return scene; }
public SunPositionTool() { //get the different members m_globe = ArcGlobe.Globe; m_globeDisplay = m_globe.GlobeDisplay as IGlobeDisplay3; m_globeDisplayRendering = m_globeDisplay as IGlobeDisplayRendering; m_globeCamera = m_globeDisplay.ActiveViewer.Camera as IGlobeCamera; m_globeViewUtil = m_globeCamera as IGlobeViewUtil; m_sceneViewer = m_globeDisplay.ActiveViewer; }
public SunPositionTool() { //get the different members m_globe = ArcGlobe.Globe; m_globeDisplay = m_globe.GlobeDisplay as IGlobeDisplay3; m_globeDisplayRendering = m_globeDisplay as IGlobeDisplayRendering; m_globeCamera = m_globeDisplay.ActiveViewer.Camera as IGlobeCamera; m_globeViewUtil = m_globeCamera as IGlobeViewUtil; m_sceneViewer = m_globeDisplay.ActiveViewer; }
public static void ZoomToBookmark(IGlobeDisplay globeDisplay, IBookmark3D pBookmark3D, double doubleDuration) { try { //创建动画轨迹并添加 IAnimationTrack pAnimationTrack = CreateZoomOverLocationAnimation(globeDisplay, pBookmark3D); //播放轨迹 IGlobe globe = globeDisplay.Globe; IAnimationTracks animationTracks = (IAnimationTracks)globe; //// Add Track //animationTracks.AddTrack(pAnimationTrack); // Only enable the track with the parsed name for (int i = 0; i <= animationTracks.TrackCount - 1; i++) { IAnimationTrack animationTrackTest = (IAnimationTrack)animationTracks.Tracks.get_Element(i); if (animationTrackTest.Name == pAnimationTrack.Name) { animationTrackTest.IsEnabled = true; } else { animationTrackTest.IsEnabled = false; } } // Play Track System.DateTime dateTimeStart = DateTime.Now; double doubleElapsed = 0; while (doubleElapsed <= doubleDuration) { // Animation Viewer animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, doubleElapsed, doubleDuration); globe.GlobeDisplay.ActiveViewer.Redraw(true); // Get Elapsed Time System.TimeSpan timeSpanElapsed = DateTime.Now.Subtract(dateTimeStart); doubleElapsed = timeSpanElapsed.TotalSeconds; } // Display Last Frame (if slow viewer) animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, 1d, 1d); #region 根据当前摄像机姿态决定应该为Global模式还是Local模式 AutoSwitchGlobeCameraOrientationMode(globe); #endregion globe.GlobeDisplay.ActiveViewer.Redraw(true); // Remove Track animationTracks.RemoveTrack(pAnimationTrack); } catch { } }
private static ISectorNode GetSectorNode(IGlobe globe, IPerson person) { var sectorNode = globe.SectorNodes.SingleOrDefault(node => IsActorInSector(node, person)); if (sectorNode is null) { return(null); } return(sectorNode); }
private void GetGeographicCoordinates(IGlobe globe, int screenX, int screenY, ref double longitude, ref double latitude, ref double altitudeInKilometers) { IGlobeDisplay globeDisplay = globe.GlobeDisplay; ISceneViewer sceneViewer = globeDisplay.ActiveViewer; ICamera camera = globeDisplay.ActiveViewer.Camera; IGlobeViewUtil globeViewUtil = camera as IGlobeViewUtil; globeViewUtil.WindowToGeographic(globeDisplay, sceneViewer, screenX, screenY, true, out longitude, out latitude, out altitudeInKilometers); }
public BookmarkManager(ESRI.ArcGIS.Controls.AxGlobeControl axGlobeControl1) { globe = axGlobeControl1.Globe; ISceneBookmarks2 sceneBookmarks = globe as ISceneBookmarks2; m_BookmarkArray = sceneBookmarks.Bookmarks; for (int i = 0; i < sceneBookmarks.BookmarkCount; i++) { IBookmark3D pBookmark = new Bookmark3DClass(); pBookmark = m_BookmarkArray.get_Element(i) as IBookmark3D; } }
private void GetGeographicCoordinates(IGlobe globe, int screenX, int screenY, ref double longitude, ref double latitude, ref double altitudeInKilometers) { IGlobeDisplay globeDisplay = globe.GlobeDisplay; ISceneViewer sceneViewer = globeDisplay.ActiveViewer; ICamera camera = globeDisplay.ActiveViewer.Camera; IGlobeViewUtil globeViewUtil = camera as IGlobeViewUtil; globeViewUtil.WindowToGeographic(globeDisplay, sceneViewer, screenX, screenY, true, out longitude, out latitude, out altitudeInKilometers); }
public Fly() { globe = ArcGlobe.Globe; scene = globe as IScene; globeDisplay = globe.GlobeDisplay; camera = globeDisplay.ActiveViewer.Camera; globeCamera = camera as IGlobeCamera; theClock = new Microsoft.VisualBasic.Devices.Clock(); flyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.Fly.cur")); moveFlyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.fly1.cur")); speed = 0; }
//放大至图层方法 private void ZoomToGlobeLayer(IGlobe globe, int layerindex) { IGlobeDisplay globeDisplay = globe.GlobeDisplay; ISceneViewer sceneViewer = globeDisplay.ActiveViewer; ICamera camera = sceneViewer.Camera; IGlobeCamera globeCamera = camera as IGlobeCamera; IScene scene = globe as IScene; ILayer layer = scene.get_Layer(layerindex); IEnvelope extent = layer.AreaOfInterest.Envelope; globeCamera.SetToZoomToExtents(extent, globe, sceneViewer); }
private static IPerson?GetAvailableFollowedPerson(IGlobe globe) { var followedPerson = globe.SectorNodes .Where(x => x.Sector != null) //Code smell. Because there are no ways to say that sector is not null. .Select(x => x.Sector !) .SelectMany(x => x.ActorManager.Items) .Select(x => x.Person) .FirstOrDefault(x => CheckFollowedFraction(x) && !x.CheckIsDead()); return(followedPerson); }
public Fly() { globe = ArcGlobe.Globe; scene = globe as IScene; globeDisplay = globe.GlobeDisplay; camera = globeDisplay.ActiveViewer.Camera; globeCamera = camera as IGlobeCamera; theClock = new Microsoft.VisualBasic.Devices.Clock(); flyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.Fly.cur")); moveFlyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.fly1.cur")); speed = 0; }
/// <summary> /// 书签创建关键帧 /// </summary> /// <param name="_pGlobe"></param> /// <param name="_pBook3D"></param> /// <returns></returns> public static IAGKeyframe CreateKeyframefromBook(IGlobe _pGlobe, IBookmark3D _pBook3D) { IScene _pScene = _pGlobe.GlobeDisplay.Scene; IAGAnimationContainer pAGAnimationContainer = _pScene as IAGAnimationContainer; IAGAnimationTracks pAGAnimationTracks = _pGlobe as IAGAnimationTracks; IAGAnimationUtils pAGAutils = new AGAnimationUtilsClass(); ESRI.ArcGIS.Animation.IAGAnimationType pAGType = new AnimationTypeGlobeCameraClass(); IAGKeyframe pGlobeKey = new GlobeCameraKeyframeClass(); pAGAutils.KeyframeFromBookmark(pAGAnimationContainer, _pBook3D as ISpatialBookmark, out pGlobeKey); return pGlobeKey; }
public Task StartAsync(IGlobe globe, IAutoplayContext context) { if (globe is null) { throw new ArgumentNullException(nameof(globe)); } if (context is null) { throw new ArgumentNullException(nameof(context)); } return(StartInternalAsync(globe, context)); }
/// <summary> /// 书签创建关键帧 /// </summary> /// <param name="_pGlobe"></param> /// <param name="_pBook3D"></param> /// <returns></returns> public static IAGKeyframe CreateKeyframefromBook(IGlobe _pGlobe, IBookmark3D _pBook3D) { IScene _pScene = _pGlobe.GlobeDisplay.Scene; IAGAnimationContainer pAGAnimationContainer = _pScene as IAGAnimationContainer; IAGAnimationTracks pAGAnimationTracks = _pGlobe as IAGAnimationTracks; IAGAnimationUtils pAGAutils = new AGAnimationUtilsClass(); ESRI.ArcGIS.Animation.IAGAnimationType pAGType = new AnimationTypeGlobeCameraClass(); IAGKeyframe pGlobeKey = new GlobeCameraKeyframeClass(); pAGAutils.KeyframeFromBookmark(pAGAnimationContainer, _pBook3D as ISpatialBookmark, out pGlobeKey); return(pGlobeKey); }
private void Form1_Load(object sender, EventArgs e) { m_Globe = axGlobeControl1.Globe; m_GlobeDisplay = m_Globe.GlobeDisplay; m_SceneView = m_GlobeDisplay.ActiveViewer; m_GlobeViewUtil = axGlobeControl1.GlobeCamera as IGlobeViewUtil; IGlobeDisplayEvents_Event m_GlobeDisplayEvents = axGlobeControl1.Globe.GlobeDisplay as IGlobeDisplayEvents_Event; //将三维视图重绘事件委托给m_GlobeDisplayEvents_AfterDraw方法 m_GlobeDisplayEvents.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(m_GlobeDisplayEvents_AfterDraw); axMapControl1.Extent = axMapControl1.FullExtent; comboBox1.SelectedIndex = 0; }
public void BindPerson(IGlobe globe, IPerson person) { if (globe is null) { throw new System.ArgumentNullException(nameof(globe)); } if (person is null) { throw new System.ArgumentNullException(nameof(person)); } Globe = globe; MainPerson = person; }
private async Task ProcessInnerAsync(IGlobe globe, ISector sector, IActor actor, SectorTransition transition) { var sectorNode = transition.SectorNode; //TODO Разобраться с этим кодом. // https://blog.cdemi.io/async-waiting-inside-c-sharp-locks/ //Asynchronously wait to enter the Semaphore. If no-one has been granted access to the Semaphore, code execution will proceed, otherwise this thread waits here until the semaphore is released #pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task await _semaphoreSlim.WaitAsync(); #pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task try { if (sectorNode.State != SectorNodeState.SectorMaterialized) { await _globeExpander.ExpandAsync(sectorNode).ConfigureAwait(false); globe.AddSectorNode(sectorNode); } // It was used as fallback later. var oldActorNode = actor.Node; try { sector.ActorManager.Remove(actor); } catch (InvalidOperationException exception) { // Пока ничего не делаем Console.WriteLine(exception); Console.WriteLine(sector.GetHashCode()); Console.WriteLine(actor); } var nextSector = sectorNode.Sector; var transitionItem = new TransitionPoolItem(actor.Person, actor.TaskSource, nextSector, sector, oldActorNode); _transitionPool.Push(transitionItem); } finally { //When the task is ready, release the semaphore. It is vital to ALWAYS release the semaphore when we are ready, or else we will end up with a Semaphore that is forever locked. //This is why it is important to do the Release within a try...finally clause; program execution may crash or take a different path, this way you are guaranteed execution _semaphoreSlim.Release(); } }
private void PlayAnimation(double duration, int numCycles) { IGlobe globe = axGlobeControl1.Globe; IAnimationTracks tracks = (IAnimationTracks)globe; IViewers3D viewers3D = globe.GlobeDisplay; //exit if document doesn't contain animation.. string sError; if (tracks.TrackCount == 0) { sError = m_AnimFilePath; if (sError == "") { sError = "To get a Sample animation file, Developer Kit Samples need to be installed!"; System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + sError); } else { System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample."); } return; } DateTime startTime; TimeSpan timeSpan; int j; double elapsedTime; for (int i = 1; i <= numCycles; i++) { startTime = DateTime.Now; j = 0; do { timeSpan = (DateTime.Now).Subtract(startTime); elapsedTime = timeSpan.TotalSeconds; if (elapsedTime > duration) { elapsedTime = duration; } tracks.ApplyTracks(null, elapsedTime, duration); viewers3D.RefreshViewers(); j = j + 1; }while (elapsedTime < duration); } }
private static void PrintReport(IGlobe globe) { var sectorNodesDiscoveredCount = globe.SectorNodes.Count(); Console.WriteLine($"Sector Nodes Discovered: {sectorNodesDiscoveredCount}"); var actorCount = globe.SectorNodes.SelectMany(x => x.Sector.ActorManager.Items).Count(); Console.WriteLine($"Actors: {actorCount}"); var fractions = globe.SectorNodes.SelectMany(x => x.Sector.ActorManager.Items) .GroupBy(x => x.Person.Fraction); foreach (var fractionGroup in fractions) { Console.WriteLine($"Fraction {fractionGroup.Key.Name}: {fractionGroup.Count()}"); } }
private async Task ProcessInternalAsync(IGlobe globe, ISector sourceSector, IActor actor, SectorTransition transition) { var sectorNode = transition.SectorNode; await _semaphoreSlim.WaitAsync().ConfigureAwait(false); try { if (sectorNode.State != SectorNodeState.SectorMaterialized) { await _globeExpander.ExpandAsync(sectorNode).ConfigureAwait(false); globe.AddSectorNode(sectorNode); } // It was used as fallback later. var oldActorNode = actor.Node; sourceSector.ActorManager.Remove(actor); var targetSector = sectorNode.Sector; if (targetSector is null) { throw new InvalidOperationException(); } var transitionItem = new TransitionPoolItem( actor.Person, actor.TaskSource, targetSector, sourceSector, oldActorNode); _transitionPool.Push(transitionItem); } finally { //When the task is ready, release the semaphore. It is vital to ALWAYS release the semaphore when we are ready, or else we will end up with a Semaphore that is forever locked. //This is why it is important to do the Release within a try...finally clause; program execution may crash or take a different path, this way you are guaranteed execution _semaphoreSlim.Release(); } }
public static void AutoSwitchGlobeCameraOrientationMode(IGlobe pGlobe) { try { ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = pGlobe.GlobeDisplay.ActiveViewer; ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera; ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; double xTarget; double yTarget; ESRI.ArcGIS.Geometry.IPoint targetCls = (globeCamera as ICamera).Target; targetCls.QueryCoords(out xTarget, out yTarget); double zTarget = targetCls.Z; // Calculate the current azimuth and inclination of the camera. //azimuth = Math.Atan2(xTarget, yTarget) * 180 / Math.PI; double inclination = (180 / Math.PI) * (Math.Asin(zTarget / Math.Sqrt(xTarget * xTarget + yTarget * yTarget + zTarget * zTarget))) - 10.0; if (inclination > 88 | inclination < -88 | double.IsNaN(inclination)) { double targetLatitude; double targetLongitude; double targetAltitude; globeCamera.GetTargetLatLonAlt(out targetLatitude, out targetLongitude, out targetAltitude); double observerLatitude; double obsLongitude; double obsAltitude; globeCamera.GetObserverLatLonAlt(out observerLatitude, out obsLongitude, out obsAltitude); //// Set the GlobeCamera to global navigation mode. globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal; globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationAttached; globeCamera.SetObserverLatLonAlt(targetLatitude, targetLongitude, obsAltitude); } else { globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal; globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationFree; } } catch { } }
public GeographicCoordinates(IGlobe globe, int screenX, int screenY) { GetGeographicCoordinates(globe, screenX, screenY, ref _longitude, ref _latitude, ref _altitudeInKilometers); }
/// <summary> /// 内插中间贞函数,只需给出第一帧和最后一帧的状态信息,即可内插出中间帧状态 /// </summary> /// <param name="pGlobe"></param> /// <param name="doubleX1_Tar">第一帧目标点X坐标</param> /// <param name="doubleY1_Tar">第一帧目标点Y坐标</param> /// <param name="doubleZ1_Tar">第一帧目标点Z坐标</param> /// <param name="doubleX1_Obs">第一帧观察点X坐标</param> /// <param name="doubleY1_Obs">第一帧观察点Y坐标</param> /// <param name="doubleZ1_Obs">第一帧观察点Z坐标</param> /// <param name="doubleX2_Tar">第二帧目标点X坐标</param> /// <param name="doubleY2_Tar">第二帧目标点Y坐标</param> /// <param name="doubleZ2_Tar">第二帧目标点Z坐标</param> /// <param name="doubleX2_Obs">第二帧观察点X坐标</param> /// <param name="doubleY2_Obs">第二帧观察点Y坐标</param> /// <param name="doubleZ2_Obs">第二帧观察点Z坐标</param> /// <returns></returns> private static IKeyframe CreateMiddleKeyframe(IGlobe pGlobe, double doubleX1_Tar, double doubleY1_Tar, double doubleZ1_Tar, double doubleX1_Obs, double doubleY1_Obs, double doubleZ1_Obs, double doubleX2_Tar, double doubleY2_Tar, double doubleZ2_Tar, double doubleX2_Obs, double doubleY2_Obs, double doubleZ2_Obs) { IUnitConverter unitConverter = new UnitConverterClass(); IGlobeDisplayRendering globeDisplayRendering = (IGlobeDisplayRendering)pGlobe.GlobeDisplay; IKeyframe pMidKeyframe = new GlobeCameraKeyframeClass(); try { pMidKeyframe.set_PropertyValueInt(0, 0); pMidKeyframe.set_PropertyValueDouble(1, (doubleY1_Tar + doubleY2_Tar) / 2);//doubleY_mid); pMidKeyframe.set_PropertyValueDouble(2, (doubleX1_Tar + doubleX2_Tar) / 2);//doubleX_mid); pMidKeyframe.set_PropertyValueDouble(3, (doubleZ1_Tar + doubleZ2_Tar) / 2); //doubleZ1_Tar/2);//// (globeDisplayRendering.GlobeRadius / -1000)); pMidKeyframe.set_PropertyValueDouble(4, (doubleY1_Obs + doubleY2_Obs) / 2);//doubleY_mid); pMidKeyframe.set_PropertyValueDouble(5, (doubleX1_Obs + doubleX2_Obs) / 2);//doubleX_mid); //改善中间过程用户体验,增加中间点Observer的高度,让高度约等于两点间距离+海拔高度 double doubleAltitide_mid = ReturnProjectDistance(pGlobe, doubleX1_Obs, doubleY1_Obs, doubleZ1_Obs, doubleX2_Obs, doubleY2_Obs, doubleZ2_Obs) / 1000; //KM //加入地表高程 doubleAltitide_mid += GetGlobeElevation(pGlobe.GlobeDisplay, (doubleX1_Obs + doubleX2_Obs) / 2, (doubleY1_Obs + doubleY2_Obs) / 2, true); pMidKeyframe.set_PropertyValueDouble(6, doubleAltitide_mid); pMidKeyframe.set_PropertyValueDouble(7, 30); pMidKeyframe.set_PropertyValueDouble(8, 0); } catch { } return pMidKeyframe; }
public static double ReturnProjectDistance(IGlobe pGlobe, double dFromX, double dFromY, double dFromZ, double dToX, double dToY, double dToZ) { IPoint pPnt1 = new Point(); IPoint pPnt2 = new Point(); pPnt1.X = dFromX; pPnt1.Y = dFromY; MakeZAware(pPnt1); pPnt1.Z = dFromZ * 1000; pPnt1.SpatialReference = pGlobe.GlobeDisplay.Scene.SpatialReference; if (pPnt1.SpatialReference is IGeographicCoordinateSystem) { pPnt1 = ProjectGeometry(pPnt1) as IPoint; } pPnt2.X = dToX; pPnt2.Y = dToY; MakeZAware(pPnt2); pPnt2.Z = dToZ * 1000; pPnt2.SpatialReference = pGlobe.GlobeDisplay.Scene.SpatialReference; if (pPnt2.SpatialReference is IGeographicCoordinateSystem) { pPnt2 = ProjectGeometry(pPnt2) as IPoint; } IProximityOperator3D pProximityOperator3D = pPnt1 as IProximityOperator3D; return pProximityOperator3D.ReturnDistance3D(pPnt2); }
public VerticalExaggerationPlayer(IGlobe globe) : base(globe) {}
public LatLonGridPlayer(IGlobe globe) : base(globe) {}
public TogglePlayerBase(IGlobe globe) : base(globe) { }
public LayersPlayer(IGlobe globe) : base(globe) { }
//按预订的路径飞行 public bool InitAnimationPlay(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath, int _FlySpeedRating,bool _IsFlyLoop,bool _IsFlyLookdown) { bool IsFoundPolyline = true; //是否能找到对应的Polyline try { scene = _axGlobeControl.GlobeDisplay.Scene; globe = _axGlobeControl.Globe; IBasicScene2 basicScene = (IBasicScene2)globe; pAgAnimationUtils = new AGAnimationUtilsClass(); //按路径飞行 ILayer layer = getLayerByName(scene, ANIMATIONPATH_LayerName); if (layer == null) { IsFoundPolyline = false; return IsFoundPolyline; } FlyPathPolyline = getPolylineFromLayer(layer, _FlyPathName); if (FlyPathPolyline == null) { IsFoundPolyline = false; return IsFoundPolyline; } //启用三维线 IZAware flyPathZAware = (IZAware)FlyPathPolyline; flyPathZAware.ZAware = true; pAnimationExtension = basicScene.AnimationExtension; CreateAnimationFromPath(globe, FlyPathPolyline, FlySpeedRating, IsFlyLoop, IsFlyLookdown); //配置飞行 //InitAnimationParameters(); //IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer; //pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内; animPlayer = (IAGAnimationPlayer)pAgAnimationUtils; } catch { } return IsFoundPolyline; }
public ViewDirectionPlayer(IGlobe globe) : base(globe) {}
public TableOfContents(IGlobe globe) { _scene = GetScene(globe); }
protected PlayerBase(IGlobe globe) { this.globe = globe; }
public void SetVariables(IGlobe pGlobe) { globe = pGlobe; }
public WmsImagePlayer(IGlobe globe) : base(globe) {}
//int _pType,, double _pDuration) /// <summary> ///第三个参数是移动的方式,其中1表示移动观察者,2表示移动目标,其他表示两个都移动 /// </summary> /// <param name="_pScene">_pGlobe</param> /// <param name="_pPolyline">_pPolyline</param> /// <param name="_pType">_pType</param> public void CreateAnimationFromPath(IGlobe _pGlobe, IPolyline _pPolyline, int _FlySpeedRating, bool _IsFlyLoop, bool _IsFlyLookdown) { try { #region //esri写的 scene = _pGlobe.GlobeDisplay.Scene; // 获取动画扩展对象 //ESRI.ArcGIS.Analyst3D.IBasicScene2 pBasicScene2 = (ESRI.ArcGIS.Analyst3D.IBasicScene2)_pScene; // Explicit Cast //ESRI.ArcGIS.Animation.IAnimationExtension pAnimationExtension = pBasicScene2.AnimationExtension; //创建两个对象,一个用于导入路径,一个用于播放 //ESRI.ArcGIS.Animation.IAGAnimationUtils pAGAnimationUtils = new ESRI.ArcGIS.Animation.AGAnimationUtilsClass(); pAGImportPathOptions = new ESRI.ArcGIS.Animation.AGImportPathOptionsClass(); // 设置参数 //参数设置不正确会出错,尤其是类型,对象等信息! pAGImportPathOptions.BasicMap = (ESRI.ArcGIS.Carto.IBasicMap)scene; pAGImportPathOptions.AnimationTracks = (ESRI.ArcGIS.Animation.IAGAnimationTracks)scene; // pAGImportPathOptions.AnimationType = new ESRI.ArcGIS.GlobeCore.AnimationTypeCameraClass(); //在Globe中不能用这个 pAGImportPathOptions.AnimationType = new AnimationTypeGlobeCameraClass(); pAGImportPathOptions.LookaheadFactor = 1; pAGImportPathOptions.PutAngleCalculationMethods(esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative, esriPathAngleCalculation.esriAngleAddRelative); //pAGImportPathOptions.AnimatedObject = _pScene.SceneGraph.ActiveViewer.Camera; //在Globe中不能用这个 pAGImportPathOptions.AnimatedObject = _pGlobe.GlobeDisplay.ActiveViewer.Camera; pAGImportPathOptions.PathGeometry = _pPolyline; //俯视飞行 if (_IsFlyLoop) { pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObserver;//观察者移动 } else //正常飞行 { pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObsAndTarget;//都移动 } //else //{ // pAGImportPathOptions.ConversionType = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathTarget; //} pAGImportPathOptions.LookaheadFactor = 1; pAGImportPathOptions.RollFactor = 0; pAGImportPathOptions.AnimationEnvironment = pAnimationExtension.AnimationEnvironment; // //InitAnimationParameters(); //持续时间 double FlyPathLength = FlyPathPolyline.Length; double flyDuration = FlyPathLength *500 /_FlySpeedRating; //飞行路线长度*300*飞行速度等级/中速等级 FlyDurationTime = flyDuration; //记录飞行时间 pAnimationExtension.AnimationEnvironment.AnimationDuration = flyDuration; pAnimationExtension.AnimationEnvironment.IsIntervalPlay = false; pAnimationExtension.AnimationEnvironment.PlayMode = esriAnimationPlayMode.esriAnimationPlayOnceForward; pAnimationExtension.AnimationEnvironment.PlayTime = pAnimationExtension.AnimationEnvironment.AnimationDuration; //IAGAnimationEnvironment pAGAeviroment = new AGAnimationEnvironmentClass(); ESRI.ArcGIS.Animation.IAGAnimationContainer AGAnimationContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer; // 创建飞行路线类似ArcGlobe中的Import,通过ArcGlobe学习ArcGlobe开发! pAgAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, pAGImportPathOptions); //该接口相当于播放的界面,可以自己做一个界面 animPlayer = pAgAnimationUtils as IAGAnimationPlayer; //animPlayer.PlayAnimation(_pScene as IAGAnimationTracks, pAGAeviroment, null); //开始飞行 #endregion } catch { } #region //用改变观察者和观察点的方式 //if (this.m_pScene.AreaOfInterest == null) // return; //// Explicit Cast //IBasicScene2 basicScene2 = (IBasicScene2)_pGlobe; //m_pAnimationExtension = basicScene2.AnimationExtension; //m_pAgAnimationUtils = new AGAnimationUtilsClass(); //IAGImportPathOptions agImportPathOptions = new AGImportPathOptionsClass(); //agImportPathOptions.AnimationEnvironment = m_pAnimationExtension.AnimationEnvironment; //IAGAnimationContainer AGAnimationContainer = m_pAnimationExtension.AnimationTracks.AnimationObjectContainer; //if (AGAnimationContainer != null) //{ // m_pAgAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, agImportPathOptions); //} #endregion }
public ViewPositionPlayer(IGlobe globe) : base(globe) { }
private static void PlayAnimationTrack(double duration, int numCycles, string FlyFilePath, IGlobe globe, GISFunction.SceneBookmark pSceneBookmark) { try { IAnimationTracks tracks = (IAnimationTracks)globe; IViewers3D viewers3D = globe.GlobeDisplay; //exit if document doesn't contain animation.. string sError; if (tracks.TrackCount == 0) { sError = FlyFilePath; if (sError == "") { sError = "飞行路径文件可能丢失,请确保程序的完整性"; System.Windows.Forms.MessageBox.Show(sError, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { System.Windows.Forms.MessageBox.Show("加载飞行文件失败,请尝试重新安装程序。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } return; } DateTime startTime; TimeSpan timeSpan; int j; double elapsedTime; for (int i = 1; i <= numCycles; i++) { startTime = DateTime.Now; j = 0; do { timeSpan = (DateTime.Now).Subtract(startTime); elapsedTime = timeSpan.TotalSeconds; if (elapsedTime > duration) elapsedTime = duration; tracks.ApplyTracks(null, elapsedTime, duration); viewers3D.RefreshViewers(); j = j + 1; } while (elapsedTime < duration); } //if(FlyFilePath.Length>4) //{ // int index = FlyFilePath.IndexOf("飞行"); // int indexFlyPath = FlyFilePath.IndexOf("FlyPath"); // if (index > 0&&indexFlyPath>0) // { // string cityName = FlyFilePath.Substring(indexFlyPath + 8, index - indexFlyPath-8); // pSceneBookmark.ZoomToScene(cityName); // } //} } catch { } }
public DisplayMessagesPlayer(IGlobe globe) : base(globe) {}