Esempio n. 1
0
        public override MeshDraft GetMeshDraft()
        {
            var draft = new MeshDraft().AddQuad(origin.Value, Vector3.right * width.Value, Vector3.up * height.Value);

            draft.Paint(wallColor);
            return(draft);
        }
Esempio n. 2
0
        private static MeshDraft BalconyWallPanel(Vector3 origin, Vector3 widthVector, Vector3 heightVector, Vector3 windowDepth,
                                                  List <Vector3> outerFrame, Color wallColor)
        {
            var wall = new MeshDraft {
                name = WallDraftName
            }
            .AddTriangleStrip(new List <Vector3>
            {
                outerFrame[0],
                origin,
                outerFrame[5],
                origin + heightVector,
                outerFrame[4],
                origin + widthVector + heightVector,
                outerFrame[3],
                origin + widthVector,
                outerFrame[2],
                origin + widthVector,
                outerFrame[1]
            });

            var innerFrame = new List <Vector3>();

            foreach (Vector3 vertex in outerFrame)
            {
                innerFrame.Add(vertex + windowDepth);
            }
            wall.AddFlatQuadBand(innerFrame, outerFrame, false);
            wall.Paint(wallColor);
            return(wall);
        }
Esempio n. 3
0
        protected static MeshDraft SocleWindowed(Vector3 origin, float width, float height, Color wallColor,
                                                 Color glassColor)
        {
            Vector3 widthVector  = Vector3.right * width;
            Vector3 heightVector = Vector3.up * height;

            Vector3 windowWidth  = Vector3.right * SocleWindowWidth;
            Vector3 windowHeigth = Vector3.up * SocleWindowHeight;
            Vector3 windowDepth  = Vector3.forward * SocleWindowDepth;
            Vector3 windowOrigin = origin + widthVector / 2 - windowWidth / 2 + Vector3.up * SocleWindowHeightOffset;
            Vector3 windowMax    = windowOrigin + windowWidth + windowHeigth;

            var wall = PerforatedQuad(origin, origin + widthVector + heightVector, windowOrigin, windowMax);

            var frame = MeshDraft.PartialBox(windowWidth, -windowDepth, windowHeigth,
                                             Directions.All & ~Directions.ZAxis);

            frame.Move(windowOrigin + windowWidth / 2 + windowHeigth / 2 + windowDepth / 2);
            wall.Add(frame);
            wall.Paint(wallColor);

            var window = new MeshDraft().AddQuad(windowOrigin + windowDepth / 2, windowWidth, windowHeigth);

            window.Paint(glassColor);
            wall.Add(window);

            return(wall);
        }
Esempio n. 4
0
        public static MeshDraft Wall(Vector3 origin, Vector3 width, Vector3 height)
        {
            MeshDraft draft = MeshDraft.Quad(origin, width, height);

            draft.Paint(BuildingGenerator.wallColor);
            return(draft);
        }
Esempio n. 5
0
        protected static MeshDraft Entrance(Vector3 origin, float width, float height, Color wallColor, Color doorColor)
        {
            Vector3 widthVector  = Vector3.right * width;
            Vector3 heightVector = Vector3.up * height;

            Vector3 doorWidth     = Vector3.right * EntranceDoorWidth;
            Vector3 doorHeight    = Vector3.up * EntranceDoorHeight;
            Vector3 doorThickness = Vector3.back * EntranceDoorThickness;
            Vector3 doorOrigin    = origin + widthVector / 2 - doorWidth / 2;

            var draft = Bracket(origin, widthVector, heightVector, doorOrigin, doorWidth, doorHeight);

            draft.Paint(wallColor);

            var doorFrame = MeshDraft.PartialBox(doorWidth, -doorThickness, doorHeight,
                                                 Directions.All & ~Directions.ZAxis);

            doorFrame.Move(doorOrigin + doorWidth / 2 + doorHeight / 2 + doorThickness / 2);
            doorFrame.Paint(doorColor);
            draft.Add(doorFrame);

            var door = new MeshDraft().AddQuad(doorOrigin + doorThickness, doorWidth, doorHeight);

            door.Paint(doorColor);
            draft.Add(door);
            return(draft);
        }
Esempio n. 6
0
        public static MeshDraft Wall(Vector3 origin, Vector3 width, Vector3 height)
        {
            MeshDraft draft = MeshDraft.Quad(origin, width, height);

            draft.Paint(Khrushchyovka.wallColor);
            return(draft);
        }
