[fix] fix various bugs

- update README to keep update with plugin design
    * refactor Select by Virtools Group section
    * add material preset function description
- fix issue about flatten uv may get zero base vector.
- update elements adder menu.
- bump up version to 3.1
This commit is contained in:
yyc12345 2023-01-31 10:47:47 +08:00
parent e153e51abd
commit 0be036fcea
6 changed files with 90 additions and 42 deletions

View File

@ -109,26 +109,22 @@ Navigate to `Material Properties` panel, select a material, you can find `Virtoo
In default, user created material will not enable Virtools Material feature. You need to click checkbox of `Virtools Material` panel to enable or disable it.
After enable Virtools Material, `Basic Parameters` section and `Advanced Parameters` section can be set. Set your material peroperties just like operating in Virtools.
Just like its name, `Basic Parameters` is basic material properties. `Advanced Parameters` is mainly related to transparent properties and usually used in the bottom of transparent column.
Just like its name, `Basic Parameters` is basic material properties. `Advanced Parameters` is mainly related to transparent properties and usually used in the bottom of transparent column.
Additionally, `Basic Parameters` section provide a preset function, allowing user to use some preset material settings, which only affect 4 basic colors, just for convenient using.
In `Operation` section, `Apply Virtools Material` will clean all existed Blender material and create a new material graph according to Virtools material properties.
And, `Parse from Blender Principled BSDF` will try parsing a Principled BSDF to Virtools material.
If your material highly rely on Blender material, please execute `Parse from Blender Principled BSDF` or disable Virtools Material feature before exporting BM file, otherwise material can not be saved correctly.
### Select by Group
### Select by Virtools Group
Plugin add 2 selection functions according to Virtools Group in Select menu.
Plugin add a selection function according to Virtools Group in Select menu.
#### Select by Virtools Group
This function firstly have 5 different selection strategies which is exactly matched with Blender selection method. Just use it like Blender selection (Set, Extend, Subtract, Invert, Intersect).
Then, select your group name to start a selection.
Select objects in active collection according to its Virtools Group properties.
The hidden object also can be selected if you check `Ignore Hide Property`.
Check `Merge Selection` will merge current selection and previous selection.
#### Filter by Virtools Group
Filter current selected object by its Virtools Group properties.
Check `Reverse` remove objects matching the requirements, not keep them.
If you can, using Subtract or Intersect modes would be better than other modes. Because these modes avoid analyzing too many objects.
For example, first, select a rough range, and then use the Intersect mode to filter objects, which is more efficient than directly using the Start mode to select.
### Quick Grouping

View File

@ -109,7 +109,8 @@ Ballance 3D是一套简单的用于制图3D相关的轻型工具集合可以
默认情况下由用户创建的材质不启用Virtools Material您可以通过点击`Virtools Material`面板的复选框来启用或关闭它。
在启用Virtools Material后可以在`Basic Parameters`和`Advanced Parameters`中设置材质属性就像在Virtools中操作一般。
`Basic Parameters`是基础材质属性。`Advanced Parameters`则是与透明相关的材质属性,主要用于半透明柱子底部等。
`Basic Parameters`是基础材质属性。`Advanced Parameters`则是与透明相关的材质属性,主要用于半透明柱子底部等。
另外,`Basic Parameters`部分提供了预设功能允许用户使用一些预设的材质设置这些设置只影响4种基本颜色方便使用。
`Operation`中的`Apply Virtools Material`将把Virtools Material应用到Blender材质上。
而`Parse from Blender Principled BSDF`将尝试将一个原理化BSDF转换为Virtools材质数据。
@ -117,21 +118,13 @@ Ballance 3D是一套简单的用于制图3D相关的轻型工具集合可以
### 按组选择
选择菜单中新增了项按照Virtools归组数据进行筛选的功能。
选择菜单中新增了项按照Virtools归组数据进行筛选的功能。
#### Select by Virtools Group
该功能首先有5种不同的选择策略与Blender的选择方法完全匹配开始、扩选、相减、反转、相交。只需像Blender选择那样使用它。
然后,选择你需要的组的名称,然后开始一次选择或筛选。
将对当前活动集合内的物体按照其Virtools Group属性进行选择。
勾选`Ignore Hide Property`后,即使是隐藏的物体,也会被筛选。
勾选`Merge Selection`,将会把选中的物体合并到当前选定的内容中。
#### Filter by Virtools Group
将会按照Virtools Group属性过滤当前选中物体。
勾选`Reverse`将会反向操作,即去除掉符合条件的物体。
如果可以,请尽可能使用`Filter by Virtools Group`而不是`Select by Virtools Group`。因为这样可以避免分析过多的物体。
例如先选定一个大致的范围,然后使用`Filter by Virtools Group`过滤,比直接使用`Select by Virtools Group`效率更高。
如果可以,请尽可能使用相减或相交模式。因为这样可以避免分析过多的物体。
例如先选定一个大致的范围,然后使用相交模式过滤,比直接使用开始模式效率更高。
### 快速归组

View File

@ -74,13 +74,26 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
if not face.select:
continue
# check whether ref edge is legal
allPoint = len(face.loops)
if allPoint <= reference_edge:
no_processed_count+=1
continue
# get correct new corrdinate system
# yyc mark:
# we use 3 points located in this face to calc
# the base of this local uv corredinate system.
# however if this 3 points are set in a line,
# this method will cause a error, zero vector error.
#
# if z axis is zero vector, we will try using face normal instead
# to try getting correct data.
#
# zero base is not important. because it will not raise any math exceptio
# just a weird uv. user will notice this problem.
# get point
p1Relative = reference_edge
p2Relative = reference_edge + 1
p3Relative = reference_edge + 2
@ -93,13 +106,19 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
p2=mathutils.Vector(tuple(face.loops[p2Relative].vert.co[x] for x in range(3)))
p3=mathutils.Vector(tuple(face.loops[p3Relative].vert.co[x] for x in range(3)))
# get y axis
new_y_axis = p2 - p1
new_y_axis.normalize()
vec1 = p3 - p2
vec1.normalize()
# get z axis
new_z_axis = new_y_axis.cross(vec1)
new_z_axis.normalize()
if not any(round(v, 7) for v in new_z_axis):
new_z_axis = face.normal.normalized()
# get x axis
new_x_axis = new_y_axis.cross(new_z_axis)
new_x_axis.normalize()
@ -109,14 +128,14 @@ def _real_flatten_uv(mesh, reference_edge, scale_correction):
(0, 1.0, 0),
(0, 0, 1.0)
))
origin_base.invert()
origin_base.invert_safe()
new_base = mathutils.Matrix((
(new_x_axis.x, new_y_axis.x, new_z_axis.x),
(new_x_axis.y, new_y_axis.y, new_z_axis.y),
(new_x_axis.z, new_y_axis.z, new_z_axis.z)
))
transition_matrix = origin_base @ new_base
transition_matrix.invert()
transition_matrix.invert_safe()
# process each face
for loop_index in range(allPoint):

View File

@ -71,6 +71,13 @@ class BALLANCE_OT_add_components(common_add_component_props):
layout.prop(self, "elements_type")
self.parent_draw(layout, self.elements_type)
@classmethod
def draw_blc_menu(self, layout):
for item in UTILS_constants.bmfile_componentList:
cop = layout.operator(
self.bl_idname, text=item,
icon_value = UTILS_icons_manager.get_element_icon(item))
cop.elements_type = item
class BALLANCE_OT_add_components_dup(common_add_component_props):
@ -79,6 +86,10 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
bl_label = "Add Duplicated Elements"
bl_options = {'UNDO'}
can_duplicated_elements = (
'P_Extra_Point', 'P_Modul_18', 'P_Modul_26'
)
elements_type: bpy.props.EnumProperty(
name="Type",
description="This element type",
@ -86,9 +97,7 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
items=tuple(
# token, display name, descriptions, icon, index
(blk, blk, "", UTILS_icons_manager.get_element_icon(blk), idx)
for idx, blk in enumerate(
('P_Extra_Point', 'P_Modul_18', 'P_Modul_26')
)
for idx, blk in enumerate(can_duplicated_elements)
),
)
@ -125,6 +134,13 @@ class BALLANCE_OT_add_components_dup(common_add_component_props):
self.parent_draw(layout, self.elements_type)
layout.prop(self, "elements_dup_times")
@classmethod
def draw_blc_menu(self, layout):
for item in self.can_duplicated_elements:
cop = layout.operator(
self.bl_idname, text=item,
icon_value = UTILS_icons_manager.get_element_icon(item))
cop.elements_type = item
class BALLANCE_OT_add_components_series(common_add_component_props):
@ -208,3 +224,11 @@ class BALLANCE_OT_add_components_series(common_add_component_props):
self.parent_draw(layout, self.elements_type)
layout.prop(self, "elements_dup_times")
layout.prop(self, "elements_span")
@classmethod
def draw_blc_menu(self, layout):
for key, item in self.supported_series.items():
cop = layout.operator(
self.bl_idname, text=item[0],
icon_value = UTILS_icons_manager.get_element_icon(item[1]))
cop.elements_type = key

View File

@ -155,6 +155,9 @@ class BALLANCE_OT_add_floors(bpy.types.Operator):
# now I migrate default side value setter to updator of enum property.
# nothing need to process in here now.
# trigger default side props updator
self.floor_type_updated(context)
return self.execute(context)

View File

@ -119,24 +119,37 @@ class BALLANCE_MT_AddRailMenu(bpy.types.Menu):
layout.operator(OBJS_add_rails.BALLANCE_OT_add_rails.bl_idname, text="Rail Section")
layout.operator(OBJS_add_rails.BALLANCE_OT_add_tunnels.bl_idname, text="Tunnel Section")
class BALLANCE_MT_AddNormalElementsMenu(bpy.types.Menu):
"""Add Ballance Elements"""
bl_idname = "BALLANCE_MT_AddNormalElementsMenu"
bl_label = "Elements"
def draw(self, context):
layout = self.layout
OBJS_add_components.BALLANCE_OT_add_components.draw_blc_menu(layout)
class BALLANCE_MT_AddDupElementsMenu(bpy.types.Menu):
"""Add Ballance Elements"""
bl_idname = "BALLANCE_MT_AddDupElementsMenu"
bl_label = "Elements"
def draw(self, context):
layout = self.layout
OBJS_add_components.BALLANCE_OT_add_components_dup.draw_blc_menu(layout)
class BALLANCE_MT_AddElementsMenu(bpy.types.Menu):
"""Add Ballance Elements"""
bl_idname = "BALLANCE_MT_AddElementsMenu"
bl_label = "Elements"
def draw(self, context):
layout = self.layout
layout.label(text="Basic Elements")
for item in UTILS_constants.bmfile_componentList:
cop = layout.operator(
OBJS_add_components.BALLANCE_OT_add_components.bl_idname,
text=item, icon_value = UTILS_icons_manager.get_element_icon(item))
cop.elements_type = item
layout.label(text="Special Elements")
layout.operator(OBJS_add_components.BALLANCE_OT_add_components_dup.bl_idname, text="Dup Elements")
layout.operator(OBJS_add_components.BALLANCE_OT_add_components_series.bl_idname, text="Elements Series")
OBJS_add_components.BALLANCE_OT_add_components.draw_blc_menu(layout)
layout.separator()
layout.label(text="Duplicated Elements")
OBJS_add_components.BALLANCE_OT_add_components_dup.draw_blc_menu(layout)
layout.separator()
layout.label(text="Elements Series")
OBJS_add_components.BALLANCE_OT_add_components_series.draw_blc_menu(layout)
# =============================================
# blender call system