コード例 #1
0
    def createBlueprintScene(self):
        # New Asset Name
        try:
            newname = self.fbxName.partition('.')[0]
            if newname[0:3] == "SM_": #todo if there are any other prefixes in the future, test for them
                asset_name = "ASB_"+ newname[3:]
                h_name = "ASH_"+ newname[3:]
            elif newname[0:4] == "CAM_": #todo if there are any other prefixes in the future, test for them
                asset_name = "ASB_"+ newname[4:]
                h_name = "ASH_"+ newname[4:]
            elif newname[0:4] == "LGT_": #todo if there are any other prefixes in the future, test for them
                asset_name = "ASB_"+ newname[4:]
                h_name = "ASH_"+ newname[4:]
            else:
                asset_name = "ASB_"+ newname
                h_name = "ASH_"+ newname
                
            

            # Save Path
            package_path = self.UEMeshDirectory
            unreal.log_warning(package_path)

            # Derive a Class from a string path
            root_class = '/OVFPPlugin/generalResources/blenderToUnrealAdgBridge/B2UAdgBridge_ImportedSceneObject.B2UAdgBridge_ImportedSceneObject'
            root_class_generated = root_class + "_C"
            root_class_loaded = unreal.EditorAssetLibrary.load_asset(root_class)
            # Derive a BlueprintGeneratedClass from a UBlueprint
            # If you have a C++ class, you can replace all this with just ue.CPPCLASSNAMEHERE
            parent_class = unreal.get_default_object(unreal.load_object(None, root_class_generated)).get_class()
            # Factory Setup
            factory = unreal.BlueprintFactory()
            factory.set_editor_property("ParentClass", parent_class)
            # Get Asset Tools
            asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
            #todo test if asset already exists. If so, do not try to create a new one?
            # Create Asset
            childBP = asset_tools.create_asset(asset_name, package_path, root_class_loaded.static_class(), factory)
            #bp_gc = unreal.EditorAssetLibrary.load_blueprint_class(childBP.get_path_name())
            #bp_cdo = unreal.get_default_object(bp_gc)
            bploc = package_path + "/" + asset_name + "." + asset_name + "_C"
            bp_cdo = unreal.get_default_object(unreal.load_object(None, bploc))
            
            unreal.log_warning(h_name)
            bp_cdo.set_editor_property('Hierarchy', unreal.load_object(None, package_path + "/" + h_name + "." + h_name))
            sceneactor = unreal.EditorLevelLibrary.spawn_actor_from_class(bp_cdo.get_class(),unreal.Vector(x=0.0, y=0.0, z=0.0)) #spawn the imported geo out into the world. TODO decide if I want to test to see if there is already a scene out in the world
            unreal.EditorAssetLibrary.save_directory(self.UEMeshDirectory) #save directory we imported into
            unreal.EditorAssetLibrary.sync_browser_to_objects([bploc])
        except Exception:
            unreal.log_warning("Issue creating ASM blueprint")
コード例 #2
0
 def get_light_component_binding(binding, bound_objects):
     for child in binding.get_child_possessables():
         child_class = child.get_possessed_object_class()
         if child_class != None and isinstance(
                 unreal.get_default_object(child_class),
                 unreal.LightComponentBase):
             return child
     return None
コード例 #3
0
    def import_static_mesh_actor(self, node):
        if node.unreal_class == None:
            return None
        if not isinstance(unreal.get_default_object(node.unreal_class),
                          unreal.StaticMeshActor):
            return None

        actor = self.spawn_actor(node, node.unreal_asset)
        if actor == None:
            return None

        self.apply_attributes(actor, usd_unreal.attributes.node.attributes,
                              node)

        return actor
コード例 #4
0
    def import_light(self, node):
        if node.unreal_class == None:
            return None
        if not isinstance(unreal.get_default_object(node.unreal_class),
                          unreal.Light):
            return None

        actor = self.spawn_actor(node, node.unreal_class)
        if actor == None:
            return None

        self.apply_attributes(actor, usd_unreal.attributes.light.attributes,
                              node)

        return actor
コード例 #5
0
    def import_camera(self, node):
        if node.unreal_class == None:
            return None
        if not isinstance(unreal.get_default_object(node.unreal_class),
                          unreal.CineCameraActor):
            return None
        actor = None
        if node.unreal_class != None:
            actor = self.spawn_actor(node, node.unreal_class,
                                     unreal.Rotator(yaw=-90))
            if actor != None:
                self.apply_attributes(actor,
                                      usd_unreal.attributes.camera.attributes,
                                      node)

        return actor