Esempio n. 7
0
        public static MeshDraft Chair(Config config)
        {
            Assert.IsTrue(config.legWidth > 0);
            Assert.IsTrue(config.legHeight > 0);
            Assert.IsTrue(config.seatWidth > 0);
            Assert.IsTrue(config.seatDepth > 0);
            Assert.IsTrue(config.seatHeight > 0);
            Assert.IsTrue(config.backHeight > 0);

            Vector3 right   = Vector3.right * (config.seatWidth - config.legWidth) / 2;
            Vector3 forward = Vector3.forward * (config.seatDepth - config.legWidth) / 2;

            var chair = new MeshDraft {
                name = "Chair"
            };

            // Generate legs
            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };

            chair.Add(Leg0(legCenters[0], config.legWidth, config.legHeight));
            chair.Add(Leg0(legCenters[1], config.legWidth, config.legHeight));
            chair.Add(Leg0(legCenters[2], config.legWidth, config.legHeight));
            chair.Add(Leg0(legCenters[3], config.legWidth, config.legHeight));

            // Generate stretchers
            if (config.hasStretchers)
            {
                var stretchersConstructor = stretchersConstructors.GetRandom();
                chair.Add(stretchersConstructor(legCenters, config.legWidth, config.legHeight));
            }

            // Generate seat
            chair.Add(Seat0(Vector3.up * config.legHeight, config.seatWidth, config.seatDepth, config.seatHeight));

            // Generate chair back
            Vector3 backCenter = Vector3.up * (config.legHeight + config.seatHeight) +
                                 Vector3.forward * (config.seatDepth - config.legWidth) / 2;
            var backConstructor = backConstructors.GetRandom();

            chair.Add(backConstructor(backCenter, config.seatWidth, config.legWidth, config.backHeight));

            // Generate armrests
            if (config.hasArmrests)
            {
                var armrestsConstructor = armrestsConstructors.GetRandom();
                chair.Add(armrestsConstructor(config.seatWidth, config.seatDepth, backCenter, config.backHeight,
                                              config.legWidth));
            }

            chair.Paint(config.color);

            return(chair);
        }
        public static MeshDraft Chair(
            float legWidth,
            float legHeight,
            float seatWidth,
            float seatDepth,
            float seatHeight,
            float backHeight,
            bool hasStretchers,
            bool hasArmrests,
            Color color)
        {
            Vector3 right   = Vector3.right * (seatWidth - legWidth) / 2;
            Vector3 forward = Vector3.forward * (seatDepth - legWidth) / 2;

            var chair = new MeshDraft {
                name = "Chair"
            };

            // Generate legs
            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };

            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            // Generate stretchers
            if (hasStretchers)
            {
                var stretchersConstructor = stretchersConstructors.GetRandom();
                chair.Add(stretchersConstructor(legCenters, legWidth, legHeight));
            }

            // Generate seat
            chair.Add(Seat0(Vector3.up * legHeight, seatWidth, seatDepth, seatHeight));

            // Generate chair back
            Vector3 backCenter      = Vector3.up * (legHeight + seatHeight) + Vector3.forward * (seatDepth - legWidth) / 2;
            var     backConstructor = backConstructors.GetRandom();

            chair.Add(backConstructor(backCenter, seatWidth, legWidth, backHeight));

            // Generate armrests
            if (hasArmrests)
            {
                var armrestsConstructor = armrestsConstructors.GetRandom();
                chair.Add(armrestsConstructor(seatWidth, seatDepth, backCenter, backHeight, legWidth));
            }

            chair.Paint(color);

            return(chair);
        }
