finish virtools groups
@ -81,8 +81,8 @@ class BBP_PG_ballance_element(bpy.types.PropertyGroup):
|
||||
type = bpy.types.Mesh
|
||||
)
|
||||
|
||||
def get_ballance_elements() -> bpy.types.CollectionProperty:
|
||||
return bpy.context.scene.ballance_elements
|
||||
def get_ballance_elements(scene: bpy.types.Scene) -> bpy.types.CollectionProperty:
|
||||
return scene.ballance_elements
|
||||
|
||||
#endregion
|
||||
|
||||
@ -151,9 +151,7 @@ def _load_element(mesh: bpy.types.Mesh, element_id: int) -> None:
|
||||
v: UTIL_virtools_types.VxVector2 = UTIL_virtools_types.VxVector2()
|
||||
yield v
|
||||
mesh_part.mVertexUV = vuv_iterator()
|
||||
def mtl_iterator() -> typing.Iterator[bpy.types.Material]:
|
||||
pass
|
||||
mesh_part.mMaterial = mtl_iterator()
|
||||
mesh_part.mMaterial = iter(tuple())
|
||||
def face_iterator() -> typing.Iterator[UTIL_blender_mesh.FaceData]:
|
||||
# create face data with 3 placeholder
|
||||
f: UTIL_blender_mesh.FaceData = UTIL_blender_mesh.FaceData([UTIL_blender_mesh.FaceVertexData() for i in range(3)])
|
||||
@ -191,13 +189,14 @@ class BallanceElementsHelper():
|
||||
This class should only have 1 instance at the same time. This class support `with` syntax to achieve this.
|
||||
This class frequently used in importing stage to create element placeholder.
|
||||
"""
|
||||
|
||||
__mSingletonMutex: typing.ClassVar[bool] = False
|
||||
__mIsValid: bool
|
||||
__mAssocScene: bpy.types.Scene
|
||||
__mElementMap: dict[int, bpy.types.Mesh]
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, assoc: bpy.types.Scene):
|
||||
self.__mElementMap = {}
|
||||
self.__mAssocScene = assoc
|
||||
|
||||
# check singleton
|
||||
if BallanceElementsHelper.__mSingletonMutex:
|
||||
@ -223,7 +222,7 @@ class BallanceElementsHelper():
|
||||
# write to ballance elements property and reset validation
|
||||
self.__write_to_ballance_elements()
|
||||
self.__mIsValid = False
|
||||
self.__mSingletonMutex = False
|
||||
BallanceElementsHelper.__mSingletonMutex = False
|
||||
|
||||
def get_element(self, element_id: int) -> bpy.types.Mesh:
|
||||
if not self.is_valid():
|
||||
@ -245,7 +244,7 @@ class BallanceElementsHelper():
|
||||
return new_mesh
|
||||
|
||||
def __write_to_ballance_elements(self) -> None:
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements()
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements(self.__mAssocScene)
|
||||
elements.clear()
|
||||
|
||||
for eleid, elemesh in self.__mElementMap.items():
|
||||
@ -258,7 +257,7 @@ class BallanceElementsHelper():
|
||||
item.mesh_ptr = elemesh
|
||||
|
||||
def __read_from_ballance_element(self) -> None:
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements()
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements(self.__mAssocScene)
|
||||
self.__mElementMap.clear()
|
||||
|
||||
item: BBP_PG_ballance_element
|
||||
@ -271,9 +270,9 @@ class BallanceElementsHelper():
|
||||
# add into map
|
||||
self.__mElementMap[mesh_id] = item.mesh_ptr
|
||||
|
||||
def reset_ballance_elements() -> None:
|
||||
def reset_ballance_elements(scene: bpy.types.Scene) -> None:
|
||||
invalid_idx: list[int] = []
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements()
|
||||
elements: bpy.types.CollectionProperty = get_ballance_elements(scene)
|
||||
|
||||
# re-load all elements
|
||||
index: int = 0
|
||||
@ -302,8 +301,8 @@ def reset_ballance_elements() -> None:
|
||||
class BBP_UL_ballance_elements(bpy.types.UIList):
|
||||
def draw_item(self, context, layout: bpy.types.UILayout, data, item: BBP_PG_ballance_element, icon, active_data, active_propname):
|
||||
if item.element_name != "" and item.mesh_ptr is not None:
|
||||
layout.label(text = item.element_name)
|
||||
layout.label(text = item.mesh_ptr, icon = 'MESH_DATA')
|
||||
layout.label(text = item.element_name, translate = False)
|
||||
layout.label(text = item.mesh_ptr, translate = False, icon = 'MESH_DATA')
|
||||
|
||||
class BBP_OT_reset_ballance_elements(bpy.types.Operator):
|
||||
"""Reset all Meshes of Loaded Ballance Elements to Original Geometry."""
|
||||
@ -316,7 +315,7 @@ class BBP_OT_reset_ballance_elements(bpy.types.Operator):
|
||||
return context.scene is not None
|
||||
|
||||
def execute(self, context):
|
||||
reset_ballance_elements()
|
||||
reset_ballance_elements(context.scene)
|
||||
return {'FINISHED'}
|
||||
|
||||
class BBP_PT_ballance_elements(bpy.types.Panel):
|
||||
|
@ -1,8 +1,365 @@
|
||||
import bpy
|
||||
import typing
|
||||
from . import UTIL_functions
|
||||
|
||||
#region Virtools Groups Define & Help Class
|
||||
|
||||
class BBP_PG_virtools_group(bpy.types.PropertyGroup):
|
||||
group_name: bpy.props.StringProperty(
|
||||
name = "Group Name",
|
||||
name = "Group Name",
|
||||
default = ""
|
||||
)
|
||||
|
||||
def get_virtools_groups(obj: bpy.types.Object) -> bpy.types.CollectionProperty:
|
||||
return obj.virtools_groups
|
||||
|
||||
def get_active_virtools_groups(obj: bpy.types.Object) -> int:
|
||||
return obj.active_virtools_groups
|
||||
|
||||
def set_active_virtools_groups(obj: bpy.types.Object, val: int) -> None:
|
||||
obj.active_virtools_groups = val
|
||||
|
||||
class VirtoolsGroupsHelper():
|
||||
"""
|
||||
A helper for object's Virtools groups adding, removal and checking.
|
||||
|
||||
All Virtools group operations should be done by this class.
|
||||
Do NOT manipulate object's Virtools group properties directly.
|
||||
"""
|
||||
__mSingletonMutex: typing.ClassVar[bool] = False
|
||||
__mIsValid: bool
|
||||
__mAssocObj: bpy.types.Object
|
||||
__mGroupsSet: set[str]
|
||||
|
||||
def __init__(self, assoc: bpy.types.Object):
|
||||
self.__mGroupsSet = set()
|
||||
self.__mAssocObj = assoc
|
||||
|
||||
# check singleton
|
||||
if VirtoolsGroupsHelper.__mSingletonMutex:
|
||||
self.__mIsValid = False
|
||||
raise UTIL_functions.BBPException('VirtoolsGroupsHelper is mutex.')
|
||||
|
||||
# set validation and read ballance elements property
|
||||
VirtoolsGroupsHelper.__mSingletonMutex = True
|
||||
self.__mIsValid = True
|
||||
self.__read_from_virtools_groups()
|
||||
|
||||
def is_valid(self) -> bool:
|
||||
return self.__mIsValid
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.dispose()
|
||||
|
||||
def dispose(self) -> None:
|
||||
if self.is_valid():
|
||||
# write to ballance elements property and reset validation
|
||||
self.__write_to_virtools_groups()
|
||||
self.__mIsValid = False
|
||||
VirtoolsGroupsHelper.__mSingletonMutex = False
|
||||
|
||||
def __check_valid(self) -> None:
|
||||
if not self.is_valid():
|
||||
raise UTIL_functions.BBPException('calling invalid VirtoolsGroupsHelper')
|
||||
|
||||
def add_group(self, gname: str) -> None:
|
||||
self.__check_valid()
|
||||
self.__mGroupsSet.add(gname)
|
||||
|
||||
def add_groups(self, gnames: typing.Iterable[str]) -> None:
|
||||
self.__check_valid()
|
||||
self.__mGroupsSet.update(gnames)
|
||||
|
||||
def remove_group(self, gname: str) -> None:
|
||||
self.__check_valid()
|
||||
self.__mGroupsSet.discard(gname)
|
||||
|
||||
def remove_groups(self, gnames: typing.Iterable[str]) -> None:
|
||||
self.__check_valid()
|
||||
for gname in gnames:
|
||||
self.__mGroupsSet.discard(gname)
|
||||
|
||||
def contain_group(self, gname: str) -> bool:
|
||||
self.__check_valid()
|
||||
return gname in self.__mGroupsSet
|
||||
|
||||
def contain_groups(self, gnames: typing.Iterable[str]) -> bool:
|
||||
"""
|
||||
Check existing intersection between group names and given collection.
|
||||
|
||||
In other words, check whether group name of given paramter is in group names with OR operator.
|
||||
|
||||
@param gnames[in] Iterable group names to check.
|
||||
@return return True if the length of the intersection between group names and given group names is not zero.
|
||||
"""
|
||||
self.__check_valid()
|
||||
for gname in gnames:
|
||||
if gname in self.__mGroupsSet:
|
||||
return True
|
||||
return False
|
||||
|
||||
def clear_all_groups(self):
|
||||
self.__check_valid()
|
||||
self.__mGroupsSet.clear()
|
||||
|
||||
def __write_to_virtools_groups(self) -> None:
|
||||
groups: bpy.types.CollectionProperty = get_virtools_groups(self.__mAssocObj)
|
||||
sel: int = get_active_virtools_groups(self.__mAssocObj)
|
||||
groups.clear()
|
||||
|
||||
for gname in self.__mGroupsSet:
|
||||
item: BBP_PG_virtools_group = groups.add()
|
||||
item.group_name = gname
|
||||
|
||||
# restore selection if necessary
|
||||
if sel >= len(self.__mGroupsSet):
|
||||
sel = len(self.__mGroupsSet) - 1
|
||||
if sel < 0:
|
||||
sel = 0
|
||||
set_active_virtools_groups(self.__mAssocObj, sel)
|
||||
|
||||
def __read_from_virtools_groups(self) -> None:
|
||||
groups: bpy.types.CollectionProperty = get_virtools_groups(self.__mAssocObj)
|
||||
self.__mGroupsSet.clear()
|
||||
|
||||
item: BBP_PG_virtools_group
|
||||
for item in groups:
|
||||
self.__mGroupsSet.add(item.group_name)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Preset Group Names
|
||||
|
||||
_g_VirtoolsGroupsPreset: tuple[str] = (
|
||||
"Sector_01",
|
||||
"Sector_02",
|
||||
"Sector_03",
|
||||
"Sector_04",
|
||||
"Sector_05",
|
||||
"Sector_06",
|
||||
"Sector_07",
|
||||
"Sector_08",
|
||||
|
||||
"P_Extra_Life",
|
||||
"P_Extra_Point",
|
||||
"P_Trafo_Paper",
|
||||
"P_Trafo_Stone",
|
||||
"P_Trafo_Wood",
|
||||
"P_Ball_Paper",
|
||||
"P_Ball_Stone",
|
||||
"P_Ball_Wood",
|
||||
"P_Box",
|
||||
"P_Dome",
|
||||
"P_Modul_01",
|
||||
"P_Modul_03",
|
||||
"P_Modul_08",
|
||||
"P_Modul_17",
|
||||
"P_Modul_18",
|
||||
"P_Modul_19",
|
||||
"P_Modul_25",
|
||||
"P_Modul_26",
|
||||
"P_Modul_29",
|
||||
"P_Modul_30",
|
||||
"P_Modul_34",
|
||||
"P_Modul_37",
|
||||
"P_Modul_41",
|
||||
|
||||
"PS_Levelstart",
|
||||
"PE_Levelende",
|
||||
"PC_Checkpoints",
|
||||
"PR_Resetpoints",
|
||||
|
||||
"Sound_HitID_01",
|
||||
"Sound_RollID_01",
|
||||
"Sound_HitID_02",
|
||||
"Sound_RollID_02",
|
||||
"Sound_HitID_03",
|
||||
"Sound_RollID_03",
|
||||
|
||||
"DepthTestCubes",
|
||||
|
||||
"Phys_Floors",
|
||||
"Phys_FloorRails",
|
||||
"Phys_FloorStopper",
|
||||
|
||||
"Shadow"
|
||||
)
|
||||
|
||||
class SharedGroupNameInputProperties():
|
||||
group_name_source: bpy.props.EnumProperty(
|
||||
name = "Group Name Source",
|
||||
items = (
|
||||
('DEFINED', "Predefined", "Pre-defined group name."),
|
||||
('CUSTOM', "Custom", "User specified group name."),
|
||||
),
|
||||
)
|
||||
|
||||
preset_group_name: bpy.props.EnumProperty(
|
||||
name="Group Name",
|
||||
description="Pick vanilla Ballance group name.",
|
||||
items=tuple(
|
||||
# token, display name, descriptions, icon, index
|
||||
(str(idx), grp, "", "", idx) for idx, grp in enumerate(_g_VirtoolsGroupsPreset)
|
||||
),
|
||||
)
|
||||
|
||||
custom_group_name: bpy.props.StringProperty(
|
||||
name = "Custom Group Name",
|
||||
description = "Input your custom group name.",
|
||||
default = "",
|
||||
)
|
||||
|
||||
def draw_group_name_input(self, layout: bpy.types.UILayout) -> None:
|
||||
layout.prop(self, 'group_name_source', expand=True)
|
||||
if (self.group_name_source == 'CUSTOM'):
|
||||
layout.prop(self, 'custom_group_name')
|
||||
else:
|
||||
layout.prop(self, 'preset_group_name')
|
||||
|
||||
def general_get_group_name(self) -> str:
|
||||
if self.group_name_source == 'CUSTOM':
|
||||
return self.custom_group_name
|
||||
else:
|
||||
return _g_VirtoolsGroupsPreset[int(self.preset_group_name)]
|
||||
|
||||
#endregion
|
||||
|
||||
#region Display Panel and Simple Operator
|
||||
|
||||
class BBP_UL_virtools_groups(bpy.types.UIList):
|
||||
def draw_item(self, context, layout: bpy.types.UILayout, data, item: BBP_PG_virtools_group, icon, active_data, active_propname):
|
||||
layout.label(text = item.group_name, translate = False, icon = 'GROUP')
|
||||
|
||||
class BBP_OT_add_virtools_groups(bpy.types.Operator, SharedGroupNameInputProperties):
|
||||
"""Add a Virtools Group for Active Object."""
|
||||
bl_idname = "bbp.add_virtools_groups"
|
||||
bl_label = "Add to Virtools Groups"
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(self, context: bpy.types.Context):
|
||||
return context.object is not None
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
def execute(self, context):
|
||||
# add group
|
||||
with VirtoolsGroupsHelper(context.object) as hlp:
|
||||
hlp.add_group(self.general_get_group_name())
|
||||
return {'FINISHED'}
|
||||
|
||||
def draw(self, context):
|
||||
self.draw_group_name_input(self.layout)
|
||||
|
||||
class BBP_OT_rm_virtools_groups(bpy.types.Operator):
|
||||
"""Remove a Virtools Group for Active Object."""
|
||||
bl_idname = "bbp.rm_virtools_groups"
|
||||
bl_label = "Remove from Virtools Groups"
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
## This class is slightly unique.
|
||||
# Because we need get user selected group name first.
|
||||
# Then pass it to helper.
|
||||
|
||||
@classmethod
|
||||
def poll(self, context: bpy.types.Context):
|
||||
if context.object is None:
|
||||
return False
|
||||
|
||||
obj = context.object
|
||||
gp = get_virtools_groups(obj)
|
||||
active_gp = get_active_virtools_groups(obj)
|
||||
return active_gp >= 0 and active_gp < len(gp)
|
||||
|
||||
def execute(self, context):
|
||||
# get selected group name first
|
||||
obj = context.object
|
||||
item: BBP_PG_virtools_group = get_virtools_groups(obj)[get_active_virtools_groups(obj)]
|
||||
gname: str = item.group_name
|
||||
# then delete it
|
||||
with VirtoolsGroupsHelper(obj) as hlp:
|
||||
hlp.remove_group(gname)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class BBP_OT_clear_virtools_groups(bpy.types.Operator):
|
||||
"""Clear All Virtools Group for Active Object."""
|
||||
bl_idname = "bbp.clear_virtools_groups"
|
||||
bl_label = "Clear Virtools Groups"
|
||||
bl_options = {'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(self, context: bpy.types.Context):
|
||||
return context.object is not None
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_confirm(self, event)
|
||||
|
||||
def execute(self, context):
|
||||
with VirtoolsGroupsHelper(context.object) as hlp:
|
||||
hlp.clear_all_groups()
|
||||
return {'FINISHED'}
|
||||
|
||||
class BBP_PT_virtools_groups(bpy.types.Panel):
|
||||
"""Show Virtools Groups Properties."""
|
||||
bl_label = "Virtools Groups"
|
||||
bl_idname = "BBP_PT_virtools_groups"
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
bl_context = "object"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.object is not None
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
target = bpy.context.active_object
|
||||
|
||||
row = layout.row()
|
||||
row.template_list(
|
||||
"BBP_UL_virtools_groups", "",
|
||||
target, "virtools_groups",
|
||||
target, "active_virtools_groups",
|
||||
rows = 6,
|
||||
maxrows = 6,
|
||||
)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.operator(BBP_OT_add_virtools_groups.bl_idname, icon='ADD', text="")
|
||||
col.operator(BBP_OT_rm_virtools_groups.bl_idname, icon='REMOVE', text="")
|
||||
col.separator()
|
||||
col.operator(BBP_OT_clear_virtools_groups.bl_idname, icon='TRASH', text="")
|
||||
|
||||
#endregion
|
||||
|
||||
def register():
|
||||
# register all classes
|
||||
bpy.utils.register_class(BBP_PG_virtools_group)
|
||||
bpy.utils.register_class(BBP_UL_virtools_groups)
|
||||
bpy.utils.register_class(BBP_OT_add_virtools_groups)
|
||||
bpy.utils.register_class(BBP_OT_rm_virtools_groups)
|
||||
bpy.utils.register_class(BBP_OT_clear_virtools_groups)
|
||||
bpy.utils.register_class(BBP_PT_virtools_groups)
|
||||
|
||||
# add into scene metadata
|
||||
bpy.types.Object.virtools_groups = bpy.props.CollectionProperty(type = BBP_PG_virtools_group)
|
||||
bpy.types.Object.active_virtools_groups = bpy.props.IntProperty()
|
||||
|
||||
def unregister():
|
||||
# del from scene metadata
|
||||
del bpy.types.Scene.active_virtools_groups
|
||||
del bpy.types.Scene.virtools_groups
|
||||
|
||||
bpy.utils.unregister_class(BBP_PT_virtools_groups)
|
||||
bpy.utils.unregister_class(BBP_OT_clear_virtools_groups)
|
||||
bpy.utils.unregister_class(BBP_OT_rm_virtools_groups)
|
||||
bpy.utils.unregister_class(BBP_OT_add_virtools_groups)
|
||||
bpy.utils.unregister_class(BBP_UL_virtools_groups)
|
||||
bpy.utils.unregister_class(BBP_PG_virtools_group)
|
||||
|
@ -77,7 +77,7 @@ g_Annotation_VXCMPFUNC: dict[int, AnnotationData] = {
|
||||
|
||||
InheritingIntEnum_t = typing.TypeVar('InheritingIntEnum_t', bound = enum.IntEnum)
|
||||
BlenderEnumPropEntry_t = tuple[str, str, str, str | int, int]
|
||||
def generate_vt_enums_for_bl_enumprop(enum_data: type[InheritingIntEnum_t], anno: dict[int, AnnotationData]) -> tuple[BlenderEnumPropEntry_t, ...]:
|
||||
def _generate_vt_enums_for_bl_enumprop(enum_data: type[InheritingIntEnum_t], anno: dict[int, AnnotationData]) -> tuple[BlenderEnumPropEntry_t, ...]:
|
||||
# define 2 assist functions
|
||||
def get_display_name(v: int, fallback: str):
|
||||
entry: AnnotationData | None = anno.get(v, None)
|
||||
@ -273,7 +273,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
texture_blend_mode: bpy.props.EnumProperty(
|
||||
name = "Texture Blend",
|
||||
description = "Texture blend mode",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXTEXTURE_BLENDMODE,
|
||||
g_Annotation_VXTEXTURE_BLENDMODE
|
||||
),
|
||||
@ -283,7 +283,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
texture_min_mode: bpy.props.EnumProperty(
|
||||
name = "Filter Min",
|
||||
description = "Texture filter mode when the texture is minified",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXTEXTURE_FILTERMODE,
|
||||
g_Annotation_VXTEXTURE_FILTERMODE
|
||||
),
|
||||
@ -293,7 +293,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
texture_mag_mode: bpy.props.EnumProperty(
|
||||
name = "Filter Mag",
|
||||
description = "Texture filter mode when the texture is magnified",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXTEXTURE_FILTERMODE,
|
||||
g_Annotation_VXTEXTURE_FILTERMODE
|
||||
),
|
||||
@ -303,7 +303,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
texture_address_mode: bpy.props.EnumProperty(
|
||||
name = "Address Mode",
|
||||
description = "The address mode controls how the texture coordinates outside the range 0..1",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXTEXTURE_ADDRESSMODE,
|
||||
g_Annotation_VXTEXTURE_ADDRESSMODE
|
||||
),
|
||||
@ -313,7 +313,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
source_blend: bpy.props.EnumProperty(
|
||||
name = "Source Blend",
|
||||
description = "Source blend factor",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXBLEND_MODE,
|
||||
g_Annotation_VXBLEND_MODE
|
||||
),
|
||||
@ -323,7 +323,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
dest_blend: bpy.props.EnumProperty(
|
||||
name = "Destination Blend",
|
||||
description = "Destination blend factor",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXBLEND_MODE,
|
||||
g_Annotation_VXBLEND_MODE
|
||||
),
|
||||
@ -333,7 +333,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
fill_mode: bpy.props.EnumProperty(
|
||||
name = "Fill Mode",
|
||||
description = "Fill mode",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXFILL_MODE,
|
||||
g_Annotation_VXFILL_MODE
|
||||
),
|
||||
@ -343,7 +343,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
shade_mode: bpy.props.EnumProperty(
|
||||
name = "Shade Mode",
|
||||
description = "Shade mode",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXSHADE_MODE,
|
||||
g_Annotation_VXSHADE_MODE
|
||||
),
|
||||
@ -387,7 +387,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
alpha_func: bpy.props.EnumProperty(
|
||||
name = "Alpha Test Function",
|
||||
description = "Alpha comparision function",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXCMPFUNC,
|
||||
g_Annotation_VXCMPFUNC
|
||||
),
|
||||
@ -397,7 +397,7 @@ class BBP_PG_virtools_material(bpy.types.PropertyGroup):
|
||||
z_func: bpy.props.EnumProperty(
|
||||
name = "Z Compare Function",
|
||||
description = "Z Comparison function",
|
||||
items = generate_vt_enums_for_bl_enumprop(
|
||||
items = _generate_vt_enums_for_bl_enumprop(
|
||||
UTIL_virtools_types.VXCMPFUNC,
|
||||
g_Annotation_VXCMPFUNC
|
||||
),
|
||||
@ -612,7 +612,7 @@ def preset_virtools_material(mtl: bpy.types.Material, preset_type: MaterialPrese
|
||||
preset_data: MaterialPresetData = g_MaterialPresets[preset_type.value]
|
||||
set_raw_virtools_material(mtl, preset_data.mData)
|
||||
|
||||
def generate_mtl_presets_for_bl_enumprop() -> tuple[BlenderEnumPropEntry_t, ...]:
|
||||
def _generate_mtl_presets_for_bl_enumprop() -> tuple[BlenderEnumPropEntry_t, ...]:
|
||||
# define 2 assist functions
|
||||
def get_display_name(v: int):
|
||||
entry: MaterialPresetData | None = g_MaterialPresets.get(v, None)
|
||||
@ -652,7 +652,7 @@ class BBP_OT_preset_virtools_material(bpy.types.Operator):
|
||||
preset_type: bpy.props.EnumProperty(
|
||||
name = "Preset",
|
||||
description = "The preset which you want to apply.",
|
||||
items = generate_mtl_presets_for_bl_enumprop(),
|
||||
items = _generate_mtl_presets_for_bl_enumprop(),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -755,8 +755,10 @@ g_BldClasses: tuple[typing.Any, ...] = (
|
||||
)
|
||||
|
||||
def register():
|
||||
for cls in g_BldClasses:
|
||||
bpy.utils.register_class(cls)
|
||||
bpy.utils.register_class(BBP_PG_virtools_material)
|
||||
bpy.utils.register_class(BBP_OT_apply_virtools_material)
|
||||
bpy.utils.register_class(BBP_OT_preset_virtools_material)
|
||||
bpy.utils.register_class(BBP_PT_virtools_material)
|
||||
|
||||
# add into material metadata
|
||||
bpy.types.Material.virtools_material = bpy.props.PointerProperty(type = BBP_PG_virtools_material)
|
||||
@ -765,5 +767,7 @@ def unregister():
|
||||
# del from material metadata
|
||||
del bpy.types.Material.virtools_material
|
||||
|
||||
for cls in g_BldClasses:
|
||||
bpy.utils.unregister_class(cls)
|
||||
bpy.utils.unregister_class(BBP_PT_virtools_material)
|
||||
bpy.utils.unregister_class(BBP_OT_preset_virtools_material)
|
||||
bpy.utils.unregister_class(BBP_OT_apply_virtools_material)
|
||||
bpy.utils.unregister_class(BBP_PG_virtools_material)
|
||||
|
@ -23,7 +23,7 @@ if "bpy" in locals():
|
||||
|
||||
#endregion
|
||||
|
||||
from . import PROP_preferences, PROP_virtools_material, PROP_ballance_element
|
||||
from . import PROP_preferences, PROP_virtools_material, PROP_ballance_element, PROP_virtools_group
|
||||
from . import OP_IMPORT_bmfile, OP_EXPORT_bmfile, OP_IMPORT_virtools, OP_EXPORT_virtools
|
||||
from . import OP_UV_flatten_uv, OP_UV_rail_uv
|
||||
|
||||
@ -87,6 +87,7 @@ def register() -> None:
|
||||
PROP_preferences.register()
|
||||
PROP_virtools_material.register()
|
||||
PROP_ballance_element.register()
|
||||
PROP_virtools_group.register()
|
||||
|
||||
OP_IMPORT_bmfile.register()
|
||||
OP_EXPORT_bmfile.register()
|
||||
@ -125,6 +126,7 @@ def unregister() -> None:
|
||||
OP_EXPORT_bmfile.unregister()
|
||||
OP_IMPORT_bmfile.unregister()
|
||||
|
||||
PROP_virtools_group.unregister()
|
||||
PROP_ballance_element.unregister()
|
||||
PROP_virtools_material.unregister()
|
||||
PROP_preferences.unregister()
|
||||
|
BIN
bbp_ng/icons/Empty.png
Normal file
After Width: | Height: | Size: 785 B |
BIN
bbp_ng/icons/element/PC_TwoFlames.png
Normal file
After Width: | Height: | Size: 663 B |
BIN
bbp_ng/icons/element/PE_Balloon.png
Normal file
After Width: | Height: | Size: 745 B |
BIN
bbp_ng/icons/element/PR_Resetpoint.png
Normal file
After Width: | Height: | Size: 945 B |
BIN
bbp_ng/icons/element/PS_FourFlames.png
Normal file
After Width: | Height: | Size: 818 B |
BIN
bbp_ng/icons/element/P_Ball_Paper.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
bbp_ng/icons/element/P_Ball_Stone.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
bbp_ng/icons/element/P_Ball_Wood.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
bbp_ng/icons/element/P_Box.png
Normal file
After Width: | Height: | Size: 984 B |
BIN
bbp_ng/icons/element/P_Dome.png
Normal file
After Width: | Height: | Size: 611 B |
BIN
bbp_ng/icons/element/P_Extra_Life.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
bbp_ng/icons/element/P_Extra_Point.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
bbp_ng/icons/element/P_Modul_01.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
bbp_ng/icons/element/P_Modul_03.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
bbp_ng/icons/element/P_Modul_08.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
bbp_ng/icons/element/P_Modul_17.png
Normal file
After Width: | Height: | Size: 494 B |
BIN
bbp_ng/icons/element/P_Modul_18.png
Normal file
After Width: | Height: | Size: 360 B |
BIN
bbp_ng/icons/element/P_Modul_19.png
Normal file
After Width: | Height: | Size: 992 B |
BIN
bbp_ng/icons/element/P_Modul_25.png
Normal file
After Width: | Height: | Size: 444 B |
BIN
bbp_ng/icons/element/P_Modul_26.png
Normal file
After Width: | Height: | Size: 691 B |
BIN
bbp_ng/icons/element/P_Modul_29.png
Normal file
After Width: | Height: | Size: 775 B |
BIN
bbp_ng/icons/element/P_Modul_30.png
Normal file
After Width: | Height: | Size: 807 B |
BIN
bbp_ng/icons/element/P_Modul_34.png
Normal file
After Width: | Height: | Size: 652 B |
BIN
bbp_ng/icons/element/P_Modul_37.png
Normal file
After Width: | Height: | Size: 695 B |
BIN
bbp_ng/icons/element/P_Modul_41.png
Normal file
After Width: | Height: | Size: 550 B |
BIN
bbp_ng/icons/element/P_Trafo_Paper.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
bbp_ng/icons/element/P_Trafo_Stone.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
bbp_ng/icons/element/P_Trafo_Wood.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
bbp_ng/icons/floor/Flat.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
bbp_ng/icons/floor/Normal1x1.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
bbp_ng/icons/floor/NormalBorder.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
bbp_ng/icons/floor/NormalCrossroad.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
bbp_ng/icons/floor/NormalFloor.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
bbp_ng/icons/floor/NormalFloorTerminal.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
bbp_ng/icons/floor/NormalInnerCorner.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
bbp_ng/icons/floor/NormalLConnector.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
bbp_ng/icons/floor/NormalOutterCorner.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
bbp_ng/icons/floor/NormalPlatform.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
bbp_ng/icons/floor/NormalSinkTransition.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
bbp_ng/icons/floor/NormalTConnector.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
bbp_ng/icons/floor/PaperTrafo.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
bbp_ng/icons/floor/RibbonBorder.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
bbp_ng/icons/floor/RibbonOutterCorner.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
bbp_ng/icons/floor/RibbonPlatform.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
bbp_ng/icons/floor/Sink1x1.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
bbp_ng/icons/floor/SinkBorder.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
bbp_ng/icons/floor/SinkCrossroad.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
bbp_ng/icons/floor/SinkFloor.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
bbp_ng/icons/floor/SinkFloorTerminal.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
bbp_ng/icons/floor/SinkInnerCorner.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
bbp_ng/icons/floor/SinkLConnector.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
bbp_ng/icons/floor/SinkOutterCorner.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
bbp_ng/icons/floor/SinkPlatform.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
bbp_ng/icons/floor/SinkTConnector.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
bbp_ng/icons/floor/StoneTrafo.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
bbp_ng/icons/floor/WideCrossroad.png
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
bbp_ng/icons/floor/WideFloor.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
bbp_ng/icons/floor/WideFloorTerminal.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
bbp_ng/icons/floor/WideLConnector.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
bbp_ng/icons/floor/WideTConnector.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
bbp_ng/icons/floor/WoodTrafo.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
bbp_ng/icons/group/SoundID_01.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
bbp_ng/icons/group/SoundID_02.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
bbp_ng/icons/group/SoundID_03.png
Normal file
After Width: | Height: | Size: 251 B |