Introduce Surface Creation Kit

This commit is contained in:
D4rkl1ght3r
2025-09-20 23:05:34 +02:00
parent 95e0db441b
commit 992465295d

View File

@@ -66,8 +66,8 @@ class RenameObjectsAndMeshesOperator(bpy.types.Operator):
class RenameChildObjectOperator(bpy.types.Operator): class RenameChildObjectOperator(bpy.types.Operator):
bl_idname = "object.rename_selected_child" bl_idname = "object.rename_selected_child"
bl_label = "Rename Selected Child (Hulls/Sur) Objects" bl_label = "Convert to Hulls/Sur Objects"
bl_description = "Rename the mesh data of the selected child object and assign a new suffix, filling gaps" bl_description = "Select Child Objects and assign to hull suffix"
def execute(self, context): def execute(self, context):
scene = context.scene scene = context.scene
@@ -95,7 +95,7 @@ class RenameChildObjectOperator(bpy.types.Operator):
used_suffixes = sorted(set(used_suffixes)) used_suffixes = sorted(set(used_suffixes))
suffixes_to_use = [] suffixes_to_use = []
# Fill in gaps starting from 1 # Fill in gaps starting from 0
expected_suffix = 0 expected_suffix = 0
for suffix in used_suffixes: for suffix in used_suffixes:
while expected_suffix < suffix: while expected_suffix < suffix:
@@ -103,6 +103,28 @@ class RenameChildObjectOperator(bpy.types.Operator):
expected_suffix += 1 expected_suffix += 1
expected_suffix = suffix + 1 expected_suffix = suffix + 1
# Prepare the special material
material_name = "material_0x00000000"
material = bpy.data.materials.get(material_name)
if material is None:
material = bpy.data.materials.new(name=material_name)
# Set viewport display color
material.diffuse_color = (1.0, 0.0, 0.0, 0.5) # RGBA
# For newer Blender versions, ensure the viewport display color is set
if hasattr(material, 'viewport_color'):
material.viewport_color = (1.0, 0.0, 0.0)
# Set material display options
material.blend_method = 'BLEND' # ensure transparency is visible
# For Eevee, ensure transparency is enabled
# (optional, depending on your render engine)
# Assign the material to each selected child object
for obj in selected_children:
# Assign the material
if obj.type == 'MESH':
if material.name not in [mat.name for mat in obj.data.materials]:
obj.data.materials.append(material)
# Now, assign suffixes: # Now, assign suffixes:
suffix_index = 0 suffix_index = 0
@@ -158,7 +180,7 @@ class LancerEditHelpersPanel(bpy.types.Panel):
# Section for renaming selected child object # Section for renaming selected child object
layout.separator() layout.separator()
layout.label(text="Rename Selected Child (Hulls/Sur) Objects") layout.label(text="Surface Creation Kit")
layout.prop(scene, "child_object_new_name") layout.prop(scene, "child_object_new_name")
layout.operator("object.rename_selected_child") layout.operator("object.rename_selected_child")
@@ -179,7 +201,7 @@ def register():
default="" default=""
) )
bpy.types.Scene.child_object_new_name = bpy.props.StringProperty( bpy.types.Scene.child_object_new_name = bpy.props.StringProperty(
name="Change Name", name="Sur Name",
description="New name for the selected child object", description="New name for the selected child object",
default="" default=""
) )