Esempio n. 9
0
        private static CompoundMeshDraft Windowpane(Vector3 min, Vector3 max, Color frameColor, Color glassColor)
        {
            Vector3 size         = max - min;
            Vector3 widthVector  = size.ToVector3XZ();
            Vector3 heightVector = size.ToVector3Y();
            Vector3 right        = widthVector.normalized;
            Vector3 normal       = Vector3.Cross(widthVector, heightVector).normalized;
            var     frame        = new MeshDraft {
                name = WallDraftName
            };

            int   rodCount = Mathf.FloorToInt(widthVector.magnitude / WindowSegmentMinWidth);
            float interval = widthVector.magnitude / (rodCount + 1);

            Vector3 frameWidth    = right * WindowFrameWidth / 2;
            Vector3 frameHeight   = Vector3.up * WindowFrameWidth / 2;
            Vector3 frameLength   = normal * WindowFrameWidth / 2;
            Vector3 startPosition = min + heightVector / 2 + frameLength / 2;

            for (int i = 0; i < rodCount; i++)
            {
                var rod = MeshDraft.PartialBox(frameWidth * 2, frameLength, heightVector - frameHeight * 2,
                                               Directions.Left | Directions.Back | Directions.Right, false)
                          .Move(startPosition + right * (i + 1) * interval);
                frame.Add(rod);
            }

            Vector3 windowMin    = min + frameWidth + frameHeight;
            Vector3 windowWidth  = widthVector - frameWidth * 2;
            Vector3 windowHeight = heightVector - frameHeight * 2;
            Vector3 windowMax    = windowMin + windowWidth + windowHeight;

            frame.Add(PerforatedQuad(min, max, windowMin, windowMax));

            var hole = MeshDraft.PartialBox(windowWidth, frameLength, windowHeight, Directions.All & ~Directions.ZAxis, false)
                       .Move(startPosition + widthVector / 2)
                       .FlipFaces();

            frame.Add(hole);
            frame.Paint(frameColor);

            var glass = new MeshDraft().AddQuad(windowMin + frameLength, windowWidth, windowHeight)
                        .Paint(glassColor);

            glass.name = GlassDraftName;

            return(new CompoundMeshDraft().Add(frame).Add(glass));
        }
        private static MeshDraft Windowpane(Vector3 min, Vector3 max, Color frameColor, Color glassColor)
        {
            Vector3 size         = max - min;
            Vector3 widthVector  = size.OnlyXZ();
            Vector3 heightVector = size.OnlyY();
            Vector3 right        = widthVector.normalized;
            Vector3 normal       = Vector3.Cross(widthVector, heightVector).normalized;
            var     draft        = new MeshDraft();

            int   rodCount = Mathf.FloorToInt(widthVector.magnitude / WindowSegmentMinWidth);
            float interval = widthVector.magnitude / (rodCount + 1);

            Vector3 frameWidth    = right * WindowFrameWidth / 2;
            Vector3 frameHeight   = Vector3.up * WindowFrameWidth / 2;
            Vector3 frameLength   = normal * WindowFrameWidth / 2;
            Vector3 startPosition = min + heightVector / 2 + frameLength / 2;

            for (int i = 0; i < rodCount; i++)
            {
                var frame = MeshDraft.PartialBox(frameWidth * 2, frameLength, heightVector - frameHeight * 2,
                                                 Directions.Left | Directions.Back | Directions.Right);
                frame.Move(startPosition + right * (i + 1) * interval);
                draft.Add(frame);
            }

            Vector3 windowMin    = min + frameWidth + frameHeight;
            Vector3 windowWidth  = widthVector - frameWidth * 2;
            Vector3 windowHeight = heightVector - frameHeight * 2;
            Vector3 windowMax    = windowMin + windowWidth + windowHeight;
            var     window       = PerforatedQuad(min, max, windowMin, windowMax);

            draft.Add(window);

            var hole = MeshDraft.PartialBox(windowWidth, frameLength, windowHeight, Directions.All & ~Directions.ZAxis);

            hole.Move(startPosition + widthVector / 2);
            hole.FlipFaces();
            draft.Add(hole);
            draft.Paint(frameColor);

            var glass = MeshDraft.Quad(windowMin + frameLength, windowWidth, windowHeight);

            glass.Paint(glassColor);
            draft.Add(glass);

            return(draft);
        }
Esempio n. 11
0
        private static MeshDraft Windowpane(Vector3 origin, Vector3 width, Vector3 heigth)
        {
            var right  = width.normalized;
            var normal = Vector3.Cross(width, heigth).normalized;
            var draft  = new MeshDraft();

            int   rodCount = Mathf.FloorToInt(width.magnitude / WindowSegmentMinWidth);
            float interval = width.magnitude / (rodCount + 1);

            var frameWidth    = right * WindowFrameWidth / 2;
            var frameHeight   = Vector3.up * WindowFrameWidth / 2;
            var frameLength   = normal * WindowFrameWidth / 2;
            var startPosition = origin + heigth / 2 + frameLength / 2;

            for (int i = 0; i < rodCount; i++)
            {
                var frame = MeshE.HexahedronDraft(frameWidth * 2, frameLength, heigth - frameHeight * 2,
                                                  Directions.Left | Directions.Back | Directions.Right);
                frame.Move(startPosition + right * (i + 1) * interval);
                draft.Add(frame);
            }

            var windowCorner = origin + frameWidth + frameHeight;
            var windowWidth  = width - frameWidth * 2;
            var windowHeigth = heigth - frameHeight * 2;
            var window       = PerforatedQuad(origin, width, heigth, windowCorner, windowWidth, windowHeigth);

            draft.Add(window);

            var hole = MeshE.HexahedronDraft(windowWidth, frameLength, windowHeigth, Directions.All & ~Directions.ZAxis);

            hole.Move(startPosition + width / 2);
            hole.FlipFaces();
            draft.Add(hole);

            draft.Paint(frameColor);

            var glass = MeshE.QuadDraft(windowCorner + frameLength, windowWidth, windowHeigth);

            glass.Paint(glassColor);
            draft.Add(glass);

            return(draft);
        }
