element3ds.com
【综合_2D_3D资源】 MapMagic World Generator v1.9.1 地形编辑器
发布于
2023-6-11
142
21

您需要 登录 才可以下载或查看,没有账号?注册

x
尊敬的游客,如果您要查看本帖关注 或 回复可见内容请关注回复后刷新页面查看!

[hide=d50000]
MapMagic World Generator v1.9.1  支持unity5.6.4及以上版本
7.jpg 9.jpg
其他资源
Horizon[ON] 1.4.1 地形编辑插件 Unity 远景  资源连接

Horizon[ON] 1.2 地形编辑插件  资源连接
MapMagic World Generator v1.9.1 地形编辑插件 资源连接
DCG Water Shader2.0 水材质  资源连接
Animated Water Texture Pack1.2 水材质 资源连接
Imagy VFX 1.3 特效文件   资源连接
iOS Project Builder for Windows 在Windows上构建iOS  资源连接
游戏工程文件
uMMORPG 修复版  支持unity5.3.2  资源连接
uMMORPG 1.131  支持unity2017.4.7  资源连接
uMMORPG 2D 1.50   支持unity2018.3.6 资源连接
MMORPG KIT 1.48c 支持unity2018.2.2 资源连接
Kings - Card Swiping Decision Game Asset 1.52 支持unity2017.4.3 资源连接
Shmup Baby 1.2 支持unity2017.7.5 资源连接
PixelTopDownShooterEngineV1.0 支持unity2017.4.1 资源连接

参与人数 1 元素币 +10 活跃度 +12

本帖被以下画板推荐:

还没有设置签名!您可以在此展示你的链接,或者个人主页!

使用道具 举报 登录

回复 <
黑鸢  发表于 2019-9-24 23:12:56  
2#
资源哪里好,肯定元素找
使用道具
松风蟹眼新汤  发表于 2019-9-26 19:21:35  
3#
千点万点,不如微元素指点
使用道具
焕焕  发表于 2019-11-1 10:25:46  
4#
感谢分享
使用道具
全能起始  发表于 2019-11-22 09:28:57  
5#
支持unity5
使用道具
忍者TT  发表于 2019-11-29 15:37:05  
6#
支持楼主了!!!
使用道具
zzlucifer  发表于 2019-12-5 10:15:29  
7#
谢谢分享。
使用道具
GaiYin210  发表于 2019-12-17 17:13:00  
8#
66
使用道具
十三月星期八  发表于 2019-12-26 08:48:45  
9#
dfasdfasdf
使用道具
qq_呆呆_U9o  发表于 2020-1-14 14:43:50  
10#
6666666666666666666
使用道具
聆雨  发表于 2020-3-9 18:04:00  
12#
使用道具
茄子123  发表于 2020-3-17 22:03:36  
13#
不错,学习!!!!!
使用道具
wyjpysh  发表于 2020-3-28 21:31:36  
14#
使用道具
*﹏1026  发表于 2020-3-31 10:31:06  
15#
规避风险
使用道具
qq_阿杰_ZTp  发表于 2020-5-26 09:08:23  
16#
牛逼.谢谢分享
使用道具
qq_跟本哈跟_NFR  发表于 2020-6-28 00:13:35  
17#
谢谢分享 很好的资源啊 值得收藏
使用道具
ytgg30545930  发表于 2020-6-28 09:59:42  
18#
tfxhhkgycflvg
使用道具
两点一线  发表于 2020-7-29 14:40:16  
19#
这里也有一个
使用道具
sabet319  发表于 2020-11-30 19:29:44  
20#
// Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// C # manual conversion work by Yun Kyu Choi

using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.IO;
using System.Text;

enum SaveFormat { Triangles, Quads }
enum SaveResolution { Full=0, Half, Quarter, Eighth, Sixteenth }

class ExportTerrain : EditorWindow
{
   SaveFormat saveFormat = SaveFormat.Triangles;
   SaveResolution saveResolution = SaveResolution.Half;

   static TerrainData terrain;
   static Vector3 terrainPos;

   int tCount;
   int counter;
   int totalCount;
   int progressUpdateInterval = 10000;

   [MenuItem("Terrain/Export To Obj...")]
   static void Init()
   {
      terrain = null;
      Terrain terrainObject = Selection.activeObject as Terrain;
      if (!terrainObject)
      {
         terrainObject = Terrain.activeTerrain;
      }
      if (terrainObject)
      {
         terrain = terrainObject.terrainData;
         terrainPos = terrainObject.transform.position;
      }

      EditorWindow.GetWindow<ExportTerrain>().Show();
   }

   void OnGUI()
   {
      if (!terrain)
      {
         GUILayout.Label("No terrain found");
         if (GUILayout.Button("Cancel"))
         {
            EditorWindow.GetWindow<ExportTerrain>().Close();
         }
         return;
      }
      saveFormat = (SaveFormat) EditorGUILayout.EnumPopup("Export Format", saveFormat);

      saveResolution = (SaveResolution) EditorGUILayout.EnumPopup("Resolution", saveResolution);

      if (GUILayout.Button("Export"))
      {
         Export();
      }
   }

