资源简介
放入工程就能用,里面一个js版本,一个是cs版本,用其中一个就行

代码片段和文件信息
// Converted from Unityscript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
// Do test the code! You usually need to change a few small bits.
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System;
using System.Text;
enum SaveFormat { Triangles Quads }
enum SaveResolution { Full Half Quarter Eighth Sixteenth }
public class ExportTerrain : EditorWindow
{
SaveFormat saveFormat = SaveFormat.Triangles;
SaveResolution saveResolution = SaveResolution.Half;
static TerrainData terrain;
static Vector3 terrainPos;
int tCount;
int counter;
int totalCount;
static ExportTerrain window;
[MenuItem(“地形导出/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;
}
window = (ExportTerrain)GetWindow(typeof(ExportTerrain) true “My Empty Window“);
window.Show();
}
void OnGUI()
{
if (!terrain)
{
GUILayout.Label(“No terrain found“);
if (GUILayout.Button(“Cancel“))
{
window.Close();
}
return;
}
saveFormat = (SaveFormat)EditorGUILayout.EnumPopup(“Export Format“ saveFormat);
saveResolution = (SaveResolution)EditorGUILayout.EnumPopup(“Resolution“ saveResolution);
if (GUILayout.Button(“导出“))
{
Export();
}
}
void Export()
{
var fileName = EditorUtility.SaveFilePanel(“Export .obj file“ ““ “Terrain“ “obj“);
int w = terrain.heightmapWidth;
int h = terrain.heightmapHeight;
var meshScale = terrain.size;
var tRes = Mathf.Pow(2 (float)saveResolution);
meshScale = new Vector3(meshScale.x / (w - 1) * tRes meshScale.y meshScale.z / (h - 1) * tRes);
var uvScale = new Vector2(1.0f / (w - 1) 1.0f / (h - 1));
var tData = terrain.GetHeights(0 0 w h);
w = (int)((w - 1) / tRes + 1);
h = (int)((h - 1) / tRes + 1);
var tVertices = new Vector3[(int)w * (int)h];
var tUV = new Vector2[(int)w * (int)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(meshScalenew Vector3(x (tData[x * (int)tRes y * (int)t
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7966 2017-10-18 18:50 ExportTerrain.cs
文件 8321 2017-10-18 17:39 ExportTerrain.js
- 上一篇:labview蓝牙接收程序
- 下一篇:NFC_READER V5.0读写程序.exe
相关资源
- Unity3D登录界面工程
- unity3d反编译工具
- 三维地形的仿真显示实现了对地图的
-
UnityWebPla
yer及UnityWebPla yerFull -
UnityWebPla
yerFull - 中国地形图(大陆部分,不附岛屿)
- unity4.0官方正式版
- Behavior Designer 1.6.3(u2018.3.0).unitypa
- Unity纪念碑谷.rar
- A Pathfinding Project Pro v4.2.2.rar
- Unity 声音播放插件,支持将字符串转
- Gaia 1.7.2
- Unity3d实现扭动挤压浏览效果
- 基于GPS-RTK与全站仪的城市道路改扩建
- GPS-RTK、全站仪联合作业在化石沟铜矿
- 探讨GPS技术在地形复杂矿山变形监测
- UnityShader卷轴效果
- 爱酱(绊爱Kizuna)模型
- cesium实现底图和地形动态切换及supe
- 遗传算法越野小车unity5.5
- unity 3D 百度语音合成 并播放
- 1:10M全球地形高程光栅格图像
- unity案例入门坦克大战源码
- Graph And Chart 1.91.unitypackage
- Animated Steel Coaster 1.51.rar
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- OpenGL三维地形建模
- unity3d_见缝插针源码及报告.zip
评论
共有 条评论