diff --git a/AGENTS.md b/AGENTS.md index 209e206..a5ef233 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -57,6 +57,7 @@ Important maps/assets: - Demo map: `/Game/LedVolume/Maps/L_LedVolume_Demo_Single` - Rotating cube sublevel exists for earlier voxelization tests: `/Game/LedVolume/Maps/L_RotatingCube_Sublevel` - Rotating 3D snowflake source level: `/Game/LedVolume/Maps/L_RotatingSnowflake_Sublevel` +- Samba Dancing FBX source level: `/Game/LedVolume/Maps/L_SambaDancing_Sublevel`; imported assets live in `/Game/LedVolume/Sources/SambaDancing`. - Remote Control preset: `/Game/LedVolume/RemoteControl/RCP_LedVolumeLive` ## Remote Control / Minimized Editor Notes @@ -103,7 +104,7 @@ Remote Control exposure rule: - The preset builder has an explicit exposure list in `Source/ledcube3d/ledcube3d.cpp`; add every new controllable property there in the same change. - Do not blindly auto-expose every reflected field; UE Remote Control can crash on unsupported/stale fields in an existing preset. - If a parameter needs a convenient user choice, prefer an enum preset property over asking the user to type raw asset paths. -- The current sublevel source selector is `SublevelSourcePreset` with `Custom`, `RotatingCube`, and `RotatingSnowflake`. +- The current sublevel source selector is `SublevelSourcePreset` with `Custom`, `RotatingCube`, `RotatingSnowflake`, and `SambaDancing`. - `VoxelizedSublevel` is still exposed for custom source maps. Sublevel source notes: diff --git a/Binaries/Win64/UnrealEditor-ledcube3d.dll b/Binaries/Win64/UnrealEditor-ledcube3d.dll index a309d32..ceed28c 100644 Binary files a/Binaries/Win64/UnrealEditor-ledcube3d.dll and b/Binaries/Win64/UnrealEditor-ledcube3d.dll differ diff --git a/Binaries/Win64/UnrealEditor-ledcube3d.pdb b/Binaries/Win64/UnrealEditor-ledcube3d.pdb index 749324a..3ea3228 100644 Binary files a/Binaries/Win64/UnrealEditor-ledcube3d.pdb and b/Binaries/Win64/UnrealEditor-ledcube3d.pdb differ diff --git a/Content/LedVolume/Maps/L_SambaDancing_Sublevel.umap b/Content/LedVolume/Maps/L_SambaDancing_Sublevel.umap new file mode 100644 index 0000000..1baab2c Binary files /dev/null and b/Content/LedVolume/Maps/L_SambaDancing_Sublevel.umap differ diff --git a/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Diffuse.uasset b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Diffuse.uasset new file mode 100644 index 0000000..5733b7a Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Diffuse.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Glossiness.uasset b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Glossiness.uasset new file mode 100644 index 0000000..fe1cbdd Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Glossiness.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Normal.uasset b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Normal.uasset new file mode 100644 index 0000000..048c281 Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Normal.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Specular.uasset b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Specular.uasset new file mode 100644 index 0000000..a0a773d Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Ch14_1001_Specular.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Ch14_Body.uasset b/Content/LedVolume/Sources/SambaDancing/Ch14_Body.uasset new file mode 100644 index 0000000..19d2a8f Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Ch14_Body.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Samba_Dancing.uasset b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing.uasset new file mode 100644 index 0000000..1d3dcfb Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Anim.uasset b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Anim.uasset new file mode 100644 index 0000000..3c98e56 Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Anim.uasset differ diff --git a/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Skeleton.uasset b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Skeleton.uasset new file mode 100644 index 0000000..ad5f44b Binary files /dev/null and b/Content/LedVolume/Sources/SambaDancing/Samba_Dancing_Skeleton.uasset differ diff --git a/Scripts/CreateSambaDancingSublevel.py b/Scripts/CreateSambaDancingSublevel.py new file mode 100644 index 0000000..0784b62 --- /dev/null +++ b/Scripts/CreateSambaDancingSublevel.py @@ -0,0 +1,108 @@ +import unreal + + +FBX_PATH = r"C:\Users\post\Downloads\Samba Dancing.fbx" +SOURCE_DIR = "/Game/LedVolume/Sources/SambaDancing" +MAP_PATH = "/Game/LedVolume/Maps/L_SambaDancing_Sublevel" +SOURCE_TAG = "LedVoxelSource" + + +def ensure_directory(path): + if not unreal.EditorAssetLibrary.does_directory_exist(path): + unreal.EditorAssetLibrary.make_directory(path) + + +def set_prop(obj, name, value): + obj.set_editor_property(name, value) + + +def import_fbx(): + ensure_directory("/Game/LedVolume") + ensure_directory("/Game/LedVolume/Sources") + ensure_directory(SOURCE_DIR) + + task = unreal.AssetImportTask() + task.set_editor_property("filename", FBX_PATH) + task.set_editor_property("destination_path", SOURCE_DIR) + task.set_editor_property("automated", True) + task.set_editor_property("replace_existing", True) + task.set_editor_property("save", True) + + options = unreal.FbxImportUI() + options.set_editor_property("import_mesh", True) + options.set_editor_property("import_as_skeletal", True) + options.set_editor_property("import_animations", True) + options.set_editor_property("mesh_type_to_import", unreal.FBXImportType.FBXIT_SKELETAL_MESH) + options.set_editor_property("create_physics_asset", False) + + task.set_editor_property("options", options) + unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) + + imported = [unreal.EditorAssetLibrary.load_asset(path) for path in task.get_editor_property("imported_object_paths")] + imported = [asset for asset in imported if asset] + + skeletal_mesh = next((asset for asset in imported if isinstance(asset, unreal.SkeletalMesh)), None) + animation = next((asset for asset in imported if isinstance(asset, unreal.AnimSequence)), None) + + if not skeletal_mesh: + assets = unreal.EditorAssetLibrary.list_assets(SOURCE_DIR, recursive=True, include_folder=False) + loaded = [unreal.EditorAssetLibrary.load_asset(path) for path in assets] + skeletal_mesh = next((asset for asset in loaded if isinstance(asset, unreal.SkeletalMesh)), None) + animation = next((asset for asset in loaded if isinstance(asset, unreal.AnimSequence)), None) + + if not skeletal_mesh: + raise RuntimeError("Samba FBX import did not produce a SkeletalMesh.") + + return skeletal_mesh, animation + + +def clear_current_level(): + for actor in unreal.EditorLevelLibrary.get_all_level_actors(): + if not isinstance(actor, unreal.WorldSettings): + unreal.EditorLevelLibrary.destroy_actor(actor) + + +def create_level(skeletal_mesh, animation): + ensure_directory("/Game/LedVolume/Maps") + if unreal.EditorAssetLibrary.does_asset_exist(MAP_PATH): + unreal.EditorLevelLibrary.load_level(MAP_PATH) + else: + unreal.EditorLevelLibrary.new_level(MAP_PATH) + clear_current_level() + + actor = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.SkeletalMeshActor, unreal.Vector(0, 0, 0), unreal.Rotator(0, 0, 0)) + actor.set_actor_label("LED_Source_Samba_Dancing") + actor.tags = [unreal.Name(SOURCE_TAG)] + + component = actor.get_editor_property("skeletal_mesh_component") + set_prop(component, "skeletal_mesh_asset", skeletal_mesh) + set_prop(component, "relative_location", unreal.Vector(0, 0, 0)) + set_prop(component, "relative_rotation", unreal.Rotator(0, 0, 0)) + set_prop(component, "relative_scale3d", unreal.Vector(1.0, 1.0, 1.0)) + set_prop(component, "visibility_based_anim_tick_option", unreal.VisibilityBasedAnimTickOption.ALWAYS_TICK_POSE_AND_REFRESH_BONES) + + if animation: + component.set_animation_mode(unreal.AnimationMode.ANIMATION_SINGLE_NODE) + component.set_animation(animation) + component.play(True) + unreal.log(f"Samba animation assigned: {animation.get_path_name()}") + else: + unreal.log_warning("No AnimSequence imported from Samba FBX; level will contain the skeletal mesh pose only.") + + light = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.DirectionalLight, unreal.Vector(-250, -350, 500), unreal.Rotator(-45, 30, 0)) + light.set_actor_label("Samba_Source_Preview_Light") + + camera = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.CineCameraActor, unreal.Vector(260, -420, 220), unreal.Rotator(-18, 34, 0)) + camera.set_actor_label("Samba_Source_Preview_Camera") + + unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True) + unreal.log(f"Created Samba sublevel: {MAP_PATH}") + + +def main(): + skeletal_mesh, animation = import_fbx() + create_level(skeletal_mesh, animation) + + +if __name__ == "__main__": + main() diff --git a/Source/ledcube3d/LedVolumeDisplayActor.cpp b/Source/ledcube3d/LedVolumeDisplayActor.cpp index 7eeb5bb..872f41e 100644 --- a/Source/ledcube3d/LedVolumeDisplayActor.cpp +++ b/Source/ledcube3d/LedVolumeDisplayActor.cpp @@ -4,6 +4,7 @@ #include "Components/HierarchicalInstancedStaticMeshComponent.h" #include "Components/InstancedStaticMeshComponent.h" +#include "Components/SkeletalMeshComponent.h" #include "Components/StaticMeshComponent.h" #include "Engine/Level.h" #include "Engine/LevelStreamingDynamic.h" @@ -1337,6 +1338,20 @@ void ALedVolumeDisplayActor::HideVoxelizedSublevelSourceActors() const MeshComponent->SetHiddenInGame(true); #if WITH_EDITOR MeshComponent->SetIsTemporarilyHiddenInEditor(true); +#endif + } + } + + TInlineComponentArray SkeletalMeshComponents; + SourceActor->GetComponents(SkeletalMeshComponents); + for (USkeletalMeshComponent* SkeletalMeshComponent : SkeletalMeshComponents) + { + if (SkeletalMeshComponent) + { + SkeletalMeshComponent->VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::AlwaysTickPoseAndRefreshBones; + SkeletalMeshComponent->SetHiddenInGame(true); +#if WITH_EDITOR + SkeletalMeshComponent->SetIsTemporarilyHiddenInEditor(true); #endif } } @@ -1589,6 +1604,21 @@ FLinearColor ALedVolumeDisplayActor::SampleWorldVoxelColor(const FVector& WorldP return SolidColor; } } + + TInlineComponentArray SkeletalMeshComponents; + SourceActor->GetComponents(SkeletalMeshComponents); + for (const USkeletalMeshComponent* SkeletalMeshComponent : SkeletalMeshComponents) + { + if (!SkeletalMeshComponent || !SkeletalMeshComponent->GetSkeletalMeshAsset()) + { + continue; + } + + if (SkeletalMeshComponent->Bounds.GetBox().IsInside(WorldPosition)) + { + return SolidColor; + } + } } return EmptyVoxelColor; diff --git a/Source/ledcube3d/LedVolumeRemoteControlActor.cpp b/Source/ledcube3d/LedVolumeRemoteControlActor.cpp index 9eb745c..d1c5cc9 100644 --- a/Source/ledcube3d/LedVolumeRemoteControlActor.cpp +++ b/Source/ledcube3d/LedVolumeRemoteControlActor.cpp @@ -680,6 +680,10 @@ void ALedVolumeRemoteControlActor::ApplySublevelSourcePreset() { VoxelizedSublevel = TSoftObjectPtr(FSoftObjectPath(TEXT("/Game/LedVolume/Maps/L_RotatingSnowflake_Sublevel.L_RotatingSnowflake_Sublevel"))); } + else if (SublevelSourcePreset == ELedSublevelSourcePreset::SambaDancing) + { + VoxelizedSublevel = TSoftObjectPtr(FSoftObjectPath(TEXT("/Game/LedVolume/Maps/L_SambaDancing_Sublevel.L_SambaDancing_Sublevel"))); + } } void ALedVolumeRemoteControlActor::QueueApply() diff --git a/Source/ledcube3d/LedVolumeTypes.h b/Source/ledcube3d/LedVolumeTypes.h index 240b03a..96033e2 100644 --- a/Source/ledcube3d/LedVolumeTypes.h +++ b/Source/ledcube3d/LedVolumeTypes.h @@ -34,7 +34,8 @@ enum class ELedSublevelSourcePreset : uint8 { Custom UMETA(DisplayName = "Custom"), RotatingCube UMETA(DisplayName = "Rotating Cube"), - RotatingSnowflake UMETA(DisplayName = "Rotating Snowflake") + RotatingSnowflake UMETA(DisplayName = "Rotating Snowflake"), + SambaDancing UMETA(DisplayName = "Samba Dancing") }; UENUM(BlueprintType)