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

2

8

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)

enter image description here

enter image description here

Dott answered 25/8, 2015 at 18:38 Comment(3)
Did you make progress afterwards? I am facing the same situation at the moment. Any help will be great!Kruter
My model was way out in space ....meaning after I zoomed out I could see it ....then I dragged it back down to where all the rest of my objects were.Dott
Yeah eventually I also converted everything to fbx along with all the texture images in the same folder and it worked. Thanks though :>Kruter
S
3
  • 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
Squirt answered 17/10, 2016 at 4:31 Comment(0)
G
1

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.

Galcha answered 25/8, 2015 at 19:52 Comment(4)
I tried just importing the .obj file --- it imports it with many many objects underneath it plus a materials folder with again many object in it (see screen shot) . I'm not sure what to drag where.Dott
Made an edit above which may help. You mentioned that you tried an FBX converter. You could try putting it into blender, and exporting from there with embedded media.Galcha
Hmmm yea maybe importing the obj or fbx file into blender. Also see my update above "UPDATE [8/25/2015]"Dott
Tried importing obj and fbx files into Blender , neither works ---- no errors or messages ---nothing happens actually --- so not sure what went wrong .Dott

© 2022 - 2024 — McMap. All rights reserved.