コード例 #1
0
        public void LoadMesh(string meshPathAndFileName, CenterPartAfterLoad centerPart, Vector2 bedCenter = new Vector2())
        {
            if (File.Exists(meshPathAndFileName))
            {
                partProcessingInfo.Visible = true;
                partProcessingInfo.progressControl.PercentComplete = 0;

                backgroundWorker = new BackgroundWorker();
                backgroundWorker.WorkerSupportsCancellation = true;

                backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);

                backgroundWorker.DoWork += (object sender, DoWorkEventArgs e) =>
                {
                    List <MeshGroup> loadedMeshGroups = MeshFileIo.Load(meshPathAndFileName, reportProgress0to100);
                    SetMeshAfterLoad(loadedMeshGroups, centerPart, bedCenter);
                    e.Result = loadedMeshGroups;
                };
                backgroundWorker.RunWorkerAsync();
                partProcessingInfo.centeredInfoText.Text = "Loading Mesh...";
            }
            else
            {
                partProcessingInfo.centeredInfoText.Text = string.Format("{0}\n'{1}'", "File not found on disk.", Path.GetFileName(meshPathAndFileName));
            }
        }
コード例 #2
0
        public void SetMeshAfterLoad(List <MeshGroup> loadedMeshGroups, CenterPartAfterLoad centerPart, Vector2 bedCenter)
        {
            MeshGroups.Clear();

            if (loadedMeshGroups == null)
            {
                partProcessingInfo.centeredInfoText.Text = string.Format("Sorry! No 3D view available\nfor this file.");
            }
            else
            {
                CreateGlDataForMeshes(loadedMeshGroups);

                AxisAlignedBoundingBox bounds = new AxisAlignedBoundingBox(Vector3.Zero, Vector3.Zero);
                bool first = true;
                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    if (first)
                    {
                        bounds = meshGroup.GetAxisAlignedBoundingBox();
                        first  = false;
                    }
                    else
                    {
                        bounds = AxisAlignedBoundingBox.Union(bounds, meshGroup.GetAxisAlignedBoundingBox());
                    }
                }

                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    // make sure the mesh is centered about the origin so rotations will come from a reasonable place
                    ScaleRotateTranslate centering = ScaleRotateTranslate.Identity();
                    centering.SetCenteringForMeshGroup(meshGroup);
                    meshTransforms.Add(centering);
                    MeshGroups.Add(meshGroup);
                }

                if (centerPart == CenterPartAfterLoad.DO)
                {
                    // make sure the entire load is centered and on the bed
                    Vector3 boundsCenter = (bounds.maxXYZ + bounds.minXYZ) / 2;
                    for (int i = 0; i < MeshGroups.Count; i++)
                    {
                        ScaleRotateTranslate moved = meshTransforms[i];
                        moved.translation *= Matrix4X4.CreateTranslation(-boundsCenter + new Vector3(0, 0, bounds.ZSize / 2) + new Vector3(bedCenter));
                        meshTransforms[i]  = moved;
                    }
                }

                trackballTumbleWidget.TrackBallController = new TrackBallController();
                trackballTumbleWidget.OnBoundsChanged(null);
                trackballTumbleWidget.TrackBallController.Scale = .03;
                trackballTumbleWidget.TrackBallController.Translate(-new Vector3(BedCenter));
                trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(0, 0, MathHelper.Tau / 16)));
                trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(-MathHelper.Tau * .19, 0, 0)));
            }
        }
コード例 #3
0
        public void SetMeshAfterLoad(List <MeshGroup> loadedMeshGroups, CenterPartAfterLoad centerPart, Vector2 bedCenter)
        {
            MeshGroups.Clear();

            if (loadedMeshGroups == null)
            {
                partProcessingInfo.centeredInfoText.Text = string.Format("Sorry! No 3D view available\nfor this file.");
            }
            else
            {
                CreateGlDataForMeshes(loadedMeshGroups);

                AxisAlignedBoundingBox bounds = new AxisAlignedBoundingBox(Vector3.Zero, Vector3.Zero);
                bool first = true;
                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    if (first)
                    {
                        bounds = meshGroup.GetAxisAlignedBoundingBox();
                        first  = false;
                    }
                    else
                    {
                        bounds = AxisAlignedBoundingBox.Union(bounds, meshGroup.GetAxisAlignedBoundingBox());
                    }
                }

                // add all the loaded meshes
                foreach (MeshGroup meshGroup in loadedMeshGroups)
                {
                    meshTransforms.Add(Matrix4X4.Identity);
                    MeshGroups.Add(meshGroup);
                }

                if (centerPart == CenterPartAfterLoad.DO)
                {
                    // make sure the entire load is centered and on the bed
                    Vector3 boundsCenter = (bounds.maxXYZ + bounds.minXYZ) / 2;
                    for (int i = 0; i < MeshGroups.Count; i++)
                    {
                        meshTransforms[i] *= Matrix4X4.CreateTranslation(-boundsCenter + new Vector3(0, 0, bounds.ZSize / 2) + new Vector3(bedCenter));
                    }
                }

                trackballTumbleWidget.TrackBallController = new TrackBallController();
                trackballTumbleWidget.OnBoundsChanged(null);

                ResetView();
            }
        }
