項(xiàng)目地址和官網(wǎng)
https://github.com/openscenegraph/OpenSceneGraph
http://www.openscenegraph.org/
1.
去官網(wǎng)下載(找最新版) OpenSceneGraph-3.6.5 released
解壓后進(jìn)入bin文件夾 我們可以利用其中osgconv.exe文件來轉(zhuǎn)換
可以先雙擊 這個(gè)osgconv.exe 如果提示缺少某個(gè)dll 去百度安裝幾個(gè)包就解決了
大概格式 就是osgconv infile.osgb outfile.obj
也可以使用多個(gè)文件合成一個(gè) 使用-h查看更多用法
注意 眾多osgb文件中一塊地形有多種清晰度 我發(fā)現(xiàn) 結(jié)尾帶T的是精度比較高的 可以單獨(dú)把結(jié)尾有t
的文件導(dǎo)出 然后區(qū)分就簡(jiǎn)單點(diǎn)
我還不知道怎么直接導(dǎo)出不同的精度模型
把導(dǎo)出的fbx模型和貼圖一起扔到Unity中就好了
C#寫的批量導(dǎo)出腳本 可以根據(jù)自己的需求來寫
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace OSGB
{
class Program
{
static void Main(string[] args)
{
string space = " ";
System.Diagnostics.Process exep = new System.Diagnostics.Process();
exep.StartInfo.FileName = @"D:\Download\OpenSceneGraph-3.6.5-VC2019-64-Release\bin\osgconv.exe";
// exep.StartInfo.Arguments = @"D:\Download\OpenSceneGraph-3.6.5-VC2019-64-Release\Tile_+253_+060_L22_0001160t2.osgb D:\Download\OpenSceneGraph-3.6.5-VC2019-64-Release\Tile_+253_+060_L22_0001160t2.fbx";
exep.StartInfo.CreateNoWindow = false;
exep.StartInfo.UseShellExecute = false;
///給到 Data文件
string rootPath = @"E:\BaiduNetdiskDownload\實(shí)景三維\ZHZX2_OSGB\Data";
var osgbDirs = Directory.GetDirectories(rootPath);
foreach (var dir in osgbDirs)
{
string infiles = "";
string outFile = "";
foreach (var file in Directory.GetFiles(dir))
{
infiles += file+space;
}
outFile = dir + ".fbx";// "\\" + Path.GetFileName(dir) + ".fbx";
exep.StartInfo.Arguments = infiles + space + outFile;
exep.Start();
exep.WaitForExit();
Console.WriteLine(outFile);
}
Console.WriteLine("轉(zhuǎn)換結(jié)束");
Console.Read();
}
}
}