How to import 3D scene (.obj file with .mtl file)

岁酱吖の 提交于 2021-02-06 11:24:39

问题


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)


回答1:


  • 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



回答2:


The easiest (and correct) way to do this will be to not use the .mtl file. Rather just bring in the textures and models, then create a material inside Unity. As a starting point it would probably be best to use the Standard shader. And then just drag the textures to the right properties on the material.

There is a small chance that the above won't work if the UV's are not correct in the mesh, but there is a very good chance that it will work.

You didn't mention the names of the textures, but presumably they will roughly match up with the property names. For instance, _d_ may be the Diffuse/Albedo.

EDIT: In the case where the above isn't an option (like your complicated object), you may have success by using the Import Materials, Material Naming and Material Search options in the import settings of the model. However, that assumes that at least the texture references are withing the .obj, which may not be the case.



来源:https://stackoverflow.com/questions/32211612/how-to-import-3d-scene-obj-file-with-mtl-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!