SequenceUnreal
Inheritance diagram
- class xrfeitoria.sequence.sequence_unreal.SequenceUnreal[source]
Sequence class for Unreal.
- classmethod add_audio(audio_asset_path: str, start_frame: int | None = None, end_frame: int | None = None) None [source]
Add an audio track to the sequence.
- Parameters:
audio_asset_path (str) – The path to the audio asset in the engine.
start_frame (Optional[int], optional) – The start frame of the audio track. Defaults to None.
end_frame (Optional[int], optional) – The end frame of the audio track. Defaults to None.
- classmethod add_to_renderer(output_path: str | Path, resolution: Tuple[int, int], render_passes: List[RenderPass], file_name_format: str = '{sequence_name}/{render_pass}/{camera_name}/{frame_number}', console_variables: Dict[str, float] = {'r.MotionBlurQuality': 0}, anti_aliasing: AntiAliasSetting | None = None, export_vertices: bool = False, export_skeleton: bool = False, export_audio: bool = False) None [source]
Add the sequence to the renderer’s job queue. Can only be called after the sequence is instantiated using
new()
oropen()
.- Parameters:
output_path (PathLike) – The path where the rendered output will be saved.
resolution (Tuple[int, int]) – The resolution of the output. (width, height)
render_passes (List[RenderPass]) – The list of render passes to be rendered.
file_name_format (str, optional) – The format of the output file name. Defaults to
{sequence_name}/{render_pass}/{camera_name}/{frame_number}
.console_variables (Dict[str, float], optional) – The console variables to be set before rendering. Defaults to {‘r.MotionBlurQuality’: 0}. Ref to What is stencil_value for details.
anti_aliasing (Optional[RenderJobUnreal.AntiAliasSetting], optional) – The anti-aliasing settings for the render job. Defaults to None.
export_vertices (bool, optional) – Whether to export vertices. Defaults to False.
export_skeleton (bool, optional) – Whether to export the skeleton. Defaults to False.
export_audio (bool, optional) – Whether to export audio. Defaults to False.
Examples
>>> import xrfeitoria as xf >>> from xrfeitoria.data_structure.models import RenderPass >>> with xf.init_blender() as xf_runner: ... seq = xf_runner.Sequence.new(seq_name='test'): ... seq.add_to_renderer( ... output_path=..., ... resolution=..., ... render_passes=[RenderPass('img', 'png')], ... ) ... xf_runner.render()
- static check_motion_data(actor_asset_path: str, motion_data: List[Dict[str, Dict[str, float | List[float]]]]) List[Dict[str, Dict[str, float | List[float]]]] [source]
Check the motion data for a given actor against the skeleton in the engine. Checks if the bone names in the motion data are a subset of the bone names in the skeleton of the actor. If not, the extra bone names in the motion data are ignored.
- Parameters:
actor_asset_path (str) – The asset path of the actor in the engine.
motion_data (List[MotionFrame]) – The motion data to be checked.
- Returns:
List[MotionFrame] – The checked motion data.
- classmethod close() None
Close the opened sequence.
- classmethod get_map_path() str [source]
Returns the path to the map corresponding to the sequence in the Unreal Engine.
- Returns:
str – engine path to the map corresponding to the sequence.
- classmethod get_playback() Tuple[int, int] [source]
Get the playback range for the sequence.
- Returns:
Tuple[int, int] – The start and end frame of the playback range.
- classmethod get_seq_path() str [source]
Returns the path to the sequence in the Unreal Engine.
- Returns:
str – engine path to the sequence.
- classmethod import_actor(file_path: str | Path, actor_name: str | None = None, location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, scale: Tuple[float, float, float] | None = None, stencil_value: int = 1) ActorBase
Imports an actor from a file and adds it to the sequence.
- Parameters:
file_path (PathLike) – The path to the file containing the actor to import.
actor_name (Optional[str], optional) – The name to give the imported actor. If not provided, a name will be generated automatically. Defaults to None.
location (Vector, optional) – The initial location of the actor. Defaults to None.
rotation (Vector, optional) – The initial rotation of the actor. Defaults to None.
scale (Vector, optional) – The initial scale of the actor. Defaults to None.
stencil_value (int, optional) – The stencil value to use for the actor. Defaults to 1.
- Returns:
ActorBase – The imported actor.
- classmethod set_camera_cut_playback(start_frame: int | None = None, end_frame: int | None = None) None [source]
Set the playback range for the sequence.
- Parameters:
start_frame (Optional[int]) – The start frame of the playback range. If not provided, the default start frame will be used.
end_frame (Optional[int]) – The end frame of the playback range. If not provided, the default end frame will be used.
- Returns:
None
- classmethod set_playback(start_frame: int | None = None, end_frame: int | None = None) None [source]
Set the playback range for the sequence.
- Parameters:
start_frame (Optional[int]) – The start frame of the playback range. If not provided, the default start frame will be used.
end_frame (Optional[int]) – The end frame of the playback range. If not provided, the default end frame will be used.
- Returns:
None
- classmethod spawn_actor(actor_asset_path: str, location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, scale: Tuple[float, float, float] | None = None, actor_name: str | None = None, stencil_value: int = 1, anim_asset_path: str | None = None, motion_data: List[Dict[str, Dict[str, float | List[float]]]] | None = None) ActorUnreal [source]
Spawns an actor in the Unreal Engine at the specified location, rotation, and scale.
- Parameters:
cls – The class object.
actor_asset_path (str) – The actor asset path in engine to spawn.
location (Optional[Vector, optional]) – The location to spawn the actor at. unit: meter.
rotation (Optional[Vector, optional]) – The rotation to spawn the actor with. unit: degree.
scale (Optional[Vector], optional) – The scale to spawn the actor with. Defaults to None.
actor_name (Optional[str], optional) – The name to give the spawned actor. Defaults to None.
stencil_value (int in [0, 255], optional) – The stencil value to use for the spawned actor. Defaults to 1. Ref to What is stencil_value for details.
anim_asset_path (Optional[str], optional) – The engine path to the animation asset of the actor. Defaults to None.
motion_data (Optional[List[MotionFrame]]) – The motion data used for FK animation.
- Returns:
ActorUnreal – The spawned actor object.
- classmethod spawn_actor_with_keys(actor_asset_path: str, transform_keys: List[SequenceTransformKey] | SequenceTransformKey, actor_name: str | None = None, stencil_value: int = 1, anim_asset_path: str | None = None, motion_data: List[Dict[str, Dict[str, float | List[float]]]] | None = None) ActorUnreal [source]
Spawns an actor in the Unreal Engine with the given asset path, transform keys, actor name, stencil value, and animation asset path.
- Parameters:
actor_asset_path (str) – The actor asset path in engine to spawn.
transform_keys (TransformKeys) – The transform keys of the actor.
actor_name (Optional[str], optional) – The name of the actor. Defaults to None.
stencil_value (int in [0, 255], optional) – The stencil value to use for the spawned actor. Defaults to 1. Ref to What is stencil_value for details.
anim_asset_path (Optional[str], optional) – The engine path to the animation asset of the actor. Defaults to None.
motion_data (Optional[List[MotionFrame]]) – The motion data used for FK animation.
- Returns:
ActorUnreal – The spawned actor.
- classmethod spawn_camera(location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, fov: float = 90.0, aspect_ratio: float = 1.7777777777777777, camera_name: str | None = None) CameraBase
Spawn a new camera in the sequence.
- Parameters:
location (Vector) – Location of the camera.
rotation (Vector) – Rotation of the camera.
fov (float in (0.0, 180.0), optional) – Field of view of the camera len. Defaults to 90.0. (unit: degrees)
aspect_ratio (float, optional) – Aspect ratio of the camera. Defaults to 16.0 / 9.0.
camera_name (str, optional) – Name of the camera. Defaults to None.
- classmethod spawn_camera_with_keys(transform_keys: List[SequenceTransformKey] | SequenceTransformKey, fov: float = 90.0, aspect_ratio: float = 1.7777777777777777, camera_name: str | None = None) CameraBase
Spawn a new camera with keyframes in the sequence.
- Parameters:
transform_keys (TransformKeys) – Keyframes of transform (location, rotation, and scale).
fov (float in (0.0, 180.0), optional) – Field of view of the camera len. Defaults to 90.0. (unit: degrees)
aspect_ratio (float, optional) – Aspect ratio of the camera. Defaults to 16.0 / 9.0.
camera_name (str, optional) – Name of the camera. Defaults to ‘Camera’.
- classmethod spawn_shape(type: Literal['plane', 'cube', 'sphere', 'cylinder', 'cone'], shape_name: str | None = None, location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, scale: Tuple[float, float, float] | None = None, stencil_value: int = 1, **kwargs) ActorBase
Spawn a shape in the sequence.
- Parameters:
type (str) – Type of new spawn shape. One of [“plane”, “cube”, “sphere”, “cylinder”, “cone”]
shape_name (str) – Name of the new added shape. Defaults to None.
location (Vector, optional) – Location of the shape. Defaults to (0, 0, 0).
rotation (Vector, optional) – Rotation of the shape. Defaults to (0, 0, 0).
scale (Vector, optional) – Scale of the shape. Defaults to (1, 1, 1).
stencil_value (int in [0, 255], optional) – Stencil value of the shape. Defaults to 1. Ref to What is stencil_value for details.
- Returns:
ShapeBlender or ShapeUnreal – New added shape.
- classmethod spawn_shape_with_keys(transform_keys: List[SequenceTransformKey] | SequenceTransformKey, type: Literal['plane', 'cube', 'sphere', 'cylinder', 'cone'], shape_name: str | None = None, stencil_value: int = 1, **kwargs) ActorBase
Spawn a shape with keyframes in the sequence.
- Parameters:
shape_name (str) – Name of the new added shape.
type (str) – Type of new spawn shape. One of [“plane”, “cube”, “sphere”, “cylinder”, “cone”]
transform_keys (TransformKeys) – Keyframes of transform (location, rotation, and scale).
stencil_value (int in [0, 255], optional) – Stencil value of the cone. Defaults to 1. Ref to What is stencil_value for details.
- Returns:
ShapeBlender or ShapeUnreal – New added shape.
- classmethod use_actor(actor: ActorBase, location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, scale: Tuple[float, float, float] | None = None, stencil_value: int | None = None, anim_asset_path: str | None = None) None
Use the specified level actor in the sequence. The location, rotation, scale, stencil_value and anim_asset set in this method are only used in the sequence. These peoperties of the actor in the level will be restored after the sequence is closed.
- Parameters:
actor (ActorUnreal or ActorBlender) – The actor to add to the sequence.
location (Optional[Vector]) – The initial location of the actor. If None, the actor’s current location is used. unit: meter.
rotation (Optional[Vector]) – The initial rotation of the actor. If None, the actor’s current rotation is used. unit: degree.
scale (Optional[Vector]) – The initial scale of the actor. If None, the actor’s current scale is used.
stencil_value (int in [0, 255], optional) – The stencil value to use for the spawned actor. Defaults to None. Ref to What is stencil_value for details.
anim_asset_path (Optional[str]) – For blender, this argument is the name of an action(bpy.types.Action).
Engine (For Unreal) –
actor. (this argument is the engine path to the animation asset to use for the) –
None (Default to None. If) –
used (the actor's current animation is) –
used. (else the specified animation is) –
- classmethod use_actor_with_keys(actor: ActorBase, transform_keys: List[SequenceTransformKey] | SequenceTransformKey, stencil_value: int | None = None, anim_asset_path: str | None = None) None
Use the specified level actor in the sequence. The transform_keys, stencil_value and anim_asset set in this method are only used in the sequence. These peoperties of the actor in the level will be restored after the sequence is closed.
- Parameters:
actor (ActorUnreal or ActorBlender) – The actor to use in the sequence.
transform_keys (Union[TransformKeys, List[TransformKeys]]) – The transform keys to use with the actor.
stencil_value (int in [0, 255], optional) – The stencil value to use for the spawned actor. Defaults to None. Ref to What is stencil_value for details.
anim_asset_path (Optional[str]) – For blender, this argument is the name of an action(bpy.types.Action).
Engine (For Unreal) –
actor. (this argument is the engine path to the animation asset to use for the) –
None (Default to None. If) –
used (the actor's current animation is) –
used. (else the specified animation is) –
- classmethod use_camera(camera: CameraBase, location: Tuple[float, float, float] | None = None, rotation: Tuple[float, float, float] | None = None, fov: float | None = None, aspect_ratio: float = 1.7777777777777777) None
Use the specified level camera in the sequence. The location, rotation and fov set in this method are only used in the sequence. The location, rotation and fov of the camera in the level will be restored after the sequence is closed.
- Parameters:
camera (CameraUnreal or CameraBlender) – The camera to use in the sequence.
location (Optional[Vector], optional) – The location of the camera. Defaults to None. unit: meter.
rotation (Optional[Vector], optional) – The rotation of the camera. Defaults to None. unit: degree.
fov (float, optional) – The field of view of the camera. Defaults to None. unit: degree.
aspect_ratio (float, optional) – The aspect ratio of the camera. Defaults to None.
- classmethod use_camera_with_keys(camera: CameraBase, transform_keys: List[SequenceTransformKey] | SequenceTransformKey, fov: float | None = None, aspect_ratio: float = 1.7777777777777777) None
Use the specified level camera in the sequence. The transform_keys and fov set in this method are only used in the sequence. The location, rotation and fov of the camera in the level will be restored after the sequence is closed.
- Parameters:
camera (CameraUnreal or CameraBlender) – The camera to use.
transform_keys (TransformKeys) – The transform keys to use.
fov (float, optional) – The field of view to use. Defaults to None. unit: degree.
aspect_ratio (float, optional) – The aspect ratio of the camera. Defaults to None.