示例#1
0
        public static MeshDraft Platform(float radius, float height, int segments = 128)
        {
            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++)
            {
                lowerRing.Add(Geometry.PointOnCircle3XZ(radius + height, currentAngle) + Vector3.down * height);
                upperRing.Add(Geometry.PointOnCircle3XZ(radius, currentAngle));
                currentAngle += segmentAngle;
            }

            var platform = new MeshDraft {
                name = "Platform"
            }
            .AddFlatQuadBand(lowerRing, upperRing, false);

            lowerRing.Reverse();
            platform.AddTriangleFan(lowerRing, Vector3.down)
            .Paint(new Color(0.5f, 0.5f, 0.5f, 1));

            platform.Add(new MeshDraft()
                         .AddTriangleFan(upperRing, Vector3.up)
                         .Paint(new Color(0.8f, 0.8f, 0.8f, 1)));

            return(platform);
        }
示例#2
0
        private void AddBottomLeftPentagon(int x, int y)
        {
            Vector2 bottomLeft = GetBottomLeftPosition(x, y);

            if (contours.useInterpolation)
            {
                draft.AddTriangleFan(new List <Vector3>
                {
                    bottomLeft,
                    bottomLeft + Vector2.up * squareSize,
                    bottomLeft + Vector2.right * contours.GetTopSide(x, y) * squareSize + Vector2.up * squareSize,
                    bottomLeft + Vector2.right * squareSize + Vector2.up * contours.GetRightSide(x, y) * squareSize,
                    bottomLeft + Vector2.right * squareSize,
                }, normal);
            }
            else
            {
                draft.AddTriangleFan(new List <Vector3>
                {
                    bottomLeft,
                    bottomLeft + Vector2.up * squareSize,
                    bottomLeft + Vector2.right * cornerWeight * squareSize + Vector2.up * squareSize,
                    bottomLeft + Vector2.right * squareSize + Vector2.up * cornerWeight * squareSize,
                    bottomLeft + Vector2.right * squareSize,
                }, normal);
            }
        }