コード例 #4
0
		public void SetMeshAfterLoad(List<MeshGroup> loadedMeshGroups, CenterPartAfterLoad centerPart, Vector2 bedCenter)
		{
			MeshGroups.Clear();

			if (loadedMeshGroups == null)
			{
				partProcessingInfo.centeredInfoText.Text = string.Format("Sorry! No 3D view available\nfor this file.");
			}
			else
			{
				CreateGlDataForMeshes(loadedMeshGroups);

				AxisAlignedBoundingBox bounds = new AxisAlignedBoundingBox(Vector3.Zero, Vector3.Zero);
				bool first = true;
				foreach (MeshGroup meshGroup in loadedMeshGroups)
				{
					if (first)
					{
						bounds = meshGroup.GetAxisAlignedBoundingBox();
						first = false;
					}
					else
					{
						bounds = AxisAlignedBoundingBox.Union(bounds, meshGroup.GetAxisAlignedBoundingBox());
					}
				}

				foreach (MeshGroup meshGroup in loadedMeshGroups)
				{
					// make sure the mesh is centered about the origin so rotations will come from a reasonable place
					ScaleRotateTranslate centering = ScaleRotateTranslate.Identity();
					centering.SetCenteringForMeshGroup(meshGroup);
					meshTransforms.Add(centering);
					MeshGroups.Add(meshGroup);
				}

				if (centerPart == CenterPartAfterLoad.DO)
				{
					// make sure the entire load is centered and on the bed
					Vector3 boundsCenter = (bounds.maxXYZ + bounds.minXYZ) / 2;
					for (int i = 0; i < MeshGroups.Count; i++)
					{
						ScaleRotateTranslate moved = meshTransforms[i];
						moved.translation *= Matrix4X4.CreateTranslation(-boundsCenter + new Vector3(0, 0, bounds.ZSize / 2) + new Vector3(bedCenter));
						meshTransforms[i] = moved;
					}
				}
				
				trackballTumbleWidget.TrackBallController = new TrackBallController();
				trackballTumbleWidget.OnBoundsChanged(null);
				trackballTumbleWidget.TrackBallController.Scale = .03;
				trackballTumbleWidget.TrackBallController.Translate(-new Vector3(BedCenter));
				trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(0, 0, MathHelper.Tau / 16)));
				trackballTumbleWidget.TrackBallController.Rotate(Quaternion.FromEulerAngles(new Vector3(-MathHelper.Tau * .19, 0, 0)));
			}
		}
コード例 #5
0
		public void LoadMesh(string meshPathAndFileName, CenterPartAfterLoad centerPart, Vector2 bedCenter = new Vector2())
		{
			if (File.Exists(meshPathAndFileName))
			{
				partProcessingInfo.Visible = true;
				partProcessingInfo.progressControl.PercentComplete = 0;

				backgroundWorker = new BackgroundWorker();
				backgroundWorker.WorkerSupportsCancellation = true;

				backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);

				backgroundWorker.DoWork += (object sender, DoWorkEventArgs e) =>
				{
					List<MeshGroup> loadedMeshGroups = MeshFileIo.Load(meshPathAndFileName, reportProgress0to100);
					SetMeshAfterLoad(loadedMeshGroups, centerPart, bedCenter);
					e.Result = loadedMeshGroups;
				};
				backgroundWorker.RunWorkerAsync();
				partProcessingInfo.centeredInfoText.Text = "Loading Mesh...";
			}
			else
			{
				partProcessingInfo.centeredInfoText.Text = string.Format("{0}\n'{1}'", "File not found on disk.", Path.GetFileName(meshPathAndFileName));
			}
		}