private void toolStripButtonHideVideo_Click(object sender, EventArgs e) { if ((sender as ToolStripButton).Text.Equals("隐藏视频")) { for (int i = 0; i < videoList.Count; i++) { IViewshed v = videoList[i]; v.VisibleMask = gviViewportMask.gviViewNone; } } else { for (int i = 0; i < videoList.Count; i++) { IViewshed v = videoList[i]; v.VisibleMask = gviViewportMask.gviViewAllNormalView; } } if ((sender as ToolStripButton).Text.Equals("隐藏视频")) { (sender as ToolStripButton).Text = "显示视频"; } else { (sender as ToolStripButton).Text = "隐藏视频"; } }
void axRenderControl1_RcMouseClickSelect3(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { if (IntersectPoint == null) { return; } if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick)) { this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal; this.axRenderControl1.RcMouseClickSelect -= new Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect3); IViewshedPickResult pr = PickResult as IViewshedPickResult; if (pr == null) { return; } IViewshed v = pr.Viewshed; if (v == null) { return; } v.Highlight(System.Drawing.Color.Red); } }
private void toolStripButtonHideProjectionLines_Click(object sender, EventArgs e) { if ((sender as ToolStripButton).Text.Equals("隐藏投影线")) { for (int i = 0; i < videoList.Count; i++) { IViewshed v = videoList[i]; v.DisplayMode = gviTVDisplayMode.gviTVShowPicture; } } else { for (int i = 0; i < videoList.Count; i++) { IViewshed v = videoList[i]; v.DisplayMode = gviTVDisplayMode.gviTVShowAll; } } if ((sender as ToolStripButton).Text.Equals("隐藏投影线")) { (sender as ToolStripButton).Text = "显示投影线"; } else { (sender as ToolStripButton).Text = "隐藏投影线"; } }
private void btnAnalyse_Click(object sender, EventArgs e) { try { WaitForm.Start("正在分析...", "请稍后"); IPoint ptStart = this._geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptStart.X = (double)this.seObserX.Value; ptStart.Y = (double)this.seObserY.Value; ptStart.Z = (double)this.seObserZ.Value + (double)this.seObserZOff.Value; IPoint ptEnd = this._geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptEnd.X = (double)this.seObjX.Value; ptEnd.Y = (double)this.seObjY.Value; ptEnd.Z = (double)this.seObjZ.Value + (double)this.seObjZOff.Value; double HorizontalAngle = (double)this.seAngle.Value; ClearViewshed(); this._vs = this._3DControl.ObjectManager.CreateViewshed(ptStart, this._3DControl.ProjectTree.RootID); IEulerAngle ang = this._3DControl.Camera.GetAimingAngles2(ptStart, ptEnd);; //ang.Set(ang.Heading, 0, ang.Roll); this._vs.AspectRatio = 1; this._vs.DisplayMode = gviTVDisplayMode.gviTVShowPicture; this._vs.Angle = ang; this._vs.FarClip = Math.Sqrt((ptStart.X - ptEnd.X) * (ptStart.X - ptEnd.X) + (ptStart.Y - ptEnd.Y) * (ptStart.Y - ptEnd.Y) + (ptStart.Z - ptEnd.Z) * (ptStart.Z - ptEnd.Z)); this._vs.FieldOfView = HorizontalAngle; this._3DControl.HighlightHelper.VisibleMask = 0; } catch (Exception ex) { } finally { WaitForm.Stop(); } }
private void ClearViewshed() { if (this._vs != null) { this._3DControl.ObjectManager.DeleteObject(this._vs.Guid); this._vs = null; } }
private void LoadSkinMeshAndViewshed() { string fileName = (strMediaPath + @"\x\Character\QiYeYuanGong.X"); if (skinMesh == null) { // 构造ModelPoint IGeometryFactory gf = new GeometryFactory(); IModelPoint mp = gf.CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint; mp.ModelName = fileName; mp.SpatialCRS = new CRSFactory().CreateFromWKT(wkt) as ISpatialCRS; // 设置位置 IMatrix matrix = new Matrix(); matrix.MakeIdentity(); matrix.SetTranslate(line.GetPoint(0).Position); mp.FromMatrix(matrix); // 创建骨骼动画 skinMesh = this.axRenderControl1.ObjectManager.CreateSkinnedMesh(mp, rootId); if (skinMesh == null) { MessageBox.Show("骨骼动画创建失败!"); return; } skinMesh.Loop = true; skinMesh.Play(); skinMesh.MaxVisibleDistance = 1000; skinMesh.ViewingDistance = 50; // 绑定到运动路径 IMotionable m = skinMesh as IMotionable; position.Set(0, 0, 0); m.Bind2(dynamicObject, position, 0, 0, 0); this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehind); } if (tv == null) { tv = this.axRenderControl1.ObjectManager.CreateViewshed(line.GetPoint(0), rootId); IMotionable tvm = tv as IMotionable; position.Set(0, 0, 0); tvm.Bind2(dynamicObject, position, 0, 0, 0); } }
void axRenderControl1_RcMouseClickSelect2(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { if (IntersectPoint == null) { return; } if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick)) { this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal; this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect2); ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = 20; ps.FillColor = System.Drawing.Color.Red; this.axRenderControl1.ObjectManager.CreateRenderPoint(IntersectPoint, ps, rootId); for (int i = 0; i < videoList.Count; i++) { IViewshed v = videoList[i]; v.Unhighlight(); double wx, wy; bool isIn = v.WorldToScreen(IntersectPoint, 1, out wx, out wy); if (isIn) { v.Highlight(System.Drawing.Color.Red); IPoint poiInWorld = v.ScreenToWorld(wx, wy); if (poiInWorld != null) { this.axRenderControl1.InteractMode = gviInteractMode.gviInteractFocus; bool bFocus = this.axRenderControl1.Camera.SetFocus(poiInWorld); if (bFocus) { MessageBox.Show("set focus success!"); } } } } } }
public void Create() { try { if (this.tv == null) { IPoint tmpPos = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ) as IPoint; tmpPos.SetCoords(0, 0, 0, 0, 0); tmpPos.SpatialCRS = new CRSFactory().CreateFromWKT(CommonUnity.RenderHelper.GetCurrentCrsWKT()) as ISpatialCRS; this.tv = CommonUnity.RenderHelper.ObjectManager.CreateViewshed(tmpPos, _Guid); if (this.tv != null) { this.guidstr = this.tv.Guid; } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } }
bool axRenderControl1_RcKeyUp(uint Flags, uint Ch) { if (curVideoIndex < 0) { return(false); } switch (Ch) { #region 键调整 case (uint)Keys.Q: { curVideo = videoList[curVideoIndex]; cp.X += factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.W: { curVideo = videoList[curVideoIndex]; cp.X -= factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.E: { curVideo = videoList[curVideoIndex]; cp.Y += factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.R: { curVideo = videoList[curVideoIndex]; cp.Y -= factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.T: { curVideo = videoList[curVideoIndex]; cp.Z += factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.Y: { curVideo = videoList[curVideoIndex]; cp.Z -= factor; vector.Set(cp.X, cp.Y, cp.Z); positionPoint.Position = vector; curVideo.Position = positionPoint; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.U: { curVideo = videoList[curVideoIndex]; cp.Heading += factor; angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.I: { curVideo = videoList[curVideoIndex]; cp.Heading -= factor; angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.O: { curVideo = videoList[curVideoIndex]; cp.Tilt += factor; vector.Set(cp.X, cp.Y, cp.Z); angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.P: { curVideo = videoList[curVideoIndex]; cp.Tilt -= factor; angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.D: { curVideo = videoList[curVideoIndex]; cp.Roll += factor; angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.F: { curVideo = videoList[curVideoIndex]; cp.Roll -= factor; angle.Set(cp.Heading, cp.Tilt, cp.Roll); curVideo.Angle = angle; //this.axRenderControl1.Camera.SetCamera(vector, angle, gviSetCameraFlags.gviSetCameraNoFlags); DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.G: { curVideo = videoList[curVideoIndex]; cp.AspectRatio += factor; curVideo.AspectRatio = cp.AspectRatio; DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.H: { curVideo = videoList[curVideoIndex]; cp.AspectRatio -= factor; curVideo.AspectRatio = cp.AspectRatio; DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.J: { curVideo = videoList[curVideoIndex]; cp.FieldOfView += factor; curVideo.FieldOfView = cp.FieldOfView; DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.K: { curVideo = videoList[curVideoIndex]; cp.FieldOfView -= factor; curVideo.FieldOfView = cp.FieldOfView; DataRow dr = dt.Rows[curRowIndex]; dr["Location"] = cp; } break; case (uint)Keys.D1: { factor = 10; } break; case (uint)Keys.D2: { factor = 1; } break; case (uint)Keys.D3: { factor = 0.1; } break; case (uint)Keys.D4: { factor = 0.01; } break; #endregion case (uint)Keys.S: { String str = cp.PropertyStrings(); streamWriter.WriteLine(str); streamWriter.Flush(); } break; case (uint)Keys.C: { curVideo = videoList[curVideoIndex]; curVideo.VisibleMask = gviViewportMask.gviViewAllNormalView; } break; case (uint)Keys.V: { curVideo = videoList[curVideoIndex]; curVideo.VisibleMask = gviViewportMask.gviViewNone; } break; } return(true); }