Project Blender Mesh Tools add-on

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
@Blake Can you add a checkbox to enable or disable adding name extension for the materials when importing meshes?

Can you give me more context? The texture file is listed in the mesh file. 'texture.dds'. That file is looked for in the TEXTURES folder. Do you have filenames that don't match?
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
For example, when I import a mesh, the material name is: E.g. “LM_Hull.dds” and it becomes “LM_Hull.dds_ProjectApollo\LMASC_LM_VC”. For me it is important not to have this “extension” and to leave the material name as it is. I made changes to the importer code myself for this, but I think it's better to have it in the add-on itself in case someone needs it.

Code:
        if src_tex:   # Material has a texture
#            mat_name = "{}_{}_{}".format(
#                src_mat.name, src_tex.split(".")[0], scene_name)
            mat_name = src_mat.name
            src_tex_file = resolve_texture_path(config, orbiter_path, src_tex)
            print("Tex: {}".format(src_tex_file))
        else:
#            mat_name = "{}_{}".format(src_mat.name, scene_name)
            mat_name = src_mat.name
 

llarian

Well-known member
Joined
Apr 1, 2009
Messages
578
Reaction score
159
Points
58
Location
Ottawa
Seems to me to be a lot of work just for one user. Can Jordan substantiate that there are more users that might justify the changes?
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
For example, when I import a mesh, the material name is: E.g. “LM_Hull.dds” and it becomes “LM_Hull.dds_ProjectApollo\LMASC_LM_VC”. For me it is important not to have this “extension” and to leave the material name as it is. I made changes to the importer code myself for this, but I think it's better to have it in the add-on itself in case someone needs it.

Code:
        if src_tex:   # Material has a texture
#            mat_name = "{}_{}_{}".format(
#                src_mat.name, src_tex.split(".")[0], scene_name)
            mat_name = src_mat.name
            src_tex_file = resolve_texture_path(config, orbiter_path, src_tex)
            print("Tex: {}".format(src_tex_file))
        else:
#            mat_name = "{}_{}".format(src_mat.name, scene_name)
            mat_name = src_mat.name

The purpose of that string it to provide a unique name for the texture/material that is imported. I hesitate to put the .dss back because the '.' in names tends to break the source files that may be generated. So, I'd like to understand better why having that in the material name would be helpful. An option would be to have a setting similar to how the object names can be customized for source generation. But yes, before doing too much I'd like to understand the use case better.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
The purpose of that string it to provide a unique name for the texture/material that is imported. I hesitate to put the .dss back because the '.' in names tends to break the source files that may be generated. So, I'd like to understand better why having that in the material name would be helpful. An option would be to have a setting similar to how the object names can be customized for source generation. But yes, before doing too much I'd like to understand the use case better.
The material names are written into an xxx_resource.h file using an extended version of meshc. These names are then used in source code to address the materials. Now if someone imports the mesh file again, the materials names will be changed and the source code will no longer work.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
For the "." the extended Meshc takes this into account and replaces it with “_”
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
The example above with “LM_Hull.dds” was only intended to show the changes made after importing.

I used the .dds to immediately recognize whether it was a material with textures or not. But I changed it and just use a "_t" for it now.
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
Ok, I think I get what you are doing. Adding that as an import parameter 'Strip file extension from texture' (default true) should not be too difficult. I have some time over Thanksgiving, there are some other changes to this I'd like to do.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
Ok, I think I get what you are doing. Adding that as an import parameter 'Strip file extension from texture' (default true) should not be too difficult. I have some time over Thanksgiving, there are some other changes to this I'd like to do.
I wanted the names of the materials from the imported mesh to be stay unchanged.

eg. Material name from the mesh "LM_Hull_t" should not become "LM_Hull_t_ProjectApollo\LMASC_LM_VC" and stay "LM_Hull_t"
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
The material name is created using the material name, the texture name (the file without the .dds) and the scene name. The reason is that Orbiter allows any combination of the material and texture to be present. Material 'Steel' for example can be use with texture 'Red.dds' for one group and 'Blue.dds' for another group. In Blender we need to distinguish between them, so we append the material and texture names together when creating the material. In addition, a material in Blender is seen by all Scenes, so the scene name (name of the mesh file) is also added so that two mesh files in different scenes can have their own materials.

It sounds like what may work is to recognize one of these concatenated material names when the mesh file is created and use only the 'material' part of the name to name the mesh material. In other words, when writing out the material name it would only include the part up to the first '_'. Then it should round trip back into Blender without messing up.

