Esempio n. 1
0
		public static async Task<CylinderObject3D> Create()
		{
			var item = new CylinderObject3D();

			await item.Rebuild();
			return item;
		}
Esempio n. 2
0
        public static CylinderObject3D Create()
        {
            var item = new CylinderObject3D();

            item.Rebuild(null);
            return(item);
        }
Esempio n. 3
0
        public async override Task Rebuild()
        {
            using (RebuildLock())
            {
                using (new CenterAndHeightMaintainer(this))
                {
                    // validate the some of the values and store in user data if changed
                    InnerDiameter = ValidateValue(InnerDiameter, "PipeWorksInnerDiameter", 15);
                    OuterDiameter = ValidateValue(OuterDiameter, "PipeWorksOuterDiameter", 20);
                    BottomReach   = ValidateValue(BottomReach, "PipeWorksBottomReach", 30);
                    FrontReach    = ValidateValue(FrontReach, "PipeWorksFrontReach", 25);
                    TopReach      = ValidateValue(TopReach, "PipeWorksTopReach", 30);

                    IObject3D topBottomConnect = await CylinderObject3D.Create(OuterDiameter, OuterDiameter, Sides, Alignment.Y);

                    IObject3D frontConnect = await CylinderObject3D.Create(OuterDiameter, OuterDiameter, Sides, Alignment.X);

                    frontConnect = new AlignObject3D(frontConnect, FaceAlign.Right, topBottomConnect, FaceAlign.Right);

                    IObject3D bottomReach = new RotateObject3D(CreateReach(BottomReach, InnerDiameter), -MathHelper.Tau / 4);
                    bottomReach = new AlignObject3D(bottomReach, FaceAlign.Back, topBottomConnect, FaceAlign.Front, 0, .02);

                    IObject3D topReach = new RotateObject3D(CreateReach(TopReach, InnerDiameter), MathHelper.Tau / 4);
                    topReach = new AlignObject3D(topReach, FaceAlign.Front, topBottomConnect, FaceAlign.Back, 0, -.02);

                    IObject3D frontReach = new RotateObject3D(CreateReach(FrontReach, InnerDiameter), 0, -MathHelper.Tau / 4);
                    frontReach = new AlignObject3D(frontReach, FaceAlign.Left, topBottomConnect, FaceAlign.Right, -.02);

                    // output multiple meshes for pipe connector
                    this.Children.Modify(list =>
                    {
                        list.Clear();
                        list.Add(topBottomConnect);
                        list.Add(frontConnect);
                        list.Add(bottomReach);
                        list.Add(topReach);
                        list.Add(frontReach);
                    });

                    this.Color = Color.Transparent;
                    this.Mesh  = null;
                }
            }

            Invalidate(InvalidateType.Children);
        }
Esempio n. 4
0
        public static async Task <CylinderObject3D> Create(double diameterBottom, double diameterTop, double height, int sides, Alignment alignment = Alignment.Z)
        {
            var item = new CylinderObject3D()
            {
                Advanced    = true,
                Diameter    = diameterBottom,
                DiameterTop = diameterTop,
                Height      = height,
                Sides       = sides,
            };

            await item.Rebuild();

            switch (alignment)
            {
            case Alignment.X:
                item.Matrix = Matrix4X4.CreateRotationY(MathHelper.Tau / 4);
                break;

            case Alignment.Y:
                item.Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 4);
                break;

            case Alignment.Z:
                // This is the natural case (how it was modeled)
                break;

            case Alignment.negX:
                item.Matrix = Matrix4X4.CreateRotationY(-MathHelper.Tau / 4);
                break;

            case Alignment.negY:
                item.Matrix = Matrix4X4.CreateRotationX(-MathHelper.Tau / 4);
                break;

            case Alignment.negZ:
                item.Matrix = Matrix4X4.CreateRotationX(MathHelper.Tau / 2);
                break;
            }

            return(item);
        }
