예제 #1
0
        public SnakeMeshGenerator()
        {
            vertices   = new List <Vector3>();
            triangles  = new List <int>();
            uv         = new List <Vector2>();
            meshInfo   = new Types.MeshInfo();
            _midPoints = new List <Vector3>();

            UVParternLookupTable.Add(0, new Vector2(0, 0));
            UVParternLookupTable.Add(1, new Vector2(0, 1));
            UVParternLookupTable.Add(2, new Vector2(1, 0));
            UVParternLookupTable.Add(3, new Vector2(1, 1));
        }
예제 #2
0
        public void RenderMesh()
        {
            if (_snakePath == null)
            {
                return;
            }

            _snakeMeshGenerator.meshSize = meshSize;

            Types.MeshInfo meshInfo = _snakeMeshGenerator.RenderSegments(_snakePath, 0, _snakePath.NumSegments - 1);
            _mesh.Clear();
            _mesh.SetVertices(meshInfo.vertices);
            _mesh.SetTriangles(meshInfo.triangles, 0);
            _mesh.SetUVs(0, meshInfo.uv);

            _mesh.RecalculateNormals();
        }