Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 9
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 263 times and has 8 replies Next Thread
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Can’t get my obj. files to connect with textures in the mtl. Files.

I just read another older thread by a user who’s having the same problem as I.

https://www.sweethome3d.com/support/forum/viewthread_thread,7711

I’ve been downloading a bunch of items from other 3D model sites to use in my SH3D project. They either originated as obj. files or I converted them in Blender, but I can’t get the obj. files to recognize or connect with the textures in the mtl. Files.

I’ve uploaded one of the model files here for examination.

https://www.dropbox.com/scl/fo/gmizl3ubqko1yh...&st=7s944ggp&dl=0

I originally got the file from here.
https://sketchfab.com/3d-models/tricorder-mk-...58b0c44b79b16826d1d3dfb69

I’m new to 3D modelling, but I understand the obj. file is just describing the form of the object while the mtl. Holds all the other data for it. I noticed that there are spaces in the name in the object file, “mtllib Star Trek Tricorder MK VII.mtl”, but I think there’s got to be more to the problem than this?
Can anyone shed some light here, please?
Thanks!
[Dec 11, 2024, 5:11:13 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 1176
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

The materials in the mtl file have no mappings to the texture images.
Fortunately you have a model with clear material names that you can connect to the correct texure image.

Edit the mtl file and for each block that matches an image name add the line "map_Kd imagename.png" to the end of the block.
For example:
newmtl Screen
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

becomes:
newmtl Screen
Ns 250.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd Screen.png

There are 44 materials listed in the obj file but you only have 16 texture images. So start with adding the map_Kd lines for those 16 images and import the object in Sweet Home 3D. The other materials are just colors so you will have to select and set a color for those yourself in the modify object dialog. With the 16 textures mapped it should start to look like the model you want. It is mentioned on the sketchfab site that some details are missing, probably the missing correct color settings.

I noticed that some textures are just images of a color square. You might consider changing the material in Sweet Home 3D from that texture to a similar color. It will reduce the size of your object and it wil render much faster.

On the dodecagon.nl site there is a manual about changing material names and one that explains the MTL file. You might want to read those to understand what you are doing with materials.
----------------------------------------
Dodecagon.nl
800+ 3D models, manuals, and projects
[Dec 11, 2024, 7:25:15 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

Wow, this is a big help! Thanks! I'm going to start this now.
[Dec 11, 2024, 7:03:24 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

Hey, I just finished with that object and it worked great! There was only a single instance where something didn't take and I'm pretty sure it's because it was a lighting affect that SW3D really wasn't designed to do. I'm pretty excited about this and am going to go practice on a bunch of other objects I couldn't get to work. Thanks!
[Dec 11, 2024, 9:14:41 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

I have a new object I'm working on but this one looks different. I assembled the textures in Blender and exported the obj. & mtl. files along with the original files in this folder, but it looks like it only has one material name and I'm not sure why as I'd assigned all the textures. Can this still be modified to work?

https://www.dropbox.com/scl/fo/48rbuy1quh8oql...&st=8b9g9ol5&dl=0
[Dec 12, 2024, 5:07:11 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 1176
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

The texture mappings in the mtl file (map_*) are ones that are not processed by Sweet Home 3D.

Remove these lines from the mtl file:
map_Ns C:/Users/Sir Thomas/Desktop/tng-hypospray-original-sternbach-design/textures/DefaultMaterial_Roughness.png
map_refl C:/Users/Sir Thomas/Desktop/tng-hypospray-original-sternbach-design/textures/DefaultMaterial_Metallic.png
map_Bump -bm 1.000000 C:/Users/Sir Thomas/Desktop/tng-hypospray-original-sternbach-design/textures/DefaultMaterial_Normal_OpenGL.png

and add the line
map_Kd DefaultMaterial_Base_Color.png

resulting in
newmtl Material.001
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd DefaultMaterial_Base_Color.png

The object is very small when you import it. It seems like width and depth are 0 and the height is 0.1. Modify it and check "Keep proportions". Set the height to 10 or 15 and the width and depth will adapt proportionally.

ETA: It's good practise to place the texture files in the same directory as the obj and mtl files. That way you don't need a path in the mtl file. A path can make the file unreadable on a different system. On top of that the current set path (a user directory) doesn't exist on someone elses computer.
And about the map_* lines: "map_Kd" is the only texture mapping recognized by Sweet Home 3D. You can view the texture files and choose the one that offers the most "normal" texture. In this case that was the image DefaultMaterial_Base_Color.png.
----------------------------------------
Dodecagon.nl
800+ 3D models, manuals, and projects
----------------------------------------
[Edit 1 times, last edit by Keet at Dec 12, 2024, 6:37:49 PM]
[Dec 12, 2024, 5:25:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

It's a tiny object but enlarging it did work fine. The object imports as just white. I checked the obj. file but can't find a line for the name of the object, which I usually make sure is the same in the mtl. file to make the connection. I just see the lines...

mtllib Hypospray.mtl
o hypo_lo
at the top.

I thought the name always came after usemtl at the top?
[Dec 12, 2024, 6:34:35 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 1176
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

It's a tiny object but enlarging it did work fine. The object imports as just white. I checked the obj. file but can't find a line for the name of the object, which I usually make sure is the same in the mtl. file to make the connection. I just see the lines...

mtllib Hypospray.mtl
o hypo_lo
at the top.

I thought the name always came after usemtl at the top?
This is not and export from Sweet Home 3D. But the line "mtllib Hypospray.mtl" is correct, it sets the reference to the mtl file. As in my previous post: the problem is in the mtl file, not the obj file.

Perform the changes I noted and import the object. If you export it again you will see that there is no "o ..." line but now a "g ..." line in the obj file. And directly below that the line with usemtl.
An obj file is 'read' from top to bottom according to the specifications. "usemtl" indicates that from that point on the material as indicated must be used for the faces that follow (f lines). Until the next usemtl is encountered to switch to that material. The Sweet Home 3D export just sets the "usemtl" line directly afte the group line (g "). Because Sweet Home 3D always groups by material that makes a better 'human readable' format, much easier than for example a Blender export.
----------------------------------------
Dodecagon.nl
800+ 3D models, manuals, and projects
----------------------------------------
[Edit 1 times, last edit by Keet at Dec 12, 2024, 6:47:48 PM]
[Dec 12, 2024, 6:41:48 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Wendell_Burke
Member




Joined: Nov 3, 2024
Post Count: 41
Status: Offline
Reply to this Post  Reply with Quote 
Re: Can’t get my obj. files to connect with textures in the mtl. Files.

Got it. I must have done something wrong before but it's working now. I didn't realize those texture samples with different shapes on them would work out so well inside SH3D. That was a nice surprise, considering how much trouble I've had with book covers & spines. Now that I know it works that way, I'll apply it to a bunch of these other files I have.

Thanks again!
[Dec 13, 2024, 12:32:06 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved