Esempio n. 1
0
        private static MeshDraft GenerateBorder(List <Vector2> roofPolygon, RoofConfig roofConfig)
        {
            List <Vector3> lowerRing = roofPolygon.ConvertAll(v => v.ToVector3XZ());
            List <Vector3> upperRing = roofPolygon.ConvertAll(v => v.ToVector3XZ() + Vector3.up * roofConfig.thickness);

            return(new MeshDraft().AddFlatQuadBand(lowerRing, upperRing, false));
        }
Esempio n. 2
0
        private static MeshDraft GenerateBorder(List <Vector2> roofPolygon, RoofConfig roofConfig)
        {
            List <Vector3> lowerRing = roofPolygon.Select(v => v.ToVector3XZ()).ToList();
            List <Vector3> upperRing = roofPolygon.Select(v => v.ToVector3XZ() + Vector3.up * roofConfig.thickness).ToList();
            var            border    = MeshDraft.FlatBand(lowerRing, upperRing);

            return(border);
        }
Esempio n. 3
0
        private static MeshDraft GenerateFlat(List <Vector2> roofPolygon, RoofConfig roofConfig)
        {
            Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness;

            var roofDraft = MeshDraft.Quad(a, d, c, b);

            return(roofDraft);
        }
Esempio n. 4
0
        public static MeshDraft GenerateHipped(List <Vector2> roofPolygon, RoofConfig roofConfig)
        {
            Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness;

            Vector3 ridgeHeight = Vector3.up * HippedRoofHeight;
            Vector3 ridgeOffset = (b - a).normalized * 2;
            Vector3 ridge0      = (a + d) / 2 + ridgeHeight + ridgeOffset;
            Vector3 ridge1      = (b + c) / 2 + ridgeHeight - ridgeOffset;
            var     roofDraft   = MeshDraft.Quad(a, ridge0, ridge1, b);

            roofDraft.Add(MeshDraft.Triangle(b, ridge1, c));
            roofDraft.Add(MeshDraft.Quad(c, ridge1, ridge0, d));
            roofDraft.Add(MeshDraft.Triangle(d, ridge0, a));
            return(roofDraft);
        }
Esempio n. 5
0
        public static MeshDraft GenerateGabled(List <Vector2> roofPolygon, RoofConfig roofConfig)
        {
            Vector3 a = roofPolygon[0].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 b = roofPolygon[1].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 c = roofPolygon[2].ToVector3XZ() + Vector3.up * roofConfig.thickness;
            Vector3 d = roofPolygon[3].ToVector3XZ() + Vector3.up * roofConfig.thickness;

            Vector3 ridgeHeight = Vector3.up * GabledRoofHeight;
            Vector3 ridge0      = (a + d) / 2 + ridgeHeight;
            Vector3 ridge1      = (b + c) / 2 + ridgeHeight;

            var roofDraft = MeshDraft.Quad(a, ridge0, ridge1, b);

            roofDraft.AddTriangle(b, ridge1, c);
            roofDraft.AddQuad(c, ridge1, ridge0, d);
            roofDraft.AddTriangle(d, ridge0, a);
            return(roofDraft);
        }
Esempio n. 6
0
        public static MeshDraft Generate(
            List <Vector2> foundationPolygon,
            float roofHeight,
            RoofConfig roofConfig)
        {
            List <Vector2> roofPolygon = Geometry.OffsetPolygon(foundationPolygon, roofConfig.overhang);

            MeshDraft roofDraft;

            switch (roofConfig.type)
            {
            case RoofType.Flat:
                roofDraft = GenerateFlat(roofPolygon, roofConfig);
                break;

            case RoofType.Gabled:
                roofDraft = GenerateGabled(roofPolygon, roofConfig);
                break;

            case RoofType.Hipped:
                roofDraft = GenerateHipped(roofPolygon, roofConfig);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (roofConfig.thickness > 0)
            {
                roofDraft.Add(GenerateBorder(roofPolygon, roofConfig));
            }

            if (roofConfig.overhang > 0)
            {
                roofDraft.Add(GenerateOverhang(foundationPolygon, roofPolygon));
            }

            roofDraft.Move(Vector3.up * roofHeight);
            roofDraft.name = "Roof";
            return(roofDraft);
        }