Esempio n. 12
0
        protected static MeshDraft BalconyGlazed(Vector3 origin, float width, float height, Color wallColor,
                                                 Color frameColor, Color glassColor, Color roofColor)
        {
            Vector3 widthVector  = Vector3.right * width;
            Vector3 heightVector = Vector3.up * height;

            Vector3 balconyHeight = Vector3.up * BalconyHeight;
            Vector3 balconyDepth  = Vector3.back * BalconyDepth;

            var draft   = new MeshDraft();
            var balcony = MeshDraft.PartialBox(widthVector, balconyDepth, balconyHeight,
                                               Directions.All & ~Directions.Up & ~Directions.Back);

            balcony.FlipFaces();
            balcony.Move(origin + widthVector / 2 + balconyDepth / 2 + balconyHeight / 2);
            balcony.Paint(wallColor);
            draft.Add(balcony);

            Vector3 roof0 = origin + heightVector;
            Vector3 roof1 = roof0 + widthVector;
            Vector3 roof2 = roof1 + balconyDepth;
            Vector3 roof3 = roof0 + balconyDepth;
            var     roof  = new MeshDraft().AddQuad(roof0, roof1, roof2, roof3);

            roof.Paint(roofColor);
            draft.Add(roof);

            Vector3 glassHeight = heightVector - balconyHeight;
            Vector3 glass0      = origin + balconyHeight;
            Vector3 glass1      = glass0 + balconyDepth;
            Vector3 glass2      = glass1 + widthVector;
            var     glass       = Windowpane(glass0, glass0 + balconyDepth + glassHeight, frameColor, glassColor);

            glass.Add(Windowpane(glass1, glass1 + widthVector + glassHeight, frameColor, glassColor));
            glass.Add(Windowpane(glass2, glass2 - balconyDepth + glassHeight, frameColor, glassColor));
            draft.Add(glass);

            return(draft);
        }
        private static MeshDraft Balcony(Vector3 origin, float width, Color wallColor)
        {
            Vector3 widthVector   = Vector3.right * width;
            Vector3 balconyHeight = Vector3.up * BalconyHeight;
            Vector3 balconyDepth  = Vector3.back * BalconyDepth;

            var balconyOuter = MeshDraft.PartialBox(widthVector, balconyDepth, balconyHeight,
                                                    Directions.All & ~Directions.Up & ~Directions.Back);

            balconyOuter.FlipFaces();
            Vector3 balconyCenter = origin + widthVector / 2 + balconyDepth / 2 + balconyHeight / 2;

            balconyOuter.Move(balconyCenter);

            Vector3 innerWidthOffset  = Vector3.right * BalconyThickness;
            Vector3 innerWidth        = widthVector - innerWidthOffset * 2;
            Vector3 innerHeightOffset = Vector3.up * BalconyThickness;
            Vector3 innerHeight       = balconyHeight - innerHeightOffset;
            Vector3 innerDepthOffset  = Vector3.back * BalconyThickness;
            Vector3 innerDepth        = balconyDepth - innerDepthOffset;
            var     balconyInner      = MeshDraft.PartialBox(innerWidth, innerDepth, innerHeight,
                                                             Directions.All & ~Directions.Up & ~Directions.Back);

            balconyInner.Move(balconyCenter - innerDepthOffset / 2 + innerHeightOffset / 2);

            Vector3 borderOrigin      = origin + widthVector + balconyHeight;
            Vector3 borderInnerOrigin = borderOrigin - innerWidthOffset;
            var     balconyBorder     = Bracket(borderOrigin, -widthVector, balconyDepth,
                                                borderInnerOrigin, -innerWidth, innerDepth);

            var balcony = new MeshDraft();

            balcony.Add(balconyOuter);
            balcony.Add(balconyInner);
            balcony.Add(balconyBorder);
            balcony.Paint(wallColor);
            return(balcony);
        }
