public static ScaleRotateTranslate CreateTranslation(double x, double y, double z)
        {
            ScaleRotateTranslate translation = ScaleRotateTranslate.Identity();

            translation.translation = Matrix4X4.CreateTranslation(x, y, z);
            return(translation);
        }
        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)));
            }
        }