コード例 #1
0
 def CreateTask_Anim_Armature_ArmatureAction003():
     ################[ Import Armature as Action type ]################
     print(
         '================[ New import task : Armature as Action type ]================'
     )
     FilePath = os.path.join(
         r'D:\Repos\Piroots2\Other Files\ExportedFbx\SkeletalMesh\Armature\Anim\Anim_Armature_ArmatureAction003.fbx'
     )
     AdditionalParameterLoc = os.path.join(
         r'D:\Repos\Piroots2\Other Files\ExportedFbx\SkeletalMesh\Armature\Anim\SK_Armature_AdditionalParameter.ini'
     )
     AssetImportPath = (os.path.join(unrealImportLocation,
                                     r'Anim').replace('\\',
                                                      '/')).rstrip('/')
     SkeletonLocation = os.path.join(
         unrealImportLocation,
         r'SK_Armature_Skeleton.SK_Armature_Skeleton').replace('\\', '/')
     OriginSkeleton = ue.find_asset(SkeletonLocation)
     task = PyFbxFactory()
     if OriginSkeleton:
         task.ImportUI.Skeleton = OriginSkeleton
     else:
         ImportFailList.append('Skeleton "' + SkeletonLocation +
                               '" Not found for "Armature" asset ')
         return
     task.ImportUI.MeshTypeToImport = EFBXImportType.FBXIT_Animation
     task.ImportUI.bImportMaterials = False
     task.ImportUI.bImportTextures = False
     task.ImportUI.bImportAnimations = True
     task.ImportUI.bImportMesh = False
     task.ImportUI.bCreatePhysicsAsset = False
     task.ImportUI.SkeletalMeshImportData.bImportMorphTargets = True
     print('================[ import asset : Armature ]================')
     try:
         asset = task.factory_import_object(FilePath, AssetImportPath)
     except:
         asset = None
     if asset == None:
         ImportFailList.append(
             'Asset "Armature" not found for after inport')
         return
     print(
         '========================= Imports of Armature completed ! Post treatment started...	========================='
     )
     print(
         '========================= Post treatment of Armature completed !	 ========================='
     )
     asset.save_package()
     asset.post_edit_change()
     ImportedList.append([asset, 'Action'])
コード例 #2
0
def fbxImport(fbx, scale=1):
    fbx_factory = PyFbxFactory()
    # build the path for the fbx file

    # configure the factory
    fbx_factory.ImportUI.bCreatePhysicsAsset = False
    fbx_factory.ImportUI.bImportMaterials = False
    fbx_factory.ImportUI.bImportTextures = False
    fbx_factory.ImportUI.bImportAnimations = False
    # scale the mesh (the Kaiju is 30 meters high !)
    fbx_factory.ImportUI.SkeletalMeshImportData.ImportUniformScale = scale

    # import the mesh
    slicer_mesh = fbx_factory.factory_import_object(fbx, '/Game/Kaiju/Slicer')
