private static List <Vector3> CreateFlatRooftop(List <Vector3> baseRoofPoints)
        {
            if (baseRoofPoints.Count <= 4)
            {
                return(null);
            }

            List <Vector3> roofPoints =
                new List <Vector3>(baseRoofPoints)
            {
                Math3D.GetCenterFromPointList(baseRoofPoints)
            };

            return(roofPoints);
        }
        private static List <Vector3> CreateRoundedRooftop(List <Vector3> baseRoofPoints, Vector3 planeDirection,
                                                           float moduleHeight)
        {
            List <Vector3> roofPoints = new List <Vector3>();

            roofPoints.AddRange(baseRoofPoints);

            Vector3 center            = Math3D.GetCenterFromPointList(baseRoofPoints);
            int     floorsTermination = 5;
            float   totalHeight       = 0;
            float   currentHeight     = moduleHeight * Random.Range(0.5f, .7f);
            float   centerFactor      = Random.Range(0.6f, 0.9f);
            float   centerExpFactor   = Random.Range(1.1f, 1.8f);
            float   heightExpFactor   = Random.Range(1.6f, 2.6f);
            float   offsetTopCenter   = Random.Range(0, 0.3f);

            for (int i = 0; i < floorsTermination; i++)
            {
                Vector3 addedHeight = (totalHeight + currentHeight) * planeDirection;

                for (int j = 0; j < baseRoofPoints.Count; j++)
                {
                    Vector3 point     = baseRoofPoints[j];
                    Vector3 newCenter = center + addedHeight;
                    point = point + addedHeight;
                    point = Vector3.Lerp(newCenter, point, centerFactor);

                    roofPoints.Add(point);
                }
                if (i < floorsTermination - 1)
                {
                    totalHeight += currentHeight;
                }

                centerFactor  /= centerExpFactor;
                currentHeight /= heightExpFactor;
            }

            roofPoints.Add(center + ((totalHeight + offsetTopCenter) * planeDirection));

            return(roofPoints);
        }
Esempio n. 3
0
        protected List <Vector3> ExtendFloorBase(List <Vector3> buildingBase, int floorNumber, float scaledFactor,
                                                 Vector3 eulerRotation,
                                                 Vector3 up)
        {
            List <Vector3> result = new List <Vector3>();

            Vector3 centerPivot =
                Math3D.GetCenterFromPointList(buildingBase) + up.normalized * ModuleHeight * floorNumber;

            for (int i = 0; i < buildingBase.Count; i++)
            {
                Vector3 vector = buildingBase[i] + up.normalized * ModuleHeight * floorNumber;
                Vector3 dir    = vector - centerPivot;
                vector = centerPivot + dir.normalized * (scaledFactor * dir.magnitude);
                vector = RotatePointAroundPivot(eulerRotation, centerPivot, vector);
                result.Add(vector);
            }

            return(result);
        }