Exemple #1
0
    static void writeSurfaceSettings(ref gUtility.CXml xml, ref StageData stage)
    {
        for (int i = 0; i < stage.surfaceList.Count; i++)
        {
            var s    = stage.surfaceList[i];
            var SURF = string.Format("SurfaceLibrary/Surface#{0}", i + 1);
            xml.Settings[SURF].WriteString("type", s.Type.ToString());
            xml.Settings[SURF].WriteString("name", s.Name);
            xml.Settings[SURF].WriteString("color", c3(s.PhysColor));

            var PHYS = string.Format("SurfaceLibrary/Surface#{0}/Phys", i + 1);
            xml.Settings[PHYS].WriteFloat("usableGrip", s.UsableGrip);
            xml.Settings[PHYS].WriteFloat("rolling", s.Rolling);
            xml.Settings[PHYS].WriteFloat("drag", s.Drag);
            xml.Settings[PHYS].WriteInt("octaves", s.Octaves);
            xml.Settings[PHYS].WriteFloat("persistance", s.Persistance);
            xml.Settings[PHYS].WriteFloat("lacunarity", s.Lacunarity);
            xml.Settings[PHYS].WriteFloat("scale", s.Scale);
            xml.Settings[PHYS].WriteFloat("scaleBump", s.ScaleBump);

            var TRAILS = string.Format("SurfaceLibrary/Surface#{0}/Trails", i + 1);
            xml.Settings[TRAILS].WriteString("trailColor", c4(s.TrailColor));
            xml.Settings[TRAILS].WriteFloat("trailBump", s.TrailBump);

            var SMOKE = string.Format("SurfaceLibrary/Surface#{0}/Smoke", i + 1);
            xml.Settings[SMOKE].WriteVector2("lifeTime", v2(s.LifeTime));
            xml.Settings[SMOKE].WriteVector2("size", v2(s.Size));
            xml.Settings[SMOKE].WriteFloat("gravity", s.Gravity);
            xml.Settings[SMOKE].WriteString("gradient", gradient(s.GradientColor));
        }
    }
Exemple #2
0
    public void BuildObject(string pathXml, bool useUnityVector = false)
    {
        gUtility.CXml xSpline = new gUtility.CXml(pathXml, false);
        if (useUnityVector)
        {
            for (int i = 1; i <= xSpline.Settings["Points"].GetNamedChildrenCount("P"); ++i)
            {
                string           POINT = string.Format("Points/P#{0}", i);
                gUtility.Vector3 pos   = xSpline.Settings[POINT].ReadVector3("value", gUtility.Vector3.ZERO);
                Vector3          posU  = new Vector3(pos.x, pos.y + 0.05f, pos.z);
                points.Add(posU);
            }
        }
        else
        {
            for (int i = 1; i <= xSpline.Settings.GetNamedChildrenCount("P"); ++i)
            {
                string           POINT = string.Format("P#{0}", i);
                gUtility.Vector3 pos   = xSpline.Settings[POINT].ReadVector3("pos", gUtility.Vector3.ZERO);
                Vector3          posU  = new Vector3(-pos.x, pos.z, -pos.y);
                points.Add(posU);

                /*
                 * GameObject point = GameObject.CreatePrimitive(PrimitiveType.Capsule); //new GameObject(string.Format("point{0}", i - 1));
                 * point.name = string.Format("point{0}", i - 1);
                 * point.transform.localScale = new UnityEngine.Vector3(0.5f, 2.0f, 0.5f);
                 * point.transform.SetParent(pointsObj.transform);
                 * point.transform.position = posU;
                 */
            }
        }
    }
