コード例 #1
0
    def create_blueprint_from_mesh(self):
        new_blueprint = ue.find_asset(self.path_to_output_asset + '/main_mesh')
        if new_blueprint is None:
            ue.log("blueprint class doesn't exists")
            new_blueprint = ue.create_blueprint(
                Character, self.path_to_output_asset + '/main_mesh')
        else:
            ue.log("blueprint class exists")
            new_blueprint = ue.find_asset(self.path_to_output_asset +
                                          '/main_mesh')
        # new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeLocation = FVector(0, -200, 150)
        # new_blueprint.GeneratedClass.get_cdo().Mesh.RelativeRotation = FRotator(0, 0, 0)
        # add empty static mesh component to blueprint class
        new_blueprint.GeneratedClass.get_cdo(
        ).CapsuleComponent.CapsuleHalfHeight = 150
        new_blueprint.GeneratedClass.get_cdo(
        ).CapsuleComponent.CapsuleRadius = 50
        st_component = ue.add_component_to_blueprint(new_blueprint,
                                                     StaticMeshComponent,
                                                     'dicom_mesh')
        ue.log("self.mesh.get_name() = " + self.mesh.get_name())
        st_component.StaticMesh = ue.load_object(
            StaticMesh, self.path_to_output_asset + "/test_test")

        ue.compile_blueprint(new_blueprint)

        # saves uasset on the hard disk
        new_blueprint.save_package()

        world = ue.get_editor_world()
        new_actor = world.actor_spawn(new_blueprint.GeneratedClass,
                                      FVector(0, 0, 150))
コード例 #2
0
def fn_setTable(stringlist, tablename):
    newarraylist = []
    if len(stringlist) == 0: return
    #버프 아이콘 경로 변경

    arraylist = stringlist
    #ue.log('정말 진실인가? : ' + str(cb_bool))
    for ttable in arraylist:
        if ue.find_asset(ttable) == None:
            #ue.log('정말 없다!')
            className = '?????'  #ue.find_asset(ttable).get_class().get_name() # #asset.className
            path = ttable
            assetname = ttable.split('.')[1]
            uesasset = '없음'
            addall = className + ',' + path + ',' + assetname + ',' + uesasset
            newarraylist.append(addall)
        else:
            #ue.log('정말 있다!')
            if checkbox_bool.is_checked() == False:
                className = ue.find_asset(ttable).get_class().get_name()
                path = ttable
                assetname = ttable.split('.')[1]
                uesasset = '있음'
                addall = className + ',' + path + ',' + assetname + ',' + uesasset
                newarraylist.append(addall)
    ue.log('제대로나옴? : ' + tablename)
    #테이블에 작성
    newslate.ClassTable(ctext, newarraylist, tablename)
コード例 #3
0
    def run_fbx_to_ueasset(self, path_to_fbx=''):
        if path_to_fbx is None:
            ue.log("provide correct path to file and proper fbx name")
        else:
            path_to_fbx = get_full_path(path_to_fbx)
            ue.log("path_to_fbx = " + path_to_fbx)
            # configure the factory
            self.fbx_factory.ImportUI.bCreatePhysicsAsset = False
            self.fbx_factory.ImportUI.bImportMaterials = False
            self.fbx_factory.ImportUI.bImportTextures = False
            self.fbx_factory.ImportUI.bImportAnimations = False
            self.fbx_factory.ImportUI.bImportAsSkeletal = True
            self.fbx_factory.ImportUI.SkeletalMeshImportData.ImportUniformScale = 0.1

            # import the mesh
            ue.log("starting to import fbx to unreal engine")
            ###### asset = factory.factory_import_object(filename, asset_name)
            # self.mesh = self.fbx_factory.factory_import_object(path_to_fbx, self.path_to_output_asset)
            self.mesh = self.fbx_factory.factory_import_object(
                path_to_fbx, self.path_to_output_asset)
            self.mesh = ue.find_asset(self.path_to_output_asset + '/test_test')
            ue.log("finished to import fbx to unreal engine ")
            self.mesh.save_package()
            ue.log("save uasset as package")
            ue.add_on_screen_debug_message(1, 30, self.mesh)
