Creating game profiles#
In order to provide dedicated support for any game, you need to implement a game profile Python module.
These modules are located in umodel_tools/game_profiles
directory in the source code tree. The modules are fetched
automatically on add-on’s loading with basic validation performed.
Game support steps#
Create a
.py
file in theumodel_tools/game_profiles
which will be your game profile script (e.g. my_game.py).Inside the file, define
GAME_NAME
andGAME_DESCRIPTION
constants. These strings will be used in the add-on’s UI.Implement all functions defined in the
GameHandler
protocol, which you can find in theumodel_tools/__init__.py
file. The functions should be implemented as free-standing functions, not methods.
Game profile API#
This module holds the configuration protocol for the supported games.
- class umodel_tools.game_profiles.__init__.GameHandler(*args, **kwargs)#
Bases:
Protocol
Modules adding support for specific games must implement this protocol.
- do_process_texture(tex_short_name: str) bool #
Determines whether to process the texture or not.
- Parameters:
tex_type – Texture type string retrieved from .props.txt.
tex_short_name – Basename of the texture file without extension.
- Returns:
True if should process, False if should discard.
- end_process_material() None #
Called at the end of the material processing, can be used to cleanup state (if any is kept).
- Param:
mat: Material that was processed.
- handle_material_texture_pbr(tex_type: str, tex_short_name: str, img_node: bpy.types.ShaderNodeTexImage, ao_mix_node: bpy.types.ShaderNodeMix, bsdf_node: bpy.types.ShaderNodeBsdfPrincipled, out_node: bpy.types.ShaderNodeOutputMaterial) None #
Handles adding texture maps to a PBR material.
- Parameters:
mat – Currently processed material.
tex_type – Current texture type.
tex_short_name – Basename of the texture file without extension.
img_node – Image node in the material’s node tree.
ao_mix_node – Ambient Occlusion mixing node in the material’s node tree.
bsdf_node – PrincipledBSDF node in the material’s node tree.
out_node – Material output node in the material’s node tree.
- handle_material_texture_simple(tex_type: str, tex_short_name: str, img_node: bpy.types.ShaderNodeTexImage, bsdf_node: bpy.types.ShaderNodeBsdfDiffuse) None #
Handles adding texture maps to a simplified material. Only diffuse maps will be processed by this function.
- Parameters:
mat – Currently processed material.
tex_type – Current texture type.
tex_short_name – Basename of the texture file without extension.
img_node – Image node in the material’s node tree.
bsdf_node – DiffuseBSDF node in the material’s node tree.
- is_diffuse_tex_type(tex_short_name: str) bool #
Identifies if the texture is a diffuse color map. Used for special logic.
- Parameters:
tex_type – Texture type string retrieved from .props.txt.
tex_short_name – Basename of the texture file without extension.
- Returns:
True if texture is a diffuse map, else False.
- process_material(desc_ast: lark.tree.Tree, use_pbr: bool) None #
Does all sorts of unspecified processing on the material prior to texture imports.
- Parameters:
mat – Blender material we are processing.
- Desc_ast:
Lark AST tree representing the corresponding material descriptor. Can be used to obtain any additional information required to implement game specifics.
- Use_pbr:
True if material is imported in a PBR mode.