Esempio n. 14
0
        private static MeshDraft Windowpane(Vector3 origin, Vector3 width, Vector3 heigth)
        {
            Vector3 right = width.normalized;
            Vector3 normal = Vector3.Cross(width, heigth).normalized;
            var draft = new MeshDraft();

            int rodCount = Mathf.FloorToInt(width.magnitude/WindowSegmentMinWidth);
            float interval = width.magnitude/(rodCount + 1);

            Vector3 frameWidth = right*WindowFrameWidth/2;
            Vector3 frameHeight = Vector3.up*WindowFrameWidth/2;
            Vector3 frameLength = normal*WindowFrameWidth/2;
            Vector3 startPosition = origin + heigth/2 + frameLength/2;
            for (int i = 0; i < rodCount; i++)
            {
                var frame = MeshDraft.Hexahedron(frameWidth*2, frameLength, heigth - frameHeight*2,
                    Directions.Left | Directions.Back | Directions.Right);
                frame.Move(startPosition + right*(i + 1)*interval);
                draft.Add(frame);
            }

            Vector3 windowCorner = origin + frameWidth + frameHeight;
            Vector3 windowWidth = width - frameWidth*2;
            Vector3 windowHeigth = heigth - frameHeight*2;
            var window = PerforatedQuad(origin, width, heigth, windowCorner, windowWidth, windowHeigth);
            draft.Add(window);

            var hole = MeshDraft.Hexahedron(windowWidth, frameLength, windowHeigth, Directions.All & ~Directions.ZAxis);
            hole.Move(startPosition + width/2);
            hole.FlipFaces();
            draft.Add(hole);

            draft.Paint(BuildingGenerator.frameColor);

            var glass = MeshDraft.Quad(windowCorner + frameLength, windowWidth, windowHeigth);
            glass.Paint(BuildingGenerator.glassColor);
            draft.Add(glass);

            return draft;
        }
Esempio n. 15
0
        public static MeshDraft Balcony(Vector3 origin, Vector3 width, Vector3 height)
        {
            Vector3 right = width.normalized;
            Vector3 normal = Vector3.Cross(height, width).normalized;
            Vector3 balconyWidth = width;
            Vector3 balconyHeight = Vector3.up*BalconyHeight;
            Vector3 balconyDepth = normal*BalconyDepth;

            var draft = new MeshDraft();
            var balconyOuter = MeshDraft.Hexahedron(balconyWidth, balconyDepth, balconyHeight,
                Directions.All & ~Directions.Up & ~Directions.Back);
            balconyOuter.FlipFaces();
            Vector3 balconyCenter = origin + width/2 + balconyDepth/2 + balconyHeight/2;
            balconyOuter.Move(balconyCenter);
            balconyOuter.Paint(BuildingGenerator.wallColor);

            Vector3 innerWidthOffset = right*BalconyThickness;
            Vector3 innerWidth = balconyWidth - innerWidthOffset*2;
            Vector3 innerHeightOffset = Vector3.up*BalconyThickness;
            Vector3 innerHeight = balconyHeight - innerHeightOffset;
            Vector3 innerDepthOffset = normal*BalconyThickness;
            Vector3 innerDepth = balconyDepth - innerDepthOffset;
            var balconyInner = MeshDraft.Hexahedron(innerWidth, innerDepth, innerHeight,
                Directions.All & ~Directions.Up & ~Directions.Back);
            balconyInner.Move(balconyCenter - innerDepthOffset/2 + innerHeightOffset/2);

            Vector3 borderOrigin = origin + balconyWidth + balconyHeight;
            Vector3 borderInnerOrigin = borderOrigin - innerWidthOffset;
            var balconyBorder = Bracket(borderOrigin, -balconyWidth, balconyDepth,
                borderInnerOrigin, -innerWidth, innerDepth);

            draft.Add(balconyOuter);
            draft.Add(balconyInner);
            draft.Add(balconyBorder);

            Vector3 windowWidthOffset = right*WindowWidthOffset;
            Vector3 windowHeightOffset = Vector3.up*WindowHeightOffset;
            Vector3 windowWidth = right*(width.magnitude - WindowWidthOffset*2);
            Vector3 windowHeight = Vector3.up*WindowHeight;
            Vector3 windowDepth = normal*WindowDepth;

            int rodCount = Mathf.FloorToInt(windowWidth.magnitude/WindowSegmentMinWidth);
            Vector3 doorWidth = right*windowWidth.magnitude/(rodCount + 1);
            Vector3 doorHeight = windowHeightOffset + windowHeight;

            List<Vector3> outerFrame = new List<Vector3>
            {
                origin + windowWidthOffset + innerHeightOffset,
                origin + windowWidthOffset + doorHeight,
                origin + windowWidthOffset + windowWidth + doorHeight,
                origin + windowWidthOffset + windowWidth + windowHeightOffset,
                origin + windowWidthOffset + doorWidth + windowHeightOffset,
                origin + windowWidthOffset + doorWidth + innerHeightOffset
            };

            var panel = MeshDraft.TriangleStrip(new List<Vector3>
            {
                outerFrame[0],
                origin,
                outerFrame[1],
                origin + height,
                outerFrame[2],
                origin + width + height,
                outerFrame[3],
                origin + width,
                outerFrame[4],
                origin + width,
                outerFrame[5]
            });

            draft.Add(panel);

            List<Vector3> innerFrame = new List<Vector3>();
            foreach (Vector3 vertex in outerFrame)
            {
                innerFrame.Add(vertex - windowDepth);
            }
            var frame = MeshDraft.FlatBand(innerFrame, outerFrame);
            draft.Add(frame);

            draft.Paint(BuildingGenerator.wallColor);

            draft.Add(Windowpane(outerFrame[0] - windowDepth, doorWidth, doorHeight - innerHeightOffset));
            draft.Add(Windowpane(outerFrame[4] - windowDepth, windowWidth - doorWidth, windowHeight));

            return draft;
        }
        public static MeshDraft Chair(float legWidth, float legHeight, Vector3 seatDimensions, float backHeight,
            bool hasStretchers, bool hasArmrests)
        {
            Vector3 right = Vector3.right*(seatDimensions.x - legWidth)/2;
            Vector3 forward = Vector3.forward*(seatDimensions.z - legWidth)/2;

            var chair = new MeshDraft {name = "Chair"};

            // Generate legs
            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };
            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            // Generate stretchers
            if (hasStretchers)
            {
                var stretcherFunc = new Func<Vector3[], float, float, MeshDraft>[]
                {
                    Stretchers.XStretchers,
                    Stretchers.HStretchers,
                    Stretchers.BoxStretchers
                }.GetRandom();
                chair.Add(stretcherFunc(legCenters, legWidth, legHeight));
            }

            chair.Add(Seat0(Vector3.up*legHeight, seatDimensions.x, seatDimensions.z, seatDimensions.y));

            // Generate chair back
            var backFunc = new Func<Vector3, float, float, float, MeshDraft>[]
            {
                Backs.Back0,
                Backs.Back1,
                Backs.RodBack
            }.GetRandom();
            Vector3 backCenter = Vector3.up*(legHeight + seatDimensions.y) +
                                 Vector3.forward*(seatDimensions.z - legWidth)/2;
            chair.Add(backFunc(backCenter, seatDimensions.x, legWidth, backHeight));

            // Generate armrests
            if (hasArmrests)
            {
                var armrestsFunc = new Func<Vector3, Vector3, float, float, MeshDraft>[]
                {
                    Armrests.Armrests0,
                    Armrests.Armrests1
                }.GetRandom();
                chair.Add(armrestsFunc(seatDimensions, backCenter, backHeight, legWidth));
            }

            chair.Paint(RandomE.colorHSV);

            return chair;
        }
