Ejemplo n.º 1
0
 private static Mesh GenerateSkinnedLOD(Transform transform, SkinnedMeshRenderer[] renderers, float quality, out Material[] materials, out Transform[] mergedBones, DecimationAlgorithm.StatusReportCallback statusCallback)
 {
     if (renderers.Length == 1)
     {
         var renderer          = renderers[0];
         var rendererTransform = renderer.transform;
         var mesh          = renderer.sharedMesh;
         var meshTransform = transform.worldToLocalMatrix * rendererTransform.localToWorldMatrix;
         materials   = renderer.sharedMaterials;
         mergedBones = renderer.bones;
         return(MeshDecimatorUtility.DecimateMesh(mesh, meshTransform, quality, false, statusCallback));
     }
     else
     {
         var sourceMeshes  = new Mesh[renderers.Length];
         var transforms    = new Matrix4x4[renderers.Length];
         var meshMaterials = new Material[renderers.Length][];
         var meshBones     = new Transform[renderers.Length][];
         for (int i = 0; i < renderers.Length; i++)
         {
             var renderer          = renderers[i];
             var rendererTransform = renderer.transform;
             sourceMeshes[i]  = renderer.sharedMesh;
             transforms[i]    = transform.worldToLocalMatrix * rendererTransform.localToWorldMatrix;
             meshMaterials[i] = renderer.sharedMaterials;
             meshBones[i]     = renderer.bones;
         }
         return(MeshDecimatorUtility.DecimateMeshes(sourceMeshes, transforms, meshMaterials, meshBones, quality, false, out materials, out mergedBones, statusCallback));
     }
 }
Ejemplo n.º 2
0
        private static Mesh GenerateSkinnedLOD(Transform transform, SkinnedMeshRenderer renderer, float quality, out Material[] materials, out Transform[] mergedBones, DecimationAlgorithm.StatusReportCallback statusCallback)
        {
            var rendererTransform = renderer.transform;
            var mesh          = renderer.sharedMesh;
            var meshTransform = transform.worldToLocalMatrix * rendererTransform.localToWorldMatrix;

            materials   = renderer.sharedMaterials;
            mergedBones = renderer.bones;
            return(MeshDecimatorUtility.DecimateMesh(mesh, meshTransform, quality, false, statusCallback));
        }
Ejemplo n.º 3
0
        private static Mesh GenerateStaticLOD(Transform transform, MeshRenderer renderer, float quality, out Material[] materials, DecimationAlgorithm.StatusReportCallback statusCallback)
        {
            var rendererTransform = renderer.transform;
            var meshFilter        = renderer.GetComponent <MeshFilter>();
            var mesh          = meshFilter.sharedMesh;
            var meshTransform = transform.worldToLocalMatrix * rendererTransform.localToWorldMatrix;

            materials = renderer.sharedMaterials;
            return(MeshDecimatorUtility.DecimateMesh(mesh, meshTransform, quality, false, statusCallback));
        }
Ejemplo n.º 4
0
 private static Mesh GenerateStaticLOD(Transform transform, MeshRenderer[] renderers, float quality, out Material[] materials, DecimationAlgorithm.StatusReportCallback statusCallback)
 {
     if (renderers.Length == 1)
     {
         return(GenerateStaticLOD(transform, renderers[0], quality, out materials, statusCallback));
     }
     else
     {
         var sourceMeshes  = new Mesh[renderers.Length];
         var transforms    = new Matrix4x4[renderers.Length];
         var meshMaterials = new Material[renderers.Length][];
         for (int i = 0; i < renderers.Length; i++)
         {
             var renderer          = renderers[i];
             var rendererTransform = renderer.transform;
             var meshFilter        = renderer.GetComponent <MeshFilter>();
             sourceMeshes[i]  = meshFilter.sharedMesh;
             transforms[i]    = transform.worldToLocalMatrix * rendererTransform.localToWorldMatrix;
             meshMaterials[i] = renderer.sharedMaterials;
         }
         return(MeshDecimatorUtility.DecimateMeshes(sourceMeshes, transforms, meshMaterials, quality, false, out materials, statusCallback));
     }
 }