Esempio n. 1
0
        private static MeshDraft Platform(float radius, float baseOffset, int segments, float heignt)
        {
            float segmentAngle = 360f / segments;
            float currentAngle = 0;

            var lowerRing = new List <Vector3>(segments);
            var upperRing = new List <Vector3>(segments);

            for (var i = 0; i < segments; i++)
            {
                var lowerPoint = PTUtils.PointOnCircle3XZ(radius + baseOffset, currentAngle);
                lowerRing.Add(lowerPoint + Vector3.down * heignt);

                var upperPoint = PTUtils.PointOnCircle3XZ(radius, currentAngle);
                upperRing.Add(upperPoint);
                currentAngle -= segmentAngle;
            }

            var platform = new MeshDraft {
                name = "Platform"
            };
            var bottom = MeshDraft.TriangleFan(lowerRing);

            bottom.Add(MeshDraft.Band(lowerRing, upperRing));
            bottom.Paint(new Color(0.5f, 0.5f, 0.5f, 1));
            platform.Add(bottom);

            upperRing.Reverse();
            var top = MeshDraft.TriangleFan(upperRing);

            top.Paint(new Color(0.8f, 0.8f, 0.8f, 1));
            platform.Add(top);

            return(platform);
        }