Esempio n. 17
0
        private static MeshDraft Balcony(Vector3 origin, Vector3 width, Vector3 height)
        {
            var right         = width.normalized;
            var normal        = Vector3.Cross(height, width).normalized;
            var balconyWidth  = width;
            var balconyHeight = Vector3.up * BalconyHeight;
            var balconyDepth  = normal * BalconyDepth;

            var draft        = new MeshDraft();
            var balconyOuter = MeshE.HexahedronDraft(balconyWidth, balconyDepth, balconyHeight,
                                                     Directions.All & ~Directions.Up & ~Directions.Back);

            balconyOuter.FlipFaces();
            var balconyCenter = origin + width / 2 + balconyDepth / 2 + balconyHeight / 2;

            balconyOuter.Move(balconyCenter);
            balconyOuter.Paint(wallColor);

            var innerWidthOffset  = right * BalconyThickness;
            var innerWidth        = balconyWidth - innerWidthOffset * 2;
            var innerHeightOffset = Vector3.up * BalconyThickness;
            var innerHeight       = balconyHeight - innerHeightOffset;
            var innerDepthOffset  = normal * BalconyThickness;
            var innerDepth        = balconyDepth - innerDepthOffset;
            var balconyInner      = MeshE.HexahedronDraft(innerWidth, innerDepth, innerHeight,
                                                          Directions.All & ~Directions.Up & ~Directions.Back);

            balconyInner.Move(balconyCenter - innerDepthOffset / 2 + innerHeightOffset / 2);

            var borderOrigin      = origin + balconyWidth + balconyHeight;
            var borderInnerOrigin = borderOrigin - innerWidthOffset;
            var balconyBorder     = Bracket(borderOrigin, -balconyWidth, balconyDepth,
                                            borderInnerOrigin, -innerWidth, innerDepth);

            draft.Add(balconyOuter);
            draft.Add(balconyInner);
            draft.Add(balconyBorder);

            var windowWidthOffset  = right * WindowWidthOffset;
            var windowHeightOffset = Vector3.up * WindowHeightOffset;
            var windowWidth        = right * (width.magnitude - WindowWidthOffset * 2);
            var windowHeight       = Vector3.up * WindowHeight;
            var windowDepth        = normal * WindowDepth;

            int rodCount   = Mathf.FloorToInt(windowWidth.magnitude / WindowSegmentMinWidth);
            var doorWidth  = right * windowWidth.magnitude / (rodCount + 1);
            var doorHeight = windowHeightOffset + windowHeight;

            var outerFrame = new List <Vector3>
            {
                origin + windowWidthOffset + innerHeightOffset,
                origin + windowWidthOffset + doorHeight,
                origin + windowWidthOffset + windowWidth + doorHeight,
                origin + windowWidthOffset + windowWidth + windowHeightOffset,
                origin + windowWidthOffset + doorWidth + windowHeightOffset,
                origin + windowWidthOffset + doorWidth + innerHeightOffset
            };

            var panel = MeshE.TriangleStripDraft(new List <Vector3>
            {
                outerFrame[0],
                origin,
                outerFrame[1],
                origin + height,
                outerFrame[2],
                origin + width + height,
                outerFrame[3],
                origin + width,
                outerFrame[4],
                origin + width,
                outerFrame[5]
            });

            draft.Add(panel);

            var innerFrame = new List <Vector3>();

            foreach (var vertex in outerFrame)
            {
                innerFrame.Add(vertex - windowDepth);
            }
            var frame = MeshE.FlatBandDraft(innerFrame, outerFrame);

            draft.Add(frame);

            draft.Paint(wallColor);

            draft.Add(Windowpane(outerFrame[0] - windowDepth, doorWidth, doorHeight - innerHeightOffset));
            draft.Add(Windowpane(outerFrame[4] - windowDepth, windowWidth - doorWidth, windowHeight));

            return(draft);
        }