Exemple #3
0
    static void writeLayoutSettings(ref gUtility.CXml xml, int maxLayouts = 50)
    {
        for (int i = 0; i < maxLayouts; i++)
        {
            var scene = SceneManager.GetSceneByName("layout" + i.ToString());
            if (scene.name == null)
            {
                break;
            }

            foreach (var item in scene.GetRootGameObjects())
            {
                var info        = item.GetComponentInChildren <LayoutInfo>();
                var startFinish = item.GetComponentInChildren <StartFinish>();
                var path        = item.GetComponentInChildren <LayoutPath>();
                if (info != null)
                {
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("name", info.Name);
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("description", info.Description);
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteBool("saveTimes", info.SaveTimes);
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("nation", info.GetCountryCode(true));
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("surfaces", info.GetSurfaces());
                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("tags", info.Tags);
                    //break;
                }
                if (startFinish != null)
                {
                    float realLength = startFinish.RealLength;
                    // calc points:
                    int allPoints = path.GetPointsCount();
                    // I want a point each 5 meters
                    float minDist = realLength / Convert.ToSingle(allPoints);

                    int eachPoint = 1;
                    if (minDist < 5.0f)
                    {
                        // less than 5 meters, use less points
                        int newPoints = Convert.ToInt32(Mathf.Ceil(realLength / 5.0f));
                        eachPoint = Convert.ToInt32(Mathf.Floor(allPoints / newPoints));
                    }

                    xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteFloat("length", realLength);
                    if (path != null)
                    {
                        string pointExport = "";
                        for (int pt = 0; pt < path.GetPointsCount(); pt += eachPoint)
                        {
                            var point = path.GetPoint(pt);
                            pointExport += string.Format(CultureInfo.InvariantCulture, "{0} {1} {2} ", point.x, point.y, point.z);
                        }
                        pointExport = pointExport.Trim();
                        xml.Settings[string.Format("Layouts/Layout{0}", i)].WriteString("points", pointExport);
                    }
                }
            }
        }
    }
Exemple #4
0
    public void ExportXml(string pathXml)
    {
        gUtility.CXml xSpline = new gUtility.CXml(pathXml, true);
        for (int i = 0; i < points.Count; i++)
        {
            string           POINT = string.Format("Points/P#{0}", i + 1);
            gUtility.Vector3 pos   = new gUtility.Vector3(-points[i].x, points[i].z, -points[i].y);
            xSpline.Settings[POINT].WriteVector3("value", pos);
        }

        xSpline.Commit();
    }
    public void BuildObject(string pathXml)
    {
        gUtility.CXml xSpline = new gUtility.CXml (pathXml, false);

        pacenotes = new GameObject("LayoutPacenotes");
        pacenotes.transform.SetParent (transform);

        for (int i = 1; i <= xSpline.Settings.GetNamedChildrenCount("P"); ++i)
        {
            string POINT = string.Format("P#{0}", i);
            gUtility.Vector3 pos = xSpline.Settings[POINT].ReadVector3("pos", gUtility.Vector3.ZERO);
            Vector3 posU = new Vector3(-pos.x, pos.z, -pos.y);
            points.Add(posU);
            /*
            GameObject point = GameObject.CreatePrimitive(PrimitiveType.Capsule); //new GameObject(string.Format("point{0}", i - 1));
            point.name = string.Format("point{0}", i - 1);
            point.transform.localScale = new UnityEngine.Vector3(0.5f, 2.0f, 0.5f);
            point.transform.SetParent(pointsObj.transform);
            point.transform.position = posU;
            */
        }
        calcLength();
    }
    public void BuildObject(string pathXml)
    {
        gUtility.CXml xSpline = new gUtility.CXml(pathXml, false);

        pacenotes = new GameObject("LayoutPacenotes");
        pacenotes.transform.SetParent(transform);

        for (int i = 1; i <= xSpline.Settings.GetNamedChildrenCount("P"); ++i)
        {
            string           POINT = string.Format("P#{0}", i);
            gUtility.Vector3 pos   = xSpline.Settings[POINT].ReadVector3("pos", gUtility.Vector3.ZERO);
            Vector3          posU  = new Vector3(-pos.x, pos.z, -pos.y);
            points.Add(posU);

            /*
             * GameObject point = GameObject.CreatePrimitive(PrimitiveType.Capsule); //new GameObject(string.Format("point{0}", i - 1));
             * point.name = string.Format("point{0}", i - 1);
             * point.transform.localScale = new UnityEngine.Vector3(0.5f, 2.0f, 0.5f);
             * point.transform.SetParent(pointsObj.transform);
             * point.transform.position = posU;
             */
        }
        calcLength();
    }
