Exemple #1
0
        public static Material CreateTableauMaterial(
            RenderTargetComponent.TextureUpdateEventHandler eventHandler,
            object objectRef,
            Material sampleMaterial,
            int tableauSizeX,
            int tableauSizeY,
            bool continuousTableau = false)
        {
            if ((NativeObject)sampleMaterial == (NativeObject)null)
            {
                sampleMaterial = Material.GetDefaultTableauSampleMaterial(true);
            }
            Material copy = sampleMaterial.CreateCopy();
            uint     materialShaderFlagMask = (uint)copy.GetShader().GetMaterialShaderFlagMask("use_tableau_blending");
            ulong    shaderFlags            = copy.GetShaderFlags();

            copy.SetShaderFlags(shaderFlags | (ulong)materialShaderFlagMask);
            string str = "";

            System.Type type = objectRef.GetType();
            MaterialCacheIDGetMethodDelegate getMethodDelegate;

            if (!continuousTableau && HasTableauCache.TableauCacheTypes.TryGetValue(type, out getMethodDelegate))
            {
                str = getMethodDelegate(objectRef).ToLower();
                Texture fromResource = Texture.CheckAndGetFromResource(str);
                if ((NativeObject)fromResource != (NativeObject)null)
                {
                    copy.SetTexture(Material.MBTextureType.DiffuseMap2, fromResource);
                    return(copy);
                }
            }
            if (str != "")
            {
                Texture.ScaleTextureWithRatio(ref tableauSizeX, ref tableauSizeY);
            }
            Texture tableauTexture = Texture.CreateTableauTexture(str, eventHandler, objectRef, tableauSizeX, tableauSizeY);

            if (str != "")
            {
                TableauView tableauView = tableauTexture.TableauView;
                tableauView.SetSaveFinalResultToDisk(true);
                tableauView.SetFileNameToSaveResult(str);
                tableauView.SetFileTypeToSave(View.TextureSaveFormat.TextureTypeDds);
            }
            if (str != "")
            {
                tableauTexture.TransformRenderTargetToResource(str);
            }
            copy.SetTexture(Material.MBTextureType.DiffuseMap2, tableauTexture);
            return(copy);
        }
        public static Texture AddTableau(
            RenderTargetComponent.TextureUpdateEventHandler eventHandler,
            object objectRef,
            int tableauSizeX,
            int tableauSizeY)
        {
            Texture     tableauTexture = Texture.CreateTableauTexture(nameof(AddTableau), eventHandler, objectRef, tableauSizeX, tableauSizeY);
            TableauView tableauView    = tableauTexture.TableauView;

            tableauView.SetRenderOnDemand(false);
            tableauView.SetResolutionScaling(true);
            return(tableauTexture);
        }