如何导入3D场景(.obj文件和.mtl文件) [英] How to import 3D scene (.obj file with .mtl file)

查看:763
本文介绍了如何导入3D场景(.obj文件和.mtl文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我购买了一个房间的3D模型.该模型为 .obj 格式.现在,我正在尝试将此模型导入Unity3D.

模型随附:

  • 5 x .obj 文件
  • 5 x .mtl 个文件
  • n x .jpg 个文件
  • n x .tga 个文件

.mtl 文件包含我的PC上不存在的路径.所以我删除了路径.图像文件( .jpg 和amp; .mtl )与 .obj 文件位于同一目录中.当我尝试导入 .obj 文件时,房间上没有任何材料.然后,我尝试使用FBX转换器(选中嵌入媒体")将 .obj 转换为 .fbx ,并且仍然在导入时没有任何内容3D房间(它是不可见的).我还尝试将所有 .jpg .tga 文件导入Unity中根Assets文件夹下的文件夹,然后导入 .obj .mtl 文件.

我做错了什么?Unity3D是否使用 .mtl 来确定在哪里可以找到所需的图像文件?是否有可能可以了解一些进口日志?


更新[8/25/2015]

  1. 我编辑了所有我的 .mtl 文件并删除了路径,因此它只是图像文件名(即 map_Ka Arch 53-wood 14.jpg )./p>

  2. 我将所有 .jpg .tga 文件复制到同一目录中的纹理" 文件夹中.

  3. p>
  4. 我使用FBX转换器将 .obj 文件转换为 .fbx .

  5. .fbx 导入Unity3D.

它仍然会创建一个没有材质(不可见)的模型,但是它在导入时自动创建的材质文件夹中包含的文件要少得多,这些文件映射到我在Assets文件夹下导入的图像-也许这是进度吗?不确定...

UPDATE [8/25/2015]#2

可能我的模型可以正确导入,但是我设置不正确吗?我导入的 .fbx 模型的下面有多个Mesh过滤器.每个Mesh滤镜的Albedo确实映射到我导入到Assets文件夹下的图像(请参见屏幕截图),但是当我将根模型拖到场景中时,它仍然是透明的-为什么?

更新[2015年8月27日]

我无法使 .obj / .mtl 组合工作.我能够让作者转换为fbx,因此我也试图使其正常工作(转换后的fbx文件遇到相同的问题).我此时会创建一个新的SO问题(

解决方案

  • 使用fbx(将obj转换为fbx,obj不起作用)
  • 将fbx导入为资产
  • 将textrure图像文件导入为资产
    (图像命名:modelname_Texture_0.jpg modelname_Texture_1.jpg等,fbx名称:modelname.fbx)
  • 从收藏夹中选择模型->所有模型
    在检查器标签的材料"下
  • 选择进口材料>物质命名
  • 选择模型名称+模型的材料
    物质搜索
  • 选择本地材料的文件夹
  • 单击应用"
    完成

I bought a 3D Model of a room. The model is in the .obj format. Now, I'm trying to import this model into Unity3D.

The Model came with:

  • 5 x .obj files
  • 5 x .mtl files
  • n x .jpg files
  • n x .tga files

The .mtl files contained paths that do not exist on my PC. So I removed the paths. The images files (.jpg & .mtl) are in the same directory as the .obj files. When I tried to import the .obj files, the room has no material on it. I then tried to use the FBX converter (with "Embed media" checked) to convert the .obj to .fbx and still when I import it, there is no material on the 3D room (it's invisible). I also tried importing all the .jpg and .tga files to a folder underneath the root Assets folder in Unity then importing the .obj and .mtl files.

What am I doing wrong? Does Unity3D use the .mtl to determine where to find the image files required? Is there an import log that could possibly shed some light?


UPDATE [8/25/2015]

  1. I edited all my .mtl files and removed the paths so its just the image filename (i.e. map_Ka Arch 53-wood 14.jpg).

  2. I copied all my .jpg and .tga files to a "Textures" folder in the same directory.

  3. I used the FBX Converter to convert the .obj files to .fbx.

  4. Imported the .fbx into Unity3D.

It still creates a model with no material (invisible) on it but the material folder it automatically creates upon import has much less files in it and those files map to images I imported under my Assets folder -- maybe this is progress? Not sure...

UPDATE [8/25/2015] #2

Possibly my model is importing correctly but I'm not setting something right? My .fbx model that I imported has number of Mesh filters underneath it. Each Mesh filter's Albedo does map to an image that I imported underneath my Assets folder (see screen shot) but still still when I drag the root model into my scene it is transparent -- why?

UPDATE [8/27/2015]

I was not able to get the .obj / .mtl combo working. I was able to get the author to convert to fbx so I'm trying to get that working as well (same issues I'm having with my converted fbx files). I create a new SO question at this point (Imported .fbx model Is Transparent)

解决方案

  • use fbx (convert obj to fbx, obj doesn't work)
  • import fbx as asset
  • import textrure images files as asset
    (image naming: modelname_Texture_0.jpg modelname_Texture_1.jpg etc, fbx name: modelname.fbx)
  • select the model from favorites -> all models
    in the inspectors tab under materials
  • select import materials > material naming
  • select model name + model's material
    material search
  • select local material's folder
  • click apply
    done

这篇关于如何导入3D场景(.obj文件和.mtl文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