Exemple #7
0
    public static void ExportCar()
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);

        var car = (CarData)AssetDatabase.LoadAssetAtPath(assetPath, typeof(CarData));

        string path = EditorUtility.OpenFolderPanel("Save Car", car.exportPath, "");

        if (!string.IsNullOrEmpty(path))
        {
            car.exportPath = path;
            EditorUtility.SetDirty(car);
            AssetDatabase.SaveAssets();

            GameObject go = GameObject.Find("RallyCar");
            if (go == null)
            {
                EditorUtility.DisplayDialog("Create Car", "Error! RallyCar GambeObject not found", "Ok!!");
                return;
            }
            SetLayerRecursively(go, 8);

            string name = go.name;

            UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab("Assets/" + name + ".prefab");
            PrefabUtility.ReplacePrefab(go, prefab);
            AssetDatabase.Refresh();

            foreach (var item in AssetDatabase.GetAllAssetBundleNames())
            {
                Debug.Log(item + " deleted!");
                AssetDatabase.RemoveAssetBundleName(item, true);
            }

            AssetImporter carImporter = AssetImporter.GetAtPath("Assets/RallyCar.prefab");

            carImporter.assetBundleName = "car.grPack";
            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ForceRebuildAssetBundle, BuildTarget.StandaloneWindows64);

            EditorUtility.DisplayDialog("Create Car", "Car created in\r\n" + path, "Ok!!");

            // write data car
            gUtility.CXml carXml  = new gUtility.CXml(path + @"/car.xml", true);
            string        aPath   = "Assets/Car.data.asset";
            var           carData = (CarData)AssetDatabase.LoadAssetAtPath(aPath, typeof(CarData));
            carXml.Settings["Car"].WriteString("name", carData.Name);
            carXml.Settings["Car"].WriteString("description", carData.Description);
            carXml.Settings["Car"].WriteString("brand", carData.Brand);
            carXml.Settings["Car"].WriteString("group", carData.Group);
            carXml.Settings["Car"].WriteString("transmission", carData.Transmission);
            carXml.Settings["Car"].WriteString("tags", carData.Tags);
            carXml.Commit();

            // export physics
            GameObject.FindObjectOfType <CarPhysics>().ExportXml(path + "/dumpPhysics.xml");

            // export setups
            if (!File.Exists(path + "/Setup.xml"))
            {
                File.Copy("Assets/gCarEditor/Resources/Setup/Setup.xml.txt", path + "/Setup.xml");
            }
            if (!File.Exists(path + "/default.xml"))
            {
                File.Copy("Assets/gCarEditor/Resources/Setup/default.xml.txt", path + "/default.xml");
            }

            // docs folder
            if (!Directory.Exists(path + "/docs"))
            {
                Directory.CreateDirectory(path + "/docs");
            }
            if (!File.Exists(path + "/docs/livery.png"))
            {
                File.Copy("Assets/gCarEditor/Resources/Textures/livery.png", path + "/docs/livery.png");
            }
            if (!File.Exists(path + "/docs/car.png"))
            {
                File.Copy("Assets/gCarEditor/Resources/Textures/car.png", path + "/docs/car.png");
            }
        }
    }
Exemple #8
0
    static void getPhysicsData(int idMat, Texture2D tex, string materialName, ref gUtility.CXml xml, ref StageData stage)
    {
        if (tex == null)
        {
            return;
        }
        string          path = AssetDatabase.GetAssetPath(tex);
        TextureImporter A    = (TextureImporter)AssetImporter.GetAtPath(path);

        if (A == null)
        {
            return;
        }
        A.sRGBTexture   = true;
        A.isReadable    = true;
        A.mipmapEnabled = false;
        A.filterMode    = FilterMode.Point;
        AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

        Color32[,] colors = new Color32[16, 16];

        int stepPx  = tex.width / 16;
        int firstPx = stepPx / 2;

        for (int x = 0; x < 16; x++)
        {
            for (int y = 0; y < 16; y++)
            {
                colors[x, y] = tex.GetPixel(x * stepPx + firstPx, y * stepPx + firstPx);
            }
        }
        bool singleColor   = true;
        bool singleColumns = true;

        // check if is everything the same
        var firstCol = colors[0, 0];

        for (int x = 0; x < 16; x++)
        {
            for (int y = 0; y < 16; y++)
            {
                if (!equal(colors[x, y], firstCol))
                {
                    singleColor = false;
                    break;
                }
            }
            if (!singleColor)
            {
                break;
            }
        }

        if (!singleColor)
        {
            // check if is by columns
            for (int x = 0; x < 16; x++)
            {
                firstCol = colors[x, 0];
                for (int y = 0; y < 16; y++)
                {
                    if (!equal(colors[x, y], firstCol))
                    {
                        singleColumns = false;
                        break;
                    }
                }
                if (!singleColumns)
                {
                    break;
                }
            }
        }

        if (singleColor)
        {
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("name", materialName);
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("surface", getStageID(ref stage, colors[0, 0]).ToString());
        }
        else if (singleColumns)
        {
            string retID = "";
            for (int x = 0; x < 16; x++)
            {
                retID += getStageID(ref stage, colors[x, 0]).ToString() + " ";
            }
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("name", materialName);
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("surface", retID.Trim());
        }
        else
        {
            string retID = "";
            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    retID += getStageID(ref stage, colors[x, y]).ToString() + " ";
                }
            }
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("name", materialName);
            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("surface", retID.Trim());
        }
    }
