public void CreateRidge(Vector3 topCtrlPoint, Vector3 secCtrlPoint, Vector3 thirdCtrlPoint, Vector3 lastCtrlPoint)
    {
        NewRidgeStruct ridge   = new NewRidgeStruct();
        CatLine        catLine = new CatLine();

        ridge.dicCtrlPoint.Add(Define.TopPoint, topCtrlPoint);
        ridge.dicCtrlPoint.Add(Define.SecPoint, secCtrlPoint);
        ridge.dicCtrlPoint.Add(Define.ThirdPoint, thirdCtrlPoint);
        ridge.dicCtrlPoint.Add(Define.LastPoint, lastCtrlPoint);
    }
    public NewRidgeStruct CreateRidgeNoTile(List <Vector3> ctrlList)
    {
        NewRidgeStruct ridge   = new NewRidgeStruct();
        CatLine        catLine = new CatLine();

        ridge.dicCtrlPoint.Add(Define.TopPoint, ctrlList[0]);
        ridge.dicCtrlPoint.Add(Define.SecPoint, ctrlList[1]);
        ridge.dicCtrlPoint.Add(Define.ThirdPoint, ctrlList[2]);
        ridge.dicCtrlPoint.Add(Define.LastPoint, ctrlList[3]);

        catLine.CalculateInnerPointByList(ctrlList, 0);
        //ridge.tilePosList = catLine.CalculateAnchorPosByInnerPointList(catLine.innerPointList, catLine.innerPointList.Count - 1, 0, Define.mainRidgeTileHeight);
        ridge.innerPosList = catLine.innerPointList;
        return(ridge);
    }
    /**
     * 計算膨脹列比率表 " 2 "
     * 輸入 : 1. fInflated : 最大膨脹值 , 2. fatOffset : 最大膨脹位置位移 ,3. segCount : 段數
     * 最大膨脹位置位移為 (-1~1 表示柱子的 1/4高處 到 3/4處)
     */
    public List <float> CalculateColumeRadiusInflateList(float fInflated, float fatOffset, int segCount)
    {
        List <float> listRad = new List <float>()
        {
            1.0f
        };
        int     halfSeg    = segCount / 2;
        float   InflateVal = fInflated / halfSeg;
        CatLine rateLine   = new CatLine();

        rateLine.controlPointPosList.Add(new Vector3(1.0f, 0.0f, 0.0f));
        rateLine.controlPointPosList.Add(new Vector3(fInflated, this.eaveColumnHeight / 2 + (this.eaveColumnHeight / 4 * fatOffset), 0.0f));
        rateLine.controlPointPosList.Add(new Vector3(1.0f, this.eaveColumnHeight, 0.0f));
        rateLine.SetLineNumberOfPoints(Define.Medium);
        rateLine.SetCatmullRom(0.0f);

        for (int iIndex = 1; iIndex <= segCount; iIndex++)
        {
            //** 不知為何用轉型會失敗
            // float Rate = iIndex / segCount;
            // int index = (int)((rateLine.innerPointList.Count-1) * Rate);
            listRad.Add(rateLine.innerPointList[(rateLine.innerPointList.Count - 1) / (segCount + 1) * iIndex].x);
        }

        //for (int iIndex = 0; iIndex < segCount; iIndex++)
        //{
        //    if (iIndex <= halfSeg)
        //    {
        //        listRad.Add(listRad[listRad.Count-1] + InflateVal);
        //    }
        //    else
        //    {
        //        listRad.Add(listRad[listRad.Count-1] - InflateVal);
        //    }
        //}
        listRad.Add(1.0f);
        return(listRad);
    }
    /**
     * 建立規則曲線環狀Mesh(?)
     */
    public List <Vector3> CreateRegularCurveRingMesh(Vector3 centerPos, List <Vector3> localPosList, Vector3 axis, int nbSides, int segmentation, float rotateAngle, MeshFilter meshFilter)
    {
        List <Vector3> controlPointPosList = new List <Vector3>();

        controlPointPosList.Clear();

        Mesh mesh = new Mesh();

        meshFilter.mesh = mesh;
        mesh.Clear();

        float _2pi = Mathf.PI * 2f;

        List <Vector3> globalPosList = new List <Vector3>();

        for (int i = 0; i < localPosList.Count; i++)
        {
            Vector3 pos = localPosList[i] + centerPos;
            globalPosList.Add(pos);
        }

        globalPosList.Reverse();

        CatLine curve = new CatLine();

        curve.controlPointPosList = globalPosList;
        curve.SetLineNumberOfPoints(segmentation);
        curve.SetCatmullRom(0.1f);
        // PosList
        Vector3[] pList = new Vector3[(nbSides + 1) * curve.anchorInnerPointlist.Count];
        int       vert  = 0;

        for (int i = 0; i < curve.anchorInnerPointlist.Count; i++)
        {
            float   radius          = DistancePointLine(curve.anchorInnerPointlist[i], centerPos, axis);
            Vector3 radiusCenterPos = ProjectPointLine(curve.anchorInnerPointlist[i], centerPos, axis) + centerPos;

            pList[vert++] = radiusCenterPos;
            for (int j = 0; j < nbSides; j++)
            {
                float   rad = (float)j / nbSides * _2pi;
                Vector3 pos = Quaternion.AngleAxis(rotateAngle, Vector3.up) * (new Vector3(Mathf.Cos(rad) * radius, 0f, Mathf.Sin(rad) * radius) + radiusCenterPos);
                pList[vert++] = pos;
                controlPointPosList.Add(pos);
                //ShowPos(pos, this.Buildings[selectFloor], Color.red, 0.8f);
                //MainController.ShowPos(pos, MainController.Instance.Buildings[MainController.Instance.selectFloor].building, Color.red, 0.8f);
                MainController.ShowPos(pos, MainController.Instance.Buildings[MainController.Instance.selectFloor].GetComponent <BuildingObj>().building, Color.red, 0.8f);
            }
        }
        #region Vertices
        Vector3[] vertices = new Vector3[3 * nbSides * 2 + curve.anchorInnerPointlist.Count * 6 * nbSides];
        vert = 0;

        // Bottom cap
        for (int i = 0; i < nbSides; i++)
        {
            vertices[vert++] = pList[0];
            vertices[vert++] = pList[i + 1];
            vertices[vert++] = pList[(i + 1) % nbSides + 1];
        }

        // Top cap
        for (int i = 0; i < nbSides; i++)
        {
            vertices[vert++] = pList[(nbSides + 1) * (curve.anchorInnerPointlist.Count - 1)];
            vertices[vert++] = pList[(i + 1) % nbSides + 1 + (nbSides + 1) * (curve.anchorInnerPointlist.Count - 1)];
            vertices[vert++] = pList[i + 1 + (nbSides + 1) * (curve.anchorInnerPointlist.Count - 1)];
        }

        // Sides
        for (int i = 0; i < nbSides; i++)
        {
            for (int j = 0; j < curve.anchorInnerPointlist.Count - 1; j++)
            {
                vertices[vert++] = pList[i + 1 + j * (nbSides + 1)];
                vertices[vert++] = pList[(i + 1) % nbSides + 1 + (nbSides + 1) + j * (nbSides + 1)];
                vertices[vert++] = pList[(i + 1) % nbSides + 1 + j * (nbSides + 1)];


                vertices[vert++] = pList[i + 1 + j * (nbSides + 1)];
                vertices[vert++] = pList[i + 1 + (nbSides + 1) + j * (nbSides + 1)];
                vertices[vert++] = pList[(i + 1) % nbSides + 1 + (nbSides + 1) + j * (nbSides + 1)];
            }
        }

        #endregion
        #region Normales
        Vector3[] normales = new Vector3[vertices.Length];
        vert = 0;
        // Bottom cap
        for (int i = 0; i < nbSides * 3; i++)
        {
            normales[vert++] = Vector3.down;
        }
        // Top cap
        for (int i = 0; i < nbSides * 3; i++)
        {
            normales[vert++] = Vector3.up;
        }
        for (int i = 0; i < nbSides; i++)
        {
            for (int j = 0; j < curve.anchorInnerPointlist.Count - 1; j++)
            {
                Vector3 nor = Vector3.Cross(pList[i + 1 + (nbSides + 1) + j * (nbSides + 1)] - pList[i + 1 + j * (nbSides + 1)], pList[(i + 1) % nbSides + 1 + j * (nbSides + 1)] - pList[i + 1 + j * (nbSides + 1)]).normalized;
                for (int n = 0; n < 6; n++)
                {
                    normales[vert++] = nor;
                }
            }
        }
        #endregion
        #region Triangles
        int[] triangles = new int[vertices.Length];
        vert = 0;
        for (int i = 0; i < triangles.Length; i++)
        {
            triangles[vert++] = i;
        }
        #endregion
        mesh.vertices = vertices;
        mesh.normals  = normales;
        //mesh.uv = uvs;
        mesh.triangles = triangles;

        mesh.RecalculateBounds();
        ;

        return(controlPointPosList);
    }