2

I'm using a program called Noesis to convert game map files to .obj files. The output gives me an .obj and .tga image files. After importing the .obj, I noticed that there are many materials in its index which have the same names as the .tga files. I have manually repeated this action to assign all image textures to the materials: Select Material #0-27> Select "Image Texture" in the "Base Color" option under "Surface" > Open the .tga

Is there a way to automate this process using loops?

I've been searching for answers and I found some similar questions, but my question isn't really getting answered in my search. I'm really interested in learning Python, and I thought this would be a great first project, but I need a little help to get me going.

I determined I need to do at least two things:

1. bpy.data.objects["The Sanctuaryof Zi'tah"].active_material_index = #
2. bpy.ops.image.open(filepath="C:\Users\\admin\\Desktop\\noesisv4423\\Zitah\\rt_w01c.tga", directory="C:\Users\\admin\\Desktop\\noesisv4423\\Zitah", files=[{"name":"model rt_w01c.tga", "name":"model rt_w01c.tga"}]

The index number identifies the material as a number in the order of the index, so how I do I get it to identify it by its set name, and then go into the folder the obj is located in to get the corresponding image texture?

EDIT 1:

Material Index

When I select "Base Color" here and choose "Image Texture" before opening the file, an image texture node is created.

Texture image files

  • Hi and Weclome! There is a file called "bla.obj" and a corresponding image texture with the same name (bla.tga) for the base color in the same folder right? Are there multiple materials per mesh? I suggest add the file structure and one example (obj and texture) to your question to make sure the question is clear to everybody. – brockmann Apr 15 '20 at 18:41
  • @brockmann Thank you for your help. Yes and yes. I have added pictures to illustrate what I'm working with. – antiquixote Apr 16 '20 at 00:54
  • According to your edit the obj is called The Sanctuaryof Zi'tah.obj and the texture is called model rt_w01c.tga, I'd expect something like model_Sanctuaryof_rt_w01c.tga... so that's more like a "No". Basically we need any relation between them, name, date whatever to match geo and texture... Please enable the extensions in windows explorer and re-post the screenshot, pretty useless at the moment. We need to understand and figure a relationship before coding otherweise it's a waste of time, so again the easiest way is adding a obj and tga file... – brockmann Apr 16 '20 at 06:43

0 Answers0