Exemplo n.º 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;
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public void BuildFromMesh(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;
            gameObject.AddComponent <MeshRenderer>().sharedMaterial = _materialProvider.GetSharedMaterial(mesh.TextureIndex);
            gameObject.transform.parent = tile.GameObject.transform;
        }