问题
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
files5
x.mtl
filesn
x.jpg
filesn
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]
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
).I copied all my
.jpg
and.tga
files to a "Textures" folder in the same directory.I used the FBX Converter to convert the
.obj
files to.fbx
.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