Inside of Blender I need to account for the material+texture+scene combinations. I don't see a way around that.

I hope that represents what you are getting at.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
The material name is created using the material name, the texture name (the file without the .dds) and the scene name. The reason is that Orbiter allows any combination of the material and texture to be present. Material 'Steel' for example can be use with texture 'Red.dds' for one group and 'Blue.dds' for another group. In Blender we need to distinguish between them, so we append the material and texture names together when creating the material. In addition, a material in Blender is seen by all Scenes, so the scene name (name of the mesh file) is also added so that two mesh files in different scenes can have their own materials.

It sounds like what may work is to recognize one of these concatenated material names when the mesh file is created and use only the 'material' part of the name to name the mesh material. In other words, when writing out the material name it would only include the part up to the first '_'. Then it should round trip back into Blender without messing up.

Inside of Blender I need to account for the material+texture+scene combinations. I don't see a way around that.

I hope that represents what you are getting at.
I am happy with being able to select when exporting that the material names remains unchanged. Hopefully the separation at the first "_" shouldn't cause any problems since it also appears in the names themselves.
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
New release available 2.1.3.

Adds a new build parameter that will allow you to parse the material name at the first '_'. As discussed above, that should allow you to save an imported mesh file using the same material name as the original mesh.

Also fixes an issue finding texture files on Linux. I did some minimal testing on this, but I was able to import several stock meshes as well as my SR71r mesh. Textures all appeared to work. Play with this and let me know how it works under Linux. I have little experience with Blender/Orbiter in Linux.

Github: https://github.com/BMCDad/orbiter-blender
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
New release available 2.1.3.

Adds a new build parameter that will allow you to parse the material name at the first '_'. As discussed above, that should allow you to save an imported mesh file using the same material name as the original mesh.

Also fixes an issue finding texture files on Linux. I did some minimal testing on this, but I was able to import several stock meshes as well as my SR71r mesh. Textures all appeared to work. Play with this and let me know how it works under Linux. I have little experience with Blender/Orbiter in Linux.

Github: https://github.com/BMCDad/orbiter-blender
Doesn't work as it should. e.g. "FDAI_errorneedle" becomes "FDAI"
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
Doesn't work as it should. e.g. "FDAI_errorneedle" becomes "FDAI"
Yeah, I knew that might be a problem. Another option is to pick another delimiter when building the material name on import and parse on that. Or let the importer pick something they know will be unique. There is probably some way to store that with the blend file so it knows how to pick it apart again.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
In my opinion, the names should not be changed when importing.
So you can also see the “original” names in the outliner.
As far as I know, the fact that a material with the same name can be used with two or more different textures shouldn't cause any problems since the mesh has already been exported.
I haven't seen a case like this yet. If this is the case, someone can also use the “current” method.
The fact that someone can edit several scenes at the same time shouldn't be a problem either, in such a case everyone can only edit a single scene, that's what I do anyway, I prefer to have control over which mesh I want to build.
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
In my opinion, the names should not be changed when importing.
So you can also see the “original” names in the outliner.
As far as I know, the fact that a material with the same name can be used with two or more different textures shouldn't cause any problems since the mesh has already been exported.
I haven't seen a case like this yet. If this is the case, someone can also use the “current” method.
The fact that someone can edit several scenes at the same time shouldn't be a problem either, in such a case everyone can only edit a single scene, that's what I do anyway, I prefer to have control over which mesh I want to build.

There is a pre-release 2.1.4 version you can try out. It allows you to disable the generation of the material name on import and simply uses the material names in the mesh file. The default behavior remains the same. If you want to see the issues this causes try importing ShuttleA with the new import option disabled.


Also, unrelated, I did run the plugin through its paces in Blender 4.0 and have so far found no issues.
 

Jordan

Active member
Joined
May 13, 2010
Messages
137
Reaction score
80
Points
43
Location
Germany
@Blake At least I don't see any difference in the material names. Left enabled, right disabled? Did I miss something?
By the way, on the right it is exactly how I wanted it.

1701726075188.png
 

Blake

Addon Developer
Addon Developer
Joined
Mar 9, 2009
Messages
235
Reaction score
123
Points
58
Location
Lehi, Utah
@Blake At least I don't see any difference in the material names. Left enabled, right disabled? Did I miss something?
By the way, on the right it is exactly how I wanted it.

View attachment 35883

Where are you not seeing the difference? Your screenshot appears to show the behavior we want. The incoming material name has the texture name and mesh name appended on the left. On the right its just the material name alone (option disabled).
 
Top