devNotes 3-2-2017 Procedural Meshing

        public static Vector3 Pos_on_Ellipse(float lenX, float lenY, float theta)
        {
            return new Vector3(lenX * Mathf.Cos(Mathf.PI * theta / 180), lenY * Mathf.Sin(Mathf.PI * theta / 180), 0);
        }

        public static MeshDraft Arc_Mesh_Zoom(float t, float lenX, float lenY_Top, float lenY_Bot, int Segments_Per_Semi, float horzScale, float vertScale, float scale_UV_X, float scale_UV_Y, float uv_Vert_Offset)
        {
            var draft = new MeshDraft { name = "Arc_Mesh_Zoom" };
            List<Vector3> vOuterRing = new List<Vector3>();
            List<Vector2> vUV_OuterRing = new List<Vector2>();
            List<Vector3> vInnerRing = new List<Vector3>();
            List<Vector2> vUV_InnerRing = new List<Vector2>();

            float ang = 0;
            float dAng = 180 / Segments_Per_Semi;
            Vector3 v;
            Vector3 vZero = Vector3.zero;

            if (t <= 0.5f)
            {
                t *= 2;
                for (int i = 0; i < Segments_Per_Semi; i++)
                {
                    vInnerRing.Add(vZero);
                    vUV_InnerRing.Add(new Vector2(0.5f, 0.5f));
                    v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);

                    vUV_OuterRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    v *= t;
                    vOuterRing.Add(v);
                    ang += dAng;
                }

                for (int i = 0; i < Segments_Per_Semi; i++)
                {
                    vInnerRing.Add(vZero);
                    vUV_InnerRing.Add(new Vector2(0.5f, 0.5f));
                    v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);
                    vUV_OuterRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    v *= t;
                    vOuterRing.Add(v);
                    ang += dAng;
                }
                draft.Add(Band_UVs(vInnerRing, vOuterRing, vUV_InnerRing, vUV_OuterRing));
                return draft;
            }
            else
            {
                t = (t - 0.5f) * 2f;
                for (int i = 0; i < Segments_Per_Semi; i++)
                {
                    v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);
                    vOuterRing.Add(v);
                    vUV_OuterRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    v *= t;
                    vInnerRing.Add(v);
                    vUV_InnerRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));

                    ang += dAng;
                }

                for (int i = 0; i < Segments_Per_Semi; i++)
                {
                    v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);

                    vOuterRing.Add(v);
                    vUV_OuterRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    v *= t;
                    vInnerRing.Add(v);
                    vUV_InnerRing.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));

                    ang += dAng;
                }
                draft.Add(Band_UVs(vInnerRing, vOuterRing, vUV_InnerRing, vUV_OuterRing));
                return draft;
            }
        }

        public static MeshDraft Arc_Mesh_Plate_Fan(float t, float lenX, float lenY_Top, float lenY_Bot, int Segments_Per_Semi, float horzScale, float vertScale, float scale_UV_X, float scale_UV_Y, float uv_Vert_Offset)
        {
            var draft = new MeshDraft { name = "Arc_Mesh_Plate_Fan" };

            Vector3 center = new Vector3(0, 0, 0);
            float ang = 0;
            float deltAng = 180 / Segments_Per_Semi;
            List<Vector3> vFan_Verts = new List<Vector3>();
            List<Vector2> vUVs = new List<Vector2>();

            float d = (t < 0.5f ? 2*t : (1-t)*2);
            float fan = 90*d;

            vFan_Verts.Add(center);
            vUVs.Add(new Vector2(0.5f, 0.5f));
            vFan_Verts.Add(center);
            vUVs.Add(new Vector2(0.5f, 0.5f));
            vFan_Verts.Add(center);
            vUVs.Add(new Vector2(0.5f, 0.5f));

            Vector3 v;
            if (t <= 0.5)
            {
                for (int i = 0; i < Segments_Per_Semi; i++)
                {
                    if (ang > 90 - fan && ang < 90 + fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);
                        vFan_Verts.Add(v);
                        vUVs.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }
                draft.Add(TriangleFan_UVs(vFan_Verts, vUVs));

                List<Vector3> vFan_Verts_Bot = new List<Vector3>();
                List<Vector2> vUVs_Bot = new List<Vector2>();

                vFan_Verts_Bot.Add(center);
                vUVs_Bot.Add(new Vector2(0.5f, 0.5f));
                vFan_Verts_Bot.Add(center);
                vUVs_Bot.Add(new Vector2(0.5f, 0.5f));
                vFan_Verts_Bot.Add(center);
                vUVs_Bot.Add(new Vector2(0.5f, 0.5f));

                for (int i = 0; i < Segments_Per_Semi + 1; i++)
                {
                    if (ang >= 270 - fan && ang <= 270 + fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);
                        vFan_Verts_Bot.Add(v);
                        vUVs_Bot.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }
                draft.Add(TriangleFan_UVs(vFan_Verts_Bot, vUVs_Bot));
            }
            else
            {
                //0-90
                for (int i = 0; i < Segments_Per_Semi/2; i++)
                {
                    if (ang <= fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);
                        vFan_Verts.Add(v);
                        vUVs.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }
                vFan_Verts.Add(center);
                vUVs.Add(new Vector2(0.5f, 0.5f));

                //90 = 180
                ang = 90;
                for (int i = 0; i < Segments_Per_Semi / 2 + 1; i++)
                {
                    if (ang >= 180 - fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);
                        vFan_Verts.Add(v);
                        vUVs.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }
                draft.Add(TriangleFan_UVs(vFan_Verts, vUVs));

                List<Vector3> vFan_Verts_Bot = new List<Vector3>();
                List<Vector2> vUVs_Bot = new List<Vector2>();

                vFan_Verts_Bot.Add(center);
                vUVs_Bot.Add(new Vector2(0.5f, 0.5f));

                //180 - 270
                ang = 180;
                for (int i = 0; i < Segments_Per_Semi/2; i++)
                {
                    if (ang <= 180+fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);
                        vFan_Verts_Bot.Add(v);
                        vUVs_Bot.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }

                vFan_Verts_Bot.Add(center);
                vUVs_Bot.Add(new Vector2(0.5f, 0.5f));

                //270-360
                ang = 270;
                for (int i = 0; i < Segments_Per_Semi / 2 + 1; i++)
                {
                    if (ang >= 360 - fan)
                    {
                        v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);
                        vFan_Verts_Bot.Add(v);
                        vUVs_Bot.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                    }
                    ang += deltAng;
                }
                draft.Add(TriangleFan_UVs(vFan_Verts_Bot, vUVs_Bot));
            }      
            return draft;
        }


        public static MeshDraft Arc_Mesh_Plate(float lenX, float lenY_Top, float lenY_Bot, int Segments_Per_Semi, float horzScale, float vertScale, float scale_UV_X, float scale_UV_Y, float uv_Vert_Offset)
        {
            var draft = new MeshDraft { name = "Arc_Mesh_Plate" };
            
            Vector3 center = new Vector3(0, 0, 0);
            float ang = 0;
            float deltAng = 180 / Segments_Per_Semi;
            List<Vector3> vFan_Verts = new List<Vector3>();
            List<Vector2> vUVs = new List<Vector2>();

            vFan_Verts.Add(center);
            vUVs.Add(new Vector2(0.5f, 0.5f));
            Vector3 v;
            for (int i = 0; i < Segments_Per_Semi; i++)
            {
                v = Pos_on_Ellipse(lenX * horzScale, lenY_Top * vertScale, ang);
                vFan_Verts.Add(v);
                vUVs.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y *(v.y / lenY_Top))+uv_Vert_Offset));
                ang += deltAng;
            }

            for(int i = 0; i < Segments_Per_Semi+1; i++)
            {
                v = Pos_on_Ellipse(lenX * horzScale, lenY_Bot * vertScale, ang);
                vFan_Verts.Add(v);
                vUVs.Add(new Vector2(0.5f * (1 + scale_UV_X * (v.x / lenY_Top)), 0.5f * (1 + scale_UV_Y * (v.y / lenY_Top)) + uv_Vert_Offset));
                ang += deltAng;
            }
            draft.Add(TriangleFan_UVs(vFan_Verts,vUVs));
            return draft;
        }

       


        public static MeshDraft Arc_Cube(float arch_Angle, float theta_Pos, float lenX, float lenY, int spar_Segments, float inner_Height, float inner_Width, float rounding_Radius, int rounding_Segments)
        {
            var draft = new MeshDraft { name = "Arc_Cube - VU Button Work" };

            Vector3 center_loc = Pos_on_Ellipse( lenX, lenY, theta_Pos);
            Vector3 left_loc = Pos_on_Ellipse(lenX, lenY, theta_Pos+arch_Angle/2);
            Vector3 right_loc = Pos_on_Ellipse( lenX, lenY, theta_Pos - arch_Angle / 2);

            Vector3 left_Pointing  = Vector3.Cross(Vector3.forward, Vector3.Normalize(left_loc));
            Vector3 right_Pointing = Vector3.Cross(Vector3.Normalize(right_loc),Vector3.forward);

            //Left End Plate
            Vector3 vH = Vector3.Normalize(left_loc);
            Vector3 vW = Vector3.forward;
            float h = inner_Height/2;
            float w = inner_Width / 2;

            List<Vector3> vEndPlate_Left = new List<Vector3>();
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius - vW * w);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius - vW * w - vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius - vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius + vW * w - vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius + vW * w);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius + vW * w + vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius + vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius - vW * w + vH * h);
            vEndPlate_Left.Add(left_loc + left_Pointing * rounding_Radius - vW * w);

            draft.Add(TriangleFan(vEndPlate_Left));

            //Right End Plate
            vH = Vector3.Normalize(right_loc);

            List<Vector3> vEndPlate_Right = new List<Vector3>();
            
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius - vW * w);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius - vW * w + vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius + vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius + vW * w + vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius + vW * w);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius + vW * w - vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius - vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius - vW * w - vH * h);
            vEndPlate_Right.Add(right_loc + right_Pointing * rounding_Radius - vW * w);

            draft.Add(TriangleFan(vEndPlate_Right));
            float arch_delta_ang = arch_Angle / spar_Segments;

            vH = Vector3.Normalize(left_loc);
            vW = Vector3.forward;

            List<Vector3> vCrossSec_L = new List<Vector3>();
            List<Vector3> norm_CSec_L = new List<Vector3>();

            float arch_ang_inner = 0;
            float ang = 0;
            float dAng = Mathf.PI / (2*rounding_Segments);
            Vector3 vCirc;

            vCrossSec_L.Add(left_loc - vW * (w + rounding_Radius));
            norm_CSec_L.Add(-vW);
            for (int i = 0; i<rounding_Segments; i++)
            {
                vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                vCrossSec_L.Add(left_loc - vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                ang += dAng;
            }

            vCrossSec_L.Add(left_loc + vH * (h + rounding_Radius));
            norm_CSec_L.Add(vH);
            for (int i = 0; i < rounding_Segments; i++)
            {
                vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                vCrossSec_L.Add(left_loc + vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                ang += dAng;
            }

            vCrossSec_L.Add(left_loc + vW * (w + rounding_Radius));
            norm_CSec_L.Add(vW);

            for (int i = 0; i < rounding_Segments; i++)
            {
                vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                vCrossSec_L.Add(left_loc + vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                ang += dAng;
            }

            vCrossSec_L.Add(left_loc - vH * (h + rounding_Radius));
            norm_CSec_L.Add(-vH);

            for (int i = 0; i < rounding_Segments; i++)
            {
                vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                vCrossSec_L.Add(left_loc - vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                ang += dAng;
            }
            vCrossSec_L.Add(left_loc - vW * (w + rounding_Radius));
            norm_CSec_L.Add(-vW);

            for (int j = 0; j < spar_Segments; j++)
            {
                List<Vector3> vCrossSec_R = new List<Vector3>();
                List<Vector3> norm_CSec_R = new List<Vector3>();
                arch_ang_inner -= arch_delta_ang;
                center_loc = Pos_on_Ellipse(lenX, lenY, theta_Pos + arch_Angle / 2 + arch_ang_inner);
                vH = Vector3.Normalize(center_loc);

                ang = 0;

                vCrossSec_R.Add(center_loc - vW * (w + rounding_Radius));
                norm_CSec_R.Add(-vW);
                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_R.Add(center_loc - vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_R.Add(center_loc + vH * (h + rounding_Radius));
                norm_CSec_R.Add(vH);
                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_R.Add(center_loc + vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_R.Add(center_loc + vW * (w + rounding_Radius));
                norm_CSec_R.Add(vW);
                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_R.Add(center_loc + vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_R.Add(center_loc - vH * (h + rounding_Radius));
                norm_CSec_R.Add(-vH);

                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_R.Add(center_loc - vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }
                vCrossSec_R.Add(center_loc - vW * (w + rounding_Radius));
                norm_CSec_R.Add(-vW);


                draft.Add(Band_Flip(vCrossSec_L, norm_CSec_L, vCrossSec_R, norm_CSec_L));
                vCrossSec_L = vCrossSec_R;
                norm_CSec_L = norm_CSec_R;
            }

            //CAPS
            Vector3 cap_loc = left_loc;
            Vector3 pointing = left_Pointing;
            float dir = 1;
            for (int k = 0; k < 2; k++)
            {
                if(k == 1)
                {
                    cap_loc = right_loc;
                    pointing = right_Pointing;
                    dir = -1;
                }

                vCrossSec_L = new List<Vector3>();
                norm_CSec_L = new List<Vector3>();
                vH = Vector3.Normalize(cap_loc);

                float incRad = rounding_Radius / rounding_Segments;
                float accRad = 0;

                vCrossSec_L.Add(cap_loc - vW * (w + rounding_Radius));
                norm_CSec_L.Add(-vW);
                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_L.Add(cap_loc - vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_L.Add(cap_loc + vH * (h + rounding_Radius));
                norm_CSec_L.Add(vH);
                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_L.Add(cap_loc + vW * w + vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_L.Add(cap_loc + vW * (w + rounding_Radius));
                norm_CSec_L.Add(vW);

                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_L.Add(cap_loc + vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }

                vCrossSec_L.Add(cap_loc - vH * (h + rounding_Radius));
                norm_CSec_L.Add(-vH);

                for (int i = 0; i < rounding_Segments; i++)
                {
                    vCirc = PTUtils.PointOnCircle3_XY2(rounding_Radius, ang);
                    vCrossSec_L.Add(cap_loc - vW * w - vH * h - vCirc.x * vW + vCirc.y * vH);
                    norm_CSec_L.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH));
                    ang += dAng;
                }
                vCrossSec_L.Add(cap_loc - vW * (w + rounding_Radius));
                norm_CSec_L.Add(-vW);

                for (int j = 0; j < rounding_Segments; j++)
                {
                    List<Vector3> vCrossSec_R = new List<Vector3>();
                    List<Vector3> norm_CSec_R = new List<Vector3>();
                    arch_ang_inner -= arch_delta_ang;
                    //center_loc = Pos_on_Ellipse(dist_From_Axis, lenX, lenY, theta_Pos + arch_Angle / 2 + arch_ang_inner);
                    //vH = Vector3.Normalize(left_loc);

                    ang = 0;

                    //float incRad = rounding_Radius / rounding_Segments;
                    //float accRad = 0;
                    accRad += incRad;
                    //New_Rad = Radius * sin(Arccos(Inc_Accum / Radius))

                    float newRad = rounding_Radius * Mathf.Sin(Mathf.Acos(accRad / rounding_Radius));

                    if (j == rounding_Segments - 1) newRad = 0;

                    vCrossSec_R.Add(cap_loc - vW * (w + newRad) + accRad* pointing);
                    norm_CSec_R.Add(-vW);
                    for (int i = 0; i < rounding_Segments; i++)
                    {
                        vCirc = PTUtils.PointOnCircle3_XY2(newRad, ang);
                        vCrossSec_R.Add(cap_loc - vW * w + vH * h - vCirc.x * vW + vCirc.y * vH + accRad * pointing);
                        norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH + accRad * pointing));
                        ang += dAng;
                    }

                    vCrossSec_R.Add(cap_loc + vH * (h + newRad) + accRad * pointing);
                    norm_CSec_R.Add(vH);
                    for (int i = 0; i < rounding_Segments; i++)
                    {
                        vCirc = PTUtils.PointOnCircle3_XY2(newRad, ang);
                        vCrossSec_R.Add(cap_loc + vW * w + vH * h - vCirc.x * vW + vCirc.y * vH + accRad * pointing);
                        norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH + accRad * pointing));
                        ang += dAng;
                    }

                    vCrossSec_R.Add(cap_loc + vW * (w + newRad) + accRad * pointing);
                    norm_CSec_R.Add(vW);
                    for (int i = 0; i < rounding_Segments; i++)
                    {
                        vCirc = PTUtils.PointOnCircle3_XY2(newRad, ang);
                        vCrossSec_R.Add(cap_loc + vW * w - vH * h - vCirc.x * vW + vCirc.y * vH + accRad * pointing);
                        norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH + accRad * pointing));
                        ang += dAng;
                    }

                    vCrossSec_R.Add(cap_loc - vH * (h + newRad) + accRad * pointing );
                    norm_CSec_R.Add(-vH);

                    for (int i = 0; i < rounding_Segments; i++)
                    {
                        vCirc = PTUtils.PointOnCircle3_XY2(newRad, ang);
                        vCrossSec_R.Add(cap_loc - vW * w - vH * h - vCirc.x * vW + vCirc.y * vH + accRad * pointing);
                        norm_CSec_R.Add(Vector3.Normalize(-vCirc.x * vW + vCirc.y * vH + accRad * pointing));
                        ang += dAng;
                    }
                    vCrossSec_R.Add(cap_loc - vW * (w + newRad) + accRad * pointing);
                    norm_CSec_R.Add(-vW);

                    if (k == 0)
                    {
                        draft.Add(Band_Flip(vCrossSec_R, norm_CSec_R, vCrossSec_L, norm_CSec_L));
                    }
                    else
                    {
                        draft.Add(Band_Flip( vCrossSec_L, norm_CSec_L, vCrossSec_R, norm_CSec_R));
                    }

                    vCrossSec_L = vCrossSec_R;
                    norm_CSec_L = norm_CSec_R;
                }
            }

            return draft;    
        }

procedural_rounded_button