示例#1
0
        protected void AddUV(FilterMeshData filterMeshData, BlockType type, byte extendId, Direction direction)
        {
            BlockAttributeCalculator calculator = BlockAttributeCalculatorFactory.GetCalculator(type);
            Rect  uvRect = calculator.GetUVRect(extendId, direction);
            float scale  = uvRect.width * 0.03f;

            filterMeshData.uv.Add(new Vector2(uvRect.x + uvRect.width - scale, uvRect.y + uvRect.height - scale));
            filterMeshData.uv.Add(new Vector2(uvRect.x + scale, uvRect.y + uvRect.height - scale));
            filterMeshData.uv.Add(new Vector2(uvRect.x + scale, uvRect.y + scale));
            filterMeshData.uv.Add(new Vector2(uvRect.x + uvRect.width - scale, uvRect.y + scale));
        }
示例#2
0
        public void SetFilterMeshData(FilterMeshData filterMeshData)
        {
            Mesh mesh = filter.sharedMesh;

            if (mesh == null)
            {
                mesh = MeshMemoryCache.Instance.GetMesh();
            }
            else
            {
                mesh.Clear();
            }
            mesh.vertices  = filterMeshData.vertices.ToArray();
            mesh.triangles = filterMeshData.triangles.ToArray();
            mesh.uv        = filterMeshData.uv.ToArray();
            mesh.colors    = filterMeshData.colors.ToArray();
//			Debug.Log("vertices:" + filterMeshData.vertices.Count +
//			          " triangles:" + filterMeshData.triangles.Count +
//			          " uv:" + filterMeshData.uv.Count +
//			          " colors:" + filterMeshData.colors.Count);
            mesh.RecalculateNormals();
            mesh.Optimize();
            mesh.MarkDynamic();
            filter.sharedMesh = null;
            filter.sharedMesh = mesh;

//            if(mesh == null)
//            {
//              mesh = new Mesh();
//            }
//            else
//            {
//              mesh.Clear();
//            }
//            mesh.vertices = filterMeshData.vertices.ToArray();
//            mesh.triangles = filterMeshData.triangles.ToArray();
//            mesh.uv = filterMeshData.uv.ToArray();
//            mesh.colors = filterMeshData.colors.ToArray();
//            mesh.RecalculateNormals();
//			mesh.Optimize();
//            layerMask = LayerMask.NameToLayer("TerrainMesh");
        }