コード例 #3
0
 def CreateTask_SM_Goal_Ring1():
     ################[ Import Goal_Ring1 as StaticMesh type ]################
     print(
         '================[ New import task : Goal_Ring1 as StaticMesh type ]================'
     )
     FilePath = os.path.join(
         r'D:\Projects\Git\RetroTowerDefense\ExportedFbx\StaticMesh\SM_Goal_Ring1.fbx'
     )
     AdditionalParameterLoc = os.path.join(
         r'D:\Projects\Git\RetroTowerDefense\ExportedFbx\StaticMesh\SM_Goal_Ring1_AdditionalParameter.ini'
     )
     AssetImportPath = (os.path.join(unrealImportLocation,
                                     r'').replace('\\', '/')).rstrip('/')
     task = PyFbxFactory()
     task.ImportUI.MeshTypeToImport = EFBXImportType.FBXIT_StaticMesh
     task.ImportUI.bImportMaterials = True
     task.ImportUI.bImportTextures = False
     task.ImportUI.bImportAnimations = False
     task.ImportUI.bImportMesh = True
     task.ImportUI.bCreatePhysicsAsset = True
     task.ImportUI.TextureImportData.MaterialSearchLocation = EMaterialSearchLocation.Local
     task.ImportUI.StaticMeshImportData.bCombineMeshes = True
     task.ImportUI.StaticMeshImportData.bAutoGenerateCollision = True
     task.ImportUI.StaticMeshImportData.bGenerateLightmapUVs = True
     print('================[ import asset : Goal_Ring1 ]================')
     try:
         asset = task.factory_import_object(FilePath, AssetImportPath)
     except:
         asset = None
     if asset == None:
         ImportFailList.append(
             'Asset "Goal_Ring1" not found for after inport')
         return
     print(
         '========================= Imports of Goal_Ring1 completed ! Post treatment started...	========================='
     )
     asset.BodySetup.CollisionTraceFlag = ECollisionTraceFlag.CTF_UseDefault
     lods_to_add = GetOptionByIniFile(AdditionalParameterLoc,
                                      'LevelOfDetail')
     for x, lod in enumerate(lods_to_add):
         pass
         asset.static_mesh_import_lod(lod, x + 1)
     print(
         '========================= Post treatment of Goal_Ring1 completed !	 ========================='
     )
     asset.save_package()
     asset.post_edit_change()
     ImportedList.append([asset, 'StaticMesh'])
コード例 #4
0
    def CreateTask_SK_Armature():
        ################[ Import Armature as SkeletalMesh type ]################
        print(
            '================[ New import task : Armature as SkeletalMesh type ]================'
        )
        FilePath = os.path.join(
            r'D:\Repos\Piroots2\Other Files\ExportedFbx\SkeletalMesh\Armature\SK_Armature.fbx'
        )
        AdditionalParameterLoc = os.path.join(
            r'D:\Repos\Piroots2\Other Files\ExportedFbx\SkeletalMesh\Armature\SK_Armature_AdditionalParameter.ini'
        )
        AssetImportPath = (os.path.join(unrealImportLocation,
                                        r'').replace('\\', '/')).rstrip('/')
        task = PyFbxFactory()
        task.ImportUI.MeshTypeToImport = EFBXImportType.FBXIT_SkeletalMesh
        task.ImportUI.bImportMaterials = True
        task.ImportUI.bImportTextures = False
        task.ImportUI.bImportAnimations = False
        task.ImportUI.bCreatePhysicsAsset = True
        task.ImportUI.bImportAnimations = False
        task.ImportUI.bImportMesh = True
        task.ImportUI.bCreatePhysicsAsset = True
        task.ImportUI.TextureImportData.MaterialSearchLocation = EMaterialSearchLocation.Local
        task.ImportUI.SkeletalMeshImportData.bImportMorphTargets = True
        print('================[ import asset : Armature ]================')
        try:
            asset = task.factory_import_object(FilePath, AssetImportPath)
        except:
            asset = None
        if asset == None:
            ImportFailList.append(
                'Asset "Armature" not found for after inport')
            return
        print(
            '========================= Imports of Armature completed ! Post treatment started...	========================='
        )
        skeleton = asset.skeleton
        current_sockets = skeleton.Sockets
        new_sockets = []
        sockets_to_add = GetOptionByIniFile(AdditionalParameterLoc, 'Sockets',
                                            True)
        for socket in sockets_to_add:
            #Create socket
            new_socket = SkeletalMeshSocket('', skeleton)
            new_socket.SocketName = socket[0]
            print(socket[0])
            new_socket.BoneName = socket[1]
            l = socket[2]
            r = socket[3]
            s = socket[4]
            new_socket.RelativeLocation = FVector(l[0], l[1], l[2])
            new_socket.RelativeRotation = FRotator(r[0], r[1], r[2])
            new_socket.RelativeScale = FVector(s[0], s[1], s[2])
            new_sockets.append(new_socket)
        skeleton.Sockets = new_sockets

        lods_to_add = GetOptionByIniFile(AdditionalParameterLoc,
                                         'LevelOfDetail')
        for x, lod in enumerate(lods_to_add):
            pass
        print(
            '========================= Post treatment of Armature completed !	 ========================='
        )
        asset.save_package()
        asset.post_edit_change()
        ImportedList.append([asset, 'SkeletalMesh'])