Exemple #9
0
    static void getPuddlesData(int idMat, Texture2D tex, int wetSize, string materialName, float puddleSize, ref gUtility.CXml xml)
    {
        if (tex == null)
        {
            return;
        }
        string          path = AssetDatabase.GetAssetPath(tex);
        TextureImporter A    = (TextureImporter)AssetImporter.GetAtPath(path);

        if (A == null)
        {
            return;
        }
        A.isReadable = true;
        AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

        float[,] colors = new float[wetSize * 2, wetSize * 2];

        // save the new texture
        var debugTexR = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 0, true);

        Graphics.CopyTexture(tex, debugTexR);
        debugTexR.Apply();
        debugTexR = scaleTexture(debugTexR, wetSize, wetSize);

        var debugTexG = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 0, true);

        Graphics.CopyTexture(tex, debugTexG);
        debugTexG.Apply();
        debugTexG = scaleTexture(debugTexG, wetSize, wetSize);

        var debugTexB = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 0, true);

        Graphics.CopyTexture(tex, debugTexB);
        debugTexB.Apply();
        debugTexB = scaleTexture(debugTexB, wetSize, wetSize);

        var debugTexA = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 0, true);

        Graphics.CopyTexture(tex, debugTexA);
        debugTexA.Apply();
        debugTexA = scaleTexture(debugTexA, wetSize, wetSize);

        var debugTex = new Texture2D(wetSize * 2, wetSize * 2, TextureFormat.ARGB32, false);

        /*
         * |B|A|
         * -----
         * |R|G|
         */
        for (int y = 0; y < wetSize * 2; y++)
        {
            for (int x = 0; x < wetSize * 2; x++)
            {
                if (x < wetSize)
                {
                    if (y < wetSize)
                    {
                        // R
                        var color = debugTexR.GetPixel(x, y);
                        var wet   = color.r;
                        debugTex.SetPixel(x, y, new Color(wet, wet, wet, 1.0f));
                        colors[x, y] = wet;
                    }
                    else
                    {
                        // B
                        var color = debugTexB.GetPixel(x, y - wetSize);
                        var wet   = color.b;
                        debugTex.SetPixel(x, y, new Color(wet, wet, wet, 1.0f));
                        colors[x, y] = wet;
                    }
                }
                else
                {
                    if (y < wetSize)
                    {
                        // G
                        var color = debugTexG.GetPixel(x - wetSize, y);
                        var wet   = color.g;
                        debugTex.SetPixel(x, y, new Color(wet, wet, wet, 1.0f));
                        colors[x, y] = wet;
                    }
                    else
                    {
                        // A
                        var color = debugTexA.GetPixel(x - wetSize, y - wetSize);
                        var wet   = color.a;
                        debugTex.SetPixel(x, y, new Color(wet, wet, wet, 1.0f));
                        colors[x, y] = wet;
                    }
                }
            }
        }
        debugTex.Apply();

        if (!Directory.Exists("Assets/PhysTextures"))
        {
            Directory.CreateDirectory("Assets/PhysTextures");
        }
        var texName = string.Format("Assets/PhysTextures/puddles_{0}.png", materialName);

        if (File.Exists(texName))
        {
            File.Delete(texName);
        }
        byte[] bytes = debugTex.EncodeToPNG();
        File.WriteAllBytes(texName, bytes);

        string retWet = "";

        for (int y = 0; y < wetSize; y++)
        {
            for (int x = 0; x < wetSize; x++)
            {
                retWet += colors[x, y].ToString(CultureInfo.InvariantCulture) + " ";
            }
        }
        // retWet = retWet.Trim().Replace(",", ".");
        xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteFloat("puddlesSize", puddleSize);
        xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("puddles", retWet);
    }
