コード例 #1
0
        private void AdjustChildSize(object sender, EventArgs e)
        {
            if (Children.Count > 0)
            {
                var aabb = UntransformedChildren.GetAxisAlignedBoundingBox();
                ItemWithTransform.Matrix = Matrix4X4.Identity;
                var scale  = Vector3.One;
                var width  = Width.Value(this);
                var depth  = Depth.Value(this);
                var height = Height.Value(this);
                if (StretchX)
                {
                    scale.X = width / aabb.XSize;
                }
                if (StretchY)
                {
                    scale.Y = depth / aabb.YSize;
                }
                if (StretchZ)
                {
                    scale.Z = height / aabb.ZSize;
                }

                switch (LockProportion)
                {
                case LockProportions.None:
                    break;

                case LockProportions.X_Y:
                    var minXy = Math.Min(scale.X, scale.Y);
                    scale.X = minXy;
                    scale.Y = minXy;
                    break;

                case LockProportions.X_Y_Z:
                    var minXyz = Math.Min(Math.Min(scale.X, scale.Y), scale.Z);
                    scale.X = minXyz;
                    scale.Y = minXyz;
                    scale.Z = minXyz;
                    break;
                }

                if (aabb.XSize > 0 && aabb.YSize > 0 && aabb.ZSize > 0)
                {
                    ItemWithTransform.Matrix = Object3DExtensions.ApplyAtPosition(ItemWithTransform.Matrix, aabb.Center, Matrix4X4.CreateScale(scale));
                }
            }
        }
コード例 #2
0
        private void AdjustChildSize(object sender, EventArgs e)
        {
            var aabb = ItemToScale.GetAxisAlignedBoundingBox();

            ScaleItem.Matrix = Matrix4X4.Identity;
            var scale = Vector3.One;

            if (StretchX)
            {
                scale.X = Width / aabb.XSize;
            }

            if (StretchY)
            {
                scale.Y = Depth / aabb.YSize;
            }

            if (StretchZ)
            {
                scale.Z = Height / aabb.ZSize;
            }

            switch (MaintainRatio)
            {
            case MaintainRatio.None:
                break;

            case MaintainRatio.X_Y:
                var minXy = Math.Min(scale.X, scale.Y);
                scale.X = minXy;
                scale.Y = minXy;
                break;

            case MaintainRatio.X_Y_Z:
                var minXyz = Math.Min(Math.Min(scale.X, scale.Y), scale.Z);
                scale.X = minXyz;
                scale.Y = minXyz;
                scale.Z = minXyz;
                break;
            }

            ScaleItem.Matrix = Object3DExtensions.ApplyAtPosition(ScaleItem.Matrix, aabb.Center, Matrix4X4.CreateScale(scale));
        }
コード例 #3
0
        private void AdjustChildSize(object sender, EventArgs e)
        {
            if (Children.Count > 0)
            {
                var aabb = UntransformedChildren.GetAxisAlignedBoundingBox();
                ItemWithTransform.Matrix = Matrix4X4.Identity;
                var scale = Vector3.One;
                if (StretchZ)
                {
                    scale.Z = SizeZ / aabb.ZSize;
                }

                var minXy = Math.Min(scale.X, scale.Y);
                scale.X = minXy;
                scale.Y = minXy;

                ItemWithTransform.Matrix = Object3DExtensions.ApplyAtPosition(ItemWithTransform.Matrix, aabb.Center, Matrix4X4.CreateScale(scale));
            }
        }
コード例 #4
0
        private void AdjustChildSize(object sender, EventArgs e)
        {
            if (Children.Count > 0)
            {
                var aabb = SourceItem.GetAxisAlignedBoundingBox();
                TransformItem.Matrix = Matrix4X4.Identity;
                var scale = Vector3.One;
                if (StretchX)
                {
                    scale.X = SizeX / aabb.XSize;
                }
                if (StretchY)
                {
                    scale.Y = SizeY / aabb.YSize;
                }
                if (StretchZ)
                {
                    scale.Z = SizeZ / aabb.ZSize;
                }

                switch (MaintainRatio)
                {
                case MaintainRatio.None:
                    break;

                case MaintainRatio.X_Y:
                    var minXy = Math.Min(scale.X, scale.Y);
                    scale.X = minXy;
                    scale.Y = minXy;
                    break;

                case MaintainRatio.X_Y_Z:
                    var minXyz = Math.Min(Math.Min(scale.X, scale.Y), scale.Z);
                    scale.X = minXyz;
                    scale.Y = minXyz;
                    scale.Z = minXyz;
                    break;
                }

                TransformItem.Matrix = Object3DExtensions.ApplyAtPosition(TransformItem.Matrix, aabb.Center, Matrix4X4.CreateScale(scale));
            }
        }