Beispiel #1
0
        /// <summary>
        /// Creates the curve.
        /// </summary>
        /// <param name="positionList">Position list.</param>
        /// <param name="action">メッシュ生成に必要な情報を受け取るコールバック.</param>
        public static void CreateArea(List <Vector3> positionList, Action <MeshSet> action)
        {
            var positionSetList = new Utility.PositionSetList();

            for (int i = 0; i < positionList.Count; i++)
            {
                int prevIndex = i - 1;
                int nextIndex = i + 1;

                if (i == 0)
                {
                    prevIndex = positionList.Count - 1;
                }

                if (i == positionList.Count - 1)
                {
                    nextIndex = 0;
                }

                positionSetList.Add(new Utility.PositionSet
                {
                    position  = positionList[i],
                    Index     = i,
                    PrevIndex = prevIndex,
                    NextIndex = nextIndex,
                });
            }

            Utility.SeparateAreaSet(positionSetList, action);
        }
Beispiel #2
0
        public static void CreateAreaMesh(Utility.PositionSetList areaSet, Action <CreateRoadMeshScripts.MeshSet> action)
        {
            var verticesList  = new List <Vector3>();
            var trianglesList = new List <int>();
            var uvList        = new List <Vector2>();

            while (areaSet.Count != 2)
            {
                var index = verticesList.Count;
                // 最東を選ぶ
                var tri  = areaSet.GetSortedList()[0];
                var next = areaSet.FindByIndex(tri.NextIndex);
                var prev = areaSet.FindByIndex(tri.PrevIndex);
                // 最東から内側のメッシュ生成する
                verticesList.Add(tri.position);
                verticesList.Add(next.position);
                verticesList.Add(prev.position);
                CreateRoadMeshScripts.AddTrianglesList(verticesList, trianglesList, index + 0, index + 1, index + 2, Vector3.up);
                uvList.Add(new Vector2(0, 0));
                uvList.Add(new Vector2(1, 0));
                uvList.Add(new Vector2(1, 1));
                // 選んだ頂点を減らす。
                areaSet.RemoveSortedListFirst();
            }

            CreateRoadMeshScripts.CreateMeshSet(verticesList, trianglesList, uvList, action);
        }