AcTools.Render.Base.Utils.GeometryGenerator.BuildCylinderTopCap C# (CSharp) Method

BuildCylinderTopCap() private static method

private static BuildCylinderTopCap ( float topRadius, float height, int sliceCount, MeshData &ret ) : void
topRadius float
height float
sliceCount int
ret MeshData
return void
        private static void BuildCylinderTopCap(float topRadius, float height, int sliceCount, ref MeshData ret) {
            var baseIndex = ret.Vertices.Count;

            var y = 0.5f * height;
            var dTheta = 2.0f * MathF.PI / sliceCount;

            for (var i = 0; i <= sliceCount; i++) {
                var x = topRadius * MathF.Cos(i * dTheta);
                var z = topRadius * MathF.Sin(i * dTheta);

                var u = x / height + 0.5f;
                var v = z / height + 0.5f;
                ret.Vertices.Add(new Vertex(x, y, z, 0, 1, 0, 1, 0, 0, u, v));
            }
            ret.Vertices.Add(new Vertex(0, y, 0, 0, 1, 0, 1, 0, 0, 0.5f, 0.5f));
            var centerIndex = ret.Vertices.Count - 1;
            for (var i = 0; i < sliceCount; i++) {
                ret.Indices.Add(centerIndex);
                ret.Indices.Add(baseIndex + i + 1);
                ret.Indices.Add(baseIndex + i);
            }
        }