0
$\begingroup$

I'm trying to import a map alongside with models from Jedi Academy (Quake3 based game - idTech3 engine) and I use a program called Noesis to open map in .bsp format. It works and shows textures correctly: enter image description here This program has ability to export map into obj/fbx/dae and many more formats. So I've chosen obj format, loaded into Blender and there are no textures shown, only meshes. The strange thing is that I heard that materials are held in .mtl file, but there is no such file in game data nor Noesis didn't generate anything like that.

But here's the weird thing, this program treat's materials as they were textures, this is part of the output obj file: https://pastebin.com/EHR1JXJn

So you can clearly see there: usemtl textures/desert/stucco_grime And this textures/desert/stucco_grime is actually a jpg file!

enter image description here

Indeed blender thinks it's material and not texture:

enter image description here

So I can create manually a material, and load a texture from this jpg file to it and it will work, but there are hundreds of models and I'm looking for some automatic way of doing this


A couple side questions:

  1. Any good tutorial what are UV's that everyone are talking about, these are essentially coordinates where to apply texture on given mesh?
  2. There is no such thing as "material" generally? A "material" is internal thing of game engine that decides how to renders model, like adding bump-mapping and changing color intensity? If so, why there are "mtl" files available in .obj format
$\endgroup$
2
  • 2
    $\begingroup$ Please read: blender.stackexchange.com/a/57541/1853. This is a question is asked quite often, you can use the serach box on the top of the page to find more answers. Also please don't make more than one question on your post. $\endgroup$
    – user1853
    Commented Nov 23, 2017 at 23:23
  • $\begingroup$ Thanks @cegaton but I've seen already this thread, I understand that I can't import materials, but I'm looking for a way to automatically create material and assign associated texture from file for every object since I'm having around 3000 objects on map and it's too much work to do manually. This is what I need: for each object seen in scene create material and assign texture from file, I can do the programming just tell me if it is possible and where to :P $\endgroup$ Commented Nov 24, 2017 at 2:31

1 Answer 1

0
$\begingroup$

In case someone wondered I just resolved my problem by writing some code:

import bpy

for obj in bpy.data.objects:
    if obj.active_material is not None:
        if obj.active_material.name.startswith('textures'):
            print(obj.active_material.name)
            mat = obj.active_material
            tex = 0
            if mat.texture_slots[0] is not None:
                continue
            try:
                tex = bpy.data.textures[mat.name]
            except KeyError:
                tex = bpy.data.textures.new(mat.name, 'IMAGE')
                try:
                    tex.image = bpy.data.images.load('path/to/assets/' + mat.name + '.jpg')
                except RuntimeError:
                    print(mat.name + ' not found')
                    continue
            slot = mat.texture_slots.add()
            slot.texture = tex
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .