Beispiel #1
0
 public void Init(MyStandardMaterialKey key)
 {
     if (key.Technique == MyMeshDrawTechnique.MESH)
     {
         InitStandard(key.CmFilepath, key.NgFilepath, key.ExtFilepath);
     }
     else if (key.Technique == MyMeshDrawTechnique.DECAL)
     {
         InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, false);
     }
     else if (key.Technique == MyMeshDrawTechnique.DECAL_NOPREMULT)
     {
         InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, false, false);
     }
     else if (key.Technique == MyMeshDrawTechnique.DECAL_CUTOUT)
     {
         InitDecal(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath, true, true);
     }
     else if (key.Technique == MyMeshDrawTechnique.ALPHA_MASKED)
     {
         InitAlphamask(key.CmFilepath, key.NgFilepath, key.ExtFilepath, key.AlphamaskFilepath);
     }
     else if (key.Technique == MyMeshDrawTechnique.GLASS)
     {
         MyRenderProxy.Error("Glass material cannot be processed by this object");
     }
     else
     {
         MyRenderProxy.Error("Material is not resolved, please extend the functionality of the new pipeline or move object to the old pipeline");
     }
 }
Beispiel #2
0
        Dictionary <string, MyGlassMaterial> m_glassMaterials = new Dictionary <string, MyGlassMaterial>(); // key is materialName

        public MyStandardMaterial GetOrCreateStandardMaterial(string materialName, MyMeshDrawTechnique technique, string cmFilepath, string ngFilepath, string extFilepath, string alphamaskFilepath)
        {
            MyStandardMaterialKey key = new MyStandardMaterialKey
            {
                Technique         = technique,
                CmFilepath        = cmFilepath,
                NgFilepath        = ngFilepath,
                ExtFilepath       = extFilepath,
                AlphamaskFilepath = alphamaskFilepath,
            };

            MyStandardMaterial material;

            if (m_standardMaterials.TryGetValue(key, out material))
            {
                return(material);
            }

            material = new MyStandardMaterial();
            material.Init(key);

            m_standardMaterials.Add(key, material);

            return(material);
        }