Exemple #10
0
    static void getWetData(int idMat, Texture2D tex, int wetSize, string materialName, ref gUtility.CXml xml)
    {
        if (tex == null)
        {
            return;
        }
        string          path = AssetDatabase.GetAssetPath(tex);
        TextureImporter A    = (TextureImporter)AssetImporter.GetAtPath(path);

        if (A == null)
        {
            return;
        }
        A.isReadable = true;
        AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);

        float[,] colors = new float[wetSize, wetSize];

        // save the new texture
        var debugTex = new Texture2D(tex.width, tex.height, tex.format, tex.mipmapCount > 0, true);

        Graphics.CopyTexture(tex, debugTex);
        debugTex.Apply();
        debugTex = scaleTexture(debugTex, wetSize, wetSize);

        for (int y = 0; y < wetSize; y++)
        {
            for (int x = 0; x < wetSize; x++)
            {
                var color = debugTex.GetPixel(x, y);
                var wet   = color.a;

                /*
                 * if (shaderVersion == 2)
                 * {
                 *  wet = 1.0f + wet * -1.0f;
                 * }
                 */
                debugTex.SetPixel(x, y, new Color(wet, wet, wet, 1.0f));
                colors[x, y] = wet;
            }
        }
        debugTex.Apply();

        var texName = string.Format("Assets/PhysTextures/wet_{0}.png", materialName);

        if (!Directory.Exists("Assets/PhysTextures"))
        {
            Directory.CreateDirectory("Assets/PhysTextures");
        }

        try
        {
            if (File.Exists(texName))
            {
                File.Delete(texName);
            }
        }
        catch (Exception ex)
        {
            Debug.LogWarning(ex.ToString());
        }
        byte[] bytes = debugTex.EncodeToPNG();
        File.WriteAllBytes(texName, bytes);

        string retWet = "";

        for (int y = 0; y < wetSize; y++)
        {
            for (int x = 0; x < wetSize; x++)
            {
                retWet += colors[x, y].ToString(CultureInfo.InvariantCulture) + " ";
            }
        }
        // retWet = retWet.Trim().Replace(",", ".");
        xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteString("wet", retWet);
    }
Exemple #11
0
    static void ExportStage()
    {
        PhysMatNames        = null;
        PhysMatDisplacement = null;

        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);

        StageData stage = (StageData)AssetDatabase.LoadAssetAtPath(assetPath, typeof(StageData));

        string path = EditorUtility.OpenFolderPanel("Save Stage", stage.exportPath, "");

        if (!string.IsNullOrEmpty(path))
        {
            stage.exportPath = path;

            // 1: save scenes
            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                EditorSceneManager.SaveScene(SceneManager.GetSceneAt(i));
            }

            // 2: clear old files
            foreach (var item in Directory.GetFiles(path))
            {
                var fileName = Path.GetFileName(item).ToLower();
                if (fileName.EndsWith(".manifest") ||
                    fileName == "stage.grpack" ||
                    (fileName.StartsWith("layout") && fileName.EndsWith(".grpack")) ||
                    fileName == Path.GetFileName(path).ToLower() ||
                    fileName == "stage.xml")
                {
                    File.Delete(item);
                }
            }

            EditorUtility.SetDirty(stage);
            AssetDatabase.SaveAssets();

            /* TODO: removed, no VertexPainter attached
             * // 3: apply vertex data
             * foreach (var item in Object.FindObjectsOfType<JBooth.VertexPainterPro.VertexInstanceStream>())
             * {
             *  item.Apply();
             * }
             */
            // 4: store xml data
            // write data stages
            gUtility.CXml stageXml = new gUtility.CXml(path + @"/stage.xml", true);

            writeSurfaceSettings(ref stageXml, ref stage);
            writeStageSettings(ref stageXml, ref stage);
            writeLayoutSettings(ref stageXml);
            writeMaterialSettings(ref stageXml, ref stage);

            stageXml.Commit();

            // dump collision
            if (PhysMatNames != null)
            {
                CreateCollision(path);
            }

            AssetDatabase.SaveAssets();

            // 5: rollback the textures edited:
            // not at the moment... rollbackEditTextures();
            // 6: build stage!
            BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ForceRebuildAssetBundle, BuildTarget.StandaloneWindows64);
            EditorUtility.DisplayDialog("Create Stage", "Stage created in\r\n" + path, "Ok!!");
        }
        else
        {
            EditorUtility.DisplayDialog("Create Stage", "no path selected!!", "Ok.. I'll try again");
        }
    }