Esempio n. 5
0
        public override async Task Rebuild()
        {
            this.DebugDepth("Rebuild");

            using (RebuildLock())
            {
                var currentAssetPath = ImageObject == null?AggContext.StaticData.ToAssetPath(Path.Combine("Images", "mh-logo.png")) : ImageObject.AssetPath;

                this.Children.Modify((list) =>
                {
                    list.Clear();
                });

                var imageObject = new ImageObject3D()
                {
                    AssetPath = currentAssetPath,
                };

                await imageObject.Rebuild();

                this.Children.Add(imageObject);

                IObject3D logoBase = new CylinderObject3D(outerDiameter, 3, 60);
                IObject3D logoRing = new AlignObject3D(new RingObject3D(outerDiameter, innerDiameter, 2, 60), FaceAlign.Bottom, logoBase, FaceAlign.Top);

                IObject3D coinBlank = logoBase.Plus(logoRing);
                if (CreateHook)
                {
                    var cube = await CubeObject3D.Create(4, 2, 4);

                    IObject3D connect = logoBase.Plus(new AlignObject3D(cube, FaceAlign.Front | FaceAlign.Bottom, logoBase, FaceAlign.Back | FaceAlign.Bottom, 0, -.5));
                    IObject3D hook    = logoBase.Plus(new AlignObject3D(new RingObject3D(10, 7, 5, 30), FaceAlign.Front | FaceAlign.Bottom, connect, FaceAlign.Back | FaceAlign.Bottom, 0, -.5));

                    coinBlank = coinBlank.Plus(connect);
                    coinBlank = coinBlank.Plus(hook);
                }

                var imageToPath = new ImageToPathObject3D();

                imageToPath.Children.Add(imageObject);

                await imageToPath.Rebuild();

                var inputShape = imageToPath.VertexSource;

                if (Inflate != 0)
                {
                    var bounds = inputShape.GetBounds();
                    var scale  = Math.Max(bounds.Width, bounds.Height) / (17 * 4);
                    inputShape = inputShape.Offset(Inflate * scale);
                }

                if (AlternateCentering)
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, GetCenteringTransformVisualCenter(inputShape, innerDiameter / 2));
                }
                else
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, GetCenteringTransformExpandedToRadius(inputShape, innerDiameter / 2));
                }

                if (ScalePercent != 100 &&
                    ScalePercent != 0)
                {
                    inputShape = new VertexSourceApplyTransform(inputShape, Affine.NewScaling(ScalePercent / 100.0));
                }

                if (NegativeSpace)
                {
                    var disk = new Ellipse(0, 0, innerDiameter / 2 + .2, innerDiameter / 2 + .2)
                    {
                        ResolutionScale = 1000
                    };
                    inputShape = disk.Minus(inputShape);
                }

                imageToPath.VertexSource = inputShape;

                var pathExtrusion = new LinearExtrudeObject3D();
                pathExtrusion.Children.Add(imageToPath);
                await pathExtrusion.Rebuild();

                IObject3D extrusionObject = imageObject;

                var loadingScale = 32 / extrusionObject.XSize();
                extrusionObject = new ScaleObject3D(extrusionObject, loadingScale, loadingScale, 1 / extrusionObject.ZSize());
                extrusionObject = PlaceOnBase(logoBase, extrusionObject);

                this.Children.Add(coinBlank);
                this.Children.Add(extrusionObject);
            }

            Invalidate(InvalidateType.Mesh);
        }
Esempio n. 6
0
        public override async Task Rebuild()
        {
            using (RebuildLock())
            {
                using (new CenterAndHeightMaintainer(this))
                {
                    // validate the some of the values and store in user data if changed
                    InnerDiameter = ValidateValue(InnerDiameter, "PipeWorksInnerDiameter", 15);
                    OuterDiameter = ValidateValue(OuterDiameter, "PipeWorksOuterDiameter", 20);
                    BottomReach   = ValidateValue(BottomReach, "PipeWorksBottomReach", 30);
                    FrontReach    = ValidateValue(FrontReach, "PipeWorksFrontReach", 25);

                    IObject3D bottomReach  = new RotateObject3D(CreateReach(BottomReach, InnerDiameter), -MathHelper.Tau / 4);
                    IObject3D frontReach   = null;
                    IObject3D elbowConnect = null;
                    if (Angle < 90)
                    {
                        frontReach = bottomReach.Clone();

                        var translate = new Vector3(-OuterDiameter / 2, 0, 0);
                        bottomReach.Translate(translate);

                        frontReach = new RotateObject3D(frontReach, 0, 0, -MathHelper.DegreesToRadians(Angle));
                        translate  = Vector3Ex.Transform(-translate, Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(Angle)));
                        frontReach.Translate(translate);

                        var torus = new TorusObject3D();

                        using (torus.RebuildLock())
                        {
                            torus.Advanced      = true;
                            torus.InnerDiameter = 0;
                            OuterDiameter       = OuterDiameter * 2;
                            torus.RingSides     = Sides;
                            torus.Sides         = Sides;
                            torus.StartingAngle = Angle;
                            torus.EndingAngle   = 180;
                        }

                        torus.Invalidate(new InvalidateArgs(torus, InvalidateType.Properties));
                        elbowConnect = torus;
                    }
                    else if (Angle < 270)
                    {
                        bottomReach.Translate(0, -OuterDiameter / 2, 0);
                        IObject3D reachConnect = await CylinderObject3D.Create(OuterDiameter, OuterDiameter, Sides, Alignment.Y);

                        reachConnect = new AlignObject3D(reachConnect, FaceAlign.Front, bottomReach, FaceAlign.Back);
                        reachConnect = new SetCenterObject3D(reachConnect, bottomReach.GetCenter(), true, false, true);
                        bottomReach  = bottomReach.Plus(reachConnect);

                        frontReach = bottomReach.Clone();
                        frontReach = new RotateObject3D(frontReach, 0, 0, -MathHelper.DegreesToRadians(Angle));

                        elbowConnect = new SphereObject3D(OuterDiameter, Sides);
                    }

                    // output multiple meshes for pipe connector
                    this.Children.Modify(list =>
                    {
                        list.Clear();
                        list.Add(elbowConnect);
                        list.Add(bottomReach);
                        list.Add(frontReach);
                    });

                    this.Color = Color.Transparent;
                    this.Mesh  = null;
                }
            }

            Invalidate(InvalidateType.Children);
        }