Example #1
0
        public override MeshDraft Construct(Vector2 parentLayoutOrigin)
        {
            var roofDraft = ConstructRoofBase(out List <Vector2> roofPolygon2, out List <Vector3> roofPolygon3);

            var tessellator = new Tessellator();

            tessellator.AddContour(roofPolygon3);
            tessellator.Tessellate(normal: Vector3.up);
            var roofTop = tessellator.ToMeshDraft()
                          .Move(Vector3.up * roofConfig.thickness);

            for (var i = 0; i < roofTop.vertexCount; i++)
            {
                roofTop.normals.Add(Vector3.up);
            }
            return(roofDraft.Add(roofTop)
                   .Paint(roofColor));
        }
Example #2
0
        protected static MeshDraft ConstructContourDraft(List <Vector2> skeletonPolygon2, float roofPitch)
        {
            Vector2 edgeA          = skeletonPolygon2[0];
            Vector2 edgeB          = skeletonPolygon2[1];
            Vector2 edgeDirection2 = (edgeB - edgeA).normalized;
            Vector3 roofNormal     = CalculateRoofNormal(edgeDirection2, roofPitch);

            var skeletonPolygon3 = skeletonPolygon2.ConvertAll(v => v.ToVector3XZ());

            var tessellator = new Tessellator();

            tessellator.AddContour(skeletonPolygon3);
            tessellator.Tessellate(normal: Vector3.up);
            var contourDraft = tessellator.ToMeshDraft();

            for (var i = 0; i < contourDraft.vertexCount; i++)
            {
                Vector2 vertex = contourDraft.vertices[i].ToVector2XZ();
                float   height = CalculateVertexHeight(vertex, edgeA, edgeDirection2, roofPitch);
                contourDraft.vertices[i] = new Vector3(vertex.x, height, vertex.y);
                contourDraft.normals.Add(roofNormal);
            }
            return(contourDraft);
        }