Exemple #12
0
    static void writeMaterialSettings(ref gUtility.CXml xml, ref StageData stage)
    {
        int idMat = 0;

        matExported         = new List <string>();
        PhysMatNames        = new Dictionary <string, int>();
        PhysMatDisplacement = new Dictionary <string, float>();
        var renderers = (Renderer[])Resources.FindObjectsOfTypeAll(typeof(Renderer));

        foreach (Renderer renderer in renderers)
        {
            foreach (Material mat in renderer.sharedMaterials)
            {
                if (mat != null)
                {
                    if (mat.shader.name.Contains("gRally/Phys"))
                    {
                        Texture tex         = null;
                        Texture texWet      = null;
                        Texture texPuddles  = null;
                        float   puddlesSize = 1.0f;
                        int     shaderVer   = 0;
                        if (mat.shader.name.EndsWith("1"))
                        {
                            shaderVer = 1;
                            tex       = mat.GetTexture("_PhysMap");
                            texWet    = mat.GetTexture("_MainTex");
                            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteFloat("maxDisplacement", 0.0f);

                            if (!PhysMatNames.ContainsKey(mat.name))
                            {
                                PhysMatNames.Add(mat.name, idMat);
                                PhysMatDisplacement.Add(mat.name, 0.0f);
                            }
                        }
                        else if (mat.shader.name.EndsWith("2"))
                        {
                            shaderVer   = 2;
                            tex         = mat.GetTexture("_PhysicalTexture");
                            texWet      = mat.GetTexture("_RSpecGTransparencyBAOAWetMap");
                            texPuddles  = mat.GetTexture("_PuddlesTexture");
                            puddlesSize = mat.GetFloat("_PuddlesSize");
                            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteFloat("maxDisplacement", mat.GetFloat("_MaxDisplacementmeters"));

                            if (!PhysMatNames.ContainsKey(mat.name))
                            {
                                PhysMatNames.Add(mat.name, idMat);
                                PhysMatDisplacement.Add(mat.name, mat.GetFloat("_MaxDisplacementmeters"));
                            }
                        }
                        else if (mat.shader.name.EndsWith("3"))
                        {
                            shaderVer   = 3;
                            tex         = mat.GetTexture("_PhysicalTexture");
                            texWet      = mat.GetTexture("_RSpecGTransparencyBAOAWetMap");
                            texPuddles  = mat.GetTexture("_PuddlesTexture");
                            puddlesSize = mat.GetFloat("_PuddlesSize");
                            xml.Settings[string.Format("Materials/Material#{0}", idMat + 1)].WriteFloat("maxDisplacement", mat.GetFloat("_MaxDisplacementmeters"));

                            if (!PhysMatNames.ContainsKey(mat.name))
                            {
                                PhysMatNames.Add(mat.name, idMat);
                                PhysMatDisplacement.Add(mat.name, mat.GetFloat("_MaxDisplacementmeters"));
                            }
                        }
                        if (tex != null)
                        {
                            if (!matExported.Contains(mat.name))
                            {
                                getPhysicsData(idMat, tex as Texture2D, mat.name, ref xml, ref stage);
                                getWetData(idMat, texWet as Texture2D, 16, mat.name, ref xml);
                                if (texPuddles != null)
                                {
                                    getPuddlesData(idMat, texPuddles as Texture2D, 32, mat.name, puddlesSize, ref xml);
                                }
                                idMat++;
                                matExported.Add(mat.name);
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #13
0
 static void writeStageSettings(ref gUtility.CXml xml, ref StageData stage)
 {
     xml.Settings["Stage/Geo"].WriteFloat("latitude", stage.latitude);
     xml.Settings["Stage/Geo"].WriteFloat("longitude", stage.longitude);
     xml.Settings["Stage/Geo"].WriteFloat("north", stage.north);
 }