示例#1
0
        /// <inheritdoc />
        public void BuildMesh(Tile tile, Mesh mesh)
        {
            var gameObject = new GameObject(mesh.Name);

            var uMesh = new UnityEngine.Mesh();

            uMesh.vertices  = mesh.Vertices;
            uMesh.triangles = mesh.Triangles;
            uMesh.colors    = mesh.Colors;
            uMesh.uv        = mesh.Uvs;
            uMesh.uv2       = mesh.Uvs2;
            uMesh.uv3       = mesh.Uvs3;

            uMesh.RecalculateNormals();

            gameObject.isStatic = true;
            gameObject.AddComponent <MeshFilter>().mesh = uMesh;
            // TODO use TextureIndex to select proper material.
            string texture = tile.QuadKey.LevelOfDetail == 16
                ? @"Materials/SurfaceTexturedColored"
                : @"Materials/SurfaceColored";

            gameObject.AddComponent <MeshRenderer>().sharedMaterial = _materialProvider.GetSharedMaterial(texture);
            gameObject.transform.parent = tile.GameObject.transform;
        }
示例#2
0
 private Material GetMaterial(Element element)
 {
     return(_materialProvider.GetSharedMaterial("Materials/" + element.Styles["material"]));
 }