21 Commits

Author SHA1 Message Date
b1199f6a21 doc: translate documentation 2024-07-27 11:44:35 +08:00
47a8d81ecd doc: translate documentation 2024-07-26 09:46:16 +08:00
24ac07a3b3 doc: translate documentation 2024-07-25 10:37:16 +08:00
b647d7256f doc: translate documentation 2024-07-24 13:49:13 +08:00
421f01b3db doc: translate documentation 2024-07-23 11:01:41 +08:00
f215d3487f doc: translate documentation 2024-07-22 16:40:52 +08:00
1661f82a07 doc: update english documentation 2024-07-21 14:42:02 +08:00
512e7e868b doc: add english documentation.
- add english documentation for install-plugin and tech-info chapters.
- modify gitignore because we do not need redist folder any more.
2024-07-20 10:26:50 +08:00
427bad4f6b fix: fix various trivial issues
- update blender_manifest.toml to the latest version and fix the issues raised by blender when packaging.
- use blender do packaging work. remove redist.py because blender_manifest.toml has gitignore like filter feature when packaging.
- update document about installing, configurating, building plugin for blender 4.2.
- update a document image for blender 4.2.
2024-07-19 15:25:38 +08:00
209d212287 fix: fix blender mesh writer issue.
- fix blender mesh writer with the reference of FBX Importer.
- ballance map importer now may works as expected (still need more review).
2024-07-18 20:23:21 +08:00
2271b0a621 fix: remove bl_info.
- remove bl_info in __init__.py because blender_manifest.toml has replace it.
2024-07-17 21:20:40 +08:00
6940428b88 fix: fix blender 4.2 mesh issue.
- fix issue that blender 4.2 lost use_auto_smooth and calc_split_normals. (it almost works but not perfect. still need more debugging)
- remove depracted material blend_mode. use modern one instead. (the modern setting make me consufes but it works)
2024-07-17 19:45:35 +08:00
aa602a7bb8 fix: update to blender 4.2 LTS
- update to Blender 4.2 LTS
- fix issue that can not find specular property in priniciple BSDF when applying virtools material.
- update blender manifest toml to let plugin works.
- there are various mesh works need to be fixed in later commits. this commit can not works normally on blender 4.2
2024-07-17 09:23:16 +08:00
8588f097a2 fix: change default screw steps to 28.
- change default screw steps to 28 (7 steps for 90 degree)
- update blender mesh annotation.
2024-05-25 20:32:30 +08:00
5d8ffb7e48 feat: add redist script
- add redist script for the convenience of building plugin package, especially for Blender 4.2
2024-05-21 16:19:13 +08:00
270fddff52 feat: do some trivial adaptions for blender 4.2 LTS
- add blender_manifest.toml
- add a removal note for bl_info in __init__.py.
- it doesn't mean that this plugin now can be used in blender 4.2. I just add some trivial changes which do not break current compatibility to reduce migration work in future.
2024-05-17 09:15:12 +08:00
084e7fbe61 feat: add extra transform for rail creation
- add extra transform for rail creation.
- remove scale from extra transform because it is rarely used. because Ballance can not handle the physicalization of scaled object.
2024-05-13 13:39:42 +08:00
190be6ec61 fix: restore extra transform to identy when entering bme operator. 2024-05-10 15:33:28 +08:00
36e925101e feat: extra transform properties for bme creation.
- add extra transform properties (translation, rotation and scale) for bme creation operator. this is good for "what you seen is what you gotten" and can increase user experience when add bme protorypes. please note these extra transform is applied to object after moving to cursor, not the mesh self.
- fix a weired bug that bme creation execute() may get outdated configurations when switch bme type in pop up window. the solution is simply adding an extra outdated flag checker at the head of execute(). but i have no spare time to research whether this patch is correct for this bug.
2024-05-10 14:44:37 +08:00
84e7e8380f feat: hide some operators in edit mode and add some notify for grouping oper.
- now grouping, ungrouping clear groups operators will show a report at the bottom of blender to indicate their work have done.
- disable fix material, 3ds max align, select by virtools group operators in edit mode to prevent any possible undefined behavior.
2024-04-22 21:06:41 +08:00
c58af8ce48 fix: fix face generation error of BME streets prototype. 2024-04-22 21:06:35 +08:00
43 changed files with 954 additions and 145 deletions

View File

@ -1,4 +1,4 @@
import bpy import bpy, mathutils
import typing import typing
from . import PROP_preferences from . import PROP_preferences
from . import UTIL_functions, UTIL_bme from . import UTIL_functions, UTIL_bme
@ -43,7 +43,7 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
# So these is the solution about generating cache list according to the change of bme struct type. # So these is the solution about generating cache list according to the change of bme struct type.
# First, update function will only set a "outdated" flag for operator which is a pre-registered Blender property. # First, update function will only set a "outdated" flag for operator which is a pre-registered Blender property.
# The "outdated" flags is not showen and not saved. # The "outdated" flags is not showen and not saved.
# Then call a internal cache list update function at the begin of `invoke` and `draw`. # Then call a internal cache list update function at the begin of `invoke`, `execute` and `draw`.
# In this internal cache list updator, check "outdated" flag first, if cache is outdated, update and reset flag. # In this internal cache list updator, check "outdated" flag first, if cache is outdated, update and reset flag.
# Otherwise do nothing. # Otherwise do nothing.
# #
@ -141,11 +141,34 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
type = BBP_PG_bme_adder_cfgs, type = BBP_PG_bme_adder_cfgs,
) # type: ignore ) # type: ignore
## Extra transform for good "what you see is what you gotten".
# Extra transform will be added after moving this object to cursor.
extra_translation: bpy.props.FloatVectorProperty(
name = "Extra Translation",
description = "The extra translation applied to object after moving to cursor.",
size = 3,
subtype = 'TRANSLATION',
step = 50, # same step as the float entry of BBP_PG_bme_adder_cfgs
default = (0.0, 0.0, 0.0)
) # type: ignore
extra_rotation: bpy.props.FloatVectorProperty(
name = "Extra Rotation",
description = "The extra rotation applied to object after moving to cursor.",
size = 3,
subtype = 'EULER',
step = 100, # We choosen 100, mean 1. Sync with property window.
default = (0.0, 0.0, 0.0)
) # type: ignore
@classmethod @classmethod
def poll(self, context): def poll(cls, context):
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder() return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder()
def invoke(self, context, event): def invoke(self, context, event):
# reset extra transform to identy
self.extra_translation = (0.0, 0.0, 0.0)
self.extra_rotation = (0.0, 0.0, 0.0)
self.extra_scale = (1.0, 1.0, 1.0)
# create internal list # create internal list
self.bme_struct_cfg_index_cache = [] self.bme_struct_cfg_index_cache = []
# trigger default bme struct type updator # trigger default bme struct type updator
@ -156,6 +179,9 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
return self.execute(context) return self.execute(context)
def execute(self, context): def execute(self, context):
# call internal updator
self.__internal_update_bme_struct_type()
# collect cfgs data # collect cfgs data
cfgs: dict[str, typing.Any] = {} cfgs: dict[str, typing.Any] = {}
for (cfg, cfg_index) in self.bme_struct_cfg_index_cache: for (cfg, cfg_index) in self.bme_struct_cfg_index_cache:
@ -178,8 +204,14 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
cfgs cfgs
) )
# move to cursor # add into scene and move to cursor
UTIL_functions.add_into_scene_and_move_to_cursor(obj) UTIL_functions.add_into_scene_and_move_to_cursor(obj)
# add extra transform
obj.matrix_world = obj.matrix_world @ mathutils.Matrix.LocRotScale(
mathutils.Vector(self.extra_translation),
mathutils.Euler(self.extra_rotation, 'XYZ'),
mathutils.Vector((1.0, 1.0, 1.0)) # no scale
)
# select created object # select created object
UTIL_functions.select_certain_objects((obj, )) UTIL_functions.select_certain_objects((obj, ))
return {'FINISHED'} return {'FINISHED'}
@ -194,6 +226,7 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
layout.prop(self, 'bme_struct_type') layout.prop(self, 'bme_struct_type')
# visit cfgs cache list to show cfg # visit cfgs cache list to show cfg
layout.label(text = "Prototype Configurations:")
for (cfg, cfg_index) in self.bme_struct_cfg_index_cache: for (cfg, cfg_index) in self.bme_struct_cfg_index_cache:
# create box for cfgs # create box for cfgs
box_layout: bpy.types.UILayout = layout.box() box_layout: bpy.types.UILayout = layout.box()
@ -225,12 +258,24 @@ class BBP_OT_add_bme_struct(bpy.types.Operator):
grids.prop(self.bme_struct_cfgs[cfg_index + 1], 'prop_bool', text = 'Bottom') # bottom grids.prop(self.bme_struct_cfgs[cfg_index + 1], 'prop_bool', text = 'Bottom') # bottom
grids.separator() grids.separator()
# show extra transform props
# forcely order that each one are placed horizontally
layout.label(text = "Extra Transform:")
# translation
layout.label(text = 'Translation')
hbox_layout: bpy.types.UILayout = layout.row()
hbox_layout.prop(self, 'extra_translation', text = '')
# rotation
layout.label(text = 'Rotation')
hbox_layout = layout.row()
hbox_layout.prop(self, 'extra_rotation', text = '')
@classmethod @classmethod
def draw_blc_menu(self, layout: bpy.types.UILayout): def draw_blc_menu(cls, layout: bpy.types.UILayout):
for ident in _g_EnumHelper_BmeStructType.get_bme_identifiers(): for ident in _g_EnumHelper_BmeStructType.get_bme_identifiers():
# draw operator # draw operator
cop = layout.operator( cop = layout.operator(
self.bl_idname, cls.bl_idname,
text = _g_EnumHelper_BmeStructType.get_bme_showcase_title(ident), text = _g_EnumHelper_BmeStructType.get_bme_showcase_title(ident),
icon_value = _g_EnumHelper_BmeStructType.get_bme_showcase_icon(ident) icon_value = _g_EnumHelper_BmeStructType.get_bme_showcase_icon(ident)
) )

View File