   void Export()
   {
      string fileName = EditorUtility.SaveFilePanel("Export .obj file", "", "Terrain", "obj");
      int w = terrain.heightmapWidth;
      int h = terrain.heightmapHeight;
      Vector3 meshScale = terrain.size;
      int tRes = (int)Mathf.Pow(2, (int)saveResolution );
      meshScale = new Vector3(meshScale.x / (w - 1) * tRes, meshScale.y, meshScale.z / (h - 1) * tRes);
      Vector2 uvScale = new Vector2(1.0f / (w - 1), 1.0f / (h - 1));
      float[,] tData = terrain.GetHeights(0, 0, w, h);

      w = (w - 1) / tRes + 1;
      h = (h - 1) / tRes + 1;
      Vector3[] tVertices = new Vector3[w * h];
      Vector2[] tUV = new Vector2[w * h];

      int[] tPolys;

      if (saveFormat == SaveFormat.Triangles)
      {
         tPolys = new int[(w - 1) * (h - 1) * 6];
      }
      else
      {
         tPolys = new int[(w - 1) * (h - 1) * 4];
      }

      // Build vertices and UVs
      for (int y = 0; y < h; y++)
      {
         for (int x = 0; x < w; x++)
         {
            tVertices[y * w + x] = Vector3.Scale(meshScale, new Vector3(-y, tData[x * tRes, y * tRes], x)) + terrainPos;
            tUV[y * w + x] = Vector2.Scale( new Vector2(x * tRes, y * tRes), uvScale);
         }
      }

      int  index = 0;
      if (saveFormat == SaveFormat.Triangles)
      {
         // Build triangle indices: 3 indices into vertex array for each triangle
         for (int y = 0; y < h - 1; y++)
         {
            for (int x = 0; x < w - 1; x++)
            {
               // For each grid cell output two triangles
               tPolys[index++] = (y * w) + x;
               tPolys[index++] = ((y + 1) * w) + x;
               tPolys[index++] = (y * w) + x + 1;

               tPolys[index++] = ((y + 1) * w) + x;
               tPolys[index++] = ((y + 1) * w) + x + 1;
               tPolys[index++] = (y * w) + x + 1;
            }
         }
      }
      else
      {
         // Build quad indices: 4 indices into vertex array for each quad
         for (int y = 0; y < h - 1; y++)
         {
            for (int x = 0; x < w - 1; x++)
            {
               // For each grid cell output one quad
               tPolys[index++] = (y * w) + x;
               tPolys[index++] = ((y + 1) * w) + x;
               tPolys[index++] = ((y + 1) * w) + x + 1;
               tPolys[index++] = (y * w) + x + 1;
            }
         }
      }

      // Export to .obj
      StreamWriter sw = new StreamWriter(fileName);
      try
      {

         sw.WriteLine("# Unity terrain OBJ File");

         // Write vertices
         System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
         counter = tCount = 0;
         totalCount = (tVertices.Length * 2 + (saveFormat == SaveFormat.Triangles ? tPolys.Length / 3 : tPolys.Length / 4)) / progressUpdateInterval;
         for (int i = 0; i < tVertices.Length; i++)
         {
            UpdateProgress();
            StringBuilder sb = new StringBuilder("v ", 20);
            // StringBuilder stuff is done this way because it's faster than using the "{0} {1} {2}"etc. format
            // Which is important when you're exporting huge terrains.
            sb.Append(tVertices.x.ToString()).Append(" ").
               Append(tVertices.y.ToString()).Append(" ").
               Append(tVertices.z.ToString());
            sw.WriteLine(sb);
         }
         // Write UVs
         for (int i = 0; i < tUV.Length; i++)
         {
            UpdateProgress();
            StringBuilder sb = new StringBuilder("vt ", 22);
            sb.Append(tUV.x.ToString()).Append(" ").
               Append(tUV.y.ToString());
            sw.WriteLine(sb);
         }
         if (saveFormat == SaveFormat.Triangles)
         {
            // Write triangles
            for (int i = 0; i < tPolys.Length; i += 3)
            {
               UpdateProgress();
               StringBuilder sb = new StringBuilder("f ", 43);
               sb.Append(tPolys + 1).Append("/").Append(tPolys + 1).Append(" ").
                  Append(tPolys[i + 1] + 1).Append("/").Append(tPolys[i + 1] + 1).Append(" ").
                  Append(tPolys[i + 2] + 1).Append("/").Append(tPolys[i + 2] + 1);
               sw.WriteLine(sb);
            }
         }
         else
         {
            // Write quads
            for (int i = 0; i < tPolys.Length; i += 4)
            {
               UpdateProgress();
               StringBuilder sb = new StringBuilder("f ", 57);
               sb.Append(tPolys + 1).Append("/").Append(tPolys + 1).Append(" ").
                  Append(tPolys[i + 1] + 1).Append("/").Append(tPolys[i + 1] + 1).Append(" ").
                  Append(tPolys[i + 2] + 1).Append("/").Append(tPolys[i + 2] + 1).Append(" ").
                  Append(tPolys[i + 3] + 1).Append("/").Append(tPolys[i + 3] + 1);
               sw.WriteLine(sb);
            }
         }
      }
      catch(Exception err)
      {
         Debug.Log("Error saving file: " + err.Message);
      }
      sw.Close();

      terrain = null;
      EditorUtility.DisplayProgressBar("Saving file to disc.", "This might take a while...", 1f);
      EditorWindow.GetWindow<ExportTerrain>().Close();      
      EditorUtility.ClearProgressBar();
   }

   void UpdateProgress()
   {
      if (counter++ == progressUpdateInterval)
      {
         counter = 0;
         EditorUtility.DisplayProgressBar("Saving...", "", Mathf.InverseLerp(0, totalCount, ++tCount));
      }
   }
}
使用道具
12下一页

快来发表你宝贵的意见吧!

zthc 实名

通过了实名认证的内容创造者

  

主题
22
精华
1
超神
0
扩散
0
微金
1863
智慧
0
余额
0
在线时间
657 小时

短剑 长剑 铁剑 长枪 绿色药水 紫色药水

快速回复 返回顶部 返回列表