Пример #1
0
    public void LoadStratumScdTextures(bool Loading = true)
    {
        // Load Stratum Textures Paths

        for (int i = 0; i < Textures.Length; i++)
        {
            if (Loading)
            {
                MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Stratum textures " + (i + 1) + " )");

                if (i >= map.Layers.Count)
                {
                    map.Layers.Add(new Layer());
                }

                Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathTexture);
                Textures[i].NormalPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathNormalmap);
                if (Textures[i].AlbedoPath.StartsWith("/"))
                {
                    Textures[i].AlbedoPath = Textures[i].AlbedoPath.Remove(0, 1);
                }
                if (Textures[i].NormalPath.StartsWith("/"))
                {
                    Textures[i].NormalPath = Textures[i].NormalPath.Remove(0, 1);
                }

                Textures[i].AlbedoScale = map.Layers[i].ScaleTexture;
                Textures[i].NormalScale = map.Layers[i].ScaleNormalmap;
            }

            string Env = GetGamedataFile.EnvScd;
            if (Textures[i].AlbedoPath.ToLower().StartsWith("maps"))
            {
                Env = GetGamedataFile.MapScd;
            }

            try
            {
                Textures[i].AlbedoPath = GetGamedataFile.FindFile(Env, Textures[i].AlbedoPath);
                //Debug.Log("Found: " + Textures[i].AlbedoPath);
                GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].AlbedoPath, i, false);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Albedo tex: " + Textures[i].AlbedoPath);
                Debug.LogError(e);
            }

            Env = GetGamedataFile.EnvScd;
            if (Textures[i].NormalPath.ToLower().StartsWith("maps"))
            {
                Env = GetGamedataFile.MapScd;
            }

            try
            {
                Textures[i].NormalPath = GetGamedataFile.FindFile(Env, Textures[i].NormalPath);
                //Debug.Log("Found: " + Textures[i].NormalPath);
                GetGamedataFile.LoadTextureFromGamedata(GetGamedataFile.EnvScd, Textures[i].NormalPath, i, true);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Normal tex: " + Textures[i].NormalPath);
                Debug.LogError(e);
            }
        }
    }
Пример #2
0
    public void LoadStratumScdTextures(bool Loading = true)
    {
        // Load Stratum Textures Paths


        bool NormalMapFix = false;

        for (int i = 0; i < Textures.Length; i++)
        {
            if (Loading)
            {
                MapLuaParser.Current.InfoPopup.Show(true, "Loading map...\n( Stratum textures " + (i + 1) + " )");

                if (i >= map.Layers.Count)
                {
                    map.Layers.Add(new Layer());
                }

                Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathTexture);
                if (Textures[i].AlbedoPath.StartsWith("/"))
                {
                    Textures[i].AlbedoPath = Textures[i].AlbedoPath.Remove(0, 1);
                }
                Textures[i].AlbedoScale = map.Layers[i].ScaleTexture;


                if (string.IsNullOrEmpty(map.Layers[i].PathNormalmap))
                {
                    if (i == 9)
                    {
                        // Upper stratum normal should be empty!
                        Textures[i].NormalPath = "";
                        Debug.Log("Clear Upper stratum normal map");
                    }
                    else
                    {
                        Textures[i].NormalPath = "env/tundra/layers/tund_sandlight_normal.dds";
                        Debug.Log("Add missing normalmap on stratum " + i);
                        NormalMapFix = true;
                    }
                }
                else
                {
                    if (i == 9)
                    {
                        // Upper stratum normal should be empty!
                        Textures[i].NormalPath = "";
                        NormalMapFix           = true;
                    }
                    else
                    {
                        Textures[i].NormalPath = GetGamedataFile.FixMapsPath(map.Layers[i].PathNormalmap);
                        if (Textures[i].NormalPath.StartsWith("/"))
                        {
                            Textures[i].NormalPath = Textures[i].NormalPath.Remove(0, 1);
                        }
                    }
                }
                Textures[i].NormalScale = map.Layers[i].ScaleNormalmap;
            }


            /*string Env = GetGamedataFile.EnvScd;
             * if (GetGamedataFile.IsMapPath(Textures[i].AlbedoPath))
             *      Env = GetGamedataFile.MapScd;*/

            try
            {
                Textures[i].AlbedoPath = GetGamedataFile.FindFile(Textures[i].AlbedoPath);
                //Debug.Log("Found: " + Textures[i].AlbedoPath);
                GetGamedataFile.LoadTextureFromGamedata(Textures[i].AlbedoPath, i, false);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Albedo tex: " + Textures[i].AlbedoPath);
                Debug.LogError(e);
            }

            /*Env = GetGamedataFile.EnvScd;
            *  if (GetGamedataFile.IsMapPath(Textures[i].NormalPath))
            *       Env = GetGamedataFile.MapScd;*/

            try
            {
                Textures[i].NormalPath = GetGamedataFile.FindFile(Textures[i].NormalPath);
                //Debug.Log("Found: " + Textures[i].NormalPath);
                GetGamedataFile.LoadTextureFromGamedata(Textures[i].NormalPath, i, true);
            }
            catch (System.Exception e)
            {
                Debug.LogError(i + ", Normal tex: " + Textures[i].NormalPath);
                Debug.LogError(e);
            }
        }


        if (NormalMapFix)
        {
            GenericInfoPopup.ShowInfo("Fixed wrong or missing normalmap textures on stratum layers");
        }
    }