@ -33,6 +33,50 @@ c_SideSpiralRailScrew: float = 3.6
#region Operator Helpers #region Operator Helpers
class SharedExtraTransform():
"""
This class is served for all rail creation which allow user
provide extra transform after moving created rail to cursor.
For "what you look is what you gotten" experience, this extra transform is essential.
"""
extra_translation: bpy.props.FloatVectorProperty(
name = "Extra Translation",
description = "The extra translation applied to object after moving to cursor.",
size = 3,
subtype = 'TRANSLATION',
step = 50, # same step as the float entry of BBP_PG_bme_adder_cfgs
default = (0.0, 0.0, 0.0)
) # type: ignore
extra_rotation: bpy.props.FloatVectorProperty(
name = "Extra Rotation",
description = "The extra rotation applied to object after moving to cursor.",
size = 3,
subtype = 'EULER',
step = 100, # We choosen 100, mean 1. Sync with property window.
default = (0.0, 0.0, 0.0)
) # type: ignore
def draw_extra_transform_input(self, layout: bpy.types.UILayout) -> None:
# show extra transform props
# forcely order that each one are placed horizontally
layout.label(text = "Extra Transform:")
# translation
layout.label(text = 'Translation')
row = layout.row()
row.prop(self, 'extra_translation', text = '')
# rotation
layout.label(text = 'Rotation')
row = layout.row()
row.prop(self, 'extra_rotation', text = '')
def general_get_extra_transform(self) -> mathutils.Matrix:
return mathutils.Matrix.LocRotScale(
mathutils.Vector(self.extra_translation),
mathutils.Euler(self.extra_rotation, 'XYZ'),
mathutils.Vector((1.0, 1.0, 1.0)) # no scale
)
class SharedRailSectionInputProperty(): class SharedRailSectionInputProperty():
""" """
This class is served for user to pick the transition type of rail. This class is served for user to pick the transition type of rail.
@ -112,7 +156,7 @@ class SharedScrewRailInputProperty():
rail_screw_steps: bpy.props.IntProperty( rail_screw_steps: bpy.props.IntProperty(
name = "Steps", name = "Steps",
description = "The segment count per iteration. More segment, more smooth but lower performance.", description = "The segment count per iteration. More segment, more smooth but lower performance.",
default = 16, default = 28,
min = 1, min = 1,
) # type: ignore ) # type: ignore
@ -147,7 +191,8 @@ class BBP_OT_add_rail_section(SharedRailSectionInputProperty, bpy.types.Operator
lambda bm: _create_rail_section( lambda bm: _create_rail_section(
bm, self.general_get_is_monorail(), bm, self.general_get_is_monorail(),
c_DefaultRailRadius, c_DefaultRailSpan c_DefaultRailRadius, c_DefaultRailSpan
) ),
mathutils.Matrix.Identity(4)
) )
return {'FINISHED'} return {'FINISHED'}
@ -163,7 +208,8 @@ class BBP_OT_add_transition_section(bpy.types.Operator):
def execute(self, context): def execute(self, context):
_rail_creator_wrapper( _rail_creator_wrapper(
lambda bm: _create_transition_section(bm, c_DefaultRailRadius, c_DefaultRailSpan) lambda bm: _create_transition_section(bm, c_DefaultRailRadius, c_DefaultRailSpan),
mathutils.Matrix.Identity(4)
) )
return {'FINISHED'} return {'FINISHED'}
@ -171,7 +217,7 @@ class BBP_OT_add_transition_section(bpy.types.Operator):
layout = self.layout layout = self.layout
layout.label(text = 'No Options Available') layout.label(text = 'No Options Available')
class BBP_OT_add_straight_rail(SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator): class BBP_OT_add_straight_rail(SharedExtraTransform, SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator):
"""Add Straight Rail""" """Add Straight Rail"""
bl_idname = "bbp.add_straight_rail" bl_idname = "bbp.add_straight_rail"
bl_label = "Straight Rail" bl_label = "Straight Rail"
@ -184,7 +230,8 @@ class BBP_OT_add_straight_rail(SharedRailSectionInputProperty, SharedRailCapInpu
self.general_get_is_monorail(), c_DefaultRailRadius, c_DefaultRailSpan, self.general_get_is_monorail(), c_DefaultRailRadius, c_DefaultRailSpan,
self.general_get_rail_length(), 0, self.general_get_rail_length(), 0,
self.general_get_rail_start_cap(), self.general_get_rail_end_cap() self.general_get_rail_start_cap(), self.general_get_rail_end_cap()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -196,8 +243,10 @@ class BBP_OT_add_straight_rail(SharedRailSectionInputProperty, SharedRailCapInpu
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
class BBP_OT_add_transition_rail(SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator): class BBP_OT_add_transition_rail(SharedExtraTransform, SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator):
"""Add Transition Rail""" """Add Transition Rail"""
bl_idname = "bbp.add_transition_rail" bl_idname = "bbp.add_transition_rail"
bl_label = "Transition Rail" bl_label = "Transition Rail"
@ -210,7 +259,8 @@ class BBP_OT_add_transition_rail(SharedRailCapInputProperty, SharedStraightRailI
c_DefaultRailRadius, c_DefaultRailSpan, c_DefaultRailRadius, c_DefaultRailSpan,
self.general_get_rail_length(), self.general_get_rail_length(),
self.general_get_rail_start_cap(), self.general_get_rail_end_cap() self.general_get_rail_start_cap(), self.general_get_rail_end_cap()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -221,8 +271,10 @@ class BBP_OT_add_transition_rail(SharedRailCapInputProperty, SharedStraightRailI
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
class BBP_OT_add_side_rail(SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator): class BBP_OT_add_side_rail(SharedExtraTransform, SharedRailCapInputProperty, SharedStraightRailInputProperty, bpy.types.Operator):
"""Add Side Rail""" """Add Side Rail"""
bl_idname = "bbp.add_side_rail" bl_idname = "bbp.add_side_rail"
bl_label = "Side Rail" bl_label = "Side Rail"
@ -246,7 +298,8 @@ class BBP_OT_add_side_rail(SharedRailCapInputProperty, SharedStraightRailInputPr
self.general_get_rail_length(), self.general_get_rail_length(),
c_NormalSideRailAngle if self.side_rail_type == 'NORMAL' else c_StoneSideRailAngle, c_NormalSideRailAngle if self.side_rail_type == 'NORMAL' else c_StoneSideRailAngle,
self.general_get_rail_start_cap(), self.general_get_rail_end_cap() self.general_get_rail_start_cap(), self.general_get_rail_end_cap()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -258,8 +311,10 @@ class BBP_OT_add_side_rail(SharedRailCapInputProperty, SharedStraightRailInputPr
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
class BBP_OT_add_arc_rail(SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator): class BBP_OT_add_arc_rail(SharedExtraTransform, SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator):
"""Add Arc Rail""" """Add Arc Rail"""
bl_idname = "bbp.add_arc_rail" bl_idname = "bbp.add_arc_rail"
bl_label = "Arc Rail" bl_label = "Arc Rail"
@ -281,7 +336,8 @@ class BBP_OT_add_arc_rail(SharedRailSectionInputProperty, SharedRailCapInputProp
self.general_get_rail_start_cap(), self.general_get_rail_end_cap(), self.general_get_rail_start_cap(), self.general_get_rail_end_cap(),
math.degrees(self.rail_screw_angle), 0, 1, # blender passed value is in radians math.degrees(self.rail_screw_angle), 0, 1, # blender passed value is in radians
self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius() self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -294,8 +350,10 @@ class BBP_OT_add_arc_rail(SharedRailSectionInputProperty, SharedRailCapInputProp
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
class BBP_OT_add_spiral_rail(SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator): class BBP_OT_add_spiral_rail(SharedExtraTransform, SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator):
"""Add Spiral Rail""" """Add Spiral Rail"""
bl_idname = "bbp.add_spiral_rail" bl_idname = "bbp.add_spiral_rail"
bl_label = "Spiral Rail" bl_label = "Spiral Rail"
@ -323,7 +381,8 @@ class BBP_OT_add_spiral_rail(SharedRailCapInputProperty, SharedScrewRailInputPro
self.general_get_rail_start_cap(), self.general_get_rail_end_cap(), self.general_get_rail_start_cap(), self.general_get_rail_end_cap(),
360, self.rail_screw_screw, self.rail_screw_iterations, 360, self.rail_screw_screw, self.rail_screw_iterations,
self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius() self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -336,8 +395,10 @@ class BBP_OT_add_spiral_rail(SharedRailCapInputProperty, SharedScrewRailInputPro
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
class BBP_OT_add_side_spiral_rail(SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator): class BBP_OT_add_side_spiral_rail(SharedExtraTransform, SharedRailSectionInputProperty, SharedRailCapInputProperty, SharedScrewRailInputProperty, bpy.types.Operator):
"""Add Side Spiral Rail""" """Add Side Spiral Rail"""
bl_idname = "bbp.add_side_spiral_rail" bl_idname = "bbp.add_side_spiral_rail"
bl_label = "Side Spiral Rail" bl_label = "Side Spiral Rail"
@ -360,7 +421,8 @@ class BBP_OT_add_side_spiral_rail(SharedRailSectionInputProperty, SharedRailCapI
self.general_get_rail_start_cap(), self.general_get_rail_end_cap(), self.general_get_rail_start_cap(), self.general_get_rail_end_cap(),
360, c_SideSpiralRailScrew, self.rail_screw_iterations, 360, c_SideSpiralRailScrew, self.rail_screw_iterations,
self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius() self.general_get_rail_screw_steps(), self.general_get_rail_screw_radius()
) ),
self.general_get_extra_transform()
) )
return {'FINISHED'} return {'FINISHED'}
@ -372,6 +434,8 @@ class BBP_OT_add_side_spiral_rail(SharedRailSectionInputProperty, SharedRailCapI
layout.separator() layout.separator()
layout.label(text = 'Rail Cap') layout.label(text = 'Rail Cap')
self.draw_rail_cap_input(layout) self.draw_rail_cap_input(layout)
layout.separator()
self.draw_extra_transform_input(layout)
#endregion #endregion
@ -460,7 +524,7 @@ def _bmesh_cap(bm: bmesh.types.BMesh, edges: list[bmesh.types.BMEdge]) -> None:
#region Real Rail Creators #region Real Rail Creators
def _rail_creator_wrapper(fct_poly_cret: typing.Callable[[bmesh.types.BMesh], None]) -> bpy.types.Object: def _rail_creator_wrapper(fct_poly_cret: typing.Callable[[bmesh.types.BMesh], None], extra_transform: mathutils.Matrix) -> bpy.types.Object:
# create mesh first # create mesh first
bm: bmesh.types.BMesh = bmesh.new() bm: bmesh.types.BMesh = bmesh.new()
@ -473,8 +537,6 @@ def _rail_creator_wrapper(fct_poly_cret: typing.Callable[[bmesh.types.BMesh], No
bm.free() bm.free()
# setup smooth for mesh # setup smooth for mesh
mesh.use_auto_smooth = True
mesh.auto_smooth_angle = math.radians(50)
mesh.shade_smooth() mesh.shade_smooth()
# create object and assoc with it # create object and assoc with it
@ -492,6 +554,8 @@ def _rail_creator_wrapper(fct_poly_cret: typing.Callable[[bmesh.types.BMesh], No
# move to cursor # move to cursor
UTIL_functions.add_into_scene_and_move_to_cursor(obj) UTIL_functions.add_into_scene_and_move_to_cursor(obj)
# add extra transform
obj.matrix_world = obj.matrix_world @ extra_transform
# select created object # select created object
UTIL_functions.select_certain_objects((obj, )) UTIL_functions.select_certain_objects((obj, ))

View File

@ -1,4 +1,5 @@
import bpy import bpy
from . import UTIL_functions
from . import PROP_virtools_material, PROP_preferences from . import PROP_virtools_material, PROP_preferences
class BBP_OT_fix_all_material(bpy.types.Operator): class BBP_OT_fix_all_material(bpy.types.Operator):
@ -9,7 +10,9 @@ class BBP_OT_fix_all_material(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder() # only enable this when plugin have a valid ballance texture folder
# and we are in object mode
return PROP_preferences.get_raw_preferences().has_valid_blc_tex_folder() and UTIL_functions.is_in_object_mode()
def invoke(self, context, event): def invoke(self, context, event):
wm = context.window_manager wm = context.window_manager

View File

@ -43,25 +43,25 @@ class BBP_PG_legacy_align_history(bpy.types.PropertyGroup):
align_x: bpy.props.BoolProperty( align_x: bpy.props.BoolProperty(
name = "X Position", name = "X Position",
default = False, default = False,
) ) # type: ignore
align_y: bpy.props.BoolProperty( align_y: bpy.props.BoolProperty(
name = "Y Position", name = "Y Position",
default = False, default = False,
) ) # type: ignore
align_z: bpy.props.BoolProperty( align_z: bpy.props.BoolProperty(
name = "Z Position", name = "Z Position",
default = False, default = False,
) ) # type: ignore
current_align_mode: bpy.props.EnumProperty( current_align_mode: bpy.props.EnumProperty(
name = "Current Object (Active Object)", name = "Current Object (Active Object)",
items = _g_EnumHelper_AlignMode.generate_items(), items = _g_EnumHelper_AlignMode.generate_items(),
default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter), default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter),
) ) # type: ignore
target_align_mode: bpy.props.EnumProperty( target_align_mode: bpy.props.EnumProperty(
name = "Target Objects (Other Objects)", name = "Target Objects (Other Objects)",
items = _g_EnumHelper_AlignMode.generate_items(), items = _g_EnumHelper_AlignMode.generate_items(),
default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter), default = _g_EnumHelper_AlignMode.to_selection(AlignMode.AxisCenter),
) ) # type: ignore
#endregion #endregion
@ -109,21 +109,21 @@ class BBP_OT_legacy_align(bpy.types.Operator):
options = {'HIDDEN', 'SKIP_SAVE'}, options = {'HIDDEN', 'SKIP_SAVE'},
default = True, # default True value to make it as a "light" button, not a grey one. default = True, # default True value to make it as a "light" button, not a grey one.
update = apply_flag_updated, update = apply_flag_updated,
) ) # type: ignore
recursive_hinder: bpy.props.BoolProperty( recursive_hinder: bpy.props.BoolProperty(
name = "Recursive Hinder", name = "Recursive Hinder",
description = "An internal flag to prevent the loop calling to apply_flags's updator.", description = "An internal flag to prevent the loop calling to apply_flags's updator.",
options = {'HIDDEN', 'SKIP_SAVE'}, options = {'HIDDEN', 'SKIP_SAVE'},
default = False, default = False,
) ) # type: ignore
align_history : bpy.props.CollectionProperty( align_history : bpy.props.CollectionProperty(
name = "Historys", name = "Historys",
description = "Align history.", description = "Align history.",
type = BBP_PG_legacy_align_history, type = BBP_PG_legacy_align_history,
) ) # type: ignore
@classmethod @classmethod
def poll(self, context): def poll(cls, context):
return _check_align_requirement() return _check_align_requirement()
def invoke(self, context, event): def invoke(self, context, event):
@ -180,10 +180,13 @@ class BBP_OT_legacy_align(bpy.types.Operator):
#region Core Functions #region Core Functions
def _check_align_requirement() -> bool: def _check_align_requirement() -> bool:
# if we are not in object mode, do not do legacy align
if not UTIL_functions.is_in_object_mode():
return False
# check current obj # check current obj
if bpy.context.active_object is None: if bpy.context.active_object is None:
return False return False
# check target obj with filter of current obj # check target obj with filter of current obj
length = len(bpy.context.selected_objects) length = len(bpy.context.selected_objects)
if bpy.context.active_object in bpy.context.selected_objects: if bpy.context.active_object in bpy.context.selected_objects:

View File

@ -38,7 +38,11 @@ class BBP_OT_select_object_by_virtools_group(bpy.types.Operator, PROP_virtools_g
description = "Selection mode", description = "Selection mode",
items = _g_EnumHelper_SelectMode.generate_items(), items = _g_EnumHelper_SelectMode.generate_items(),
default = _g_EnumHelper_SelectMode.to_selection(SelectMode.Intersect) default = _g_EnumHelper_SelectMode.to_selection(SelectMode.Intersect)
) ) # type: ignore
@classmethod
def poll(cls, context):
return UTIL_functions.is_in_object_mode()
def invoke(self, context, event): def invoke(self, context, event):
wm = context.window_manager wm = context.window_manager
@ -119,7 +123,7 @@ class BBP_OT_add_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.
bl_options = {'UNDO'} bl_options = {'UNDO'}
@classmethod @classmethod
def poll(self, context): def poll(cls, context):
return len(bpy.context.selected_objects) != 0 return len(bpy.context.selected_objects) != 0
def invoke(self, context, event): def invoke(self, context, event):
@ -131,6 +135,7 @@ class BBP_OT_add_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.
for obj in bpy.context.selected_objects: for obj in bpy.context.selected_objects:
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp: with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
gp.add_group(group_name) gp.add_group(group_name)
self.report({'INFO'}, "Grouping objects successfully.")
return {'FINISHED'} return {'FINISHED'}
def draw(self, context): def draw(self, context):
@ -143,7 +148,7 @@ class BBP_OT_rm_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.S
bl_options = {'UNDO'} bl_options = {'UNDO'}
@classmethod @classmethod
def poll(self, context): def poll(cls, context):
return len(bpy.context.selected_objects) != 0 return len(bpy.context.selected_objects) != 0
def invoke(self, context, event): def invoke(self, context, event):
@ -155,6 +160,7 @@ class BBP_OT_rm_objects_virtools_group(bpy.types.Operator, PROP_virtools_group.S
for obj in bpy.context.selected_objects: for obj in bpy.context.selected_objects:
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp: with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
gp.remove_group(group_name) gp.remove_group(group_name)
self.report({'INFO'}, "Ungrouping objects successfully.")
return {'FINISHED'} return {'FINISHED'}
def draw(self, context): def draw(self, context):
@ -167,7 +173,7 @@ class BBP_OT_clear_objects_virtools_group(bpy.types.Operator):
bl_options = {'UNDO'} bl_options = {'UNDO'}
@classmethod @classmethod
def poll(self, context): def poll(cls, context):
return len(bpy.context.selected_objects) != 0 return len(bpy.context.selected_objects) != 0
def invoke(self, context, event): def invoke(self, context, event):
@ -179,6 +185,7 @@ class BBP_OT_clear_objects_virtools_group(bpy.types.Operator):
for obj in bpy.context.selected_objects: for obj in bpy.context.selected_objects:
with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp: with PROP_virtools_group.VirtoolsGroupsHelper(obj) as gp:
gp.clear_groups() gp.clear_groups()
self.report({'INFO'}, "Clear objects groups successfully.")
return {'FINISHED'} return {'FINISHED'}
#endregion #endregion

View File

@ -397,13 +397,20 @@ def apply_to_blender_material(mtl: bpy.types.Material):
# bnode.inputs["Emission"].default_value = rawdata.mEmissive.to_const_rgba() # bnode.inputs["Emission"].default_value = rawdata.mEmissive.to_const_rgba()
mtl.specular_intensity = rawdata.mSpecularPower mtl.specular_intensity = rawdata.mSpecularPower
bnode.inputs["Specular"].default_value = UTIL_functions.clamp_float( bnode.inputs["Specular IOR Level"].default_value = UTIL_functions.clamp_float(
rawdata.mSpecularPower, 0.0, 1.0 rawdata.mSpecularPower, 0.0, 1.0
) )
# set some alpha data # set some alpha data
mtl.use_backface_culling = not rawdata.mEnableTwoSided mtl.use_backface_culling = not rawdata.mEnableTwoSided
mtl.blend_method = 'BLEND' if rawdata.mEnableAlphaBlend else 'OPAQUE' if rawdata.mEnableAlphaBlend:
# In old format: mtl.blend_method = 'BLEND'
mtl.surface_render_method = 'BLENDED'
mtl.use_raytrace_refraction = True
else:
# In old format: mtl.blend_method = 'OPAQUE'
mtl.surface_render_method = 'DITHERED'
mtl.use_raytrace_refraction = False
# set texture # set texture
if rawdata.mTexture is not None: if rawdata.mTexture is not None:

View File

@ -107,8 +107,8 @@ class TemporaryMesh():
""" """
__mBindingObject: bpy.types.Object | None __mBindingObject: bpy.types.Object
__mTempMesh: bpy.types.Mesh | None __mTempMesh: bpy.types.Mesh
def __init__(self, binding_obj: bpy.types.Object): def __init__(self, binding_obj: bpy.types.Object):
self.__mBindingObject = binding_obj self.__mBindingObject = binding_obj
@ -149,7 +149,7 @@ class MeshReader():
A helper class TemporaryMesh can help you do this. A helper class TemporaryMesh can help you do this.
""" """
__mAssocMesh: bpy.types.Mesh | None ##< The binding mesh for this reader. None if this reader is invalid. __mAssocMesh: bpy.types.Mesh ##< The binding mesh for this reader. None if this reader is invalid.
def __init__(self, assoc_mesh: bpy.types.Mesh): def __init__(self, assoc_mesh: bpy.types.Mesh):
self.__mAssocMesh = assoc_mesh self.__mAssocMesh = assoc_mesh
@ -157,7 +157,6 @@ class MeshReader():
# triangulate temp mesh # triangulate temp mesh
if self.is_valid(): if self.is_valid():
self.__triangulate_mesh() self.__triangulate_mesh()
self.__mAssocMesh.calc_normals_split()
def is_valid(self) -> bool: def is_valid(self) -> bool:
return self.__mAssocMesh is not None return self.__mAssocMesh is not None
@ -171,7 +170,6 @@ class MeshReader():
def dispose(self) -> None: def dispose(self) -> None:
if self.is_valid(): if self.is_valid():
# reset mesh # reset mesh
self.__mAssocMesh.free_normals_split()
self.__mAssocMesh = None self.__mAssocMesh = None
def get_vertex_position_count(self) -> int: def get_vertex_position_count(self) -> int:
@ -203,10 +201,10 @@ class MeshReader():
raise UTIL_functions.BBPException('try to call an invalid MeshReader.') raise UTIL_functions.BBPException('try to call an invalid MeshReader.')
cache: UTIL_virtools_types.VxVector3 = UTIL_virtools_types.VxVector3() cache: UTIL_virtools_types.VxVector3 = UTIL_virtools_types.VxVector3()
for nml in self.__mAssocMesh.loops: for nml in self.__mAssocMesh.corner_normals:
cache.x = nml.normal.x cache.x = nml.vector.x
cache.y = nml.normal.y cache.y = nml.vector.y
cache.z = nml.normal.z cache.z = nml.vector.z
yield cache yield cache
def get_vertex_uv_count(self) -> int: def get_vertex_uv_count(self) -> int:
@ -318,7 +316,7 @@ class MeshWriter():
then refer it to all face uv. then refer it to all face uv.
""" """
__mAssocMesh: bpy.types.Mesh | None ##< The binding mesh for this writer. None if this writer is invalid. __mAssocMesh: bpy.types.Mesh ##< The binding mesh for this writer. None if this writer is invalid.
__mVertexPos: array.array ##< Array item is float(f). Length must be an integer multiple of 3. __mVertexPos: array.array ##< Array item is float(f). Length must be an integer multiple of 3.
__mVertexNormal: array.array ##< Array item is float(f). Length must be an integer multiple of 3. __mVertexNormal: array.array ##< Array item is float(f). Length must be an integer multiple of 3.
@ -348,6 +346,9 @@ class MeshWriter():
# Value is key's index in __mMtlSlot. # Value is key's index in __mMtlSlot.
__mMtlSlotMap: dict[bpy.types.Material | None, int] __mMtlSlotMap: dict[bpy.types.Material | None, int]
## The attribute name storing temporary normals data inside mesh.
__cTempNormalAttrName: typing.ClassVar[str] = 'temp_custom_normals'
def __init__(self, assoc_mesh: bpy.types.Mesh): def __init__(self, assoc_mesh: bpy.types.Mesh):
self.__mAssocMesh = assoc_mesh self.__mAssocMesh = assoc_mesh
@ -446,15 +447,19 @@ class MeshWriter():
self.__mAssocMesh.polygons.add(len(self.__mFaceVertexCount)) self.__mAssocMesh.polygons.add(len(self.__mFaceVertexCount))
# create uv layer # create uv layer
self.__mAssocMesh.uv_layers.new(do_init = False) self.__mAssocMesh.uv_layers.new(do_init = False)
# split normals, it is IMPORTANT
self.__mAssocMesh.create_normals_split()
# add vertex position data # add vertex position data
self.__mAssocMesh.vertices.foreach_set('co', self.__mVertexPos) self.__mAssocMesh.vertices.foreach_set('co', self.__mVertexPos)
# add face vertex pos index data # add face vertex pos index data
self.__mAssocMesh.loops.foreach_set('vertex_index', self.__mFacePosIndices) self.__mAssocMesh.loops.foreach_set('vertex_index', self.__mFacePosIndices)
# add face vertex nml by function # add face vertex nml by function via mesh custom attribute
self.__mAssocMesh.loops.foreach_set('normal', # NOTE: Blender 4.0 / 4.1 changed. I copy these code from FBX Importer.
temp_normal_attribute: bpy.types.FloatVectorAttribute
temp_normal_attribute = typing.cast(
bpy.types.FloatVectorAttribute,
self.__mAssocMesh.attributes.new(MeshWriter.__cTempNormalAttrName, 'FLOAT_VECTOR', 'CORNER')
)
temp_normal_attribute.data.foreach_set('vector',
tuple(_flat_face_nml_index(self.__mFaceNmlIndices, self.__mVertexNormal)) tuple(_flat_face_nml_index(self.__mFaceNmlIndices, self.__mVertexNormal))
) )
# add face vertex uv by function # add face vertex uv by function
@ -494,14 +499,22 @@ class MeshWriter():
# this should not happend in normal case, for testing, please load "Level_1.NMO" (Ballance Level 1). # this should not happend in normal case, for testing, please load "Level_1.NMO" (Ballance Level 1).
# copy data from loops preserved in validate(). # copy data from loops preserved in validate().
# NOTE: Blender 4.0 / 4.1 changed. I copy these code from FBX Importer.
loops_normals = array.array('f', [0.0] * (len(self.__mAssocMesh.loops) * 3)) loops_normals = array.array('f', [0.0] * (len(self.__mAssocMesh.loops) * 3))
self.__mAssocMesh.loops.foreach_get('normal', loops_normals) temp_normal_attribute = typing.cast(
bpy.types.FloatVectorAttribute,
self.__mAssocMesh.attributes[MeshWriter.__cTempNormalAttrName]
)
temp_normal_attribute.data.foreach_get("vector", loops_normals)
# apply data # apply data
self.__mAssocMesh.normals_split_custom_set( self.__mAssocMesh.normals_split_custom_set(
tuple(_nest_custom_split_normal(loops_normals)) tuple(_nest_custom_split_normal(loops_normals))
) )
# enable auto smooth. it is IMPORTANT self.__mAssocMesh.attributes.remove(
self.__mAssocMesh.use_auto_smooth = True # MARK: idk why I need fucking get this attribute again.
# But if I were not, this function must raise bullshit exception!
self.__mAssocMesh.attributes[MeshWriter.__cTempNormalAttrName]
)
def __clear_mesh(self): def __clear_mesh(self):
if not self.is_valid(): if not self.is_valid():

View File

@ -80,6 +80,16 @@ def select_certain_objects(objs: tuple[bpy.types.Object, ...]) -> None:
# select first object as active object # select first object as active object
bpy.context.view_layer.objects.active = objs[0] bpy.context.view_layer.objects.active = objs[0]
def is_in_object_mode() -> bool:
# get active object from context
obj = bpy.context.active_object
# if there is no active object, we think it is in object mode
if obj is None: return True
# simply check active object mode
return obj.mode == 'OBJECT'
class EnumPropHelper(): class EnumPropHelper():
""" """
These class contain all functions related to EnumProperty, including generating `items`, These class contain all functions related to EnumProperty, including generating `items`,

View File

@ -1,16 +1,3 @@
bl_info = {
"name": "Ballance Blender Plugin",
"description": "Ballance mapping tools for Blender",
"author": "yyc12345",
"version": (4, 0),
"blender": (3, 6, 0),
"category": "Object",
"support": "COMMUNITY",
"warning": "Please read document before using this plugin.",
"doc_url": "https://github.com/yyc12345/BallanceBlenderHelper",
"tracker_url": "https://github.com/yyc12345/BallanceBlenderHelper/issues"
}
#region Reload and Import #region Reload and Import
# import core lib # import core lib

View File

@ -0,0 +1,81 @@
# Full context are copied from https://docs.blender.org/manual/en/dev/extensions/getting_started.html
# Please note any update of this manifest
schema_version = "1.0.0"
# Example of manifest file for a Blender extension
# Change the values according to your extension
id = "bbp_ng"
version = "4.0.0"
name = "Ballance Blender Plugin"
tagline = "The specialized add-on served for creating game map of Ballance"
maintainer = "yyc12345 <yyc12321@outlook.com>"
# Supported types: "add-on", "theme"
type = "add-on"
# Optional link to documentation, support, source files, etc
website = "https://github.com/yyc12345/BallanceBlenderHelper"
# Optional list defined by Blender and server, see:
# https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html
tags = ["Object", "Mesh", "UV", "Import-Export"]
blender_version_min = "4.2.0"
# # Optional: Blender version that the extension does not support, earlier versions are supported.
# # This can be omitted and defined later on the extensions platform if an issue is found.
# blender_version_max = "5.1.0"
# License conforming to https://spdx.org/licenses/ (use "SPDX: prefix)
# https://docs.blender.org/manual/en/dev/advanced/extensions/licenses.html
license = [
"SPDX:GPL-3.0-or-later",
]
# Optional: required by some licenses.
# copyright = [
# "2002-2024 Developer Name",
# "1998 Company Name",
# ]
# Optional list of supported platforms. If omitted, the extension will be available in all operating systems.
platforms = ["windows-x64", "linux-x64"]
# Supported platforms: "windows-x64", "macos-arm64", "linux-x64", "windows-arm64", "macos-x64"
# Optional: bundle 3rd party Python modules.
# https://docs.blender.org/manual/en/dev/advanced/extensions/python_wheels.html
# wheels = [
# "./wheels/hexdump-3.3-py3-none-any.whl",
# "./wheels/jsmin-3.0.1-py3-none-any.whl",
# ]
# Optional: add-ons can list which resources they will require:
# * files (for access of any filesystem operations)
# * network (for internet access)
# * clipboard (to read and/or write the system clipboard)
# * camera (to capture photos and videos)
# * microphone (to capture audio)
#
# If using network, remember to also check `bpy.app.online_access`
# https://docs.blender.org/manual/en/dev/advanced/extensions/addons.html#internet-access
#
# For each permission it is important to also specify the reason why it is required.
# Keep this a single short sentence without a period (.) at the end.
# For longer explanations use the documentation or detail page.
[permissions]
# network = "Need to sync motion-capture data to server"
files = "Import/export Virtools file from/to disk"
# clipboard = "Copy and paste bone transforms"
# Optional: build settings.
# https://docs.blender.org/manual/en/dev/advanced/extensions/command_line_arguments.html#command-line-args-extension-build
[build]
paths_exclude_pattern = [
"__pycache__/", # Python runtime cache
".style.yapf", # Python code style
"*.gitkeep", # Git directory keeper
".gitignore", # Git Ignore File
"*.md", # Useless document.
"/raw_jsons", # Raw JSONs.
"/raw_icons", # Raw Icons.
"/tools", # Assistant tools.
]

View File

@ -43,7 +43,7 @@
"params": { "params": {
"length": "length", "length": "length",
"height": "height", "height": "height",
"face": "(face[0], face[1], face[3], face[2], face[5], False)", "face": "(face[0], face[1], face[2], face[3], face[5], False)",
"is_sink": "is_sink", "is_sink": "is_sink",
"is_ribbon": "False" "is_ribbon": "False"
}, },

View File

@ -15,7 +15,7 @@ def resize_image(src_file: str, dst_file: str) -> None:
def create_thumbnails() -> None: def create_thumbnails() -> None:
# get folder path # get folder path
root_folder: str = os.path.dirname(os.path.dirname(__file__)) root_folder: str = common.get_plugin_folder()
# prepare handler # prepare handler
def folder_handler(src_folder: str, dst_folder: str) -> None: def folder_handler(src_folder: str, dst_folder: str) -> None:

View File

@ -14,7 +14,7 @@ def compress_json(src_file: str, dst_file: str) -> None:
def create_compressed_jsons() -> None: def create_compressed_jsons() -> None:
# get folder path # get folder path
root_folder: str = os.path.dirname(os.path.dirname(__file__)) root_folder: str = common.get_plugin_folder()
# prepare handler # prepare handler
def folder_handler(src_folder: str, dst_folder: str) -> None: def folder_handler(src_folder: str, dst_folder: str) -> None:

View File

@ -1,4 +1,12 @@
import os, typing import os, typing, fnmatch, shutil
def get_plugin_folder() -> str:
"""
Get the absolute path to plugin root folder.
@return The absolute path to plugin root folder.
"""
return os.path.dirname(os.path.dirname(__file__))
def relative_to_folder(abs_path: str, src_parent: str, dst_parent: str) -> str: def relative_to_folder(abs_path: str, src_parent: str, dst_parent: str) -> str:
""" """

View File

@ -1,4 +1,29 @@
# Ballance Properties # Ballance Properties
!!! info "Work in Progress" The Ballance attributes are distinct from the Virtools attributes, which are a set of attributes dedicated to Ballance mapping. These properties are hosted in the scene and do not change within the same scene (mapping does not involve scene switching in Blender). The panels related to the Ballance property can be found in the `Scene` properties panel, as shown below, and they are:
This part of manual still work in progress.
* `Ballance Elements` panel (red arrows), corresponding to Ballance elements
* `BME Materials` panel (green arrow), corresponds to BME materials.
* `Ballance Map` panel (blue arrow), which corresponds to the Ballance map information.
Among these, only the Ballance Map information is the one you need to focus on, the other attributes are not normally of interest, except in the case of errors in some of the materials or meshes in the map.
![](../imgs/ballance-properties.png)
## Ballance Map Information
Ballance Map infomation currently has only one option, Sector (map sector count). This attribute indicates the final desired number of sectors for the current map. This attribute is mainly used to work around the bug of exporting map, see the [Import and Export Virtools Document](./import-export-virtools.md) section for details on the bug.
The only thing you need to do is to check if this field is the number of sectors you expect before exporting the final map. Note that although you can set this field at the beginning of creating your map, there are other features in BBP that may modify this field, such as adding elements, importing Virtools documents, etc. For example, if you have a map with sector 3 specified and you are adding an element that belongs to sector 4, this value will automatically increase to 4. Similarly, when importing a Ballance map with a total of 4 sectors, this value will also increase to 4 (if the previous value was less than 4). The main reason for doing this is so that users can use this plugin without perceiving this value, especially when making slight modifications to some existing maps. Doing so, however, may not meet the user's needs in some cases, so it is still recommended that you check this field before exporting.
## Ballance Elements
Ballance Elements keep a record of the meshes of all the elements you have added using the BBP Add Elements feature. Meshes generally take up the largest amount of data in a 3D file, so reducing the number of meshes, i.e. by sharing meshes between objects of the same shape, can drastically reduce the size of the map file. When you use BBP to add an element-related function, it will first try to get the element's mesh from here, and if there is no corresponding mesh, it will be loaded and recorded here.
This panel is for viewing only, not editing. If you have accidentally modified the meshes of a BBP-added element (which should not have been modified in the first place) and want to restore its original shape, just click `Reset Ballance Elements` to reset all the element meshes in the list to their correct state.
## BME Materials
Similar to the Ballance Elements, records the materials used when adding floor using BME. This is also designed so that materials can be reused, so that you don't need to create a set of materials associated with each object you create, greatly reducing the number of duplicate materials.
This panel is for viewing only, not editing. When you accidentally modify BME related materials (which should not have been modified) and want to restore them, just click `Reset BME Materials` to reset all materials in the list to their correct state.

View File

@ -1,4 +1,33 @@
# Add Floor # Add Floor
!!! info "Work in Progress" ## Start Generating
This part of manual still work in progress.
In the 3D view, click `Add - Floors` to expand the Add Floors menu. The menu is shown below.
![](../imgs/bme-adder.png)
Click on the menu to see all supported floor types in the submenu that pops up. Their names and icons hint at the style and shape of the floor it is intended to create.
!!! info "BME is extensible"
BME's floor adder is extensible, each item in the menu is actually described by a set of JSON data. You can read the [Technical Information](./tech-infos.md) section to learn how we write this JSON, and you can even expand the types of floors that BME can create to suit your needs.
## Configure Floor
Clicking on one of the floor types will open the floor creation dialog, here we are showing a Normal Platform as shown below. In the dialog, we can configure various properties of this floor type, such as the length, width, height, distance, and whether the surface is displayed or not, to customize the geometry it generates so that it meets our requirements.
![](../imgs/bme-adder-dialog.png)
In the Normal Platform dialog, we can first see that it asks us to provide the length and width of the floor, which determines the size of our platform, and there is a text description to help you understand what this property controls.
Then it also asks us to provide the height of the platform, which defaults to 5, which is the default height of the floor in Ballance. Anything less than 5 creates a thin floor similar to the one in the "The Devil Dragon" map, and anything greater than 5 creates a very high floor wall similar to the one in the "Exaggeratedly Dense Space Station" map.
Finally, it tells us which sides of the floor we need to configure to display. Note that Top and Bottom are the top and bottom surfaces along the height direction (Z axis), while Front, Back, Left, and Right are the front, back, left, and right surfaces when looking down with your head on the -X axis and your eyes on the -Z axis. You may notice that there is a perspective cube in the center of these six face buttons, and in fact the positions of these six face options correspond to the positions of the six faces of this perspective cube.
## Tips
Each floor type has a different number of configuration entries, so for different floor types, you will need to follow the configuration hint text to understand what the corresponding configuration does. Some floor types may have a large number of configuration entries, while others may have no configuration entries at all.
The default values for the floor type configuration are set to the values that were most commonly used when the floor was created. The values are reset to the defaults each time the floor type is switched or recreated.

View File

@ -1,4 +1,41 @@
# Compile and Distribute Plugin # Compile and Distribute Plugin
!!! info "Work in Progress" This page will guide you in compiling the plugin as well as distributing it.
This part of manual still work in progress.
## Compiling LibCmo with BMap
BBP's Virtools file native import/export functionality relies on BMap and its Python binding PyBMap. In order to distribute the plugin, we need to first compile BMap and its predecessor LibCmo, and before doing so, you need to check the version of BMap you need. Because BBP doesn't always use the latest version of BMap, e.g. if you're compiling an older version of BBP, it's obviously not possible to rely on the latest version of BMap. BMap is constantly being upgraded, and the functionality it provides is constantly changing, and different versions of BMap are incompatible. BBP usually states the version of BMap it uses at the time of release, but if BBP doesn't point it out, you may need to look for the most recent version of BMap that compiles with the version of BBP at the time of its release.
After specifying the version, you need to visit [LibCmo GitHub repository](https://github.com/yyc12345/libcmo21). Then clone the project and use the Git command to go to the corresponding version (or just download the source code of the corresponding version). Then follow LibCmo's compilation manual to compile to get BMap. on Windows, you'll usually get the files `BMap.dll` and `BMap.pdb`. On Linux, it will be `BMap.so`.
Then we need to configure PyBMap, which comes with LibCmo. Please follow the manual of PyBMap to combine the compiled binary BMap library with PyBMap. That is to complete the PyBMap configuration.
Then we need to copy the configured PyBMap to our project under `bbp_ng/PyBMap` to complete this step.
## Generate Thumbnails and Compress JSON
BBP comes with a built-in set of custom icons, as well as the JSON files needed by its component BME to describe the structure. By batch generating thumbnails and compressing JSON operations, the size of these parts can be reduced, making them suitable for loading in Blender and easier to distribute.
Go to the `bbp_ng/tools` folder and run `python3 build_icons.py` which will batch generate thumbnails (this requires the PIL library, please install it via pip in advance). It actually generates thumbnails from the original images in the `bbp_ng/raw_icons` directory and stores them in the `bbp_ng/icons` folder. Running `python3 build_jsons.py` will compress the JSON, which actually reads, compresses, and writes the raw JSON files from the `bbp_ng/raw_jsons` directory into the `bbp_ng/jsons` folder.
## Packaging
Starting from Blender 4.2 LTS, plugins are packaged using Blender's own packaging feature.
Assuming that the final output file is `redist/bbp_ng.zip`. If you are in the root directory of the project, execute the `blender --command extension build --source-dir bbp_ng --output-filepath redist/bbp_ ng.zip` command in a command line window to finish packaging. Please note `blender` is the executable Blender program.
Blender will package the plugin according to the instructions in `blender_manifest.toml` with the following files excluded:
* `bbp_ng/raw_icons`: raw thumbnail folder.
* `bbp_ng/raw_jsons`: raw JSON folder.
* `bbp_ng/tools`: tools for compiling.
* `bbp_ng/.style.yapf`: code style description file.
* `bbp_ng/.gitignore`: gitignore
* `bbp_ng/icons/.gitkeep`: folder placeholder
* `bbp_ng/jsons/.gitkeep`: folder placeholder
## Generating Help Documentation
Although this project will utilize the GitHub Page feature to provide help documentation, sometimes you may need to provide an offline version of the help documentation, this section will explain how to generate an offline version of the help documentation.
First you need to install `mkdocs` and `pymdown-extensions` via pip. Then go to the `docs` folder and run `mkdocs build --no-directory-urls`. After running the command you get a folder called `site`, which is the help documentation that can be viewed offline.

View File

@ -1,4 +1,59 @@
# Add Component # Add Component
!!! info "Work in Progress" In the 3D view, click `Add - Components` to expand the Add Components menu. The menu is shown on the left side of the image below.
This part of manual still work in progress.
![](../imgs/component-adder.png)
The right side of the image above shows the interface for adding some components, which will be described in turn, from top to bottom on the right side are: Add Checkpoint, Add Nong Extra Point, Add Nong Ventilator, Add Ventilator Series, Add Sector Pair.
## General Components
In the Add Components menu, under the `Basic Components` category, you can add general components. For most components, adding an component requires specifying the sector it belongs to, indicating that the component is only active in that sector. However, there are some exceptions:
* PS_FourFlame: the 4-flame platform at the start of the level, which is globally unique and therefore has no sector attribute.
* PE_Ballon: the ship at the end of the level, globally unique and therefore has no sector properties.
* PC_TwoFlames: the checkpoint for the sector, with a sector attribute. However, it should be noted that its sector attribute refers to which sector it is going to check, for example, specifying a sector attribute of 1 means that it is the checkpoint of the first sector, i.e. the start of the second sector, and the second sector will be opened after passing it.
* PR_Resetpoint: the reset point of the sector with the sector attribute. However, it is important to note that the sector attribute indicates which sector it is the respawn point of. It follows that when PC_TwoFlames and PR_Resetpoint appear in pairs, PR_Resetpoint is always labeled 1 greater than PC_TwoFlames.
!!! info "Automatic name conflict detection"
A portion of the components have unique names in a Ballance map, e.g., there is and can only be one start point and one ending ship, only one checkpoint and one respawn point can exist in the same sector, etc.
BBP provides a name detection function when creating these components, and if the name already exists, it will be shown in text below when creating to remind users not to create duplicates. As shown in the upper right corner of the display image above as an example, it is trying to add a PC_TwoFlames that already exists and receives a warning.
## Add Nong Components
In the Add Components menu, under the `Nong Components` category, you can add nong components. We only provide two common types of nong components: Nong Extra Point and Nong Ventilator.
### Nong Extra Point
To add a nong extra point, you need to specify the number of nong extra point and the sector number of it. It also will automatically rotate the nong extra point with a slight degree one by one to make the nong extra point look better in the game.
### Nong Ventilator
Nong ventilator are also added by specifying the number of nong ventilators and the sector number of ventilators. The difference is that we have provided some preset values for constructing nong ventilator that will just blow up wood or stone balls, and if you are not satisfied with these preset values, you can still enter the number yourself.
!!! info "Ventilator arrays are also possible"
Did you know that nong ventilators are also possible by setting the offset to 0 when adding a ventilator series? The nong ventilator creation here is just providing some preset values.
## Add Series Components
In the Add Components menu, under the `Series Components` category, you can add series components (aka. component array). We only provide two types of commonly used series: fTilting Block Series and Ventilator Series.
### Tilting Block Series
Tilting Block Series requires you to provide the number of tilting blocks and the number of tilting blocks, and you can also adjust the spacing between adjacent tilting blocks, the default spacing is taken from the game.
### Ventilator Series
The ventilator series also requires sector number and count of ventilators, however it provides a 3D offset so that you can build a vertical or horizontal ventilator series. The default offset values are taken from the in-game values for vertical ventilator series.
## Add Components Pair
In the Add Components menu, under the `Components Pair` category, you can add pairs of components. Currently, only one type of pairs can be added: Sector Pair.
### Sector Pair
To add a Sector Pair, you need to enter a Sector number and it will automatically generate a pair of the checkpoint and respawn point components for you. For example, if you enter 1, it will automatically generate a 4-flame start point and a respawn point for Sector 1, if you enter 2, it will generate a checkpoint for Sector 1 and a respawn point for Sector 2, and so on.
!!! info "Automatic name conflict detection"
Similar to normal component additions, sector pair additions have the same name conflict detection. As an example, the lower right corner of the image above shows that the sector pair for sector 1 already exists and does not need to be added.

View File

@ -1,4 +1,29 @@
# Configure Plugin # Configure Plugin
!!! info "Work in Progress" !!! info "The plugin must be configured first"
This part of manual still work in progress. Some of the configurations of the BBP plugin are closely related to the use of the plugin, and only when the BBP plugin is correctly configured can the full functionality of the BBP plugin be used.
**Whether installing for the first time or updating**, reconfiguring the plugin is essential to ensure that the settings are correct.
## Open the Configuration Panel
Open Blender, select `Edit - Preferences`, in the window that opens go to the `Add-ons` tab and find the BBP plugin in the list. Its name is `Ballance Blender Plugin`. Make sure that the checkbox next to the name is checked, which means that the plugin is enabled. Click on the triangular arrow to the left of the checkbox to expand the plugin details to enter the configuration panel as shown in the figure.
![](../imgs/config-plugin.png)
## Start to Configure
The BBP plugin currently has 2 settings to configure.
### External Texture Folder
Please fill in the `Texture` directory of Ballance, from which the plugin will use the external texture files (i.e. the ones Ballance originally came with). Click on the folder button on the right to browse the folders and select it.
This is crucial for BBP to work properly, and only if it is filled out correctly will BBP not make errors during operation.
### No Component Collection
When importing and exporting BM files, objects that are in a collection with this name will be forced to be specified as No Component. leaving this blank means that this feature is not needed. This feature is usually used for forced element model replacement.
!!! warning "This setting is not required at this time"
Since BBP 4.0 supports native import/export of Virtools files, the BM file import/export function is no longer used. Therefore, this field is no longer useful and does not need to be filled in.

View File

@ -1,4 +1,28 @@
# Group Operation # Group Operation
!!! info "Work in Progress" ## Select by Group
This part of manual still work in progress.
`Ballance - Select by Virtools Group` provides a feature to filter by Virtools grouping data.
The feature starts with 5 different selection strategies that match Blender's selection methods exactly (Set, Extend, Subtract, Invert, Intersect). Simply use it like a Blender selection. Then, select the name of the group you need and start a selection or filter.
!!! note "About pattern selection"
If you can, use the Subtract or Intersect modes whenever possible. Because this avoids analyzing too many objects. For example, selecting a general range first and then filtering using Intersect mode is more efficient than using Set mode directly.
## Quick Grouping
The BBP plugin adds the ability to quickly group objects in 2 places. The first is the object context menu: you can select a series of objects and right click to find the quick grouping feature in the object context menu. Second is the Objects menu in Outline view: you can right-click on a selection of objects in the Outline view to find the quick grouping feature. Both menus are shown below.
![](../imgs/grouping.png)
### Group into...
Groups the selection into the group of your choice.
### Ungroup from...
Ungroups the selection from the group of your choice.
### Clear All Groups
Clear all groups for the selection. You will be asked to confirm this before executing to avoid misbehavior.

View File

@ -1,4 +1,55 @@
# Import and Export Virtools Document # Import and Export Virtools Document
!!! info "Work in Progress" !!! warning "This is experimental content"
This part of manual still work in progress. Native importing and exporting of Virtools documents is experimental content for the BBP plugin, it may have many problems, see the [Report Issue](./report-bugs.md) section to learn more. When problems are encountered, please report them. the authors of the BBP plugin are not responsible for any consequences resulting from problems with the BBP plugin.
## Import Virtools File
Virtools files can be imported by clicking `File - Import - Virtools File`. Importing supports CMO, VMO and NMO files. Clicking on it will bring up the file opening window and show the import settings in the sidebar. First of all, you need to select the Virtools file to be imported, and then configure the import settings in the sidebar. After configuring the import settings, you can click Import to start the import, and wait for the status bar at the bottom of Blender to indicate that the import is complete.
### Conflict Options
The Conflict Options section indicates what to do when the importer encounters duplicate object names. There are 4 levels, for Object, Mesh, Material and Texture. There are 2 ways to handle it: Rename and Use Current. When Rename is selected and a duplicate name is encountered, a suffix will be added to the name to make it unique. By choosing Use Current, the import of the item from the file will be ignored and the item with the same name will be used instead, which already exists in the Blender document.
!!! info "Differences from Virtools conflict resolution"
Compared to the conflict resolution dialog in Virtools, the conflict resolution options provided by the BBP plugin do not support replacement, and the granularity is not fine-tuned to individual instances, but only for an entire type. So you can't set a different conflict resolution for each instance of a conflict individually. However, this setting is sufficient for most scenarios.
The default values for the options in the Conflict Options section are the solutions that are usually selected for import. Of course, special settings are needed for special import situations, e.g. if you are importing an externally exported element model from the original version, you may be able to use Use Current option in material options instead of making a copy. The correct use of the conflict options is a matter of mapping experience and is not taught in this manual.
### Virtools Params
It is well known that Virtools uses a system-based multi-byte character encoding to process documents, and is therefore prone to what is known as garbling; Blender itself does not suffer from garbling, however, if we do not read a Virtools document with the correct encoding, the characters stored in it may still appear garbled when the Virtools document is imported into Blender. The Encodings property in the Virtools Params section specifies the encodings for reading Virtools documents. Multiple encodings can be specified, separated by a `;` (semicolon). Some common encodings are listed below:
* 1252 (Windows only): Western European encoding used by Ballance.
* 936 (Windows only): the default encoding for Chinese Windows system.
* CP1252 (non-Windows): Western European encoding used by Ballance.
* CP936 (non-Windows): the default encoding for Chinese Windows system.
The encoding attribute is very important, if you set the wrong encoding, the names of the various objects imported into Blender will be unrecognizable.
!!! warning "Encoding is a platform dependent setting"
According to the implementation of LibCmo, the underlying library used by BBP's Virtools documentation for the import module, the encoding attribute is a platform dependent setting. Under Windows, the [Windows Code Page](https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers) number is required here. Under other operating systems, LibCmo uses iconv for character encoding and decoding, so you need to use the legal [Iconv Encoding Identifier](https://www.gnu.org/software/libiconv/).
## Export Virtools File
Virtools files can be exported by clicking `File - Export - Virtools File`. Clicking on it will bring up the file opening window and show you the export settings in the sidebar. First of all, you need to select the location of the exported Virtools file, then configure the export settings in the sidebar, after configuring the export settings, you can click Export to start the export, and wait for the status bar at the bottom of Blender to indicate that the export is complete.
### Export Target
The Export Target section is used to determine which objects you need to export to a Virtools document. You can choose to export a collection or an object and select the corresponding collection or object below. Note that selecting a collection will export the objects in the internal collection as well, i.e. exporting nested collections is supported.
### Virtools Params
The Virtools Params section is similar to the one in the importing Virtools document; the Encodings property determines the encoding used when exporting a Virtools document.
The Global Texture Save Option determines how textures that are set to Use Global are actually saved. In general, setting it to Raw Data will 100% guarantee that the saved Virtools document will contain the correct texture, but it may be larger, while setting it to External will minimize the size of the file, but there may be problems with the exported document not finding the texture file. We recommend that you specify how each material should be saved individually when you set it up, rather than relying on the global option to set it up. This option is for re-editing old maps that rely on the Global Texture Saving Option. It should also be noted that even though there is a Use Global option in this option, please **don't** select it or it will result in an error, because obviously you can't have a global option that then uses the global option's settings.
The Use Compress property specifies whether saved documents are stored compressed. Compression can significantly reduce the size of a document, and on modern computer platforms, the performance loss caused by compression is almost negligible. When Use Compress is selected, an additional Compress Level attribute is displayed, which specifies the level of compression; the higher the value, the greater the compression rate and the smaller the file.
### Ballance Params
The Ballance Params section contains parameters that optimize the export process for Ballance-specific content.
Successive Sector is an option to work around a bug that occurs when exporting groups of sectors. For some reason, if there are no elements in a sector (actually, no objects are grouped in a sector group), the export plugin thinks that the sector group doesn't exist and misses the export. And since Ballance determines the final sector, i.e. the sector where the spaceships appears, by incrementing the number of sectors from 1 to the last sector group that exists, the combination of the two causes Ballance to incorrectly determine the number of sectors in the map, and thus display the spaceships in the wrong sector, which is an export bug. when this option is checked, the exported document will be pre-defined according to the number of sectors specified in the Ballance Map information in the current Blender file. When this option is checked, the exported document will pre-create all of the sectors according to the number of sectors specified in the Ballance map information in the current Blender file before exporting, so that you don't miss creating some sector groups, and the spaceships will be displayed in the correct sectors.
This option is usually checked when exporting playable maps, if you just want to export some models then you need to turn this option off, otherwise it will create a lot of useless sector groups in the final file.

View File

@ -1,7 +1,7 @@
# Ballance Blender Plugin User Manual # Ballance Blender Plugin User Manual
!!! info "May Outdated" !!! info "May be Outdated"
This document has been translated from other languages and may not always be up to date. This document is translated from other languages and may not always be up to date.
Welcome to the Ballance Blender Plugin, the user manual for the free and open source Ballance map creation suite. Welcome to the Ballance Blender Plugin, the user manual for the free and open source Ballance map creation suite.

View File

@ -1,4 +1,57 @@
# Install Plugin # Install Plugin
!!! info "Work in Progress" ## Determining the Version
This part of manual still work in progress.
The principle of BBP's Blender support is to support the latest **LTS** version, and to spend some time migrating the plugin after the latest LTS version is released. The current plugin version **4.0** is based on Blender version **4.2.x**.
Theoretically, BBP will work fine on other versions of Blender if no major changes have been made. For example you can try to run BBP plugin based on Blender 3.6 LTS on Blender 4.0. However, the developers of BBP do not deal with bugs that only appear in non-LTS versions. before installing the plugin, please select the appropriate version.
## Uninstall the Old Plugin
If you have used BBP before then you need to uninstall it first. Older versions of BBP are usually installed in the following locations:
* `<Blender>/3.6/scripts/addons/ballance_blender_plugin`: BBP 3.0 or lower version.
* `<Blender>/3.6/scripts/addons_contrib/ballance_blender_plugin`: BBP 3.0 or lower version.
* `<Blender>/3.6/scripts/addons/bbp_ng`: BBP 4.0 internal test version
* `%APPDATA%/Blender Foundation/Blender/3.6/scripts/addons/bbp_ng`: BBP 4.0 internal test version
* `%APPDATA%/Blender Foundation/Blender/4.2/extensions/user_default/bbp_ng`: BBP 4.0 or higher version
You just need to disable the plugin in Blender first (uncheck the box in front of the plugin name) and then delete these folders (if they exist) to uninstall the plugin completely. The `<Blender>` in the path refers to the location of your Blender installation. The `3.6` and `4.2` in the path are the version numbers of your Blender installation, which need to be adjusted according to the version you have installed, and subsequent occurrences of version numbers should be understood as the same meanings.
!!! warning "Should not use Blender's plugin uninstall feature"
It is not possible to uninstall BBP using the plugin uninstall function on the Blender plugins page, because BBP loads the Virtools file read/write library BMap into Blender as soon as it is loaded by Blender (whether it is enabled or not). if you remove it while Blender is running, you will get an access denied error. Therefore you must manually delete the plugin directory after closing Blender.
If you are really not sure where the plugin is installed, you can find the `File` property in the Addons page of Blender's Preferences, and the folder it points to where the file is located is the folder to be deleted.
!!! info "`ballance_blender_plugin` and `bbp_ng`"
`ballance_blender_plugin` is the module name of the old version of the BBP plugin (before version 4.0) and `bbp_ng` is the module name of the new version of the BBP plugin (after and including version 4.0). Both are provided in order to ensure that the user actually deleted the old version of the plugin.
!!! info "`addons` and `addons_contrib`"
After Blender version 3.6 LTS, i.e. BBP version 3.3, Blender no longer supports Testing type plugins. As a result, the `addons_contrib` folder, which was dedicated to installing Testing plugins, is no longer used, and plugins need to be installed uniformly in `addons`. Both are provided to ensure that the user actually deletes the old version of the plugin.
!!! info "`addons` and `extensions`"
In Blender version 4.2 LTS, Blender uses Extensions instead of Addons to describe plugins. This has resulted in a change in where plugins are installed. Both are provided in order to ensure that the user actually removes the old version of the plugin.
## Download Plugin
You can download the latest plugin via [the Release page of the GitHub codebase for this project](https://github.com/yyc12345/BallanceBlenderHelper/releases). Plugins are provided as ZIP archives.
In addition, you can also get this plugin in the mapping tutorial web disk provided by yyc12345:
* Overworld: [Mega](https://mega.nz/#F!CV5SyapR!LbduTW51xmkDO4EDxMfH9w) (located in `Mapping` directory)
* Chinese Region Only: [Baidu Web Disk](https://pan.baidu.com/s/1QgWz7A7TEit09nPUeQtL7w?pwd=hf2u) (Extract code: hf2u, located under `制图插件(新)`)
!!! warning “Do not download this repository directly for use”
Please do not download this project's repository directly for use. First of all, because the latest commit is not guaranteed to be stable and available. The second reason is that this project contains some C++ code that needs to be compiled, and must be compiled before it can be used. See [Compile and Distribute Plugin](./compile-distribute-plugin.md) for more information.
## Install Plugin
Open Blender, click `Edit - Preferences`, in the window that opens go to the `Add-ons` tab, click on the arrow at the top right of the window and then click on the `Install from Disk.... ` button, select the ZIP archive you just downloaded, and the installation will be completed. If you don't see it in the list you can click the Refresh button or restart Blender.
You can also choose to install the plugin manually (if the above installation method fails), go to `%APPDATA%/Blender Foundation/Blender/4.2/extensions/user_default`, create a folder named `bbp_ng` and go inside it, extract the downloaded ZIP archive to this folder, start Blender and you will find BBP in the list of addons.
The name of BBP plugin in the list is `Ballance Blender Plugin`, when you find it, you can enable the plugin by checking the box on the left side of the name. The Preferences window after the plugin is installed is shown below.
![](../imgs/config-plugin.png)
After **installing or updating** the plugin, be sure to [configure plugin](./configure-plugin.md) before using it, see the next section for details.

View File

@ -1,4 +1,28 @@
# Legacy Alignment # Legacy Alignment
!!! info "Work in Progress" `Ballance - 3ds Max Align` provides an alignment function similar to the way alignment works in 3ds Max.
This part of manual still work in progress.
The so-called legacy alignment feature is a perfect reimplementation of the 3ds Max alignment operations in Blender. It makes it possible for many mappers who switch from 3ds Max to Blender to get up to speed faster and provides some convenient alignment operations. The image below shows legacy alignment in action.
![](../imgs/legacy-align.png)
## Usgae
Legacy alignment supports aligning multiple objects to a single object by first selecting the objects to be aligned in turn, then selecting the reference object at the end of the alignment (i.e. making it the active object), and then clicking `Ballance - 3ds Max Align` to bring up the legacy alignment panel, after which you can start the alignment operation.
## Introduction of the Panel
In the panel, `Align Axis` specifies the axis you want to align to, you can multi-select here to specify more than one axis, without specifying any axis you will not be able to do the alignment operation, and thus you will not be able to click the `Apply` button.
`Current Object` is the alignment reference object, which is the active object in the scene, usually the last object you selected. This option specifies what value you need to reference for alignment, with `Min` (minimum value on axis), `Center (Bounding Box)` (center of the bounding box), `Center (Axis)` (origin of the object), and `Max` (maximum value on axis) available. These options are consistent with the alignment options in 3ds Max.
The `Target Objects` are the objects that are being aligned, there may be many of them, in this option it is also specified what values you need to refer to them for alignment. The options have the same meaning as `Current Object`.
The `Apply` button, when clicked, will press the current page's configuration into the operation stack and reset the settings above, allowing you to start a new round of alignment operations without having to perform a legacy alignment again. The number of operations in the stack is shown below the `Apply` button.
!!! info "What the Apply button does"
Understanding this part is not useful for mapping, and you don't need to read what's in this box unless you're interested.
By design, Blender doesn't support so-called "operations inside the Operator", but with a few tricks we simulated Apply effect similar to the one in 3ds Max.
The Apply button is actually a specially displayed BoolProperty that listens to its value change event and, while avoiding recursive calls, records the current setting in a hidden CollectionProperty and resets its own value and displayed properties to make a visual "apply". Operator processes the alignment requirements accumulated in the CollectionProperty in turn when executing.

View File

@ -1,4 +1,29 @@
# Naming Convention # Naming Convention
!!! info "Work in Progress" ## Auto Grouping and Renaming
This part of manual still work in progress.
In the outline view, right-click on any collection to get the Auto Grouping and Renaming menu.
![](../imgs/naming-convention.png)
This plugin currently supports two naming convention.
One is the Mapping Toolchain Standards described in the [Technical Information](./tech-infos.md) section, which is named `YYC Tools Chains` in this plugin.
The second is the naming standard used by [Imengyu/Ballance](https://github.com/imengyu/Ballance), named `Imengyu Ballance` in this plugin.
These functions will ultimately only show a generalized message of success or failure. If you need to see in detail why a certain object is not converted, click `Window - Toggle System Console` and the plugin has more detailed output there.
### Rename by Group
Renames an object to an appropriate name based on its current grouping information.
This is often used when migrating original maps. Some Ballance-derived programs do not have a Virtools Group concept and therefore rely on names for grouping information.
### Convert Name
Switch between different naming standards.
Typically used to convert between different Ballance-derived programs.
### Auto Grouping
Auto-fill the grouping information for an object according to a given naming convention.
Note that the original grouping information will be overwritten.
If you follow certain naming conventions during the mapping process, this feature can do the grouping for you automatically.

View File

@ -1,4 +1,81 @@
# Add Rail # Add Rail
!!! info "Work in Progress" In the 3D view, click `Add - Rails` to expand the Add Rails menu. The menu is shown on the left side of the image below.
This part of manual still work in progress.
![](../imgs/rail-adder.png)
The right side of the picture above shows the interface for adding some rails, and we will introduce them in turn later, from top to bottom on the right side are: Add Rail Section, Add Straight Rail, Add Side Rail, Add Arc Rail, and Add Spiral Rail.
!!! info "Rails with non-standard data"
BBP's rail adding menu is designed for new players to add rails quickly, and is not designed for skilled mapper to add rails. For cases where you need rails with non-standard data, such as rails with non-standard spacing or non-standard section, you need to build the rail section with Blender's own Circle operation, and then generate the entire rail with the Extrude, Bridge, or Spiral modifiers. In this way, you can control all the parameters of each step to meet your specific needs for rail parameters.
!!! info "Source of the rail parameters"
The various parameters of rails used in the Rails Add menu are derived from actual in-game measurements and from the experience of several mappers in the Ballance community over more than a decade.
The rail section radius and gauge are derived from years of mapping experience and measurements. Side rail tilt degree data is calculated by BallanceBug. Mono and double rail transition sinking data from the calculation by Imbalanced Dream. Spiral rail spacing is measured from Level 9 and Level 13.
## Rail Sections
In the Add Rails menu, under the `Sections` category, you can add rail sections. A rail section is the outline of a rail, and the creation of a rail section is usually the first step in the creation of various types of shaped rails, e.g. rails made by lofting, extruding etc.
### Rail Section
To create a rail section, you can choose in the panel to create a mono or double rail section.
When creating a mono rail section, the octagonal rail section is automatically created with the flat side edge facing up, while the double rail section is not (vertex tip facing up). If you need to change this behavior, you need to go into edit mode after creation and manually rotate the vertices of the rail section so that the flat side or vertex tip of the rail section faces up.
### Transition Section
The mono and double rail transition section will create a rail section that is suitable for mono and double rail transitions. This rail section is created without specifying any parameters.
## Straight Rails
In the Add Rails menu, under the `Straight Rails` category, you can add straight rails.
### Straight Rail
A Straight Rail is a straight rail of rail. To create a straight rail you need to specify a Length. You can also choose to create a straight double rail or a mono rail.
When creating a mono rail, similar to a section, the flat side of the rail section is automatically turned upwards, and this behavior can be modified by entering edit mode after creation and then rotating.
The creation of straight rails also supports the capping properties, which are controlled by the Start Cap and End Cap options located under Rail Cap, which are checked to cap the corresponding end. Capping is the process of automatically adding face for the end of a rail and correctly handling its normal. This is usually done to ensure that the rail is aesthetically pleasing where it comes into contact with other surfaces or objects, rail-to-rail joints do not need to be capped.
### Transition Rail
Mono and double transition rail can often be seen as an advanced use of Transition Section creation, where the section created by the transition section is extruded and the normals are taken care of to produce the result created by this option. To create a mono or double transition rail you need to specify a Length, which is also supported by the capping property.
### Side Rail
Side rails are created by specifying a Side Type which can be either Normal (for paper or wood balls) or Stone Specific (for stone ball specific). Side rails for paper and wood balls are the usual side rails that stone balls cannot pass through. Stone Specific side rails are side rails that are more tilted and can be passed by stone balls, and of course, paper and wood balls.
In addition to the side rail type, side rail creation also requires the Length and capping attributes.
## Curve Rails
In the Add Rails menu, under the `Curve Rails` category, you can add curved rails.
### Arc Rail
The first thing you need to do with an arc rail is to specify the Angle and Radius, which indicates how much the rail will turn at what radius. Generally speaking, angles of 90, 180, and 270 degrees are more common, but any number of degrees can be specified. The radius is usually adjusted as needed. For the double rail arc, the radius is the distence between arc rail rotation center to the double rail section center. For the mono rail arc rail, is the distence between arc rail rotation center to the mono rail section center.
Steps of the arc rail, the number of steps indicates the number of segments of the arc rail, the larger the number, the smoother the arc rail looks, relatively, the vertices will be more, the storage space and rendering requirements are also higher, so you need to choose a reasonable value.
Arc rails also support double-rail mono-rail selection, you can create mono-rail arc rails and double-rail arc rails. The capping attribute is also supported.
### Spiral Rail
Spiral rail, or spiral double rail, is similar to arc rail in that you need to specify Radius, which is the radius of rotation, but not the angle, since it always rotates in 360 degrees.
Spiral rails have an Iterations property, which indicates how many times the rail will spiral up, and a Screw property, which indicates the distance between each iteration.
The spiral rail also needs to set the Steps property, which has the same meaning as the arc rail. However, it should be noted that the number of steps refers to the number of steps in each iteration, not the overall number of steps. Therefore, when adjusting the iteration attribute, you do not need to change the Steps attribute again.
Side Spiral Rail also has a capping property.
### Side Spiral Rail
Side Spiral Rail, similar to spiral rail, but the ball is rolled along the side, similar to side rail.
Side Spiral Rail does not have a Screw property, because Side Spiral Rail is designed so that adjacent spins share a common edge, so the screw is fixed.
The Radius, Iterations and Steps attributes in the Side Spiral Rail settings have the same meaning as the spiral rail. Side Spiral Rail also have a capping attribute.

View File

@ -1,4 +1,29 @@
# Report Issue # Report Issue
!!! info "Work in Progress" ## What Can Go Wrong
This part of manual still work in progress.
BBP is not perfect, and since BBP's Virtools file import/export module is written in C++, BBP is more prone to errors than other plugins, and the consequences of errors can be more serious (including but not limited to memory leaks, accidental deletion of user files, etc.).
In Blender, you will observe if the plugin execution goes wrong:
* The expected effect is not achieved
* A large stack of output text pops up at the mouse that you can't read
* After opening the console using `Window - Toggle System Console`, you can observe the Python exception output.
## What Part Went Wrong
For the BBP plugin, if you observe something like `BMap operation failed` in the Python exception output, or the `IronPad.log` file in the `<Plugin-Install-Location>/PyBMap` folder, it means that The BBP plugin's BMap section, written in C++, is in error, and **you need to immediately save your current Blender document and exit Blender**. Because the plugin is in an abnormal state at this point, you should not continue any operations.
If there is no such thing as the above, then this is just a normal Python code execution error and you don't need to worry too much about it, but the error is still fatal and it is recommended to exit Blender and report the error after doing all the necessary operations.
## Where to Report
If you have a GitHub account, you can create and report issues in [Issue page of BBP repository](https://github.com/yyc12345/BallanceBlenderHelper/issues).
If you can't do that and you have proper way to contact with plugin author, then reporting directly to the plugin author is fine.
## The Content of the Report
First of all you need to describe in detail how you raise this error and what are the results of this error. If you can upload the documentation that led to the error, please try to do so (if it's not convenient to post it publicly, you can send it to the author through a private way such as email).
You also need to provide the Python stack report output in the Blender console (use `Window - Toggle System Console` to open the console). If your error is an error in the BMap section, you also need to provide the `IronPad.log` and `IronPad.dmp` files in the `<Plugin-Install-Location>/PyBMap` folder to make it easier for developers to locate the error.

View File

@ -1,4 +1,12 @@
# Technical Information # Technical Information
!!! info "Work in Progress" * BM File Specification: https://github.com/yyc12345/gist/blob/master/BMFileSpec/BMSpec_ZH.md
This part of manual still work in progress. * Mapping toolchain standards and format of files in the `meshes' folder: https://github.com/yyc12345/gist/blob/master/BMFileSpec/YYCToolsChainSpec_ZH.md
* Format of the JSON file for BMERevenge: https://github.com/yyc12345/gist/blob/master/BMERevenge/DevDocument_v2.0_ZH.md
This plugin works with the `fake-bpy-module` module to implement type hinting to speed up development. Use the following command to install Blender's type hinting library.
* Blender 3.6: `pip install fake-bpy-module-latest==20230627`
* Blender 4.2: `pip install fake-bpy-module-latest==20240716`
The main reason for doing this is that `fake-bpy-module` doesn't release an official package for the given Blender version, so I had to install it by choosing the daily build closest to the release time of the corresponding Blender version.

View File

@ -1,4 +1,57 @@
# UV Mapping # UV Mapping
!!! info "Work in Progress" ## Rail Mapping
This part of manual still work in progress.
The menu `Ballance - Rail UV` in the 3D view provides the ability to map rails.
To start mapping rails, you need to select the rails to be mapped (multiple selections are possible) and then click on this menu. Then you only need to select the material used for the rail. This will clear all materials for the selected object and assign all materials used on each face to the material you specify. Then you will set the UV of the selected object in the same way as the rails are post-processed in Ballance, so that the rails will have the same appearance as in the game by performing this operation.
!!! info "Rails UV doesn't really matter"
In fact, all objects grouped in the `Phys_FloorRails` group undergo a post-processing when Ballance loads the level. What the post-processing method does is to reset the UVs of these objects according to a specific mapping function (`TT_ReflectionMapping` is called in Virtools). So the UVs of the rails don't really matter, because Ballance will set them uniformly for you when you enter the game, and even if you don't set any UV data to the rails, the rails will look correct when you enter the game.
Therefore, this feature is usually applied to set the UVs for objects that are not grouped in the `Phys_FloorRails` group, but you still want them to show the appearance of the rails material. Or for rendering Ballance map previews in Blender, etc.
## Mapping Along Edges
Mapping Along Edges is the most important feature of the BBP plugin, the most powerful and at the same time the most difficult to understand. It is widely used for setting UVs of custom structures or a line of floor, wood, etc. The menu `Ballance - Flatten UV` in the 3D view offers the Mapping Along Edges feature. It only works in **Edit Mode**, so you need to be in Edit Mode (and entering Face selection mode at the same time, since Mapping Along Edges operates on faces) to use it.
Mapping Along Edges is usually used in combination with [Select Face Loops](https://docs.blender.org/manual/en/4.2/modeling/meshes/selecting/loops.html), [Shortest Path](https://docs.blender.org/manual/en/4.2/modeling/meshes/selecting/linked.html#bpy-ops-mesh-shortest-path-select) and other functions. You need to first select a series of faces, for example a series of consecutive Ballance floor sides, and then click `Ballance - Flatten UV` to start mapping along edges.
The configuration screen for Mapping Along Edges is shown below, with Scale Size mode on the left and Ref. Point (refernece point) mode on the right, we'll explain the difference between these two modes later.
![](../imgs/flatten-uv.png)
Mapping Along Edges, as the name implies, means UV mapping along a certain edge. The specific operation is to use linear algebra to transform the 3D coordinates of the vertices under a new coordinate system using a transition matrix. In this new coordinate system:
* The origin is the vertex with the index specified by the Reference Edge, as shown below. The figure below identifies the vertex index of the face in UV and 3D in yellow font, and the Reference Edge is 1 in the figure, then the vertex with the vertex index of 1 in the current face is used as the origin of the new coordinate system.
* The Y-axis (i.e., the V-axis, XYZ corresponds to UVW, and will not be commented subsequently) is the line from the vertex specified by Reference Edge to the next vertex, i.e., the edge from vertex 1 to vertex 2, i.e., the edge with the serial number of 1, as shown in the following figure, which identifies the serial number of the edge of the face in purple font in the following figure in UV and 3D. Edge 1 is a vector that starts at vertex 1 and ends at vertex 2. It has a direction, is a vector, and needs to be normalized when used as a coordinate axis.
* The Z-axis is obtained by cross-multiplying and normalizing the edge specified by Reference Edge (in this case, Edge 1) with its next neighboring edge (in this case, Edge 2). In the case of a three-point covariance where the cross-multiplication yields a zero vector, an attempt is made to use the normal data of the face instead.
* The X-axis is obtained by cross-multiplying and normalizing the previously calculated Y-axis and Z-axis. The XYZ in the new coordinate system still needs to satisfy the requirements of the right-handed coordinate system.
![](../imgs/flatten-uv-mechanism.png)
After setting up the new coordinate system and building the transition matrix and transforming every vertex to the new coordinate system, we can discard the Z component and map XY to UV and mirror the vertices on the -U axis to the +U axis, which is why Flatten UV doesn't support concave polygons. The reason for mirroring is to prevent UV mapping errors, for example, in the above image, the upper edge stripe of the floor side mapping is located in the V-axis, if we flip the UV vertices in the above image along the V-axis (you can try it for better understanding), it will result in the final mapping display does not meet our expectation, i.e., the edges specified by Reference Edge do not show the floor side stripe.
!!! info "Reference Edge actually refers to"
The Reference Edge actually refers to the index of the edge that needs to be mapped to the V-axis. Because this edge is directional, it also determines the origin in the new coordinate system.
In short words, Flatten UV allows the user to specify an edge and then flatten it along the V-axis of the UV.
After determining the coordinate system, we also need to know how far this UV mapping needs to be expanded, specifically what the scaling value of this UV mapping should be. For the V-axis direction, due to the Ballance mapping charcateristic (Ballance mapping always extend along the V-axis, and in Ballance, 5 in 3D is equivalent to 1 in UV), we can know the UV:3D relationship is 1:5. While for the U-axis direction, we can't determine it, that's the work of Scale Mode property, which lets the user decide the scaling of the U-axis direction.
The Scale Size mode allows the user to directly specify the scale value, for example, the default value of 5 means that 5 in the 3D world is equal to 1 in the UV world, while the Ref. Point mode allows the user to specify the U value of the UV of a reference point in the surface, and lets the plugin calculate the scaling on the U-axis by itself. For example, if we switch the Scale Size mode in the image above to Ref. Point mode and specify Reference Point as 2 and Reference Point UV as 1 we can also apply the same texture, let's explain the principle here. First of all, Reference Point specifies the reference point, this reference point is relative to the vertex specified by Reference Edge, that is, the reference system origin of the offset, so here, Reference Edge is 1, Reference Point is 2, then the actual reference point for the vertex 3. Reference Point UV specifies a U value of 1 in the UV value of this point, i.e., it can be seen as forcing vertex 3 to be placed at a U-axis of 1. BBP will calculate the corresponding U-axis scaling value based on this point and apply it to all vertices.
Scale Size mode is usually used for floor side mapping, since these faces have fixed U-axis scaling values. The Ref. Point mode is typically used for maps where the scaling value cannot be determined (usually due to model deformation that causes the scaling value to fluctuate around the standard range of scaling values), such as the upper surface of a sink floor generated from a curve with bevel shape, as shown in the following figure. We can be sure that the UV of the center of the sink floor must be 0.5, but it is not convenient to determine its scaling value because it is difficult to calculate it, so we just use the Ref. Point mode. The top half of the figure below shows the mapping result in the Ref. Point mode, and the bottom half is in the Scale Size mode. We can observe that in the Scale Size mode, the UV of the center of the sink floor is not exactly 0.5, which results in the center of the sink floor not being dark enough on the display. The Ref. Point mode, on the other hand, accurately sets the UV of the center of the sink floor to 0.5.
![](../imgs/flatten-uv-scale-mode.png)
Finally, Flatten Mode specifies the unfolding mode, Raw means that the connection between faces is not considered at all, and each face is treated as an independent content, Floor means that the continuity of adjacent faces in the V-axis direction is taken into account, and adjacent faces will be made adjacent in the UVs as much as possible, which can avoid the problem of visual duplications caused by Raw unfolding in the case of too many subdivisions of the road surface. Floor is often used in floor mapping, so it's called Floor. Wood is similar to Floor, except that it not only considers continuity on the V-axis, but also on the U-axis, which is often used in concave and convex wood mapping, and is the reason of its name.
The figure below shows the distribution of UV mapping for three different unfolding modes. At the top is the Raw mode, where you can see that the Reference Edge of each face is expanded at the UV coordinates of the origin. In the middle is the Floor mode, where you can see that BBP unfolded a series of consecutive faces along the V-axis, instead of stacking them all at the origin as in the Raw mode. At the bottom is the Wood unfolding mode, which is unfolding a convex wood, and you can see that the continuity of the faces has been taken into account on both the V and U axes.
![](../imgs/flatten-uv-flatten-mode.png)
!!! info "Floor and Wood Flatten Mode failed"
Floor and Wood mode have more limitations than Raw modes, they only support rectangle faces, and they require a lot of modeling operations, usually only the geometry generated by batch operations (e.g. subdividing, lofting, etc.) will be correctly recognized by Floor and Wood.
If Floor and Wood unfolding modes fail and the resulting unfolded maps are completely unacceptable, try modeling in a more prescriptive way or switch to manual mapping.

View File

@ -1,4 +1,59 @@
# Virtools Properties # Virtools Properties
!!! info "Work in Progress" ## Virtools Group
This part of manual still work in progress.
The BBP plugin adds a new property to every Blender object, called Virtools Group. has the same functionality as Group in Virtools. Select an object and the `Virtools Group` panel can be found in the `Object` properties panel.
![](../imgs/virtools-group.png)
In the `Virtools Group` panel, you can click Add to group objects. After clicking the Add button, you can select Predefined and then select one of all legal Ballance group names to add. Or select Custom and enter the group name you want to add. The selected Virtools group can also be deleted by clicking the Delete button. Finally, all group data for this object can be deleted at once by clicking the Trash icon button (which will let you confirm before deleting).
BBP also provides access to Virtools groups in Blender's other menus, see [Group Operation](./group-operations.md).
## Virtools Material
The plugin adds a new property to every Blender material, called Virtools Material, which bridges the gap between Virtools materials and Blender materials. Go to the `Material` properties panel and select a material to find the `Virtools Material` panel.
![](../imgs/virtools-material.png)
You can set material properties in the `Virtools Material` panel, just like in Virtools. All material parameters in the `Virtools Material` panel are maps of the material parameters in Virtools and will be accurately reflected in the final saved Virtools document.
The `Virtools Material` panel provides a preset function, which can be started by clicking the `Preset` button at the top. The preset function allows the user to use some preset material settings, such as the material data for the top surface of the road, the sides, etc., for ease of use. Note that using a preset does not affect the material's texture options, and you will still need to set the material's texture manually once the preset has been applied.
The `Virtools Material` panel also provides the ability to convert the material data in the `Virtools Material` panel to the Blender material for a visual effect in Blender. Click the `Apply` button at the top to perform this function. When you save a Virtools document in Blender, the material data in the Virtools document will be retrieved from the values specified in the `Virtools Material` panel and not from the Blender material. This means that a proper procedure for setting up a material is to edit the material parameters in the `Virtools Material` panel and then use the `Apply` button to convert them to the Blender material, instead of editing the Blender material directly.
The `Virtools Material` panel provides material repair functionality, which is inherited from the [Ballance Virtools Plugin](https://github.com/yyc12345/BallanceVirtoolsHelper). The Material repair button is located to the right of the `Preset` button and the `Apply` button, and is a button with a wrench icon. Clicking it requires reconfirmation to prevent misuse. The material repair function determines which type of material the current material is based on the filename of the texture file it references, and then modifies the other parameters to make it visually appealing based on our preset repair settings (taken from the game). This is usually used for fixing objects that look like they have the wrong material in the game, such as a black Stopper, etc.
!!! info "There is also a global material fix function"
In the 3D view, the menu `Ballance - Fix Material` is similar to the material fix function, but it will fix all materials within the current document. Don't use this feature unless you are sure that all materials in the current document need to be fixed, as it may set some of the originally special, correct materials back to generic values that you don't want.
The Global Material Repair function also needs to be reconfirmed after clicking on it before it can be used, to prevent misuse.
The Texture property in the `Virtools Material` panel not only allows you to select a texture within a document by clicking on it, but also opens the Texture File Browser by clicking on the folder button on the right side, which allows you to select the texture you want directly from the file system (much faster than selecting it from the Shading tab). The file browser is navigated in Ballance's Texture directory by default, to make it easier to select Ballance materials.
## Virtools Texture
The BBP plugin adds a new property to all Blender textures (actually Images) called Virtools Texture, which creates a link between Virtools textures and Blender images.
Unlike Blender materials, due to Blender's implementation there is no separate properties panel for textures, so we can only access Virtools texture properties in an indirect way in the `Virtools Material` panel. First find the `Virtools Material` panel by referring to the instructions in the `Virtools Material` chapter, then select a texture or open a texture in the material slot in the `Virtools Material` panel, and you'll see that the Virtools texture attributes are displayed additionally underneath the texture attributes of the material, as shown in the highlighted portion of the image below.
![](../imgs/virtools-texture.png)
Among them, Save Option indicates how the texture is stored in Virtools, and these are the common storage methods:
* External: The file only stores the name of the referenced file. All Ballance native textures should use this mode.
* Raw Data: The texture is stored inside the file, the disadvantage is that it will lead to a large file. All non-native Ballance maps should use this mode.
* Use Global: Use global settings. We do not recommend using this unless you are modifying an existing map. We recommend explicitly specifying how individual textures are stored right here, rather than using global values. The global setting is determined when exporting the Virtools document.
The Video Format indicates the rendering mode of the texture in Virtools, and these are the commonly used modes:
* 32 Bits ARGB8888: The storage mode for all kinds of textures with transparency, such as the column gradient part.
* 16 Bits ARGB1555: The way to store all kinds of maps without transparency, such as floor.
## Virtools Mesh
The BBP plugin adds a new property to all Blender meshes called Virtools Mesh. go to the `Data` properties panel to find the `Virtools Mesh` panel.
![](../imgs/virtools-mesh.png)
The Virtools Mesh is currently only used as a compatibility feature. It has only one property, Lit Mode, that can be set. Most early maps had black floor issue because they didn't know how to set the material correctly, so the Lit Mode was often set to Prelit to get the floor to show up properly. This attribute exists for compatibility with this compromise and the user usually does not need to set this option.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -1,6 +1,6 @@
# Ballance属性 # Ballance属性
Ballance属性有别于Virtools属性它是专门为Ballance制图服务的一系列属性。这些属性寄宿于场景在同一场景中制图不会涉及Blender中的场景切换这些属性不会改变。在`Scene`属性面板可以找到Ballance属性相关的面板如下图所示分别是 Ballance属性有别于Virtools属性它是专门为Ballance制图服务的一系列属性。这些属性寄宿于场景在同一场景中制图不会涉及Blender中的场景切换这些属性不会改变。在`Scene`属性面板可以找到Ballance属性相关的面板如下图所示它们分别是:
* `Ballance Elements`面板红色箭头对应Ballance机关 * `Ballance Elements`面板红色箭头对应Ballance机关
* `BME Materials`面板绿色箭头对应BME材质 * `BME Materials`面板绿色箭头对应BME材质
@ -12,9 +12,9 @@ Ballance属性有别于Virtools属性它是专门为Ballance制图服务的
## Ballance地图信息 ## Ballance地图信息
Ballance地图信息目前只有一个选项Sector地图小节数。此属性指示了当前地图的最终期望小节数。这个属性主要是用于解决导出地图Bug的具体Bug内容可参考导入导出Virtools文档章节。 Ballance地图信息目前只有一个选项Sector地图小节数。此属性指示了当前地图的最终期望小节数。这个属性主要是用于解决导出地图Bug的具体Bug内容可参考[导入导出Virtools文档](./import-export-virtools.md)章节。
你需要做的唯一一件事就是在导出最终地图前检查此字段是否是你期望的小节数。需要注意的是尽管你可以在创建地图的一开始就设置此字段然而BBP中的其它一些功能可能会修改此字段比如添加机关导入Virtools文档等。例如当你的地图小节指定为3你正在添加一个归属于第4小节的机关那么此值会自动增加到4。同理在导入一个总共4小节的Ballance地图时此值也会增加到4如果先前值小于4的话。这主要是为了用户可以在没有感知到此值的情况下使用此插件尤其是在对某些现有地图进行略微修改时。然而如此操作可能会在某些情况下不能满足用户的需求所以仍建议你在导出前检查此字段。 你需要做的唯一一件事就是在导出最终地图前检查此字段是否是你期望的小节数。需要注意的是尽管你可以在创建地图的一开始就设置此字段然而BBP中的其它一些功能可能会修改此字段比如添加机关导入Virtools文档等。例如当你的地图小节指定为3你正在添加一个归属于第4小节的机关那么此值会自动增加到4。同理在导入一个总共4小节的Ballance地图时此值也会增加到4如果先前值小于4的话。这么做主要是为了用户可以在没有感知到此值的情况下使用此插件,尤其是在对某些现有地图进行略微修改时。然而如此操作,可能会在某些情况下不能满足用户的需求,所以仍建议你在导出前检查此字段。
## Ballance机关 ## Ballance机关

View File

@ -2,7 +2,7 @@
## 开始生成 ## 开始生成
在3D视图中点击`Add - Floors`可展开添加机关菜单。菜单如下图所示。 在3D视图中点击`Add - Floors`可展开添加路面菜单。菜单如下图所示。
![](../imgs/bme-adder.png) ![](../imgs/bme-adder.png)

View File

@ -20,7 +20,11 @@ BBP内置了一系列自定义图标以及其组件BME需要的用于描述
## 打包 ## 打包
`bbp_ng`文件夹压缩成ZIP文件即可完成打包工作。需要注意的是下列文件或文件夹不应被打包 从Blender 4.2 LTS开始插件使用Blender自带的打包功能进行打包
假定在项目根目录下执行命令,最终输出文件为`redist/bbp_ng.zip`,那么在命令行窗口中执行`blender --command extension build --source-dir bbp_ng --output-filepath redist/bbp_ng.zip`命令即可完成打包。其中`blender`为Blender的可执行程序。
Blender会根据`blender_manifest.toml`的指示,在排除下列文件的情况下将插件打包:
* `bbp_ng/raw_icons`:原始图片文件夹。 * `bbp_ng/raw_icons`:原始图片文件夹。
* `bbp_ng/raw_jsons`原始JSON文件夹。 * `bbp_ng/raw_jsons`原始JSON文件夹。
@ -30,10 +34,6 @@ BBP内置了一系列自定义图标以及其组件BME需要的用于描述
* `bbp_ng/icons/.gitkeep`:文件夹占位符 * `bbp_ng/icons/.gitkeep`:文件夹占位符
* `bbp_ng/jsons/.gitkeep`:文件夹占位符 * `bbp_ng/jsons/.gitkeep`:文件夹占位符
打包后的ZIP文件打开后如果有且只有`bbp_ng`一个文件夹,则代表打包成功。切勿直接将`bbp_ng` **内部的文件** 直接打包到ZIP文件中。
这样打包后的ZIP文件既可以直接通过Blender插件的安装功能直接安装也可以解压在插件目录下完成安装。
## 生成帮助文档 ## 生成帮助文档
虽然本项目会利用GitHub Page功能提供帮助文档但有时你可能需要提供帮助文档的离线版本本节将会介绍如何生成离线版本的帮助文档。 虽然本项目会利用GitHub Page功能提供帮助文档但有时你可能需要提供帮助文档的离线版本本节将会介绍如何生成离线版本的帮助文档。

View File

@ -7,7 +7,7 @@
## 打开配置面板 ## 打开配置面板
开启Blender选择`Edit - Preferences`,在打开的窗口中转到`Add-ons`选项卡,在`Community`分类下找到BBP插件名称为`Object: Ballance Blender Plugin`。请确保其左侧的勾已被选中,代表插件已被启用。点击勾左侧的三角箭头展开插件详细信息,如图所示,进入配置面板。 开启Blender选择`Edit - Preferences`,在打开的窗口中转到`Add-ons`选项卡,在列表中找到BBP插件名称为`Ballance Blender Plugin`。请确保其左侧的勾已被选中,代表插件已被启用。点击勾左侧的三角箭头展开插件详细信息,如图所示,进入配置面板。
![](../imgs/config-plugin.png) ![](../imgs/config-plugin.png)

View File

@ -25,7 +25,7 @@ Conflict Options冲突解决选项章节指示了当导入器遇到物体
* CP1252非Windows下Ballance所用的西欧编码 * CP1252非Windows下Ballance所用的西欧编码
* CP936非Windows下中文默认编码 * CP936非Windows下中文默认编码
编码属性非常重要如果设置了错误的编码导入Blender的各类物体的名称会出现不可认知的情况 编码属性非常重要如果设置了错误的编码导入Blender的各类物体的名称会出现不可认知的情况
!!! warning "编码是一个平台相关的设定" !!! warning "编码是一个平台相关的设定"
根据BBP的Virtools文档导入模块使用的底层库LibCmo的实现编码属性是一个平台相关的设定。在Windows下这里需要填写的是[Windows代码页](https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers)数字。而在其它操作系统下LibCmo使用iconv进行字符编码解码因此需要使用合法的[iconv编码标识符](https://www.gnu.org/software/libiconv/)。 根据BBP的Virtools文档导入模块使用的底层库LibCmo的实现编码属性是一个平台相关的设定。在Windows下这里需要填写的是[Windows代码页](https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers)数字。而在其它操作系统下LibCmo使用iconv进行字符编码解码因此需要使用合法的[iconv编码标识符](https://www.gnu.org/software/libiconv/)。

View File

@ -2,19 +2,26 @@
## 明确版本 ## 明确版本
BBP对Blender支持的原则是支持当前最新的 **LTS** 版本在最新的LTS版本释出之后会花一些时间迁移插件。当前插件版本 **4.0**基于Blender **3.6.x** 版本。 BBP对Blender支持的原则是支持当前最新的 **LTS** 版本在最新的LTS版本释出之后会花一些时间迁移插件。当前插件版本 **4.0**基于Blender **4.2.x** 版本。
理论上而言如果Blender没有做出重大改动那么BBP可以在其它版本上正常运行。例如你可以尝试在Blender 4.0上运行基于Blender 3.6的BBP插件。但BBP的开发者不会处理仅在非LTS版本中才出现的Bug。在安装插件之前请先选择适合的版本。 理论上而言如果Blender没有做出重大改动那么BBP可以在其它版本上正常运行。例如你可以尝试在Blender 4.0上运行基于Blender 3.6 LTS的BBP插件。但BBP的开发者不会处理仅在非LTS版本中才出现的Bug。在安装插件之前请先选择适合的版本。
## 卸载旧插件 ## 卸载旧插件
如果你之前使用过BBP那么你需要首先卸载它。旧版的BBP通常被安装在下列的位置中 如果你之前使用过BBP那么你需要首先卸载它。旧版的BBP通常被安装在下列的位置中
* `Blender/3.6/scripts/addons/ballance_blender_plugin` * `<Blender>/3.6/scripts/addons/ballance_blender_plugin`BBP 3.0或更低版本
* `Blender/3.6/scripts/addons_contrib/ballance_blender_plugin` * `<Blender>/3.6/scripts/addons_contrib/ballance_blender_plugin`BBP 3.0或更低版本
* `Blender/3.6/scripts/addons/bbp_ng` * `<Blender>/3.6/scripts/addons/bbp_ng`BBP 4.0内测版本
* `%APPDATA%/Blender Foundation/Blender/3.6/scripts/addons/bbp_ng`BBP 4.0内测版本
* `%APPDATA%/Blender Foundation/Blender/4.2/extensions/user_default/bbp_ng`BBP 4.0或更高版本
你只需要删除这些文件夹(如果它们存在的话)即可完全卸载插件。路径中的`Blender`指代你的Blender安装位置。路径中的`3.6`是你安装的Blender的版本号需要根据你安装的版本进行调整本手册均以`3.6`为例 你只需要先在Blender中关闭插件把插件名前面的勾取消然后再删除这些文件夹(如果它们存在的话)即可完全卸载插件。路径中的`<Blender>`指代你的Blender安装位置。路径中的`3.6``4.2`是你安装的Blender的版本号需要根据你安装的版本进行调整后续出现的版本号也按此理解
!!! warning "不应使用Blender的插件卸载功能"
不能使用Blender插件页面的插件卸载功能卸载BBP因为BBP只要被Blender加载无论是否启用都会将Virtools文件读写库BMap加载进Blender。若在Blender运行期间删除会出现拒绝访问错误。因此您必须在关闭Blender后手动删除插件目录。
如果您实在无法确定插件安装到了哪里可以在Blender的偏好设置中的插件页面里找到`File`属性,其指向文件所在的文件夹就是要删除的文件夹。
!!! info "`ballance_blender_plugin``bbp_ng`" !!! info "`ballance_blender_plugin``bbp_ng`"
`ballance_blender_plugin`是旧版BBP插件4.0版本前)的模块名,`bbp_ng`是新版BBP插件4.0版本后包括4.0版本)的模块名。为了保证用户确实删除了旧版插件,所以同时提供了这两者。 `ballance_blender_plugin`是旧版BBP插件4.0版本前)的模块名,`bbp_ng`是新版BBP插件4.0版本后包括4.0版本)的模块名。为了保证用户确实删除了旧版插件,所以同时提供了这两者。
@ -22,6 +29,9 @@ BBP对Blender支持的原则是支持当前最新的 **LTS** 版本,在最新
!!! info "`addons``addons_contrib`" !!! info "`addons``addons_contrib`"
在Blender 3.6 LTS版本即BBP 3.3版本之后Blender不再支持Testing类型插件。因而导致安装Testing插件专用的`addons_contrib`文件夹不再使用,插件需要被统一安装在`addons`中。为了保证用户确实删除了旧版插件,所以同时提供了这两者。 在Blender 3.6 LTS版本即BBP 3.3版本之后Blender不再支持Testing类型插件。因而导致安装Testing插件专用的`addons_contrib`文件夹不再使用,插件需要被统一安装在`addons`中。为了保证用户确实删除了旧版插件,所以同时提供了这两者。
!!! info "`addons``extensions`"
在Blender 4.2 LTS版本Blender使用扩展Extensions而非插件Addons来描述插件。因而导致安装插件的位置也发生了变化。为了保证用户确实删除了旧版插件所以同时提供了这两者。
## 下载插件 ## 下载插件
你可以通过[本工程的GitHub代码库的Release页面](https://github.com/yyc12345/BallanceBlenderHelper/releases)下载最新的插件。插件是以ZIP压缩包形式提供的。 你可以通过[本工程的GitHub代码库的Release页面](https://github.com/yyc12345/BallanceBlenderHelper/releases)下载最新的插件。插件是以ZIP压缩包形式提供的。
@ -36,11 +46,11 @@ BBP对Blender支持的原则是支持当前最新的 **LTS** 版本,在最新
## 安装插件 ## 安装插件
开启Blender选择`Edit - Preferences`,在打开的窗口中转到`Add-ons`选项卡,点击`Install...`按钮选择刚刚下载完毕的ZIP压缩包即可安装完成。若没有在列表中看到可选择刷新按钮或重启Blender。 开启Blender选择`Edit - Preferences`,在打开的窗口中转到`Add-ons`选项卡,点击窗口右上方的箭头,然后点击`Install from Disk...`按钮选择刚刚下载完毕的ZIP压缩包即可安装完成。若没有在列表中看到可点击刷新按钮或重启Blender。
你也可以选择手动安装插件(如果上述安装方法失败了的话),转到`Blender/3.6/scripts/addons`将下载好的ZIP压缩包内容解压到此文件夹下启动Blender即可在插件列表中找到BBP。 你也可以选择手动安装插件(如果上述安装方法失败了的话),转到`%APPDATA%/Blender Foundation/Blender/4.2/extensions/user_default`,创建一个名为`bbp_ng`的文件夹并进入将下载好的ZIP压缩包内容解压到此文件夹下启动Blender即可在插件列表中找到BBP。
BBP插件位于`Community`类别下,名称为`Object: Ballance Blender Plugin`,找到后勾选名称左侧的勾即可启用插件。插件安装成功后的偏好设置页面如下图所示。 BBP插件在列表中的名称为`Ballance Blender Plugin`,找到后勾选名称左侧的勾即可启用插件。插件安装成功后的偏好设置窗口如下图所示。
![](../imgs/config-plugin.png) ![](../imgs/config-plugin.png)

View File

@ -7,7 +7,7 @@
![](../imgs/naming-convention.png) ![](../imgs/naming-convention.png)
本插件目前支持两种命名标准。 本插件目前支持两种命名标准。
其一为技术信息章节已经阐述的制图链标准,在本插件中的名称为`YYC Tools Chains` 其一为[技术信息](./tech-infos.md)章节阐述的制图链标准,在本插件中的名称为`YYC Tools Chains`
其二为[Imengyu/Ballance](https://github.com/imengyu/Ballance)所用命名标准,在本插件中的名称为`Imengyu Ballance` 其二为[Imengyu/Ballance](https://github.com/imengyu/Ballance)所用命名标准,在本插件中的名称为`Imengyu Ballance`
这些功能最终只会展示成功与否的一个概括性消息。如果你需要详细查看某个物体为什么不能转换,请点击`Window - Toggle System Console`,插件在那里有更详细的输出。 这些功能最终只会展示成功与否的一个概括性消息。如果你需要详细查看某个物体为什么不能转换,请点击`Window - Toggle System Console`,插件在那里有更详细的输出。

View File

@ -1,10 +1,10 @@
# 添加钢轨 # 添加钢轨
在3D视图中点击`Add - Components`可展开添加钢轨菜单。菜单如下图左侧所示。 在3D视图中点击`Add - Rails`可展开添加钢轨菜单。菜单如下图左侧所示。
![](../imgs/rail-adder.png) ![](../imgs/rail-adder.png)
上图右侧则展示了一些机关添加的界面会在后续依次介绍它们右侧从上到下分别是添加Rail Section钢轨截面添加Straight Rail直钢轨添加Side Rail侧轨添加Arc Rail圆弧轨添加Spiral Rail螺旋轨 上图右侧则展示了一些钢轨添加的界面会在后续依次介绍它们右侧从上到下分别是添加Rail Section钢轨截面添加Straight Rail直钢轨添加Side Rail侧轨添加Arc Rail圆弧轨添加Spiral Rail螺旋轨
!!! info "非标准数据的钢轨" !!! info "非标准数据的钢轨"
BBP的钢轨添加菜单是为新手玩家快速添加钢轨而设计的并不是为老手添加钢轨而设计的。对于需要非标准数据的钢轨的情况例如具有非标准间距或非标准截面的钢轨你需要通过Blender自带的创建圆操作构建钢轨截面然后通过挤出桥接又或者螺旋修改器生成整个钢轨。在这样的创作过程中你可以随意控制每个步骤的所有参数以满足你对钢轨参数的特殊需求。 BBP的钢轨添加菜单是为新手玩家快速添加钢轨而设计的并不是为老手添加钢轨而设计的。对于需要非标准数据的钢轨的情况例如具有非标准间距或非标准截面的钢轨你需要通过Blender自带的创建圆操作构建钢轨截面然后通过挤出桥接又或者螺旋修改器生成整个钢轨。在这样的创作过程中你可以随意控制每个步骤的所有参数以满足你对钢轨参数的特殊需求。
@ -16,7 +16,7 @@
## 钢轨截面 ## 钢轨截面
在添加机关菜单中,`Sections`分类下的是钢轨截面的添加。钢轨截面是钢轨的轮廓,钢轨截面的创建通常是各类异形钢轨的创建的开始步骤,例如通过放样,挤出等操作制作钢轨。 在添加钢轨菜单中,`Sections`分类下的是钢轨截面的添加。钢轨截面是钢轨的轮廓,钢轨截面的创建通常是各类异形钢轨的创建的开始步骤,例如通过放样,挤出等操作制作钢轨。
### Rail Section ### Rail Section
@ -30,7 +30,7 @@
## 直线钢轨 ## 直线钢轨
在添加机关菜单中,`Straight Rails`分类下的是直线钢轨的添加。 在添加钢轨菜单中,`Straight Rails`分类下的是直线钢轨的添加。
### Straight Rail ### Straight Rail
@ -52,7 +52,7 @@
## 曲线钢轨 ## 曲线钢轨
在添加机关菜单中,`Curve Rails`分类下的是曲线钢轨的添加。 在添加钢轨菜单中,`Curve Rails`分类下的是曲线钢轨的添加。
### Arc Rail ### Arc Rail
@ -78,4 +78,4 @@
侧边螺旋轨没有螺距属性,因为侧边螺旋轨在设计上,相邻的旋进是共用一条边的,因此螺距是固定的。 侧边螺旋轨没有螺距属性,因为侧边螺旋轨在设计上,相邻的旋进是共用一条边的,因此螺距是固定的。
侧边螺旋轨设定中的Radius半径Iterations迭代和Steps步数属性含义均与螺旋轨一致。螺旋轨也有封盖属性。 侧边螺旋轨设定中的Radius半径Iterations迭代和Steps步数属性含义均与螺旋轨一致。侧边螺旋轨也有封盖属性。

View File

@ -12,7 +12,7 @@ BBP不是完美的由于BBP的Virtools文件导入导出模块是由C++编写
## 哪部分出错了 ## 哪部分出错了
对于BBP插件而言如果你在Python异常输出中观察到类似于`BMap operation failed`的字样,或者在`Blender/3.6/scripts/addons/bbp_ng/PyBMap`文件夹下观察到了`IronPad.log`文件则说明BBP插件的由C++编写的BMap部分出错了**你需要立即保存你当前的Blender文档并退出Blender。** 因为此时插件已处于非正常状态,你不应继续任何操作。 对于BBP插件而言如果你在Python异常输出中观察到类似于`BMap operation failed`的字样,或者在`<插件安装位置>/PyBMap`文件夹下观察到了`IronPad.log`文件则说明BBP插件的由C++编写的BMap部分出错了**你需要立即保存你当前的Blender文档并退出Blender。** 因为此时插件已处于非正常状态,你不应继续任何操作。
如果并没有上述情况那么这就只是普通的Python代码执行错误不需要过度担心但错误仍然是致命的建议做完所有必要的操作后退出Blender并报告错误。 如果并没有上述情况那么这就只是普通的Python代码执行错误不需要过度担心但错误仍然是致命的建议做完所有必要的操作后退出Blender并报告错误。
@ -20,10 +20,10 @@ BBP不是完美的由于BBP的Virtools文件导入导出模块是由C++编写
如果你有GitHub账户你可以在[BBP的存储库的Issue页面](https://github.com/yyc12345/BallanceBlenderHelper/issues)中创建并汇报问题。 如果你有GitHub账户你可以在[BBP的存储库的Issue页面](https://github.com/yyc12345/BallanceBlenderHelper/issues)中创建并汇报问题。
如果做不到,则直接汇报给插件作者也是可以的。 如果做不到,且你有合适的渠道可以联系到插件作者,则直接汇报给插件作者也是可以的。
## 报告的内容 ## 报告的内容
首先你需要详细描述你是如何发这个错误的,这个错误有什么结果。如果可以上传导致错误的文档,请尽量上传(如果不方便公开发布,可以通过邮件等私有渠道发送给作者)。 首先你需要详细描述你是如何发这个错误的,这个错误有什么结果。如果可以上传导致错误的文档,请尽量上传(如果不方便公开发布,可以通过邮件等私有渠道发送给作者)。
你还需要提供Blender控制台中输出的Python堆栈报告使用`Window - Toggle System Console`打开控制台。如果你的错误是BMap部分的错误你还需要提供`Blender/3.6/scripts/addons/bbp_ng/PyBMap`文件夹下的`IronPad.log``IronPad.dmp`文件以方便开发者定位错误。 你还需要提供Blender控制台中输出的Python堆栈报告使用`Window - Toggle System Console`打开控制台。如果你的错误是BMap部分的错误你还需要提供`<插件安装位置>/PyBMap`文件夹下的`IronPad.log``IronPad.dmp`文件以方便开发者定位错误。

View File

@ -4,4 +4,9 @@
* 制图工具链标准及`meshes`文件夹下的文件的格式https://github.com/yyc12345/gist/blob/master/BMFileSpec/YYCToolsChainSpec_ZH.md * 制图工具链标准及`meshes`文件夹下的文件的格式https://github.com/yyc12345/gist/blob/master/BMFileSpec/YYCToolsChainSpec_ZH.md
* BMERevenge的JSON文件的格式https://github.com/yyc12345/gist/blob/master/BMERevenge/DevDocument_v2.0_ZH.md * BMERevenge的JSON文件的格式https://github.com/yyc12345/gist/blob/master/BMERevenge/DevDocument_v2.0_ZH.md
本插件配合了`fake-bpy-module`模块来实现类型提示以加快开发速度。本插件目前基于Blender 3.6,因此使用`pip install fake-bpy-module-latest==20230627`来安装Blender的类型提示库。 这主要是因为`fake-bpy-module`没有发布官方的适用于Blender 3.6的包因此我只能通过选择最接近Blender 3.6版本发布时间的每日编译版本来安装它 本插件配合了`fake-bpy-module`模块来实现类型提示以加快开发速度。使用如下命令来安装Blender的类型提示库
* Blender 3.6: `pip install fake-bpy-module-latest==20230627`
* Blender 4.2: `pip install fake-bpy-module-latest==20240716`
这么做主要是因为`fake-bpy-module`没有发布官方的适用于指定Blender版本的包因此我只能通过选择最接近Blender对应版本发布时间的每日编译版本来安装它。

View File

@ -15,7 +15,7 @@
沿边沿贴图是BBP插件的最重要的功能最强大的功能同时也是最难以理解的功能。它广泛应用于自定义结构或一行路面木板的UV的设置。3D视图中的菜单`Ballance - Flatten UV`提供的就是沿边沿贴图功能。它只能在 **编辑模式** 下工作,因此你需要进入编辑模式(并同时进入面选择模式,因为沿边沿贴图是按面操作的)才能使用它。 沿边沿贴图是BBP插件的最重要的功能最强大的功能同时也是最难以理解的功能。它广泛应用于自定义结构或一行路面木板的UV的设置。3D视图中的菜单`Ballance - Flatten UV`提供的就是沿边沿贴图功能。它只能在 **编辑模式** 下工作,因此你需要进入编辑模式(并同时进入面选择模式,因为沿边沿贴图是按面操作的)才能使用它。
沿边沿贴图通常与[选择循环面](https://docs.blender.org/manual/en/3.6/modeling/meshes/selecting/loops.html)[选择最短路径](https://docs.blender.org/manual/en/3.6/modeling/meshes/selecting/linked.html#bpy-ops-mesh-shortest-path-select)等功能一起使用。你需要先选择一系列面例如一系列连续的Ballance路面侧边然后点击`Ballance - Flatten UV`开始进行沿边沿贴图。 沿边沿贴图通常与[选择循环面](https://docs.blender.org/manual/en/4.2/modeling/meshes/selecting/loops.html)[选择最短路径](https://docs.blender.org/manual/en/4.2/modeling/meshes/selecting/linked.html#bpy-ops-mesh-shortest-path-select)等功能一起使用。你需要先选择一系列面例如一系列连续的Ballance路面侧边然后点击`Ballance - Flatten UV`开始进行沿边沿贴图。
沿边沿贴图的配置界面如下图所示左侧是Scale Size缩放数值模式右侧是Ref. Point参考点模式我们稍后会说明这两个模式的区别。 沿边沿贴图的配置界面如下图所示左侧是Scale Size缩放数值模式右侧是Ref. Point参考点模式我们稍后会说明这两个模式的区别。
@ -23,14 +23,14 @@
沿边沿贴图顾名思义其含义就是沿着某条边进行UV贴图。具体的操作就是利用线性代数的方法使用过渡矩阵将顶点的三维坐标转换到一个新的坐标系下。在这个新的坐标系中 沿边沿贴图顾名思义其含义就是沿着某条边进行UV贴图。具体的操作就是利用线性代数的方法使用过渡矩阵将顶点的三维坐标转换到一个新的坐标系下。在这个新的坐标系中
* 原点是Reference Edge参考边指定的号的顶点如下图所示。下图在UV和3D中用黄色字体标识了面的顶点序号图中的Reference Edge为1则当前面中顶点序号为1的顶点作为新坐标系的原点。 * 原点是Reference Edge参考边指定的号的顶点如下图所示。下图在UV和3D中用黄色字体标识了面的顶点序号图中的Reference Edge为1则当前面中顶点序号为1的顶点作为新坐标系的原点。
* Y轴即V轴XYZ对应UVW后续不再注释为Reference Edge指定的顶点到下一个顶点的连线即顶点1到顶点2的边也就是序号为1的边如下图所示下图UV和3D中用紫色字体标识了面的边序号。边1是以顶点1为起始点顶点2为终点的一个向量。它有方向性是向量用作坐标轴时需要归一化。 * Y轴即V轴XYZ对应UVW后续不再注释为Reference Edge指定的顶点到下一个顶点的连线即顶点1到顶点2的边也就是序号为1的边如下图所示下图UV和3D中用紫色字体标识了面的边序号。边1是以顶点1为起始点顶点2为终点的一个向量。它有方向性是向量用作坐标轴时需要归一化。
* Z轴则是通过Reference Edge指定的边在这里是边1和其下一条相邻边在这里是边2做叉乘并归一化得出。如果发生三点共线叉乘出零向量的情况则会尝试使用面的法线数据取而代之。 * Z轴则是通过Reference Edge指定的边在这里是边1和其下一条相邻边在这里是边2做叉乘并归一化得出。如果发生三点共线叉乘出零向量的情况则会尝试使用面的法线数据取而代之。
* X轴由之前计算出的Y轴和Z轴做叉乘并归一化后得出。新坐标系下的XYZ仍然需要满足右手坐标系的要求。 * X轴由之前计算出的Y轴和Z轴做叉乘并归一化后得出。新坐标系下的XYZ仍然需要满足右手坐标系的要求。
![](../imgs/flatten-uv-mechanism.png) ![](../imgs/flatten-uv-mechanism.png)
建立完新坐标系并构建完过渡矩阵后并将每一个顶点都转换到新坐标系下后我们便可丢弃Z分量将XY映射到UV上并同时将处于-U轴侧的顶点镜像到+U轴侧这也是Flatten UV不支持凹多边形的原因。做镜像的原因是为了防止UV映射出错例如上图中路面侧边贴图的上沿花纹位于V轴如果我们将上图中UV顶点沿V轴翻转你可以试一试加深理解则会导致最终贴图显示不符合我们预期即Reference Edge指定的边并不显示路面侧边花纹。 建立完新坐标系并构建完过渡矩阵后并将每一个顶点都转换到新坐标系下后我们便可丢弃Z分量将XY映射到UV上并同时将处于-U轴侧的顶点镜像到+U轴侧这也是Flatten UV不支持凹多边形的原因。做镜像的原因是为了防止UV映射出错例如上图中路面侧边贴图的上沿花纹位于V轴如果我们将上图中UV顶点沿V轴翻转你可以试一试加深理解则会导致最终贴图显示不符合我们预期即Reference Edge指定的边并不显示路面侧边花纹。
!!! info "Reference Edge的实指" !!! info "Reference Edge的实指"
Reference Edge实际上指代的就是那条需要被贴靠到V轴上的边的序号。又因为这条边具有方向性同时也就决定了新坐标系中的原点。 Reference Edge实际上指代的就是那条需要被贴靠到V轴上的边的序号。又因为这条边具有方向性同时也就决定了新坐标系中的原点。

View File

@ -20,7 +20,7 @@ BBP还在Blender的其它菜单提供了对Virtools组的访问具体内容
`Virtools Material`面板提供了预设功能,点击顶部的`Preset`按钮即可开始进行预设。预设功能允许用户使用一些预设的材质设置,例如路面顶面,侧面的材质数据等,方便使用。需要注意的是,使用预设不会影响材质的贴图选项,当应用预设后,你仍然需要手动设置材质的贴图。 `Virtools Material`面板提供了预设功能,点击顶部的`Preset`按钮即可开始进行预设。预设功能允许用户使用一些预设的材质设置,例如路面顶面,侧面的材质数据等,方便使用。需要注意的是,使用预设不会影响材质的贴图选项,当应用预设后,你仍然需要手动设置材质的贴图。
`Virtools Material`面板同样提供把`Virtools Material`面板中的材质数据反应到Blender材质上的功能以在Blender中获得可视的效果。点击顶部的`Apply`按钮即可执行此功能。当你在Blender中保存Virtools文档时Virtools文档中的材质数据将从`Virtools Material`面板中指定的数值获取而不会从Blender材质中获取。这意味一个正确的材质设置过程是先在`Virtools Material`面板中编辑材质参数,然后使用`Apply`按钮将其反映到Blender材质上而不是直接去编辑Blender材质。 `Virtools Material`面板同样提供把`Virtools Material`面板中的材质数据转换到Blender材质上的功能以在Blender中获得可视的效果。点击顶部的`Apply`按钮即可执行此功能。当你在Blender中保存Virtools文档时Virtools文档中的材质数据将从`Virtools Material`面板中指定的数值获取而不会从Blender材质中获取。这意味一个正确的材质设置过程是先在`Virtools Material`面板中编辑材质参数,然后使用`Apply`按钮将其转换到Blender材质上而不是直接去编辑Blender材质。
`Virtools Material`面板提供了材质修复功能,这个功能来源于[Ballance Virtools Plugin](https://github.com/yyc12345/BallanceVirtoolsHelper)。材质修复按钮位于`Preset`按钮和`Apply`按钮的右侧是一个带有扳手图标的按钮。点击后需要再次确认才能使用防止误操作。材质修复功能会根据当前材质引用的贴图文件的文件名判定它是哪一种类型的材质再根据我们预设的修复设定从游戏中获取将其他参数修改得符合视觉要求。这通常用于一些游戏中看起来材质错误的物体的修复例如发黑的Stopper等。 `Virtools Material`面板提供了材质修复功能,这个功能来源于[Ballance Virtools Plugin](https://github.com/yyc12345/BallanceVirtoolsHelper)。材质修复按钮位于`Preset`按钮和`Apply`按钮的右侧是一个带有扳手图标的按钮。点击后需要再次确认才能使用防止误操作。材质修复功能会根据当前材质引用的贴图文件的文件名判定它是哪一种类型的材质再根据我们预设的修复设定从游戏中获取将其他参数修改得符合视觉要求。这通常用于一些游戏中看起来材质错误的物体的修复例如发黑的Stopper等。
@ -29,7 +29,7 @@ BBP还在Blender的其它菜单提供了对Virtools组的访问具体内容
全局材质修复功能点击后也需再次确认才能使用,以防止误操作。 全局材质修复功能点击后也需再次确认才能使用,以防止误操作。
`Virtools Material`面板中的Texture贴图属性不仅可以通过点击它来选择文档内的材质还可以通过点击右侧的文件夹按钮打开贴图文件浏览器直接从文件系统中选择你想要的贴图比从Shading菜单中选取更加快速。文件浏览器默认位于Ballance的Texture目录下以方便Ballance材质的选取。 `Virtools Material`面板中的Texture贴图属性不仅可以通过点击它来选择文档内的贴图还可以通过点击右侧的文件夹按钮打开贴图文件浏览器直接从文件系统中选择你想要的贴图比从Shading菜单中选取更加快速。文件浏览器默认位于Ballance的Texture目录下以方便Ballance材质的选取。
## Virtools贴图 ## Virtools贴图
@ -43,7 +43,7 @@ BBP插件为所有Blender贴图实际上是Image添加了新的属性
* External外部存储文件只存储引用的文件名。所有Ballance原生贴图都应该使用此模式。 * External外部存储文件只存储引用的文件名。所有Ballance原生贴图都应该使用此模式。
* Raw Data原始数据贴图存储在文件内缺点是会导致文件很大。所有非原生Ballance贴图都应该使用此模式。 * Raw Data原始数据贴图存储在文件内缺点是会导致文件很大。所有非原生Ballance贴图都应该使用此模式。
* Use Global使用全局设定。除非是正在修改地图否则我们不建议使用此方式。我们建议在这里就明确指定各个贴图的存储方式而不要使用全局值。全局设定在导出Virtools文档时被确定下来。 * Use Global使用全局设定。除非是正在修改一张已经存在地图否则我们不建议使用此方式。我们建议在这里就明确指定各个贴图的存储方式而不要使用全局值。全局设定在导出Virtools文档时被确定下来。
而Video Format表示贴图在Virtools中的渲染模式常用的模式有这几种 而Video Format表示贴图在Virtools中的渲染模式常用的模式有这几种