Exemplo n.º 1
0
    public void Bake()
    {
        //Group.Blueprint = GetGamedataFile.FixMapsPath(Group.Blueprint.Replace("\\", "/"));

        BlueprintPath = Group.Blueprint.Replace("\\", "/");

        if (!BlueprintPath.StartsWith("/"))
        {
            BlueprintPath = "/" + BlueprintPath;
        }

        BlueprintPath = GetGamedataFile.FixMapsPath(BlueprintPath);

        Position = ScmapEditor.WorldPosToScmap(Obj.Tr.position);

        RotationX = Vector3.zero;
        RotationY = Vector3.zero;
        RotationZ = Vector3.zero;
        MassMath.QuaternionToRotationMatrix(Obj.Tr.localRotation, ref RotationX, ref RotationY, ref RotationZ);

        Scale = Obj.Tr.localScale;
        if (Group.PropObject.BP != null)
        {
            Scale.x /= Group.PropObject.BP.LocalScale.x;
            Scale.y /= Group.PropObject.BP.LocalScale.y;
            Scale.z /= Group.PropObject.BP.LocalScale.z;
        }
    }
Exemplo n.º 2
0
        public void Load(Decal Source)
        {
            Type     = Source.Type;
            Tex1Path = GetGamedataFile.FixMapsPath(Source.TexPathes[0]);
            Tex2Path = GetGamedataFile.FixMapsPath(Source.TexPathes[1]);

            UpdateMaterial();
        }
Exemplo n.º 3
0
        public void Bake()
        {
            _Dec.Type     = _Dec.Shared.Type;
            _Dec.Position = ScmapEditor.WorldPosToScmap(GetPivotPoint());
            _Dec.Scale    = tr.localScale * 10f;
            _Dec.Rotation = tr.localEulerAngles * Mathf.Deg2Rad;

            _Dec.CutOffLOD     = CutOffLOD;
            _Dec.NearCutOffLOD = NearCutOffLOD;
            _Dec.TexPathes     = new string[2];
            _Dec.Shared.FixPaths();

            _Dec.Shared.Tex1Path = GetGamedataFile.FixMapsPath(_Dec.Shared.Tex1Path);
            _Dec.Shared.Tex2Path = GetGamedataFile.FixMapsPath(_Dec.Shared.Tex2Path);

            _Dec.TexPathes[0] = _Dec.Shared.Tex1Path;
            _Dec.TexPathes[1] = _Dec.Shared.Tex2Path;
            _Dec.Obj          = this;
        }
