Sergiu 8 месяцев назад
Родитель
Сommit
6f019e9136

+ 0 - 0
01_backend/ap/database/users.json


+ 22 - 0
01_backend/database/brands.json

@@ -0,0 +1,22 @@
+[
+    {
+        "id": 2001,
+        "name": "AP"
+    },
+    {
+        "id": 2002,
+        "name": "Innisfree"
+    },
+    {
+        "id": 2003,
+        "name": "Lanaige"
+    },
+    {
+        "id": 2004,
+        "name": "RYO"
+    },
+    {
+        "id": 2005,
+        "name": "Sulwhasoo"
+    }
+]

+ 107 - 0
01_backend/database/categories.json

@@ -0,0 +1,107 @@
+[
+    {
+        "id": 3001,
+        "brandId": 2005,
+        "name": "Bubbles"
+    },
+    {
+        "id": 3002,
+        "brandId": 2005,
+        "name": "TablesAndDisplay"
+    },
+    {
+        "id": 3003,
+        "brandId": 2005,
+        "name": "Water"
+    },
+    {
+        "id": 3004,
+        "brandId": 2003,
+        "name": "Bubbles"
+    },
+    {
+        "id": 3005,
+        "brandId": 2003,
+        "name": "CampaignElements"
+    },
+    {
+        "id": 3006,
+        "brandId": 2003,
+        "name": "Light"
+    },
+    {
+        "id": 3007,
+        "brandId": 2003,
+        "name": "Liquids"
+    },
+    {
+        "id": 3008,
+        "brandId": 2003,
+        "name": "Molecular"
+    },
+    {
+        "id": 3009,
+        "brandId": 2003,
+        "name": "TablesAndDisplay"
+    },
+    {
+        "id": 3010,
+        "brandId": 2002,
+        "name": "Bubbles"
+    },
+    {
+        "id": 3011,
+        "brandId": 2002,
+        "name": "LabEquipment"
+    },
+    {
+        "id": 3012,
+        "brandId": 2002,
+        "name": "Liquid"
+    },
+    {
+        "id": 3013,
+        "brandId": 2002,
+        "name": "Molecular"
+    },
+    {
+        "id": 3014,
+        "brandId": 2002,
+        "name": "Plants"
+    },
+    {
+        "id": 3015,
+        "brandId": 2002,
+        "name": "Rock"
+    },
+    {
+        "id": 3016,
+        "brandId": 2002,
+        "name": "Skin"
+    },
+    {
+        "id": 3017,
+        "brandId": 2002,
+        "name": "TablesAndDisplay"
+    },
+    {
+        "id": 3018,
+        "brandId": 2004,
+        "name": "Bubbles"
+    },
+    {
+        "id": 3019,
+        "brandId": 2004,
+        "name": "CampaignElements"
+    },
+    {
+        "id": 3020,
+        "brandId": 2004,
+        "name": "Flower"
+    },
+    {
+        "id": 3021,
+        "brandId": 2004,
+        "name": "LabEquipment"
+    }
+]

+ 54 - 0
01_backend/database/users.json

@@ -0,0 +1,54 @@
+[
+    {
+        "id": 1001,
+        "isAdmin": 1,
+        "brandList": [
+            {
+                "id": 1001,
+                "status": 1
+            },
+            {
+                "id": 1002,
+                "status": 1
+            },
+            {
+                "id": 1003,
+                "status": 1
+            },
+            {
+                "id": 1004,
+                "status": 1
+            },
+            {
+                "id": 1005,
+                "status": 1
+            }
+        ]
+    },
+    {
+        "id": 1002,
+        "isAdmin": 0,
+        "brandList": [
+            {
+                "id": 1001,
+                "status": 0
+            },
+            {
+                "id": 1002,
+                "status": 1
+            },
+            {
+                "id": 1003,
+                "status": 1
+            },
+            {
+                "id": 1004,
+                "status": 0
+            },
+            {
+                "id": 1005,
+                "status": 0
+            }
+        ]
+    }
+]

+ 111 - 1
03_blender/sd_blender/__init__.py

@@ -24,6 +24,7 @@ else:
     import os
     import base64
     import numpy as np
+    import shutil
 
     # from . import zs_renderscene as zsrs  # noqa
 
@@ -519,7 +520,12 @@ def create_cameras(scene_data):
 
         # Add the camera to the 05_Cameras collection
         collection.objects.link(camera)
-        bpy.context.scene.collection.objects.unlink(camera)
+
+        # Unlink the camera from the scene collection
+        # check all objects in scene collection, if camera is there, unlink it
+        for obj in bpy.context.scene.collection.objects:
+            if obj.name == camera.name:
+                bpy.context.scene.collection.objects.unlink(camera)
 
         # Set the camera as the active camera if "active" is true
         if camera_data["properties"]["active"]:
