|  | @@ -416,73 +416,94 @@ def set_environment(scene_data):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def create_cameras(scene_data):
 | 
	
		
			
				|  |  | -    # # Get the 05_Cameras collection, or create it if it doesn't exist
 | 
	
		
			
				|  |  | +    # Get the 05_Cameras collection, or create it if it doesn't exist
 | 
	
		
			
				|  |  |      collection_name = "05_Cameras"
 | 
	
		
			
				|  |  |      if collection_name in bpy.data.collections:
 | 
	
		
			
				|  |  |          collection = bpy.data.collections[collection_name]
 | 
	
		
			
				|  |  |      else:
 | 
	
		
			
				|  |  |          return
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    for camera_data in scene_data["scene"]["cameras"]:
 | 
	
		
			
				|  |  | +        if camera_data["properties"]["active"]:
 | 
	
		
			
				|  |  | +            # Create a new camera object
 | 
	
		
			
				|  |  | +            # bpy.ops.object.camera_add()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -# Assuming `scene_data` and `collection` are already defined
 | 
	
		
			
				|  |  | -for camera_data in scene_data["scene"]["cameras"]:
 | 
	
		
			
				|  |  | -    # Create a new camera object
 | 
	
		
			
				|  |  | -    bpy.ops.object.camera_add()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Get the newly created camera
 | 
	
		
			
				|  |  | -    camera = bpy.context.object
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera's name
 | 
	
		
			
				|  |  | -    camera.name = camera_data["name"]
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera's position
 | 
	
		
			
				|  |  | -    position = camera_data["properties"]["transform"]["position"]
 | 
	
		
			
				|  |  | -    camera.location.x = position[0]
 | 
	
		
			
				|  |  | -    camera.location.y = -position[2]
 | 
	
		
			
				|  |  | -    camera.location.z = position[1]
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera's rotation
 | 
	
		
			
				|  |  | -    rotation = camera_data["properties"]["transform"]["rotation"]
 | 
	
		
			
				|  |  | -    local_rotation = Euler(
 | 
	
		
			
				|  |  | -        (
 | 
	
		
			
				|  |  | -            math.radians(rotation[0]),
 | 
	
		
			
				|  |  | -            math.radians(rotation[1]),
 | 
	
		
			
				|  |  | -            math.radians(rotation[2]),
 | 
	
		
			
				|  |  | -        ),
 | 
	
		
			
				|  |  | -        "XYZ",
 | 
	
		
			
				|  |  | -    )
 | 
	
		
			
				|  |  | +            camera = bpy.data.objects["Camera"]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Get the newly created camera
 | 
	
		
			
				|  |  | +            # camera = bpy.context.object
 | 
	
		
			
				|  |  | +            camera_position = bpy.data.objects["Camera_Transform"]
 | 
	
		
			
				|  |  | +            camera_rotation = bpy.data.objects["Camera_Rotation"]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            position = camera_data["properties"]["transform"]["position"]
 | 
	
		
			
				|  |  | +            camera_position.location.x = position[0]
 | 
	
		
			
				|  |  | +            camera_position.location.y = -position[2]
 | 
	
		
			
				|  |  | +            camera_position.location.z = position[1]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            rotation = camera_data["properties"]["transform"]["rotation"]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            rotation_euler = Euler(
 | 
	
		
			
				|  |  | +                (
 | 
	
		
			
				|  |  | +                    math.radians(rotation[0] - 90),
 | 
	
		
			
				|  |  | +                    math.radians(rotation[2]),
 | 
	
		
			
				|  |  | +                    math.radians(rotation[1]),
 | 
	
		
			
				|  |  | +                ),
 | 
	
		
			
				|  |  | +                "XYZ",
 | 
	
		
			
				|  |  | +            )
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    # Apply the local rotation to the camera
 | 
	
		
			
				|  |  | -    camera.rotation_euler = local_rotation
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Update the camera's matrix_world to apply the local transformation
 | 
	
		
			
				|  |  | -    camera.matrix_world = camera.matrix_basis
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Calculate the global rotation
 | 
	
		
			
				|  |  | -    global_rotation = camera.matrix_world.to_euler()
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera's rotation to the global rotation
 | 
	
		
			
				|  |  | -    camera.rotation_euler = global_rotation
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera's lens properties
 | 
	
		
			
				|  |  | -    lens = camera_data["properties"]["lens"]
 | 
	
		
			
				|  |  | -    type_mapping = {
 | 
	
		
			
				|  |  | -        "PERSPECTIVE": "PERSP",
 | 
	
		
			
				|  |  | -        "ORTHOGRAPHIC": "ORTHO",
 | 
	
		
			
				|  |  | -        "PANORAMIC": "PANO",
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    camera.data.type = type_mapping.get(lens["type"].upper(), "PERSP")
 | 
	
		
			
				|  |  | -    camera.data.angle = math.radians(lens["fov"])
 | 
	
		
			
				|  |  | -    camera.data.clip_start = lens["near"]
 | 
	
		
			
				|  |  | -    camera.data.clip_end = lens["far"]
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Add the camera to the 05_Cameras collection
 | 
	
		
			
				|  |  | -    collection.objects.link(camera)
 | 
	
		
			
				|  |  | -    bpy.context.scene.collection.objects.unlink(camera)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    # Set the camera as the active camera if "active" is true
 | 
	
		
			
				|  |  | -    if camera_data["properties"]["active"]:
 | 
	
		
			
				|  |  | -        bpy.context.scene.camera = camera
 | 
	
		
			
				|  |  | +            camera_rotation.rotation_euler = rotation_euler
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Set the camera's name
 | 
	
		
			
				|  |  | +            # camera.name = camera_data["name"]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Set the camera's position
 | 
	
		
			
				|  |  | +            # position = camera_data["properties"]["transform"]["position"]
 | 
	
		
			
				|  |  | +            # camera.location.x = position[0]
 | 
	
		
			
				|  |  | +            # camera.location.y = -position[2]
 | 
	
		
			
				|  |  | +            # camera.location.z = position[1]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Set the camera's rotation
 | 
	
		
			
				|  |  | +            # rotation = camera_data["properties"]["transform"]["rotation"]
 | 
	
		
			
				|  |  | +            # local_rotation = Euler(
 | 
	
		
			
				|  |  | +            #     (
 | 
	
		
			
				|  |  | +            #         math.radians(rotation[0]),
 | 
	
		
			
				|  |  | +            #         math.radians(rotation[1]),
 | 
	
		
			
				|  |  | +            #         math.radians(rotation[2]),
 | 
	
		
			
				|  |  | +            #     ),
 | 
	
		
			
				|  |  | +            #     "XYZ",
 | 
	
		
			
				|  |  | +            # )
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # # Apply the local rotation to the camera
 | 
	
		
			
				|  |  | +            # camera.rotation_euler = local_rotation
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # # Update the camera's matrix_world to apply the local transformation
 | 
	
		
			
				|  |  | +            # camera.matrix_world = camera.matrix_basis
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # # Calculate the global rotation
 | 
	
		
			
				|  |  | +            # global_rotation = camera.matrix_world.to_euler()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # # Set the camera's rotation to the global rotation
 | 
	
		
			
				|  |  | +            # camera.rotation_euler = global_rotation
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Set the camera's lens properties
 | 
	
		
			
				|  |  | +            lens = camera_data["properties"]["lens"]
 | 
	
		
			
				|  |  | +            type_mapping = {
 | 
	
		
			
				|  |  | +                "PERSPECTIVE": "PERSP",
 | 
	
		
			
				|  |  | +                "ORTHOGRAPHIC": "ORTHO",
 | 
	
		
			
				|  |  | +                "PANORAMIC": "PANO",
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            camera.data.type = type_mapping.get(lens["type"].upper(), "PERSP")
 | 
	
		
			
				|  |  | +            camera.data.angle = math.radians(lens["fov"])
 | 
	
		
			
				|  |  | +            camera.data.clip_start = lens["near"]
 | 
	
		
			
				|  |  | +            camera.data.clip_end = lens["far"]
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Add the camera to the 05_Cameras collection
 | 
	
		
			
				|  |  | +            # collection.objects.link(camera)
 | 
	
		
			
				|  |  | +            # bpy.context.scene.collection.objects.unlink(camera)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            # Set the camera as the active camera if "active" is true
 | 
	
		
			
				|  |  | +            # if camera_data["properties"]["active"]:
 | 
	
		
			
				|  |  | +            #     bpy.context.scene.camera = camera
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def set_output_paths(base_path, project_name):
 |