//拾取当前相机状态 private void btn_PickCameraState_Click(object sender, EventArgs e) { //如果构建过相机页,则新添加时将其清空 if (_cameraMoviePage != null) { _listFrame.Clear(); lbc_FrameCount.Text = string.Format("相机状态数:0"); _cameraMoviePage = null; } //拾取当前相机状态信息 CameraFrame frame = new CameraFrame() { //获取当前相机状态 CameraState = _glbControl.Globe.CameraState, //当前状态到下一状态的持续的时间 Duration = Convert.ToDouble(numericUpDown_ConsistTime.Value), //相机状态命名 FrameName = string.Format("相机状态{0}", _listFrame.Count) }; //将当前相机状态信息添加到相机状态列表 _listFrame.Add(frame); //显示统计信息 lbc_FrameCount.Text = string.Format("相机状态数:{0}", _listFrame.Count); }
//导弹动画 private void btn_Missile_Click(object sender, EventArgs e) { //创建相机状态 GSOCameraState camera = new GSOCameraState(); camera.Longitude = 100.42875293029; camera.Latitude = 38.9355930610869; camera.Distance = 12209.9485092387; camera.Heading = -92.7905229605158; camera.Tilt = 68.5957814133134; camera.Altitude = 1490.27994062379; camera.AltitudeMode = EnumAltitudeMode.Absolute; //添加.lgd图层 _glbControl.Globe.JumpToCameraState(camera); //添加.lgd图层 GSOLayer layer = _glbControl.Globe.Layers.Add(_missileAnimatePath); if (layer != null) { //添加.gla动画文件 GSOAnimationPage page = _glbControl.Globe.AnimationPages.AddAnimationPage(_missileAnimatePath.Replace(".lgd", ".gla")); if (page != null) { page.RepeatCount = 1; page.Play(); } } }
//生成动画页预览并 private void btn_Preview_Click(object sender, EventArgs e) { //动画创建条件为有两个以上的相机状态 if (_listFrame.Count < 2) { MessageBox.Show("不满足动画创建条件,请继续拾取。"); return; } //创建动画相机 GSOAniCamera aniCamera = new GSOAniCamera(); //创建动画时间线 GSOAniObjTimeLine timeline = new GSOAniObjTimeLine(); //将动画相机与动画时间线绑定 timeline.AniObject = aniCamera; //创建动画页面 _cameraMoviePage = new GSOAnimationPage(); _cameraMoviePage.Name = "Test1"; //设置每秒帧数为60帧 _cameraMoviePage.FPS = 60; //初始化动画持续帧数 int totleFrameCount = 0; //遍历关键帧列表 for (int i = 0; i < _listFrame.Count; i++) { //创建关键帧之间的变化效果 GSOAniEffectCameraStateChange effectChange = new GSOAniEffectCameraStateChange(); //变化起始状态 CameraFrame starFrame = _listFrame[i]; effectChange.StartState = starFrame.CameraState; //变化结束状态 CameraFrame endFrame = i == _listFrame.Count - 1 ? _listFrame[i] : _listFrame[i + 1]; effectChange.EndState = endFrame.CameraState; //计算相机状态之间的持续帧数 effectChange.FrameCount = (int)(starFrame.Duration * _cameraMoviePage.FPS); //重复播放次数为1次 effectChange.RepeatCount = 1; //使用缩放高度设置为false effectChange.ZoomOutAltUsed = false; totleFrameCount += effectChange.FrameCount; //创建动画关键帧 GSOAniKeyFrame keyFrame = new GSOAniKeyFrame(); //添加状态变化效果 keyFrame.AddEffect(effectChange); //添加帧数 keyFrame.Frame = totleFrameCount; //将关键帧添加到动画时间线 timeline.AddKeyFrame(keyFrame); } //向动画页添加总帧数 _cameraMoviePage.FrameCount = totleFrameCount; //向动画页添加动画时间线 _cameraMoviePage.AddObjTimeLine(timeline); //清空其他动画 if (_glbControl.Globe.AnimationPages.Length > 0) { _glbControl.Globe.AnimationPages.RemoveAll(); } //向Globe中添加该动画页 _cameraMoviePage = _glbControl.Globe.AnimationPages.Add(_cameraMoviePage); //播放动画页 _cameraMoviePage.Play(); }
private void 线增长动画ToolStripMenuItem_Click(object sender, EventArgs e) { if (globeControl1.Globe.SelectedObject != null) { GSOFeature feature = globeControl1.Globe.SelectedObject; feature.HighLight = false; globeControl1.Globe.Refresh(); if (feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { if (feature.Geometry.Style == null) { feature.Geometry.Style = new GSOSimpleLineStyle3D(); } feature.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; ((GSOGeoPolyline3D)feature.Geometry).SmoothToSpline(); ((GSOStyle3D)feature.Geometry.Style).UsingBlur = true; globeControl1.Globe.MemoryLayer.AddFeature(feature); GSOAniFeature featureAnimation = new GSOAniFeature();//动画的类型--要素动画 featureAnimation.Feature = feature; //动画的关联对象 GSOAniEffectLineGrow effect = new GSOAniEffectLineGrow();//动画效果-线增长动画 effect.StartValue = 0; effect.EndValue = 1; effect.FrameCount = 1200; effect.RepeatCount = 1; //effect.IsSmooth = false; GSOAniKeyFrame keyFream = new GSOAniKeyFrame(); //关键帧 keyFream.Frame = 0; keyFream.AddEffect(effect); //给关键帧添加动画效果 GSOAniObjTimeLine timeLine = new GSOAniObjTimeLine();//动画对象 timeLine.Name = "线增长动画对象"; timeLine.AniObject = featureAnimation; //动画对象的动画类型 timeLine.AddKeyFrame(keyFream); //给动画对象添加关键帧 GSOAnimationPage page = new GSOAnimationPage(); //动画 page.FPS = 60; //动画--帧率 page.FrameCount = 20 * 60; //动画时长 * 帧率 //动画--帧总数 page.Name = "线增长动画"; page.AddObjTimeLine(timeLine); //给动画添加动画对象 globeControl1.Globe.AnimationPages.Add(page); globeControl1.Globe.AnimationPages.GetAt(globeControl1.Globe.AnimationPages.Length - 1).Play(); globeControl1.Refresh(); } else { MessageBox.Show("请选中一条线!","提示"); } } }
private void ConnexityAnalysis() { GSODataset curCAYDataset = m_ConnexityAnalysisFirstLayer.Dataset; string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return; } int[] arryResID; curCAYNDataset.ConnexityAnalysis(m_ConnexityAnalysisFirstFeature.ID, m_ConnexityAnaylsisSecondFeature.ID, out arryResID, false, true); m_ConnexityAnalyResFeatures = m_ConnexityAnalysisFirstLayer.GetFeaturesByIDs(arryResID); if (m_ConnexityAnalyResFeatures == null || m_ConnexityAnalyResFeatures.Length < 1) { String strLine1 = "管线:" + m_ConnexityAnalysisFirstFeature.ID; String strLine2 = "管线:" + m_ConnexityAnaylsisSecondFeature.ID; MessageBox.Show(strLine1 + " 与 " + strLine2 + " 不连通", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { int nCount = m_ConnexityAnalyResFeatures.Length; GSOGeoPolyline3D effectLine = new GSOGeoPolyline3D(); GSOPoint3ds effectPart = new GSOPoint3ds(); for (int i = 0; i < nCount; i++) { m_ConnexityAnalyResFeatures[i].HighLight = true; GSOGeoPolyline3D geoline = m_ConnexityAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { //管线显示流动效果 for (int j = 0; j < geoline.PartCount; j++) { effectLine.AddPart(geoline[j]); } } } effectLine.SmoothToSpline(); GSOFeature feature = new GSOFeature(); feature.Geometry = effectLine; if (feature.Geometry.Style == null) { feature.Geometry.Style = new GSOSimpleLineStyle3D(); } feature.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; ((GSOStyle3D)feature.Geometry.Style).UsingBlur = true; globeControl1.Globe.MemoryLayer.AddFeature(feature); GSOAniFeature featureAnimation = new GSOAniFeature();//动画的类型--要素动画 featureAnimation.Feature = feature; //动画的关联对象 GSOGeoMarker marker = new GSOGeoMarker(0, 0, 0,""); GSOMarkerStyle3D markerStyle = new GSOMarkerStyle3D(); markerStyle.IconPath = Application.StartupPath + "/Resource/image/star4.bmp"; marker.Style = markerStyle; marker.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOFeature markerFeature = new GSOFeature(); markerFeature.Geometry = marker; GSOAniEffectLineGrow effect = new GSOAniEffectLineGrow();//动画效果-线增长动画 effect.StartValue = 0; effect.EndValue = 1; effect.FrameCount = 1200; effect.RepeatCount = 1; effect.IsSmooth = false; effect.ActorFeature = markerFeature; GSOAniKeyFrame keyFream = new GSOAniKeyFrame(); //关键帧 keyFream.Frame = 0; keyFream.AddEffect(effect); //给关键帧添加动画效果 GSOAniObjTimeLine timeLine = new GSOAniObjTimeLine();//动画对象 timeLine.Name = "线增长动画对象"; timeLine.AniObject = featureAnimation; //动画对象的动画类型 timeLine.AddKeyFrame(keyFream); //给动画对象添加关键帧 GSOAnimationPage page = new GSOAnimationPage(); //动画 page.FPS = 60; //动画--帧率 page.FrameCount = 20 * 60; //动画时长 * 帧率 //动画--帧总数 page.Name = "线增长动画"; page.AddObjTimeLine(timeLine); //给动画添加动画对象 globeControl1.Globe.AnimationPages.Add(page); globeControl1.Globe.AnimationPages.GetAt(globeControl1.Globe.AnimationPages.Length - 1).Play(); globeControl1.Refresh(); } }