コード例 #4
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'])
コード例 #5
0
def CreateSequencer():
	import os.path
	import time
	import configparser
	import unreal_engine as ue
	from unreal_engine.classes import MovieSceneCameraCutTrack, MovieScene3DTransformSection, MovieScene3DTransformTrack, MovieSceneAudioTrack, CineCameraActor, LevelSequenceFactoryNew
	if ue.ENGINE_MINOR_VERSION >= 20:
		from unreal_engine.structs import FloatRange, FloatRangeBound, MovieSceneObjectBindingID, FrameRate
	else:
		from unreal_engine.structs import FloatRange, FloatRangeBound, MovieSceneObjectBindingID
	from unreal_engine import FTransform, FRotator, FVector, FColor
	from unreal_engine.enums import EMovieSceneObjectBindingSpace
	from unreal_engine.structs import MovieSceneObjectBindingID


	seqPath = r'/Game/ImportedFbx/Sequencer'
	seqName = r'MySequence'
	seqTempName = r'MySequence'+str(time.time())
	mustBeReplace = False
	startFrame = 1
	endFrame = 251
	frameRateDenominator = 1.0
	frameRateNumerator = 60
	secureCrop = 0.0001 #add end crop for avoid section overlay


	def AddSequencerSectionTransformKeysByIniFile(SequencerSection, SectionFileName, FileLoc):
		Config = configparser.ConfigParser()
		Config.read(FileLoc)
		for option in Config.options(SectionFileName):
			frame = float(option)/float(frameRateNumerator) #FrameRate
			list = Config.get(SectionFileName, option)
			list = list.split(',')
			transform = FTransform(FVector(float(list[0]), float(list[1]), float(list[2])), FRotator(float(list[3]), float(list[4]), float(list[5])))
			SequencerSection.sequencer_section_add_key(frame,transform)


	def AddSequencerSectionFloatKeysByIniFile(SequencerSection, SectionFileName, FileLoc):
		Config = configparser.ConfigParser()
		Config.read(FileLoc)
		for option in Config.options(SectionFileName):
			frame = float(option)/float(frameRateNumerator) #FrameRate
			value = float(Config.get(SectionFileName, option))
			SequencerSection.sequencer_section_add_key(frame,value)


	def AddSequencerSectionBoolKeysByIniFile(SequencerSection, SectionFileName, FileLoc):
		Config = configparser.ConfigParser()
		Config.read(FileLoc)
		for option in Config.options(SectionFileName):
			frame = float(option)/float(frameRateNumerator) #FrameRate
			value = Config.getboolean(SectionFileName, option)
			SequencerSection.sequencer_section_add_key(frame,value)


	if ue.find_asset(seqPath+'/'+seqName):
		print("Warning this file already exists")
		factory = LevelSequenceFactoryNew()
		seq = factory.factory_create_new(seqPath+'/'+seqTempName.replace('.',''))
		mustBeReplace = True
	else:
		factory = LevelSequenceFactoryNew()
		seq = factory.factory_create_new(seqPath+'/'+seqName.replace('.',''))
	if seq is None:
		return 'Error /!\ level sequencer factory_create fail' 

	print("Sequencer reference created")
	print(seq)
	ImportedCamera = [] #(CameraName, CameraGuid)
	print("========================= Import started ! =========================")
	
	#Set frame rate
	if ue.ENGINE_MINOR_VERSION >= 20:
		myFFrameRate = FrameRate()
		myFFrameRate.Denominator = frameRateDenominator
		myFFrameRate.Numerator = frameRateNumerator
		seq.MovieScene.DisplayRate = myFFrameRate
	else:
		seq.MovieScene.FixedFrameInterval = frameRateDenominator/frameRateNumerator
	
	#Set playback range
	seq.sequencer_set_playback_range(startFrame/frameRateNumerator, (endFrame-secureCrop)/frameRateNumerator)
	camera_cut_track = seq.sequencer_add_camera_cut_track()
	world = ue.get_editor_world()


	#Import camera cut section
	camera_cut_section = camera_cut_track.sequencer_track_add_section()
	for camera in ImportedCamera:
		if camera[0] == 'Camera':
			camera_cut_section.CameraBindingID = MovieSceneObjectBindingID( Guid=ue.string_to_guid( camera[1] ), Space=EMovieSceneObjectBindingSpace.Local )
	camera_cut_section.sequencer_set_section_range(1/frameRateNumerator, (251-secureCrop)/frameRateNumerator)
	if mustBeReplace == True:
		OldSeq = seqPath+'/'+seqName.replace('.','')+'.'+seqName.replace('.','')
		NewSeq = seqPath+'/'+seqTempName.replace('.','')+'.'+seqTempName.replace('.','')
		print(OldSeq)
		print(NewSeq)
		print("LevelSequence'"+OldSeq+"'")
	print('========================= Imports completed ! =========================')
	
	for cam in ImportedCamera:
		print(cam[0])
	
	print('=========================')