@@ -911,6 +917,107 @@ def export_scene_to_glb(self):
     print(f"Exported to {glb_export_path}")
 
 
+def copy_and_relink_textures(collection_name):
+    # Ensure the target directory exists
+    target_directory = bpy.path.abspath("//..")
+    textures_directory = os.path.join(target_directory, "0_Textures")
+    os.makedirs(textures_directory, exist_ok=True)
+
+    # Get the collection
+    collection = bpy.data.collections.get(collection_name)
+    if not collection:
+        print(f"Collection '{collection_name}' not found.")
+        return
+
+    # Iterate through each object in the collection
+    for obj in collection.objects:
+        if obj.type != "MESH":
+            continue
+
+        # Iterate through each material of the object
+        for mat_slot in obj.material_slots:
+            material = mat_slot.material
+            if not material:
+                continue
+
+            # Check if the material contains any image textures
+            if material.use_nodes:
+                for node in material.node_tree.nodes:
+                    if node.type == "TEX_IMAGE":
+                        image = node.image
+                        if image:
+                            # Copy the image texture to the target directory
+                            src_path = bpy.path.abspath(image.filepath)
+                            filename = os.path.basename(src_path)
+                            dest_path = os.path.join(textures_directory, filename)
+
+                            # Check if the source and destination paths are the same
+                            if os.path.abspath(src_path) != os.path.abspath(dest_path):
+                                # Check if the file already exists in the destination directory
+                                if not os.path.exists(dest_path):
+                                    shutil.copy(src_path, dest_path)
+                                else:
+                                    print(
+                                        f"File '{filename}' already exists in '{textures_directory}', relinking."
+                                    )
+
+                            # Relink the image texture to the new location
+                            image.filepath = bpy.path.relpath(dest_path)
+                            image.reload()
+
+    print(f"Textures copied and relinked to '{textures_directory}'.")
+
+
+def set_assets_render_output_paths():
+    # Get the current scene
+    scene = bpy.context.scene
+    target_directory = bpy.path.abspath("//..")
+    custom_folder = os.path.join(target_directory, "PNG")
+    blender_file_name = os.path.splitext(bpy.path.basename(bpy.data.filepath))[0]
+
+    components = blender_file_name.split("_")
+    if len(components) != 7:
+        raise ValueError(
+            "Blender file name must be in the format 'Brand_AssetName_Year_ContentUsage_ContentType_AssetType_AssetNumber'"
+        )
+
+    brand = components[0]
+    asset_name = components[1]
+    year = components[2]
+    content_usage = components[3]
+    content_type = components[4]
+    asset_type = components[5]
+    asset_number = components[6]
+
+    imag_asset_type = "IMG"
+
+    # Construct the new .blend file name
+    image_name = f"{brand}_{asset_name}_{year}_{content_usage}_{content_type}_{imag_asset_type}_{asset_number}_"
+
+    # Ensure the scene has a compositor node tree
+    if not scene.use_nodes:
+        print("Scene does not use nodes.")
+        return
+
+    node_tree = scene.node_tree
+
+    # Search for the ZS_Canvas_Output group node
+    for node in node_tree.nodes:
+        if node.type == "GROUP" and node.node_tree.name == "ZS_Canvas_Output":
+            # Check inside the group for all file output nodes
+            for sub_node in node.node_tree.nodes:
+                if sub_node.type == "OUTPUT_FILE":
+                    # Set the base_path to the custom folder
+                    sub_node.base_path = custom_folder
+
+                    # Set the path for each file output slot to the Blender file name
+
+                    for output in sub_node.file_slots:
+                        output.path = image_name
+
+    print("Output paths set.")
+
+
 # -------------------------------------------------------------------
 # Operators
 # -------------------------------------------------------------------
@@ -932,6 +1039,9 @@ class ZSSD_OT_ExportAssets(bpy.types.Operator):
     bl_description = "Export Scene Assets to FBX and GLB"
 
     def execute(self, context):
+        copy_and_relink_textures("NonConfigurable")
+        copy_and_relink_textures("WebGL")
+        set_assets_render_output_paths()
         export_scene_to_fbx(self)
         export_scene_to_glb(self)
         return {"FINISHED"}

BIN
03_blender/sd_blender/__pycache__/__init__.cpython-311.pyc


+ 1 - 0
03_blender/sd_blender/zs_ai_pre_3d_render_script.py

@@ -30,6 +30,7 @@ def update_3d_image_task_status(row_id, new_status):
         return None
 
 
+
 def __main__(*args):
     deadlinePlugin = args[0]
     job = deadlinePlugin.GetJob()