Exemplo n.º 4
0
    public void SaveScmapFile()
    {
        float LowestElevation  = ScmapEditor.MaxElevation;
        float HighestElevation = 0;

        if (Teren)
        {
            heights       = Teren.terrainData.GetHeights(0, 0, Teren.terrainData.heightmapWidth, Teren.terrainData.heightmapHeight);
            heightsLength = heights.GetLength(0);

            int y = 0;
            int x = 0;
            for (y = 0; y < map.Width + 1; y++)
            {
                for (x = 0; x < map.Height + 1; x++)
                {
                    float Height = heights[x, y];

                    LowestElevation  = Mathf.Min(LowestElevation, Height);
                    HighestElevation = Mathf.Max(HighestElevation, Height);

                    //double HeightValue = ((double)Height) * HeightResize;
                    //map.SetHeight(y, map.Height - x, (short)(HeightValue + RoundingError));
                    map.SetHeight(y, map.Height - x, (ushort)(Height * HeightResize));
                }
            }
        }

        LowestElevation  = (LowestElevation * TerrainHeight) / 0.1f;
        HighestElevation = (HighestElevation * TerrainHeight) / 0.1f;


        if (HighestElevation - LowestElevation > 49.9)
        {
            Debug.Log("Lowest point: " + LowestElevation);
            Debug.Log("Highest point: " + HighestElevation);

            Debug.LogWarning("Height difference is too high! it might couse rendering issues! Height difference is: " + (HighestElevation - LowestElevation));
            GenericInfoPopup.ShowInfo("Height difference " + (HighestElevation - LowestElevation) + " is too high!\nIt might couse rendering issues!");
        }


        if (MapLuaParser.Current.EditMenu.MapInfoMenu.SaveAsFa.isOn)
        {
            if (map.AdditionalSkyboxData == null || map.AdditionalSkyboxData.Data == null || map.AdditionalSkyboxData.Data.Position.x == 0)
            {             // Convert to v60
                LoadDefaultSkybox();
            }

            map.VersionMinor = 60;
            map.AdditionalSkyboxData.Data.UpdateSize();
        }
        else if (map.VersionMinor >= 60)        // Convert to v56
        {
            LoadDefaultSkybox();
            map.AdditionalSkyboxData.Data.UpdateSize();
            map.VersionMinor = 56;
        }

        //Debug.Log("Set Heightmap to map " + map.Width + ", " + map.Height);

        //string MapPath = EnvPaths.GetMapsPath();
        string path = MapLuaParser.MapRelativePath(MapLuaParser.Current.ScenarioLuaFile.Data.map);

        //TODO force values if needed
        //map.TerrainShader = Shader;
        map.TerrainShader = MapLuaParser.Current.EditMenu.TexturesMenu.TTerrainXP.isOn ? ("TTerrainXP") : ("TTerrain");

        map.MinimapContourColor   = new Color32(0, 0, 0, 255);
        map.MinimapDeepWaterColor = new Color32(71, 140, 181, 255);
        map.MinimapShoreColor     = new Color32(141, 200, 225, 255);
        map.MinimapLandStartColor = new Color32(119, 101, 108, 255);
        map.MinimapLandEndColor   = new Color32(206, 206, 176, 255);
        //map.MinimapLandEndColor = new Color32 (255, 255, 215, 255);
        map.MinimapContourInterval = 10;

        map.WatermapTex = new Texture2D(map.UncompressedWatermapTex.width, map.UncompressedWatermapTex.height, map.UncompressedWatermapTex.format, false);
        map.WatermapTex.SetPixels(map.UncompressedWatermapTex.GetPixels());
        map.WatermapTex.Apply();
        map.WatermapTex.Compress(true);
        map.WatermapTex.Apply();

        map.NormalmapTex = new Texture2D(map.UncompressedNormalmapTex.width, map.UncompressedNormalmapTex.height, map.UncompressedNormalmapTex.format, false);
        map.NormalmapTex.SetPixels(map.UncompressedNormalmapTex.GetPixels());
        map.NormalmapTex.Apply();
        map.NormalmapTex.Compress(true);
        map.NormalmapTex.Apply();

        map.PreviewTex = PreviewRenderer.RenderPreview(((LowestElevation + HighestElevation) / 2) * 0.1f);


        for (int i = 0; i < map.Layers.Count; i++)
        {
            Textures[i].AlbedoPath = GetGamedataFile.FixMapsPath(Textures[i].AlbedoPath);
            Textures[i].NormalPath = GetGamedataFile.FixMapsPath(Textures[i].NormalPath);

            map.Layers[i].PathTexture   = Textures[i].AlbedoPath;
            map.Layers[i].PathNormalmap = Textures[i].NormalPath;

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



        List <Prop> AllProps = new List <Prop>();

        if (EditMap.PropsInfo.AllPropsTypes != null)
        {
            int Count = EditMap.PropsInfo.AllPropsTypes.Count;
            for (int i = 0; i < EditMap.PropsInfo.AllPropsTypes.Count; i++)
            {
                AllProps.AddRange(EditMap.PropsInfo.AllPropsTypes[i].GenerateSupComProps());
            }
        }
        map.Props = AllProps;


        if (map.VersionMinor < 56)
        {
            map.ConvertToV56();
        }

        map.Save(path, map.VersionMinor);
    }
Exemplo n.º 5
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);
            }
        }
    }
Exemplo n.º 6
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");
        }
    }