예제 #1
0
    public void ExportTile(Texture2D gs, Texture2D rgb, Texture2D sat, string name)
    {
        terrainLoader.heightmap = rgb;
        terrainLoader.texture   = sat;
        terrainLoader.rgbMap    = true;

        terrainLoader.Init();

        heightImg.texture = gs;
        texImg.texture    = sat;

        //RenderTexture tex = new RenderTexture(1024, 1024, 24);
        //Camera.main.targetTexture = tex;
        Camera.main.Render();
        Debug.Log("Export " + index);
        ScreenCapture.CaptureScreenshot(Path.Combine(outPath, name + "_" + index.ToString("D4") + ".png"));

        /*
         * RenderTexture.active = tex;
         * Texture2D virtualPhoto = new Texture2D(1024, 1024, TextureFormat.RGB24, false);
         *
         * virtualPhoto.ReadPixels(new Rect(0, 0, 1024, 1024), 0, 0);
         *
         * RenderTexture.active = null;
         * Camera.main.targetTexture = null;
         * // consider ... Destroy(tempRT);
         *
         * byte[] bytes;
         * bytes = virtualPhoto.EncodeToPNG();
         *
         * System.IO.File.WriteAllBytes(@"D:\Manuel\Desktop\MASTER_THESIS\DATA\export.png", bytes);
         * // virtualCam.SetActive(false); ... no great need for this.
         */
    }
예제 #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Generate Mesh"))
        {
            loader.Init();
        }
    }
예제 #3
0
    /// <summary>
    /// Implementation of user interface.
    /// </summary>
    private void OnGUI()
    {
        int offset = 0;

        LoadDataArea   = new Rect(3, offset += 0, position.width - 6, 120);
        RenderDataArea = new Rect(3, offset += 120, position.width - 6, 130);

        // fixed window size
        GUILayout.ExpandHeight(false);
        GUILayout.ExpandWidth(false);

        #region Load Data
        GUILayout.BeginArea(LoadDataArea);
        apiKey = EditorGUILayout.TextField("Api Key", apiKey);
        lat    = EditorGUILayout.FloatField("Latitude", lat);
        lon    = EditorGUILayout.FloatField("Longitude", lon);
        rad    = EditorGUILayout.IntSlider("Radius", rad, 1000, 60000);
        level  = EditorGUILayout.IntSlider("Level", level, 7, 15);
        if (GUILayout.Button("Load Data"))
        {
            generator = new TerrainLoader(apiKey);
            generator.Init(lat, lon, rad, level);
            generator.Generate();
        }
        if (generator != null)
        {
            Progress = generator.GetProgressStatus();
        }
        else
        {
            Progress = 0;
        }
        GUILayout.EndArea();
        #endregion

        #region Render Data
        GUILayout.BeginArea(RenderDataArea);
        minIndex   = EditorGUILayout.Vector2IntField("MinIndex", minIndex);
        maxIndex   = EditorGUILayout.Vector2IntField("MaxIndex", maxIndex);
        Resolution = EditorGUILayout.IntSlider("Resolution", Resolution, 32, 1024);
        Height     = EditorGUILayout.IntSlider("Height", Height, 1, 100);
        if (GUILayout.Button("Render Data"))
        {
            renderer = new TerrainRenderer();
            renderer.Init(minIndex.x, minIndex.y, maxIndex.x, maxIndex.y, resolution, Height);
            renderer.Run();
        }
        GUILayout.EndArea();
        #endregion

        EditorGUI.ProgressBar(new Rect(3, position.height - 24, position.width - 6, 20), Progress, (Progress * 100).ToString());
    }