0
$\begingroup$

I'm not 3D artist so I really don't have much knowledge about what I'm doing, I'm sorry I couldn't really find solution to my problem. So the thing is 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: https://i.imgur.com/c1FJx4t.jpg 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! https://i.imgur.com/eJ1HZg4.png Indeed blender thinks it's material and not texture: https://i.imgur.com/w87Llq8.png 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 side questions: 1) Any good tutorial what are UV's that everyone are talking about, these are essentialy 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

Thanks for any help!

$\endgroup$
  • 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$ – cegaton Nov 23 '17 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$ – psychoboi111 Nov 24 '17 at 2:31
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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.