Esempio n. 18
0
        public static MeshDraft Chair(float legWidth, float legHeight, Vector3 seatDimensions, float backHeight,
                                      bool hasStretchers, bool hasArmrests)
        {
            Vector3 right   = Vector3.right * (seatDimensions.x - legWidth) / 2;
            Vector3 forward = Vector3.forward * (seatDimensions.z - legWidth) / 2;

            var chair = new MeshDraft {
                name = "Chair"
            };

            // Generate legs
            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };

            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            // Generate stretchers
            if (hasStretchers)
            {
                var stretcherFunc = new Func <Vector3[], float, float, MeshDraft>[]
                {
                    Stretchers.XStretchers,
                    Stretchers.HStretchers,
                    Stretchers.BoxStretchers
                }.GetRandom();
                chair.Add(stretcherFunc(legCenters, legWidth, legHeight));
            }

            chair.Add(Seat0(Vector3.up * legHeight, seatDimensions.x, seatDimensions.z, seatDimensions.y));

            // Generate chair back
            var backFunc = new Func <Vector3, float, float, float, MeshDraft>[]
            {
                Backs.Back0,
                Backs.Back1,
                Backs.RodBack
            }.GetRandom();
            Vector3 backCenter = Vector3.up * (legHeight + seatDimensions.y) +
                                 Vector3.forward * (seatDimensions.z - legWidth) / 2;

            chair.Add(backFunc(backCenter, seatDimensions.x, legWidth, backHeight));

            // Generate armrests
            if (hasArmrests)
            {
                var armrestsFunc = new Func <Vector3, Vector3, float, float, MeshDraft>[]
                {
                    Armrests.Armrests0,
                    Armrests.Armrests1
                }.GetRandom();
                chair.Add(armrestsFunc(seatDimensions, backCenter, backHeight, legWidth));
            }

            chair.Paint(RandomE.colorHSV);

            return(chair);
        }
        private MeshDraft Chair()
        {
            var legWidth = Random.Range(legWidthLB, legWidthUB);
            var legHeight = Random.Range(legHeightLB, legHeightUB);
            var seatDimensions = RandomE.Range(seatLB, seatUB);
            var backHeight = Random.Range(backHeightLB, backHeightUB);

            var chair = new MeshDraft {name = "Chair"};

            var right = Vector3.right*(seatDimensions.x - legWidth)/2;
            var forward = Vector3.forward*(seatDimensions.z - legWidth)/2;

            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };
            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            if (RandomE.Chance(0.3f))
            {
                var stretcherFunc = new Func<Vector3[], float, float, MeshDraft>[]
                {
                    XStretchers,
                    HStretchers,
                    BoxStretchers
                }.GetRandom();
                chair.Add(stretcherFunc(legCenters, legWidth, legHeight));
            }

            chair.Add(Seat0(Vector3.up*legHeight, seatDimensions.x, seatDimensions.z, seatDimensions.y));

            var backFunc = new Func<Vector3, float, float, float, MeshDraft>[]
            {
                Back0,
                Back1,
                RodBack
            }.GetRandom();
            var backCenter = Vector3.up*(legHeight + seatDimensions.y) + Vector3.forward*(seatDimensions.z - legWidth)/2;
            chair.Add(backFunc(backCenter, seatDimensions.x, legWidth, backHeight));

            if (RandomE.Chance(0.3f))
            {
                var armrestsFunc = new Func<Vector3, Vector3, float, float, MeshDraft>[]
                {
                    Armrests0,
                    Armrests1
                }.GetRandom();
                chair.Add(armrestsFunc(seatDimensions, backCenter, backHeight, legWidth));
            }

            chair.Paint(RandomE.colorHSV);

            return chair;
        }