コード例 #5
0
import unreal_engine as ue

from unreal_engine.classes import PyFbxFactory, Skeleton
from unreal_engine.enums import EFBXImportType

import os

base_directory = 'D:/Users/rober/Downloads/mixamo'

# get a reference to the skeleton
skeleton = ue.load_object(Skeleton, '/Game/run_Skeleton')

factory = PyFbxFactory()
factory.ImportUI.MeshTypeToImport = EFBXImportType.FBXIT_Animation
factory.ImportUI.Skeleton = skeleton

for item in os.listdir(base_directory):
    if item.endswith('.fbx'):
        animation = factory.factory_import_object(os.path.join(base_directory, item), '/Game/Mixamo002')
コード例 #6
0
import os.path
from unreal_engine.classes import PyFbxFactory

# instantiate a new factory
fbx_factory = PyFbxFactory()

# build the path for the fbx file
kaiju_assets_dir = os.path.join(os.path.expanduser('~/Desktop'), 'Kaiju_Assets/Slicer')

slicer_fbx = os.path.join(kaiju_assets_dir, 'slicer.fbx')

# configure the factory
fbx_factory.ImportUI.bCreatePhysicsAsset = False
fbx_factory.ImportUI.bImportMaterials = False
fbx_factory.ImportUI.bImportTextures = False
fbx_factory.ImportUI.bImportAnimations = False
# scale the mesh (the Kaiju is 30 meters high !)
fbx_factory.ImportUI.SkeletalMeshImportData.ImportUniformScale = 0.1;

# import the mesh
slicer_mesh = fbx_factory.factory_import_object(slicer_fbx, '/Game/Kaiju/Slicer')

from unreal_engine.classes import MaterialFactoryNew

material_factory = MaterialFactoryNew()

material_blades = material_factory.factory_create_new('/Game/Kaiju/Slicer/Blades_Material')

material_body = material_factory.factory_create_new('/Game/Kaiju/Slicer/Body_Material')

from unreal_engine.classes import TextureFactory
コード例 #7
0
import unreal_engine as ue

from unreal_engine.classes import PyFbxFactory, Skeleton
from unreal_engine.enums import EFBXImportType

import os

base_directory = 'D:/Users/rober/Downloads/mixamo'

# get a reference to the skeleton
skeleton = ue.load_object(Skeleton, '/Game/run_Skeleton')

factory = PyFbxFactory()
factory.ImportUI.MeshTypeToImport = EFBXImportType.FBXIT_Animation
factory.ImportUI.Skeleton = skeleton

for item in os.listdir(base_directory):
    if item.endswith('.fbx'):
        animation = factory.factory_import_object(os.path.join(base_directory, item), '/Game/Mixamo002')
コード例 #8
0
unknown_prop_number = 0
#Start importing
for model in props:

    prop_name = model['Name']


    if model["Name"].endswith("_missing"):
        prop_name = model["Name"][:model['Name'].rfind("_missing")]

    if not prop_name == 'None':
        try:
            ue.load_object(mesh_class, xmodels_path + "xmodels/" + prop_name + "." + prop_name)

        except:
            fbx_factory = PyFbxFactory()

            # build the path for the fbx file
            if model["Name"].endswith("_missing"):
                assets_dir = os.path.join(os.path.expanduser(xmodels_directory), error_object_name[0])
                obj = os.path.join(assets_dir, error_object)

            else:
                assets_dir = os.path.join(os.path.expanduser(xmodels_directory), model["Name"])
                obj = os.path.join(assets_dir, model["Name"] + LOD0 + ".obj")

            # configure the factory
            fbx_factory.ImportUI.bCreatePhysicsAsset = False
            fbx_factory.ImportUI.bImportMaterials = False
            fbx_factory.ImportUI.bImportTextures = False
            fbx_factory.ImportUI.bImportAnimations = False
コード例 #9
0
	Options = []
	for option in Config.options(OptionName):
		if (literal == True):
			Options.append(ast.literal_eval(Config.get(OptionName, option)))
		else:
			Options.append(Config.get(OptionName, option))
	return Options


