private void View_OnViewDefaultMouseDownEvent(object sender, MouseEventArgs e) { if (ckEnable.Checked == false) { return; } if (e.Button != MouseButtons.Left) { return; } VIZCore3D.NET.Data.PickedSurfaceData data = vizcore3d.View.GetPickedSurfaceNormalVector(e.X, e.Y); // 선택된 부재가 없음 if (data.Picked == false) { return; } // 표면점이 없음 if (data.Surface == false) { return; } // 선택된 지점 VIZCore3D.NET.Data.Vertex3D position = data.Position; // 선택된 지점의 Normal Vector VIZCore3D.NET.Data.Vector3D normal = data.Normal; string str = string.Format("VERTEX: {0}\r\nNORMAL : {1}", position.ToString(), normal.ToString()); System.Console.WriteLine(str); int nodeIndex = vizcore3d.View.HitTest(e.X, e.Y); if (nodeIndex < 0) { return; } VIZCore3D.NET.Data.Node node = vizcore3d.Object3D.FromIndex(nodeIndex); int noteId = vizcore3d.Review.Note.AddNoteSurface(string.Format("{0}\r\n{1}", node.GetParentName(), str), new VIZCore3D.NET.Data.Vertex3D(position.X + 5000, position.Y + 5000, position.Z + 1000), position, GetStyle()); if (ckDepthTest.Checked == true) { vizcore3d.Review.Note.EnableDepthTest(noteId, true); } }
private void btnDisassembly_Click(object sender, EventArgs e) { bool showOriginalLocation = ckShowOriginalLocation.Checked; List <VIZCore3D.NET.Data.Node> stage4 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_4" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v4 = new VIZCore3D.NET.Data.Vector3D(0, 5000, 0); VIZCore3D.NET.Data.Object3DProperty prop4 = vizcore3d.Object3D.GeometryProperty.FromNode(stage4[0], false); vizcore3d.Object3D.Transform.Move(stage4, v4); System.Threading.Thread.Sleep(500); if (showOriginalLocation == true) { ShowOriginalLocation(0, prop4, v4); } System.Threading.Thread.Sleep(200); List <VIZCore3D.NET.Data.Node> stage2 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_2" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v2 = new VIZCore3D.NET.Data.Vector3D(-5000, 0, 0); VIZCore3D.NET.Data.Object3DProperty prop2 = vizcore3d.Object3D.GeometryProperty.FromNode(stage2[0], false); vizcore3d.Object3D.Transform.Move(stage2, v2); System.Threading.Thread.Sleep(500); if (showOriginalLocation == true) { ShowOriginalLocation(1, prop2, v2); } System.Threading.Thread.Sleep(200); List <VIZCore3D.NET.Data.Node> stage3 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_3" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v3 = new VIZCore3D.NET.Data.Vector3D(8000, 0, 0); VIZCore3D.NET.Data.Object3DProperty prop3 = vizcore3d.Object3D.GeometryProperty.FromNode(stage3[0], false); vizcore3d.Object3D.Transform.Move(stage3, v3); System.Threading.Thread.Sleep(500); if (showOriginalLocation == true) { ShowOriginalLocation(2, prop3, v3); } vizcore3d.View.FitToView(); }
private void btnApply_Click(object sender, EventArgs e) { { VIZCore3D.NET.Data.CameraData camera = vizcore3d.View.GetCameraData(); VIZCore3D.NET.Data.Matrix3D matrix = new VIZCore3D.NET.Data.Matrix3D(camera.Matrix); VIZCore3D.NET.Data.Vector3D vector = matrix.GetRotation(); tbX.Value = (360 + Convert.ToInt32(vector.X)) % 360; tbY.Value = (360 + Convert.ToInt32(vector.Y)) % 360; tbZ.Value = (360 + Convert.ToInt32(vector.Z)) % 360; } this.DialogResult = DialogResult.OK; this.Close(); }
private void CustomMoveBaseSurface() { if (String.IsNullOrEmpty(txtBodyIndex1.Text) == true) { return; } int bodyIndex1 = Convert.ToInt32(txtBodyIndex1.Text); if (vizcore3d.Object3D.GetNodeKind(bodyIndex1) != Data.NodeKind.BODY) { return; } VIZCore3D.NET.Data.Vertex3D v = GetVertex(txtVertex1); VIZCore3D.NET.Data.Vertex3D line1 = GetVertex(txtVertex2); VIZCore3D.NET.Data.Vertex3D line2 = GetVertex(txtVertex3); VIZCore3D.NET.Data.Vertex3D plane = GetVertex(txtVertex4); VIZCore3D.NET.Data.Vector3D planeNormal = GetVector(txtVertex5); if (v == null) { return; } if (line1 == null) { return; } if (line2 == null) { return; } if (plane == null) { return; } if (planeNormal == null) { return; } vizcore3d.MeshEdit.MoveVertexToLineProjectionWithBaseSurface(bodyIndex1, v, line1, line2, plane, planeNormal); }
private void DrawLine(VIZCore3D.NET.Data.Vertex3D start, VIZCore3D.NET.Data.Vector3D normal) { vizcore3d.ShapeDrawing.DepthTest = true; VIZCore3D.NET.Data.Vertex3D end = VIZCore3D.NET.Data.Vector3D.FromVertex3D(start).PointToVector(normal, 1000.0f).ToVertex3D(); List <VIZCore3D.NET.Data.Vertex3DItemCollection> vertex = new List <VIZCore3D.NET.Data.Vertex3DItemCollection>(); Data.Vertex3DItemCollection item = new VIZCore3D.NET.Data.Vertex3DItemCollection(); item.Add(start); item.Add(end); vertex.Add(item); int shapeId = vizcore3d.ShapeDrawing.AddLine( vertex , 0 , Color.Orange , 5.0f , true ); }
private void View_OnViewDefaultMouseMoveEvent(object sender, MouseEventArgs e) { VIZCore3D.NET.Data.CameraData camera = vizcore3d.View.GetCameraData(); VIZCore3D.NET.Data.Matrix3D matrix = new Data.Matrix3D(camera.Matrix); VIZCore3D.NET.Data.Vector3D vector = matrix.GetRotation(); int x = Convert.ToInt32(vector.X); // X축 회전 각도 int y = Convert.ToInt32(vector.Y); // Y축 회전 각도 int z = Convert.ToInt32(vector.Z); // Z축 회전 각도 x = Math.Abs(x % 360); y = Math.Abs(y % 360); z = Math.Abs(z % 360); tbX.Value = x; tbY.Value = y; tbZ.Value = z; XOffset = x; YOffset = y; ZOffset = z; txtX.Invoke(new EventHandler(delegate { txtX.Text = x.ToString(); })); txtY.Invoke(new EventHandler(delegate { txtY.Text = y.ToString(); })); txtZ.Invoke(new EventHandler(delegate { txtZ.Text = z.ToString(); })); }
private void btnGetNormal3D_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtWorldX.Text) == true) { return; } if (String.IsNullOrEmpty(txtWorldY.Text) == true) { return; } if (String.IsNullOrEmpty(txtWorldZ.Text) == true) { return; } VIZCore3D.NET.Data.Vertex3D position = new VIZCore3D.NET.Data.Vertex3D( txtWorldX.Text , txtWorldY.Text , txtWorldZ.Text ); VIZCore3D.NET.Data.Vector3D normal = vizcore3d.View.GetSurfaceNormalVector(position); if (normal == null) { AddSurfaceData(false, false, position, new Data.Vector3D()); } else { AddSurfaceData(true, true, position, normal); DrawLine(position, normal); } }
private void btnGenerateAnimation_Click(object sender, EventArgs e) { if (vizcore3d.Model.IsOpen() == false) { return; } // 모델 데이터 맵핑 GetNodes(); ObjectProperty = new Dictionary <int, VIZCore3D.NET.Data.Object3DProperty>(); Transform = new Dictionary <int, Data.Vertex3D>(); vizcore3d.View.EnableAutoFit = false; /* 자동 화면맞춤 비활성 */ //vizcore3d.View.Projection = VIZCore3D.NET.Data.Projections.Perspective; /* 원근 뷰 설정 */ vizcore3d.Animation.UseEffect = false; /* 기본 효과 사용안함 설정 */ vizcore3d.Animation.Clear(); vizcore3d.Animation.Add("Animation"); //vizcore3d.ShowWaitForm(); vizcore3d.Object3D.Select(Data.Object3dSelectionModes.DESELECT_ALL); VIZCore3D.NET.Data.Vertex3D bay = new Data.Vertex3D(83772, -41271, 8664); vizcore3d.BeginUpdate(); foreach (KeyValuePair <int, List <VIZCore3D.NET.Data.Node> > item in Nodes) { if (item.Key <= 0) { continue; } VIZCore3D.NET.Data.Object3DProperty prop = vizcore3d.Object3D.GeometryProperty.FromNode(Nodes[item.Key], false); if (ObjectProperty.ContainsKey(item.Key) == false) { ObjectProperty.Add(item.Key, prop); } VIZCore3D.NET.Data.Vertex3D vec = new Data.Vertex3D(bay.X - prop.CenterPoint.X, bay.Y - prop.CenterPoint.Y, bay.Z - prop.MinPoint.Z); vizcore3d.Object3D.Transform.Move( Nodes[item.Key] , bay.X - prop.CenterPoint.X , bay.Y - prop.CenterPoint.Y , bay.Z - prop.MinPoint.Z , false ); Transform.Add(item.Key, vec); } foreach (KeyValuePair <int, List <VIZCore3D.NET.Data.Node> > item in Nodes) { if (item.Key <= 0) { continue; } vizcore3d.Object3D.Show(item.Value, false); } // 애니메이션 키 추가 AddKey(true, false, TimeInterval); Data.Object3DProperty propCrane = vizcore3d.Object3D.GeometryProperty.FromNode(Nodes[-7]); //for (int i = 1; i < 13; i++) foreach (KeyValuePair <int, List <VIZCore3D.NET.Data.Node> > item in Nodes) { if (item.Key <= 0) { continue; } int i = item.Key; Data.Vertex3D vecTrans = Transform[i]; // 블록 조회 vizcore3d.Object3D.Show(Nodes[i], true); // 애니메이션 키 추가 AddKey(true, false, TimeInterval); // 크레인 이동 (BAY) : 블록 위치로... MoveCrane(true, bay.X, 0.0f, 0.0f); // 크레인 호이스트 이동 : 블록 위치로... MoveCrane(false, bay.X, bay.Y, 0.0f); Data.Object3DProperty propModel = vizcore3d.Object3D.GeometryProperty.FromNode(Nodes[i]); float fOffset = propCrane.MinPoint.Z - propModel.MaxPoint.Z - 5000f; // 크레인 호이스트 : Bring To Bottom DownCrane(false, Nodes[i], fOffset); // 블록 : Bring To Top UpCrane(true, Nodes[i], fOffset); // 블록 : Bring To Center(Y) VIZCore3D.NET.Data.Vector3D tran3 = new VIZCore3D.NET.Data.Vector3D(0, -vecTrans.Y, 0); vizcore3d.Object3D.Transform.Move(Nodes[i], tran3, false); // 크레인 호이스트 이동 MoveCrane(false, bay.X, ObjectProperty[i].CenterPoint.Y, 0.0f); VIZCore3D.NET.Data.Vector3D tran4 = new VIZCore3D.NET.Data.Vector3D(-vecTrans.X, 0, 0); vizcore3d.Object3D.Transform.Move(Nodes[i], tran4, false); // 크레인 이동 (BAY) // 크레인 호이스트 이동 MoveCrane(true, ObjectProperty[i].CenterPoint.X, 0.0f, 0.0f); Data.Object3DProperty propModelO = ObjectProperty[i]; Data.Object3DProperty propModelC = vizcore3d.Object3D.GeometryProperty.FromNode(Nodes[i]); fOffset = propCrane.MinPoint.Z - propModelO.MaxPoint.Z - 5000f; // 크레인 호이스트 : Bring To Bottom DownCrane(true, Nodes[i], fOffset); // 블록 : Bring To Top UpCrane(false, null, fOffset); } AddKey(true, false, TimeInterval); vizcore3d.EndUpdate(); //vizcore3d.CloseWaitForm(); MessageBox.Show("Animation Created.", "VIZCore3D.NET", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void AddSurfaceData(bool pick, bool surface, VIZCore3D.NET.Data.Vertex3D position, VIZCore3D.NET.Data.Vector3D normal) { ListViewItem lvi = new ListViewItem( new string[] { pick == true ? "True" : "False" , surface == true ? "True" : "False" , position.ToString() , normal.ToString() } ); lvItems.Items.Add(lvi); }
private void btnDisassemblyGhost_Click(object sender, EventArgs e) { List <VIZCore3D.NET.Data.Node> stage41 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_4_1" }, false, true, false, false, true, false); vizcore3d.Object3D.Color.SetColorAndAlpha(stage41, Color.White, 20); List <VIZCore3D.NET.Data.Node> stage4 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_4" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v4 = new VIZCore3D.NET.Data.Vector3D(0, 5000, 0); VIZCore3D.NET.Data.Object3DProperty prop4 = vizcore3d.Object3D.GeometryProperty.FromNode(stage4[0], false); vizcore3d.Object3D.Transform.Move(stage4, v4); System.Threading.Thread.Sleep(500); List <VIZCore3D.NET.Data.Node> stage21 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_2_1" }, false, true, false, false, true, false); vizcore3d.Object3D.Color.SetColorAndAlpha(stage21, Color.White, 20); List <VIZCore3D.NET.Data.Node> stage2 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_2" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v2 = new VIZCore3D.NET.Data.Vector3D(-5000, 0, 0); VIZCore3D.NET.Data.Object3DProperty prop2 = vizcore3d.Object3D.GeometryProperty.FromNode(stage2[0], false); vizcore3d.Object3D.Transform.Move(stage2, v2); System.Threading.Thread.Sleep(500); List <VIZCore3D.NET.Data.Node> stage31 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_3_1" }, false, true, false, false, true, false); vizcore3d.Object3D.Color.SetColorAndAlpha(stage31, Color.White, 20); List <VIZCore3D.NET.Data.Node> stage3 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_3" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v3 = new VIZCore3D.NET.Data.Vector3D(8000, 0, 0); VIZCore3D.NET.Data.Object3DProperty prop3 = vizcore3d.Object3D.GeometryProperty.FromNode(stage3[0], false); vizcore3d.Object3D.Transform.Move(stage3, v3); System.Threading.Thread.Sleep(500); List <VIZCore3D.NET.Data.Node> stage11 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_1_1" }, false, true, false, false, true, false); vizcore3d.Object3D.Color.SetColorAndAlpha(stage11, Color.White, 20); List <VIZCore3D.NET.Data.Node> stage1 = vizcore3d.Object3D.Find.QuickSearch(new List <string>() { "STAGE_1" }, false, true, false, false, true, false); VIZCore3D.NET.Data.Vector3D v1 = new VIZCore3D.NET.Data.Vector3D(0, 0, 5000); VIZCore3D.NET.Data.Object3DProperty prop1 = vizcore3d.Object3D.GeometryProperty.FromNode(stage3[0], false); vizcore3d.Object3D.Transform.Move(stage1, v1); System.Threading.Thread.Sleep(500); vizcore3d.View.FitToView(); }
private void ShowOriginalLocation(int index, VIZCore3D.NET.Data.Object3DProperty prop, VIZCore3D.NET.Data.Vector3D v) { List <Color> color = new List <Color>(); color.Add(Color.FromArgb(10, 255, 0, 0)); color.Add(Color.FromArgb(10, 0, 255, 0)); color.Add(Color.FromArgb(10, 0, 0, 255)); vizcore3d.SelectionBox.Add(prop.GetBoundBox(), color[index], Color.FromArgb(100, 255, 255, 255), ""); VIZCore3D.NET.Data.Vertex3DItemCollection items = new VIZCore3D.NET.Data.Vertex3DItemCollection(); items.Add(prop.CenterPoint); items.Add(prop.CenterPoint + v.ToVertex3D()); vizcore3d.ShapeDrawing.AddLine( new List <Data.Vertex3DItemCollection>() { items } , 0 , Color.Red , 5.0f , true ); }
private void btnTest_Click(object sender, EventArgs e) { VIZCore3D.NET.Data.Vertex3D center = new VIZCore3D.NET.Data.Vertex3D(txtCenterX.Text, txtCenterY.Text, txtCenterZ.Text); VIZCore3D.NET.Data.Vector3D dir = new VIZCore3D.NET.Data.Vector3D(txtDirX.Text, txtDirY.Text, txtDirZ.Text); VIZCore3D.NET.Data.Vector3D up = new VIZCore3D.NET.Data.Vector3D(txtUpX.Text, txtUpY.Text, txtUpZ.Text); System.Drawing.Color fontColor = btnFontColor.BackColor; int heightStart = Convert.ToInt32(txtHeight1.Text); int heightEnd = Convert.ToInt32(txtHeight2.Text); int sizeStart = Convert.ToInt32(txtSize1.Text); int sizeEnd = Convert.ToInt32(txtSize2.Text); int offsetHeight = Convert.ToInt32(txtOffsetHeight.Text); int offsetSize = Convert.ToInt32(txtOffsetSize.Text); bool fixingHeight = rbFixingHeight.Checked; bool fixingSize = rbFixingSize.Checked; vizcore3d.BeginUpdate(); lvItems.BeginUpdate(); if (fixingHeight == true) { int step = (sizeEnd - sizeStart) / offsetSize; for (int i = 0; i < step; i++) { int itemSize = sizeStart + (i * offsetSize); VIZCore3D.NET.Data.Vertex3D itemCenter = new VIZCore3D.NET.Data.Vertex3D(center.X, center.Y - (heightStart * i), center.Z); string title = string.Format("Height: {0} / Size: {1}", heightStart, itemSize); VIZCore3D.NET.Data.TextDrawingItem item = vizcore3d.TextDrawing.Add( itemCenter , dir , up , heightStart , itemSize , fontColor , title ); //AddList(item); } } else { int step = (heightEnd - heightStart) / offsetHeight; for (int i = 0; i < step; i++) { int itemHeight = heightStart + (i * offsetHeight); VIZCore3D.NET.Data.Vertex3D itemCenter = new VIZCore3D.NET.Data.Vertex3D(center.X, center.Y - (itemHeight * i), center.Z); string title = string.Format("Height: {0} / Size: {1}", itemHeight, sizeStart); VIZCore3D.NET.Data.TextDrawingItem item = vizcore3d.TextDrawing.Add( itemCenter , dir , up , itemHeight , sizeStart , fontColor , title ); //AddList(item); } } lvItems.EndUpdate(); vizcore3d.EndUpdate(); }
private void btnApply_Click(object sender, EventArgs e) { InitModelTransform(); vizcore3d.View.EnableAnimation = false; //vizcore3d.View.Projection = VIZCore3D.NET.Data.Projections.Perspective; //vizcore3d.View.FitToView(); vizcore3d.View.FOV = 74.0f; // 45 ~ 74 float height = Convert.ToSingle(txtHeight.Text) * 1000.0f; float distance = 1000.0f; if (rbDistance10.Checked == true) { distance *= 10; } else if (rbDistance13.Checked == true) { distance *= 13; } else if (rbDistance16.Checked == true) { distance *= 16; } else if (rbDistance19.Checked == true) { distance *= 19; } else if (rbDistance25.Checked == true) { distance *= 25; } float angle = 0.0f; if (rbAngle42.Checked == true) { angle = 42.6f; } if (rbAngle38.Checked == true) { angle = 38.4f; } if (rbAngle35.Checked == true) { angle = 35.6f; } if (rbAngle33.Checked == true) { angle = 33.7f; } if (rbAngle30.Checked == true) { angle = 30.1f; } int transform = Convert.ToInt32(cbTransform.Text); /* * // Camera Position * VIZCore3D.NET.Data.Vertex3D v = new VIZCore3D.NET.Data.Vertex3D(0, distance, height); * * // Move Camera * vizcore3d.View.MoveCamera(v, 0.0f, false); * * // Rotate Camera * vizcore3d.View.RotateCameraByAxis( * VIZCore3D.NET.Data.BaseAxis.WORLD * , VIZCore3D.NET.Data.Axis.X * , VIZCore3D.NET.Data.Directions.PLUS * , angle); * * // Rotate Model * vizcore3d.Object3D.Transform.Rotate(new List<int>() { 0 }, 0, 0, transform, true, false); */ // Camera Position VIZCore3D.NET.Data.Vector3D camera = vizcore3d.View.GetCameraEyePosition(); // Model Center VIZCore3D.NET.Data.BoundBox3D boundBox = vizcore3d.Model.BoundBox; VIZCore3D.NET.Data.Vertex3D position = new VIZCore3D.NET.Data.Vertex3D( camera.X , camera.Y - distance , camera.Z - (boundBox.LengthZ * 0.5f) - height //, boundBox.MinZ - height ); vizcore3d.Object3D.Transform.MoveTo( new List <int>() { 0 } , position ); // Rotate Camera /* * vizcore3d.View.RotateCameraByAxis( * VIZCore3D.NET.Data.BaseAxis.LOCAL * , VIZCore3D.NET.Data.Axis.X * , VIZCore3D.NET.Data.Directions.MINUS * , angle); */ //vizcore3d.View.RotateCameraByAxis( // VIZCore3D.NET.Data.BaseAxis.WORLD // , VIZCore3D.NET.Data.Axis.X // , VIZCore3D.NET.Data.Directions.PLUS // , angle); //vizcore3d.View.RotateCameraByScreenAxis(-angle, 0, 0); // Rotate Model vizcore3d.Object3D.Transform.Rotate(new List <int>() { 0 }, 0, 0, -transform, true, false); }
public ClashItem(VIZCore3D.NET.Data.Vector3D v) { Completed = false; Translation = v; ClashID = -1; }