示例#1
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)));
            }
        }
 private void DeleteSelectedMesh()
 {
     // don't ever delet the last mesh
     if (MeshGroups.Count > 1)
     {
         MeshGroups.RemoveAt(SelectedMeshGroupIndex);
         MeshGroupExtraData.RemoveAt(SelectedMeshGroupIndex);
         MeshGroupTransforms.RemoveAt(SelectedMeshGroupIndex);
         SelectedMeshGroupIndex    = Math.Min(SelectedMeshGroupIndex, MeshGroups.Count - 1);
         saveButton.Visible        = true;
         saveAndExitButton.Visible = true;
         Invalidate();
     }
 }
示例#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();
            }
        }
 private void PullMeshDataFromAsynchLists()
 {
     MeshGroups.Clear();
     foreach (MeshGroup mesh in asynchMeshGroups)
     {
         MeshGroups.Add(mesh);
     }
     MeshGroupTransforms.Clear();
     foreach (ScaleRotateTranslate transform in asynchMeshGroupTransforms)
     {
         MeshGroupTransforms.Add(transform);
     }
     MeshGroupExtraData.Clear();
     foreach (PlatingMeshGroupData meshData in asynchPlatingDatas)
     {
         MeshGroupExtraData.Add(meshData);
     }
 }