def get_actor_collision_bounding_box(actor): static_mesh_component = actor.static_mesh_component static_mesh = static_mesh_component.static_mesh body_setup = static_mesh.get_editor_property('body_setup') agg_geometry = body_setup.get_editor_property('agg_geom') box = agg_geometry.get_editor_property('box_elems')[0] collision_center = box.get_editor_property('center') collision_x_bounds_half = box.get_editor_property('x') / 2.0 collision_y_bounds_half = box.get_editor_property('y') / 2.0 collision_z_bounds_half = box.get_editor_property('z') / 2.0 box_rotator = box.get_editor_property('rotation').transform() upper_corner = unreal.Vector(collision_x_bounds_half, collision_y_bounds_half, collision_z_bounds_half) lower_corner = unreal.Vector(-collision_x_bounds_half, -collision_y_bounds_half, -collision_z_bounds_half) upper_corner = box_rotator.transform_direction(upper_corner) lower_corner = box_rotator.transform_direction(lower_corner) upper_corner = upper_corner.add(collision_center) lower_corner = lower_corner.add(collision_center) return (upper_corner, lower_corner)
def deferredSpawnActor(): world = unreal.EditorLevelLibrary.get_editor_world() # ! blueprint actor actor_class = unreal.EditorAssetLibrary.load_blueprint_class( '/Game/BluePrint/bp_actor') actor_location = unreal.Vector(random.uniform(0.0, 2000.0), random.uniform(0.0, 2000.0), 0.0) actor_rotation = unreal.Rotator(random.uniform(0.0, 360.0), random.uniform(0.0, 360.0), random.uniform(0.0, 360.0)) actor_scale = unreal.Vector(random.uniform(0.1, 2.0), random.uniform(0.1, 2.0), random.uniform(0.1, 2.0)) actor_transform = unreal.Transform(actor_location, actor_rotation, actor_scale) # ! "GameplayStatics.begin_spawning_actor_from_class()" is deprecated. Use BeginDeferredActorSpawnFromClass instead. # actor = unreal.GameplayStatics.begin_spawning_actor_from_class(world, actor_class, actor_transform) # unreal.GameplayStatics.finish_spawning_actor(actor, actor_transform) actor = unreal.EditorCppLib.begin_spawn_actor(world, actor_class, actor_transform) unreal.EditorCppLib.finish_spawn_actor(actor, actor_transform) # import EditorFunction_1 as ef # reload(ef) # ef.executeSlowTask()
def SpawnSurroundingActor(ActorToSpawn, Core, CenterObject, Distance=10, NumberOfWalls=0) : if NumberOfWalls <= 0 : NumberOfWalls = Distance spawningActorAsset = unreal.EditorAssetLibrary().find_asset_data(ActorToSpawn) spawningActorObject = spawningActorAsset.get_asset() level_actor_list = unreal.EditorLevelLibrary().get_all_level_actors() for a in level_actor_list: if a.get_name() == Core : core_object = a if a.get_name() == CenterObject : center_object = a ForwardVector = center_object.get_actor_forward_vector() PerpendicularVector = unreal.Vector(1, 1, ((ForwardVector.x + ForwardVector.y) * -1) / ForwardVector.z ) PerpendicularVector = PerpendicularVector * Distance NewPosition = PerpendicularVector + center_object.get_actor_location() RotationAxis = center_object.get_actor_location() - core_object.get_actor_location() with unreal.ScopedEditorTransaction("Spawn Surrounding Actors") as trans: for i in range(0, NumberOfWalls, 2) : ResultPosition = unreal.MathLibrary().rotate_angle_axis(NewPosition, i * 360 / Distance, RotationAxis) unit_direction = unreal.MathLibrary().get_direction_unit_vector(core_object.get_actor_location(), ResultPosition) ResultLocation = (unit_direction * 590) + core_object.get_actor_location() spawned_actor = unreal.EditorLevelLibrary().spawn_actor_from_object(spawningActorObject, ResultLocation) spawned_actor.set_actor_relative_scale3d(unreal.Vector(0.1, 0.1, 2.0)) spawned_actor.set_actor_rotation(GetCoreBasedRotation(core_object.get_actor_location(), spawned_actor), True)
def spawnBlueprintActor_EXAMPLE(): path = '/Game/MyBlueprint' location = unreal.Vector(1000.0, 400.0, 0.0) rotation = unreal.Rotator(90.0, 0.0, 0.0) scale = unreal.Vector(1.0, 1.0, 5.0) properties = {'tags': ['MyFirstTag', 'MySecondTag'], 'hidden': False} print WorldFunctions.spawnBlueprintActor(path, location, rotation, scale, None, properties)
def build_import_options(): options = unreal.FbxImportUI() # ---- MESH options.set_editor_property('import_mesh', True) options.set_editor_property('import_textures', False) options.set_editor_property('import_materials', False) options.set_editor_property('import_as_skeletal', False) # Static Mesh options.static_mesh_import_data.set_editor_property( 'auto_generate_collision', False) # ---- Transform options.static_mesh_import_data.set_editor_property( 'import_translation', unreal.Vector(0.0, 0.0, 0.0)) options.static_mesh_import_data.set_editor_property( 'import_rotation', unreal.Rotator(0.0, 0.0, 0.0)) options.static_mesh_import_data.set_editor_property( 'import_uniform_scale', 1.0) # ---- Miscellaneous options.static_mesh_import_data.set_editor_property( 'convert_scene', True) options.static_mesh_import_data.set_editor_property( 'force_front_x_axis', False) options.static_mesh_import_data.set_editor_property( 'convert_scene_unit', True) options.set_editor_property('override_full_name', True) return options
def spawn_wall(x, y, z, yaw): if plane: location = unreal.Vector() location.x = x location.y = y location.z = z rotation = unreal.Rotator() rotation.yaw = yaw rotation.roll = 90 spawned_actor = unreal.EditorLevelLibrary.spawn_actor_from_object( plane, location, rotation) scale = unreal.Vector() scale.x = 5 scale.y = 3 scale.z = 0.2 spawned_actor.set_actor_relative_scale3d(scale)
def main(): """Execute the main functionality of the example script""" locations = [] for x in range(ACTOR_COUNT_DIMENSIONS[0]): for y in range(ACTOR_COUNT_DIMENSIONS[1]): for z in range(ACTOR_COUNT_DIMENSIONS[2]): locations.append((x * ACTOR_SEPARATION_DISTANCE, y * ACTOR_SEPARATION_DISTANCE, z * ACTOR_SEPARATION_DISTANCE)) total_frames = len(locations) text_label = 'Generating Example Sequence' new_sequence = create_new_level_sequence('/Game', 'ExamplePythonSequence') with unreal.ScopedSlowTask(total_frames, text_label) as example_task: example_task.make_dialog(True) for cube_location in locations: if example_task.should_cancel(): break cube = spawn_actor(unreal.Vector(*cube_location)) # Add the cube to the generated sequence add_actor_to_sequence(new_sequence, cube) # Move the progress bar example_task.enter_progress_frame() # Automatically open the sequence unreal.AssetToolsHelpers.get_asset_tools().open_editor_for_assets( [new_sequence])
def importCamera(levelSequence, cameraPath, fbxCamName='UNREAL_CAMERA_SHOT'): ''' import camera shot from fbx &create focus length etc :param levelSequence: target sequence :param cameraPath: fbx folder path :param fbxCamName: cameraName in both file and sequence :return: None ''' cine_camera = unreal.EditorLevelLibrary.spawn_actor_from_class( unreal.CineCameraActor, unreal.Vector()) cine_camera.set_actor_label(fbxCamName) camera_comp_bind = unreal.MovieSceneSequence.add_possessable( levelSequence, cine_camera.get_cine_camera_component()) camera_bind = unreal.MovieSceneSequence.add_spawnable_from_instance( levelSequence, cine_camera) camera_comp_bind.set_parent(camera_bind) focal_length_track = camera_comp_bind.add_track( unreal.MovieSceneFloatTrack) focal_length_track.set_property_name_and_path('CurrentFocalLength', 'CurrentFocalLength') focal_length_section = focal_length_track.add_section() focal_length_section.set_start_frame_bounded(0) focal_length_section.set_end_frame_bounded(0) Aperture_length_track = camera_comp_bind.add_track( unreal.MovieSceneFloatTrack) Aperture_length_track.set_property_name_and_path('CurrentAperture', 'CurrentAperture') aperture_length_section = Aperture_length_track.add_section() aperture_length_section.set_start_frame_bounded(0) aperture_length_section.set_end_frame_bounded(0) levelSequence.get_bindings()[0].remove() # camera_id = unreal.MovieSceneObjectBindingID() # camera_id.set_editor_property('guid', binding.get_id()) # camera_cut_track = levelSequence.add_master_track(unreal.MovieSceneCameraCutTrack) # camera_section = camera_cut_track.add_section() # camera_section.set_range(0.0, 1000.0) # camera_section.set_camera_binding_id(camera_id) # # # # possessable = levelSequence.add_spawnable_from_class(wo) # # import_setting = unreal.MovieSceneUserImportFBXSettings() import_setting.set_editor_property('create_cameras', False) import_setting.set_editor_property('force_front_x_axis', False) import_setting.set_editor_property('match_by_name_only', True) import_setting.set_editor_property('reduce_keys', False) import_setting.set_editor_property('reduce_keys_tolerance', 0.001) # world = unreal.EditorLevelLibrary.get_editor_world() cam = unreal.SequencerTools.import_fbx(world, levelSequence, [camera_bind], import_setting, cameraPath)
def test_spawn_actor(unreal_object, scale=None): location = unreal.Vector(10, 20, 30) rotation = unreal.Rotator(44, 55, 66) actor = unreal.EditorLevelLibrary.spawn_actor_from_object( unreal_object, location, rotation) if scale != None: actor.set_actor_scale3d(scale) return actor
def createSplash(json_path): with open(json_path, "r") as json_file: data = json.load(json_file) for asset_name in data: pos = data[asset_name]["position"] rot = data[asset_name]["rotation"] splash_scale = data[asset_name]["splash_scale"] foam_scale = data[asset_name]["foam_scale"] splash_type = data[asset_name]["splash_type"] if splash_type == 1: # splash bottom splash = lib.load_asset( '/Game/Test_assets/WaterfallTool/Particles/PS_BottomSplash.PS_BottomSplash' ) splash_scale *= 2 elif splash_type == 0: # splash top splash = lib.load_asset( '/Game/Test_assets/WaterfallTool/Particles/PS_TopSplash.PS_TopSplash' ) actor_location = unreal.Vector(pos[0] * 100, pos[1] * 100, pos[2] * 100) #actor_rotation = unreal.Rotator(rot[0],rot[2],rot[1]) m_vector = unreal.Vector() m_vector.set(0, 0, 1) m_rot = m_vector.rotator_from_axis_and_angle(rot[1]) actor_rotation = unreal.Rotator(rot[0], rot[2], rot[1]) #actor_rotation = m_rot actor_splash_scale = unreal.Vector(splash_scale[0], splash_scale[1], splash_scale[2]) actor_foam_scale = unreal.Vector(foam_scale[0], foam_scale[1], foam_scale[2]) m_name = "streamSplash" actor_splash = unreal.EditorLevelLibrary.spawn_actor_from_object( splash, actor_location, actor_rotation) actor_splash.set_folder_path('/' + m_name + '/') actor_splash_tags = actor_splash.get_editor_property('tags') actor_splash_tags.append('stream splash') actor_splash.set_editor_property('tags', actor_splash_tags) actor_splash.set_actor_scale3d(actor_splash_scale) actor_splash_componet = actor_splash.get_components_by_class( unreal.ParticleSystemComponent)[0] actor_splash_componet.set_translucent_sort_priority(100)
def deferredSpawnActor(): world = unreal.EditorLevelLibrary.get_editor_world() actor_class = unreal.EditorAssetLibrary.load_blueprint_class('/Game/BluePrint/MyActor') actor_location = unreal.Vector(0.0, 0.0, 0.0) actor_rotation = unreal.Rotator(0.0, 0.0, 0.0) actor_scale = unreal.Vector(1.0, 1.0, 1.0) actor_transform = unreal.Transform(actor_location, actor_rotation, actor_scale) actor = unreal.EditorCppLib.begin_spawn_actor(world, actor_class, actor_transform) actor_tags = actor.get_editor_property('tags') actor_tags.append('My Python Tag') actor.set_editor_property('tags', actor_tags) unreal.EditorCppLib.finish_spawn_actor(actor, actor_transform) # import WorldFunctions as wf # reload(wf) # wf.spawnActor()
def align_l_up(self): base, target = self.get_selected_actors() info = level_lib.get_level_viewport_camera_info() if not info: toast(u"无法获取摄像机信息") return cam_location, cam_rotation = info origin, extent = base.get_actor_bounds(True) line = cam_location - origin line.normalize() x_val = line.dot(unreal.Vector(1, 0, 0)) y_val = line.dot(unreal.Vector(0, 1, 0)) z_val = line.dot(unreal.Vector(0, 0, 1)) # NOTE 正对 X 轴 if x_val > 0.5: pass
def main(): for asset in util_lib.get_selected_assets(): name = asset.get_name() if not isinstance(asset, unreal.StaticMesh): continue container_path = os.path.splitext(asset.get_path_name())[0] container = unreal.load_asset(Socket_Path) if not container: print(f"失败路径 -> {container_path}") return container = level_lib.spawn_actor_from_object( container, unreal.Vector(0.0, 0.0, 0.0)) r = unreal.AttachmentRule.SNAP_TO_TARGET for socket in container.root_component.get_all_socket_names(): mesh = level_lib.spawn_actor_from_object( asset, unreal.Vector(0.0, 0.0, 0.0)) mesh.attach_to_actor(container, socket, r, r, r, False)
def test_level_export_import_main(): unreal.EditorLoadingAndSavingUtils.new_blank_map(False) test_populate_world() #print(" call export_level") export_level_path = 'level_export/export_level.usda' export_task = usd_unreal.export_level.USDExportLevel() export_task.export_level( os.path.join(test_directory_generated, export_level_path), unreal.EditorLevelLibrary.get_editor_world()) #if not compare_usd_files(os.path.join(test_directory_generated, export_level_path), os.path.join(test_directory_expected, export_level_path)): # return False unreal.EditorLoadingAndSavingUtils.new_blank_map(False) # import the exported level import_exported_level(export_level_path) # export 'deltas' version of level before making changes export_level_unchanged_path = 'level_export/export_level_unchanged.usda' usd_unreal.export_level.export_current_level( os.path.join(test_directory_generated, export_level_unchanged_path)) #if not compare_usd_files(os.path.join(test_directory_generated, export_level_unchanged_path), os.path.join(test_directory_expected, export_level_unchanged_path)): # return False # change level then export 'deltas' version after making changes actor = unreal.EditorLevelLibrary.spawn_actor_from_object( unreal.load_asset("/Engine/BasicShapes/Cube.Cube"), unreal.Vector(0, 0, -100), unreal.Rotator(0, 0, 0)) actor.set_actor_label("CubeAdded") actor = find_actor_by_label("CubePlaced") actor.set_actor_location(unreal.Vector(100, 60, -250), False, True) actor = find_actor_by_label("CubeToDelete") unreal.EditorLevelLibrary.destroy_actor(actor) export_level_changed_path = 'level_export/export_level_changed.usda' usd_unreal.export_level.export_current_level( os.path.join(test_directory_generated, export_level_changed_path)) #if not compare_usd_files(os.path.join(test_directory_generated, export_level_changed_path), os.path.join(test_directory_expected, export_level_changed_path)): # return False return True
def mouseDoubleClickEvent(self, event): """ 双击生成 物体 """ super(PlacerItem, self).mouseDoubleClickEvent(event) selected = level_lib.get_selected_level_actors() location = selected[-1].get_actor_location( ) if selected else unreal.Vector(0, 0, 0) level_lib.spawn_actor_from_object(self.asset, location)
def add_mesh_to_level(): static_mesh_actor = unreal.StaticMeshActor() location1 = unreal.Vector(1000.0, 400.0, 0.0) rotation1 = unreal.Rotator(0.0, 0.0, 0.0) new_actor = unreal.EditorLevelLibrary.spawn_actor_from_object( static_mesh_actor, location1, rotation1) yourmesh = unreal.EditorAssetLibrary.load_asset('/Game/EGC_Bake/abc1.abc1') # static_mesh_ins = unreal.StaticMeshComponent() # static_mesh_ins.set_static_mesh(yourmesh) unreal.EditorLevelLibrary.replace_mesh_components_meshes_on_actors( [new_actor], None, yourmesh)
def create_camera(self): # 添加相机剪辑轨道 camera_cut_track = self.ass.add_master_track(unreal.MovieSceneCameraCutTrack) # 添加相机剪裁的可视 camera_cut_section = camera_cut_track.add_section() self.make_range(camera_cut_section) camera_actor = unreal.EditorLevelLibrary().spawn_actor_from_class( unreal.CineCameraActor, unreal.Vector(0, 0, 0), unreal.Rotator(0, 0, 0)) camera_actor.set_actor_label("doodle_camera") camera_component = camera_actor.get_cine_camera_component() # ratio = math.tan(film_fov / 360.0 * math.pi) * 2 # 添加一些相机熟悉 filmback = camera_component.get_editor_property("filmback") # focal_length = camera_component.get_editor_property("current_focal_length") filmback.set_editor_property("sensor_height", 20.25) filmback.set_editor_property("sensor_width", 36.0) focus_settings = camera_component.get_editor_property("focus_settings") focus_settings.set_editor_property( "focus_method", unreal.CameraFocusMethod.DISABLE) # 添加相机绑定 camera_binding = self.ass.add_possessable(camera_actor) camera_binding_id = self.ass.make_binding_id( camera_binding, unreal.MovieSceneObjectBindingSpace.LOCAL) camera_cut_section.set_camera_binding_id(camera_binding_id) # 添加transform_track轨道 transform_track = camera_binding.add_track(unreal.MovieScene3DTransformTrack) transform_section = transform_track.add_section() self.make_range(transform_section) # 添加子组件绑定 camera_component_binding = self.ass.add_possessable(camera_component) # 添加当前焦距 camera_component_focal_track = camera_component_binding.add_track(unreal.MovieSceneFloatTrack) camera_component_focal_track.set_property_name_and_path("当前焦距", "CurrentFocalLength") camera_component_focal_track_section = camera_component_focal_track.add_section() self.make_range(camera_component_focal_track_section) # channels = camera_component_focal_track_section.get_channels()[0] # channels.add_key(unreal.FrameNumber(950), 35, 0.0, unreal.SequenceTimeUnit.DISPLAY_RATE) # 添加当前光圈 camera_component_focal_track = camera_component_binding.add_track(unreal.MovieSceneFloatTrack) camera_component_focal_track.set_property_name_and_path("当前光圈", "CurrentAperture") camera_component_focal_track_section = camera_component_focal_track.add_section() self.make_range(camera_component_focal_track_section) # 添加手动聚焦 camera_component_focal_track = camera_component_binding.add_track(unreal.MovieSceneFloatTrack) camera_component_focal_track.set_property_name_and_path("手动聚焦距离(聚焦设置)", "FocusSettings.ManualFocusDistance") camera_component_focal_track_section = camera_component_focal_track.add_section() self.make_range(camera_component_focal_track_section)
def mouseDoubleClickEvent(self, event): """ 双击生成 物体 """ super(PlacerItem, self).mouseDoubleClickEvent(event) selected = level_lib.get_selected_level_actors() location = ( selected[-1].get_actor_location() if selected else unreal.Vector(0, 0, 0) ) sys_lib.begin_transaction(TRANSCATION, "spawn actor", None) level_lib.spawn_actor_from_object(self.asset, location) sys_lib.end_transaction()
def buildAnimationImportOptions(skeleton_path=''): options = unreal.FbxImportUI() # unreal.FbxImportUI options.set_editor_property('import_animations', True) options.skeleton = unreal.load_asset(skeleton_path) # unreal.FbxMeshImportData options.anim_sequence_import_data.set_editor_property('import_translation', unreal.Vector(0.0, 0.0, 0.0)) options.anim_sequence_import_data.set_editor_property('import_rotation', unreal.Rotator(0.0, 0.0, 0.0)) options.anim_sequence_import_data.set_editor_property('import_uniform_scale', 1.0) # unreal.FbxAnimSequenceImportData options.anim_sequence_import_data.set_editor_property('animation_length', unreal.FBXAnimationLengthImportType.FBXALIT_EXPORTED_TIME) options.anim_sequence_import_data.set_editor_property('remove_redundant_keys', False) return options
def test_populate_world(): actors = [] def spawn_actor(unreal_object, scale=None): a = test_spawn_actor(unreal_object) actors.append(a) return a # empty actor actor = spawn_actor(unreal.Actor.static_class()) # lights actor = spawn_actor(unreal.RectLight.static_class()) actor = spawn_actor(unreal.PointLight.static_class()) actor = spawn_actor(unreal.DirectionalLight.static_class()) actor = spawn_actor(unreal.SpotLight.static_class()) # sky light actor = unreal.EditorLevelLibrary.spawn_actor_from_object( unreal.SkyLight.static_class(), unreal.Vector(0, 0, 0), unreal.Rotator(0, 0, 0)) actor = spawn_actor(unreal.CineCameraActor.static_class()) actor.set_actor_label("CineCameraPlaced") actor = unreal.EditorLevelLibrary.spawn_actor_from_object( unreal.load_asset("/Engine/BasicShapes/Cube.Cube"), unreal.Vector(0, 0, -200), unreal.Rotator(0, 0, 0)) actor.set_actor_scale3d(unreal.Vector(7, 5, 1)) actor.set_actor_label("CubePlaced") actor = unreal.EditorLevelLibrary.spawn_actor_from_object( unreal.load_asset("/Engine/BasicShapes/Cube.Cube"), unreal.Vector(0, 100, -100), unreal.Rotator(0, 0, 0)) actor.set_actor_scale3d(unreal.Vector(1, 1, 0.5)) actor.set_actor_label("CubeToDelete") return actors
def offset_actor(self): actors = level_lib.get_selected_level_actors() if not actors: return x = self.TransformX_SB.value() y = self.TransformY_SB.value() z = self.TransformZ_SB.value() sys_lib.begin_transaction(TRANSCATION, "offset actor", None) for actor in actors: actor.modify(True) actor.add_actor_local_offset(unreal.Vector(x, y, z), False, False) actor.modify(False) sys_lib.end_transaction()
def buildSkeletalMeshImportOptions(): options = unreal.FbxImportUI() # unreal.FbxImportUI options.set_editor_property('import_mesh', True) options.set_editor_property('import_textures', False) options.set_editor_property('import_materials', False) options.set_editor_property('import_as_skeletal', True) # Skeletal Mesh # unreal.FbxMeshImportData options.skeletal_mesh_import_data.set_editor_property('import_translation', unreal.Vector(0.0, 0.0, 0.0)) options.skeletal_mesh_import_data.set_editor_property('import_rotation', unreal.Rotator(0.0, 0.0, 0.0)) options.skeletal_mesh_import_data.set_editor_property('import_uniform_scale', 1.0) # unreal.FbxSkeletalMeshImportData options.skeletal_mesh_import_data.set_editor_property('import_morph_targets', True) options.skeletal_mesh_import_data.set_editor_property('update_skeleton_reference_pose', False) return options
def myTick(self, delta_seconds): self.time_while_this_window_is_open += delta_seconds self.widget.label.setText("{} Seconds".format( self.time_while_this_window_is_open)) if self.random_actor: actor_location = self.random_actor.get_actor_location() speed = 300.0 * delta_seconds if self.random_actor_is_going_up: if actor_location.z > 1000.0: self.random_actor_is_going_up = False else: speed = -speed if actor_location.z < 0.0: self.random_actor_is_going_up = True self.random_actor.add_actor_world_offset( unreal.Vector(0.0, 0.0, speed), False, False)
def myTick(self, delta_seconds): # Set Time self.time_while_this_window_is_open += delta_seconds self.widget.lbl_Seconds.setText("%.1f Seconds" % self.time_while_this_window_is_open) # Affect Actor if self.random_actor: actor_location = self.random_actor.get_actor_location() speed = 300.0 * delta_seconds if self.random_actor_is_going_up: if actor_location.z > 1000.0: self.random_actor_is_going_up = False else: speed = -speed if actor_location.z < 0.0: self.random_actor_is_going_up = True self.random_actor.add_actor_world_offset(unreal.Vector(0.0, 0.0, speed), False, False)
def _set_option(self, frame_start=0, frame_end=0): options = unreal.AbcImportSettings() conversion = unreal.AbcConversionSettings() rotation = unreal.Vector(0.0, 90, 0.0) conversion.set_editor_property("rotation", rotation) options.set_editor_property("conversion_settings", conversion) options.import_type = unreal.AlembicImportType.SKELETAL options.sampling_settings.frame_start = frame_start options.sampling_settings.frame_end = frame_end options.sampling_settings.skip_empty = True #未解决 初始帧无法读取的问题前先用0代替 # self.frame_start = frame_start self.frame_end = frame_end self.option = options
def buildStaticMeshImportOptions(): options = unreal.FbxImportUI() # unreal.FbxImportUI options.set_editor_property('import_mesh', True) options.set_editor_property('import_textures', False) options.set_editor_property('import_materials', False) options.set_editor_property('import_as_skeletal', False) # Static Mesh # unreal.FbxMeshImportData options.static_mesh_import_data.set_editor_property('import_translation', unreal.Vector(0.0, 0.0, 0.0)) options.static_mesh_import_data.set_editor_property('import_rotation', unreal.Rotator(0.0, 0.0, 0.0)) options.static_mesh_import_data.set_editor_property('import_uniform_scale', 1.0) # unreal.FbxStaticMeshImportData options.static_mesh_import_data.set_editor_property('combine_meshes', True) options.static_mesh_import_data.set_editor_property('generate_lightmap_u_vs', True) options.static_mesh_import_data.set_editor_property('auto_generate_collision', True) return options
def myTick(self, delta_seconds): self.time_while_this_window_is_open += delta_seconds self.widget.label.setText("{} Seconds".format( self.time_while_this_window_is_open)) if self.random_actor: actor_scale = self.random_actor.get_actor_scale3d() speed = 3.0 * delta_seconds if self.random_actor_is_going_up: if actor_scale.z > 2.0: self.random_actor_is_going_up = False else: speed = -speed if actor_scale.z < 0.5: self.random_actor_is_going_up = True self.random_actor.set_actor_scale3d( unreal.Vector(actor_scale.x + speed, actor_scale.y + speed, actor_scale.z + speed))
def build_import_options(): options = unreal.FbxImportUI() # ---- MESH options.set_editor_property('mesh_type_to_import', unreal.FBXImportType.FBXIT_SKELETAL_MESH) options.set_editor_property('import_mesh', True) options.set_editor_property('import_textures', False) options.set_editor_property('import_materials', False) options.set_editor_property('import_as_skeletal', True) # Static Mesh options.skeletal_mesh_import_data.set_editor_property( 'vertex_color_import_option', unreal.VertexColorImportOption.REPLACE) options.skeletal_mesh_import_data.set_editor_property( 'update_skeleton_reference_pose', True) options.skeletal_mesh_import_data.set_editor_property( 'use_t0_as_ref_pose', True) options.skeletal_mesh_import_data.set_editor_property( 'preserve_smoothing_groups', True) options.skeletal_mesh_import_data.set_editor_property( 'import_meshes_in_bone_hierarchy', True) options.skeletal_mesh_import_data.set_editor_property( 'import_morph_targets', False) options.skeletal_mesh_import_data.set_editor_property( 'import_mesh_lo_ds', False) options.skeletal_mesh_import_data.set_editor_property( 'normal_import_method', unreal.FBXNormalImportMethod.FBXNIM_IMPORT_NORMALS_AND_TANGENTS) # ---- Transform options.skeletal_mesh_import_data.set_editor_property( 'import_translation', unreal.Vector(0.0, 0.0, 0.0)) options.skeletal_mesh_import_data.set_editor_property( 'import_rotation', unreal.Rotator(0.0, 0.0, 0.0)) options.skeletal_mesh_import_data.set_editor_property( 'import_uniform_scale', 1.0) # ---- Miscellaneous options.skeletal_mesh_import_data.set_editor_property( 'convert_scene', True) options.skeletal_mesh_import_data.set_editor_property( 'force_front_x_axis', False) options.skeletal_mesh_import_data.set_editor_property( 'convert_scene_unit', True) options.set_editor_property('override_full_name', True) return options
def buildSkeletalMeshImportOptions(self): skeletal_mesh_import_data = unreal.FbxSkeletalMeshImportData() skeletal_mesh_import_data.set_editor_property( 'update_skeleton_reference_pose', False) skeletal_mesh_import_data.set_editor_property( 'import_meshes_in_bone_hierarchy', True) skeletal_mesh_import_data.set_editor_property('use_t0_as_ref_pose', False) skeletal_mesh_import_data.set_editor_property( 'preserve_smoothing_groups', True) skeletal_mesh_import_data.set_editor_property('import_morph_targets', True) import_translation = unreal.Vector(0, 0, 0) skeletal_mesh_import_data.set_editor_property('import_translation', import_translation) import_rotation = unreal.Rotator(0, 0, 0) skeletal_mesh_import_data.set_editor_property('import_rotation', import_rotation) skeletal_mesh_import_data.set_editor_property('import_uniform_scale', 1.0) skeletal_mesh_import_data.set_editor_property('convert_scene', True) skeletal_mesh_import_data.set_editor_property('force_front_x_axis', False) skeletal_mesh_import_data.set_editor_property('convert_scene_unit', False) # SkeletalMeshImportData->bImportAsScene = false; options = unreal.FbxImportUI() options.set_editor_property('skeletal_mesh_import_data', skeletal_mesh_import_data) options.set_editor_property('import_mesh', True) options.set_editor_property('import_textures', False) options.set_editor_property('import_materials', False) options.set_editor_property('import_as_skeletal', True) options.set_editor_property('skeleton', None) # options.skeletal_mesh_import_data.set_edtitor_property('import_translation') # options.skeletal_mesh_import_data.set_edtitor_property('import_rotation') # options.skeletal_mesh_import_data.set_edtitor_property('import_uniform_scale') # options.skeletal_mesh_import_data.set_edtitor_property('combine_meshes',False) # options.skeletal_mesh_import_data.set_edtitor_property('generate_lightmap_u_v') # options.skeletal_mesh_import_data.set_edtitor_property('generate_lightmap') return options
def myTick(self, delta_seconds): # Set Time self.time_while_this_window_is_open += delta_seconds self.widget.lbl_Seconds.setText("%.1f Seconds" % self.time_while_this_window_is_open) # Affect Actor if self.random_actor: actor_scale = self.random_actor.get_actor_scale3d() speed = 1.0 * delta_seconds if self.random_actor_is_growing: if actor_scale.z > 4.0: self.random_actor_is_growing = False else: speed = -speed if actor_scale.z < 0.5: self.random_actor_is_growing = True self.random_actor.set_actor_scale3d( unreal.Vector(actor_scale.x + speed, actor_scale.y + speed, actor_scale.z + speed))