#Select and open seq in content browser
	seq.sequencer_changed(True)
	return 'Sequencer created with success !' 
コード例 #6
0
from unreal_engine.structs import FloatRange, FloatRangeBound, MovieSceneObjectBindingID, FrameRate
from unreal_engine import FTransform, FVector, FColor
from unreal_engine.enums import EMovieSceneObjectBindingSpace


def AddSequencerSectionKeysByIniFile(SequencerSection, SectionFileName,
                                     FileLoc):
    Config = configparser.ConfigParser()
    Config.read(FileLoc)
    for option in Config.options(SectionFileName):
        frame = float(option) / 24  #FrameRate
        value = float(Config.get(SectionFileName, option))
        SequencerSection.sequencer_section_add_key(frame, value)


seq = ue.find_asset("LevelSequence'/Game/ImportedFbx/MySequence.MySequence'")
if seq:
    print("Sequencer reference found")
    ImportedCamera = []  #(CameraName, CameraGuid)
    print(
        "========================= Import started ! =========================")

    #Set frame rate
    myFFrameRate = FrameRate()
    myFFrameRate.Denominator = 1.0
    myFFrameRate.Numerator = 24
    seq.MovieScene.DisplayRate = myFFrameRate

    #Set playback range
    seq.sequencer_set_playback_range(0.041666666666666664, 10.416666666666666)
    camera_cut_track = seq.sequencer_add_camera_cut_track()
コード例 #7
0
        frame = float(option) / frameRateNumerator  #FrameRate
        value = float(Config.get(SectionFileName, option))
        SequencerSection.sequencer_section_add_key(frame, value)


def AddSequencerSectionBoolKeysByIniFile(SequencerSection, SectionFileName,
                                         FileLoc):
    Config = configparser.ConfigParser()
    Config.read(FileLoc)
    for option in Config.options(SectionFileName):
        frame = float(option) / frameRateNumerator  #FrameRate
        value = Config.getboolean(SectionFileName, option)
        SequencerSection.sequencer_section_add_key(frame, value)


if ue.find_asset(seqLocation + '/' + seqName):
    print("Warning this file already exists")
    factory = LevelSequenceFactoryNew()
    seq = factory.factory_create_new(seqLocation + '/' +
                                     seqTempName.replace('.', ''))
    mustBeReplace = True
else:
    factory = LevelSequenceFactoryNew()
    seq = factory.factory_create_new(seqLocation + '/' +
                                     seqName.replace('.', ''))

if seq:
    print("Sequencer reference created")
    print(seq)
    ImportedCamera = []  #(CameraName, CameraGuid)
    print(