#Process import
print('========================= Import started ! =========================')



################[ Import Cube as StaticMesh type ]################
fbx_factory = PyFbxFactory()
fbx_factory.ImportUI.bImportMaterials = True
fbx_factory.ImportUI.bImportTextures = False
fbx_factory.ImportUI.TextureImportData.MaterialSearchLocation = EMaterialSearchLocation.Local
fbx_factory.ImportUI.StaticMeshImportData.bCombineMeshes = True
fbx_factory.ImportUI.StaticMeshImportData.bAutoGenerateCollision = True
FbxLoc = os.path.join(r'C:\Users\hichu\Documents\GitHub\Blender-Rigging\ExportedFbx\StaticMesh\SM_Cube.fbx')
AdditionalParameterLoc = os.path.join(r'C:\Users\hichu\Documents\GitHub\Blender-Rigging\ExportedFbx\StaticMesh\SM_Cube_AdditionalParameter.ini')
AssetImportLocation = (os.path.join(UnrealImportLocation, r'').replace('\\','/')).rstrip('/')
try:
	asset = fbx_factory.factory_import_object(FbxLoc, AssetImportLocation)
	lods_to_add = GetOptionByIniFile(AdditionalParameterLoc, 'LevelOfDetail')
	for x, lod in enumerate(lods_to_add):
		asset.static_mesh_import_lod(lod, x+1)
	asset.save_package()
	asset.post_edit_change()
コード例 #10
0
import time

# in which content folder to store the new assets
kaiju_destination = '/Game/Kaiju'
# the path from where new assets are loaded
kaiju_source = os.path.expanduser('~/Desktop')

# an fbx skeletal mesh
kaiju_mesh = 'slicer_tpose.fbx'
# textures (from substance designer)
kaiju_textures = ['slicer_BaseColor.tga', 'slicer_Emissive.tga', 'slicer_Normal.tga', 'slicer_OcclusionRoughnessMetallic.tga']
# an fbx skeletal animation
kaiju_animation = 'slicer_walking.fbx'

# start configuring the mesh importer
factory = PyFbxFactory()
factory.ImportUI.bCreatePhysicsAsset = False
factory.ImportUI.bImportMaterials = False
factory.ImportUI.bImportTextures = False
factory.ImportUI.bImportAnimations = False
# scale the mesh
factory.ImportUI.SkeletalMeshImportData.ImportUniformScale = 0.1;

# import the mesh
mesh = factory.factory_import_object(os.path.join(kaiju_source, kaiju_mesh), kaiju_destination)


# start configurint the texture importer
texture_factory = TextureFactory()

imported_textures = []
コード例 #11
0
import os.path
from unreal_engine.classes import PyFbxFactory

path_to_output_asset = '/Game/DicomMeshAssets/1'
path_to_fbx = 'C:/Users/DAN/Desktop/finalProject'
fbx_name = 'untitled.fbx'
# instantiate a new factory
fbx_factory = PyFbxFactory()


# build the path for the fbx file
#kaiju_assets_dir = path_to_fbx
#os.path.join(os.path.expanduser('~/Desktop'), 'Kaiju_Assets/Slicer')
def run_fbx_to_ueasset(path_to_fbx='', fbx_name=''):
    if (path_to_fbx != None and fbx_name != None):
        full_path = os.path.join(path_to_fbx, fbx_name)
        print(full_path)

        # configure the factory
        fbx_factory.ImportUI.bCreatePhysicsAsset = False
        fbx_factory.ImportUI.bImportMaterials = False
        fbx_factory.ImportUI.bImportTextures = False
        fbx_factory.ImportUI.bImportAnimations = False
        # scale the mesh (the Kaiju is 30 meters high !)
        fbx_factory.ImportUI.SkeletalMeshImportData.ImportUniformScale = 0.1

        # import the mesh
        slicer_mesh = fbx_factory.factory_import_object(
            full_path, path_to_output_asset)
    else:
        print("provide correct path to file and proper fbx name")