Esempio n. 20
0
        public static MeshDraft Chair(
            float legWidth,
            float legHeight,
            float seatWidth,
            float seatDepth,
            float seatHeight,
            float backHeight,
            bool hasStretchers,
            bool hasArmrests,
            Color color)
        {
            Vector3 right = Vector3.right*(seatWidth - legWidth)/2;
            Vector3 forward = Vector3.forward*(seatDepth - legWidth)/2;

            var chair = new MeshDraft {name = "Chair"};

            // Generate legs
            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };
            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            // Generate stretchers
            if (hasStretchers)
            {
                var stretchersConstructor = stretchersConstructors.GetRandom();
                chair.Add(stretchersConstructor(legCenters, legWidth, legHeight));
            }

            // Generate seat
            chair.Add(Seat0(Vector3.up*legHeight, seatWidth, seatDepth, seatHeight));

            // Generate chair back
            Vector3 backCenter = Vector3.up*(legHeight + seatHeight) + Vector3.forward*(seatDepth - legWidth)/2;
            var backConstructor = backConstructors.GetRandom();
            chair.Add(backConstructor(backCenter, seatWidth, legWidth, backHeight));

            // Generate armrests
            if (hasArmrests)
            {
                var armrestsConstructor = armrestsConstructors.GetRandom();
                chair.Add(armrestsConstructor(seatWidth, seatDepth, backCenter, backHeight, legWidth));
            }

            chair.Paint(color);

            return chair;
        }
        private MeshDraft Chair()
        {
            var legWidth       = Random.Range(legWidthLB, legWidthUB);
            var legHeight      = Random.Range(legHeightLB, legHeightUB);
            var seatDimensions = RandomE.Range(seatLB, seatUB);
            var backHeight     = Random.Range(backHeightLB, backHeightUB);

            var chair = new MeshDraft {
                name = "Chair"
            };

            var right   = Vector3.right * (seatDimensions.x - legWidth) / 2;
            var forward = Vector3.forward * (seatDimensions.z - legWidth) / 2;

            var legCenters = new Vector3[]
            {
                -right - forward,
                right - forward,
                right + forward,
                -right + forward
            };

            chair.Add(Leg0(legCenters[0], legWidth, legHeight));
            chair.Add(Leg0(legCenters[1], legWidth, legHeight));
            chair.Add(Leg0(legCenters[2], legWidth, legHeight));
            chair.Add(Leg0(legCenters[3], legWidth, legHeight));

            if (RandomE.Chance(0.3f))
            {
                var stretcherFunc = new Func <Vector3[], float, float, MeshDraft>[]
                {
                    XStretchers,
                    HStretchers,
                    BoxStretchers
                }.Choice();
                chair.Add(stretcherFunc(legCenters, legWidth, legHeight));
            }

            chair.Add(Seat0(Vector3.up * legHeight, seatDimensions.x, seatDimensions.z, seatDimensions.y));

            var backFunc = new Func <Vector3, float, float, float, MeshDraft>[]
            {
                Back0,
                Back1,
                RodBack
            }.Choice();
            var backCenter = Vector3.up * (legHeight + seatDimensions.y) + Vector3.forward * (seatDimensions.z - legWidth) / 2;

            chair.Add(backFunc(backCenter, seatDimensions.x, legWidth, backHeight));

            if (RandomE.Chance(0.3f))
            {
                var armrestsFunc = new Func <Vector3, Vector3, float, float, MeshDraft>[]
                {
                    Armrests0,
                    Armrests1
                }.Choice();
                chair.Add(armrestsFunc(seatDimensions, backCenter, backHeight, legWidth));
            }

            chair.Paint(RandomE.colorHSV);

            return(chair);
        }