Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }