diff --git a/.gitignore b/.gitignore index 193ec9d..e433cee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ RuntimeMeshComponent/Binaries/* RuntimeMeshComponent/Intermediate/* +# MetaHumans +Content/MetaHumans/* + # Local tests Content/LocalTest/* Content/LocalTests/* diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index f2e54dd..3e9357b 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -2,7 +2,7 @@ GlobalDefaultGameMode=/Stereolabs/ZED/Blueprints/GameMode/BP_ZED_GameMode.BP_ZED_GameMode_C GameInstanceClass=/Script/ZED.ZEDGameInstance EditorStartupMap=/Game/ZED/Levels/L_BodyTrackingSingle.L_BodyTrackingSingle -GameDefaultMap=/Game/ZED/Levels/L_BodyTrackingMulti.L_BodyTrackingMulti +GameDefaultMap=/Game/Local/L_BodyTrackingSiggraph.L_BodyTrackingSiggraph [/Script/Engine.Engine] diff --git a/Content/ZED/Assets/Island/Bark.uasset b/Content/ZED/Assets/Island/Bark.uasset index b162d63..0ee9a94 100644 Binary files a/Content/ZED/Assets/Island/Bark.uasset and b/Content/ZED/Assets/Island/Bark.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Bodymat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Bodymat.uasset new file mode 100644 index 0000000..c4cb1f5 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Bodymat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Bottommat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Bottommat.uasset new file mode 100644 index 0000000..050e9a8 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Bottommat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Eyelashmat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Eyelashmat.uasset new file mode 100644 index 0000000..cb3154b Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Eyelashmat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Hairmat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Hairmat.uasset new file mode 100644 index 0000000..6c1c96a Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Hairmat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Shoesmat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Shoesmat.uasset new file mode 100644 index 0000000..7862139 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Shoesmat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Materials/Remy/Topmat.uasset b/Content/ZED/Assets/Mannequin/Materials/Remy/Topmat.uasset new file mode 100644 index 0000000..35c0639 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Materials/Remy/Topmat.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/Remy/ABP_Remy.uasset b/Content/ZED/Assets/Mannequin/Mesh/Remy/ABP_Remy.uasset new file mode 100644 index 0000000..252af36 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Mesh/Remy/ABP_Remy.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/Remy/IKRetarget_Remy.uasset b/Content/ZED/Assets/Mannequin/Mesh/Remy/IKRetarget_Remy.uasset new file mode 100644 index 0000000..f08b5c6 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Mesh/Remy/IKRetarget_Remy.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/Remy/IK_Remy.uasset b/Content/ZED/Assets/Mannequin/Mesh/Remy/IK_Remy.uasset new file mode 100644 index 0000000..ac791a9 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Mesh/Remy/IK_Remy.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/Remy/SKM_Remy.uasset b/Content/ZED/Assets/Mannequin/Mesh/Remy/SKM_Remy.uasset new file mode 100644 index 0000000..dbdadeb Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Mesh/Remy/SKM_Remy.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/Remy/SK_Remy.uasset b/Content/ZED/Assets/Mannequin/Mesh/Remy/SK_Remy.uasset new file mode 100644 index 0000000..395afa1 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Mesh/Remy/SK_Remy.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Mesh/ZED_Manny/CR_ZED_Manny_FootIK.uasset b/Content/ZED/Assets/Mannequin/Mesh/ZED_Manny/CR_ZED_Manny_FootIK.uasset index 91b7d7f..b634318 100644 Binary files a/Content/ZED/Assets/Mannequin/Mesh/ZED_Manny/CR_ZED_Manny_FootIK.uasset and b/Content/ZED/Assets/Mannequin/Mesh/ZED_Manny/CR_ZED_Manny_FootIK.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse.uasset new file mode 100644 index 0000000..7b7efb3 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse_ncl1_1.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse_ncl1_1.uasset new file mode 100644 index 0000000..471fca7 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Diffuse_ncl1_1.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss.uasset new file mode 100644 index 0000000..97f6776 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss_ncl1_1.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss_ncl1_1.uasset new file mode 100644 index 0000000..588acd1 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Gloss_ncl1_1.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal.uasset new file mode 100644 index 0000000..1f8b9fe Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal_ncl1_1.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal_ncl1_1.uasset new file mode 100644 index 0000000..88d3e02 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Normal_ncl1_1.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Opacity.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Opacity.uasset new file mode 100644 index 0000000..4980c1d Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Opacity.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular.uasset new file mode 100644 index 0000000..326292d Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular_ncl1_1.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular_ncl1_1.uasset new file mode 100644 index 0000000..668b6ae Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Body_Specular_ncl1_1.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Diffuse.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Diffuse.uasset new file mode 100644 index 0000000..92e1b8d Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Diffuse.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Gloss.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Gloss.uasset new file mode 100644 index 0000000..55af7e9 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Gloss.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Normal.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Normal.uasset new file mode 100644 index 0000000..82e239b Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Normal.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Specular.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Specular.uasset new file mode 100644 index 0000000..3c14d88 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Bottom_Specular.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Diffuse.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Diffuse.uasset new file mode 100644 index 0000000..9b72a7e Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Diffuse.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Gloss.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Gloss.uasset new file mode 100644 index 0000000..f252fac Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Gloss.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Normal.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Normal.uasset new file mode 100644 index 0000000..cee1bf6 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Normal.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Opacity.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Opacity.uasset new file mode 100644 index 0000000..4b44f67 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Opacity.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Specular.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Specular.uasset new file mode 100644 index 0000000..aa4f080 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Hair_Specular.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Diffuse.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Diffuse.uasset new file mode 100644 index 0000000..cc170f5 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Diffuse.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Gloss.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Gloss.uasset new file mode 100644 index 0000000..3690a1c Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Gloss.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Normal.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Normal.uasset new file mode 100644 index 0000000..1cccd38 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Normal.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Specular.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Specular.uasset new file mode 100644 index 0000000..15ec397 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Shoes_Specular.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Diffuse.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Diffuse.uasset new file mode 100644 index 0000000..df44da2 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Diffuse.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Gloss.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Gloss.uasset new file mode 100644 index 0000000..2c39784 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Gloss.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Normal.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Normal.uasset new file mode 100644 index 0000000..2f1ee2a Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Normal.uasset differ diff --git a/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Specular.uasset b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Specular.uasset new file mode 100644 index 0000000..9c27dd8 Binary files /dev/null and b/Content/ZED/Assets/Mannequin/Textures/Remy/Remy_Top_Specular.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/ABP_ZED_Manny.uasset b/Content/ZED/Blueprints/BodyTracking/ABP_ZED_Manny.uasset index 9e84fbe..b921e32 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/ABP_ZED_Manny.uasset and b/Content/ZED/Blueprints/BodyTracking/ABP_ZED_Manny.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_BodyTracking_Visualizer.uasset b/Content/ZED/Blueprints/BodyTracking/BP_BodyTracking_Visualizer.uasset index 15ad346..7c29f13 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/BP_BodyTracking_Visualizer.uasset and b/Content/ZED/Blueprints/BodyTracking/BP_BodyTracking_Visualizer.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_Remy.uasset b/Content/ZED/Blueprints/BodyTracking/BP_Remy.uasset new file mode 100644 index 0000000..4330693 Binary files /dev/null and b/Content/ZED/Blueprints/BodyTracking/BP_Remy.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton.uasset b/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton.uasset index 9a5d866..02bb315 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton.uasset and b/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton_Visualizer.uasset b/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton_Visualizer.uasset index a32e58f..dddf0b8 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton_Visualizer.uasset and b/Content/ZED/Blueprints/BodyTracking/BP_SDK_Skeleton_Visualizer.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_VirtualCanvas.uasset b/Content/ZED/Blueprints/BodyTracking/BP_VirtualCanvas.uasset index d84c188..d2a2b05 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/BP_VirtualCanvas.uasset and b/Content/ZED/Blueprints/BodyTracking/BP_VirtualCanvas.uasset differ diff --git a/Content/ZED/Blueprints/BodyTracking/BP_ZED_Manny.uasset b/Content/ZED/Blueprints/BodyTracking/BP_ZED_Manny.uasset index e3ebf9c..2b72c24 100644 Binary files a/Content/ZED/Blueprints/BodyTracking/BP_ZED_Manny.uasset and b/Content/ZED/Blueprints/BodyTracking/BP_ZED_Manny.uasset differ diff --git a/Content/ZED/Levels/L_BodyTrackingMulti.umap b/Content/ZED/Levels/L_BodyTrackingMulti.umap index 7f69741..8406fb0 100644 Binary files a/Content/ZED/Levels/L_BodyTrackingMulti.umap and b/Content/ZED/Levels/L_BodyTrackingMulti.umap differ diff --git a/Content/ZED/Levels/L_BodyTrackingSingle.umap b/Content/ZED/Levels/L_BodyTrackingSingle.umap index 74e2b2b..4313a04 100644 Binary files a/Content/ZED/Levels/L_BodyTrackingSingle.umap and b/Content/ZED/Levels/L_BodyTrackingSingle.umap differ diff --git a/Content/ZED/Materials/BodyTracking/M_ZEDVIEW.uasset b/Content/ZED/Materials/BodyTracking/M_ZEDVIEW.uasset index cbd20d4..166222f 100644 Binary files a/Content/ZED/Materials/BodyTracking/M_ZEDVIEW.uasset and b/Content/ZED/Materials/BodyTracking/M_ZEDVIEW.uasset differ diff --git a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsBaseTypes.cpp b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsBaseTypes.cpp index b657dad..2f313e0 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsBaseTypes.cpp +++ b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsBaseTypes.cpp @@ -10,7 +10,8 @@ FSlSpatialMappingParameters::FSlSpatialMappingParameters() PresetResolution(ESlSpatialMappingResolution::SMR_Medium), PresetRange(ESlSpatialMappingRange::SMR_Auto), bSaveTexture(false)/*, - bUseChunkOnly(bUseChunkOnly)*/ + bUseChunkOnly(bUseChunkOnly)*/, + StabilityCounter(0) { MaxRange = sl::SpatialMappingParameters::get(sl::unreal::ToSlType(PresetRange)); Resolution = sl::SpatialMappingParameters::get(sl::unreal::ToSlType(PresetResolution)); diff --git a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsCameraProxy.cpp b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsCameraProxy.cpp index 4f93e0a..40ab25b 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsCameraProxy.cpp +++ b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsCameraProxy.cpp @@ -440,6 +440,7 @@ void USlCameraProxy::Internal_EnableTracking(const FSlPositionalTrackingParamete sl_positional_tracking_parameters.set_as_static = NewTrackingParameters.bSetAsStatic; sl_positional_tracking_parameters.set_floor_as_origin = NewTrackingParameters.bSetFloorAsOrigin; sl_positional_tracking_parameters.set_gravity_as_origin = NewTrackingParameters.bSetGravityAsOrigin; + sl_positional_tracking_parameters.mode = (SL_POSITIONAL_TRACKING_MODE)NewTrackingParameters.Mode; SL_SCOPE_LOCK(Lock, GrabSection) ErrorCode = (SL_ERROR_CODE)sl_enable_positional_tracking(CameraID, &sl_positional_tracking_parameters, TCHAR_TO_UTF8(*NewTrackingParameters.AreaFilePath)); @@ -909,7 +910,9 @@ bool USlCameraProxy::RetrieveMeshAsync(USlMesh* Mesh) Mesh->Vertices.SetNum(Mesh->NbVertices * 3); Mesh->Triangles.SetNum(Mesh->NbTriangles * 3); Mesh->UVs.SetNum(Mesh->NbVertices * 2); - ErrorCode = (SL_ERROR_CODE)sl_retrieve_whole_mesh(CameraID, Mesh->Vertices.GetData(), Mesh->Triangles.GetData(), Mesh->UVs.GetData(), Mesh->Texture.GetData()); + Mesh->Colors.SetNum(Mesh->NbVertices * 3); + + ErrorCode = (SL_ERROR_CODE)sl_retrieve_whole_mesh(CameraID, Mesh->Vertices.GetData(), Mesh->Triangles.GetData(), Mesh->Colors.GetData(), Mesh->UVs.GetData(), Mesh->Texture.GetData()); if (ErrorCode != SL_ERROR_CODE_SUCCESS) { diff --git a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsMesh.cpp b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsMesh.cpp index d27d1b6..9f7a2e4 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsMesh.cpp +++ b/Plugins/Stereolabs/Source/Stereolabs/Private/Core/StereolabsMesh.cpp @@ -49,8 +49,9 @@ bool USlMesh::Filter(const FSlMeshFilterParameters& MeshFilterParameters/* = FSl Vertices.SetNum(NbVertices * 3); UVs.SetNum(NbVertices * 2); Triangles.SetNum(NbTriangles * 3); + Colors.SetNum(NbVertices * 3); - (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), UVs.GetData(), Texture.GetData()); + (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), Colors.GetData(), UVs.GetData(), Texture.GetData()); return bFiltered; } @@ -68,8 +69,10 @@ bool USlMesh::ApplyTexture(bool bSRGB/* = false*/) Vertices.SetNum(NbVertices * 3); UVs.SetNum(NbVertices * 2); Triangles.SetNum(NbTriangles * 3); + Colors.SetNum(NbVertices * 3); + Texture.SetNum(TextureSize[0] * TextureSize[1] * 4); - SL_ERROR_CODE err = (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), UVs.GetData(), Texture.GetData()); + SL_ERROR_CODE err = (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), Colors.GetData(), UVs.GetData(), Texture.GetData()); } @@ -139,8 +142,9 @@ bool USlMesh::Load(const FString& FilePath, bool bUpdateChunksOnly/* = false*/) Vertices.SetNum(NbVertices * 3); UVs.SetNum(NbVertices * 2); Triangles.SetNum(NbTriangles * 3); + Colors.SetNum(NbVertices * 3); - (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), UVs.GetData(), Texture.GetData()); + (SL_ERROR_CODE)sl_retrieve_whole_mesh(GSlCameraProxy->GetCameraID(), Vertices.GetData(), Triangles.GetData(), Colors.GetData(), UVs.GetData(), Texture.GetData()); return bIsLoaded; } diff --git a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsBaseTypes.h b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsBaseTypes.h index e322e13..b0e6d76 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsBaseTypes.h +++ b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsBaseTypes.h @@ -141,13 +141,16 @@ ENUM_CLASS_FLAGS(ESlMemoryType) * SDK Video resolutions * see sl::RESOLUTION */ -UENUM(BlueprintType, Category = "Stereolabs|Enum") -enum class ESlResolution : uint8 + UENUM(BlueprintType, Category = "Stereolabs|Enum") + enum class ESlResolution : uint8 { R_HD2K UMETA(DisplayName = "HD 2K"), R_HD1080 UMETA(DisplayName = "HD 1080p"), + R_HD1200 UMETA(DisplayName = "HD 1200p (ZED X only)"), R_HD720 UMETA(DisplayName = "HD 720p"), - R_VGA UMETA(DisplayName = "VGA") + R_SVGA UMETA(DisplayName = "SVGA (ZED X only)"), + R_VGA UMETA(DisplayName = "VGA"), + R_AUTO UMETA(DisplayName = "AUTO, 1200p for ZEDX and 720 otherwise") }; /* @@ -498,6 +501,16 @@ enum class ESlSelfCalibrationState : uint8 SCS_Success UMETA(DisplayName = "Success"), }; +/* +* Lists the mode of positional tracking that can be used. +*/ +UENUM(BlueprintType, Category = "Stereolabs|Enum") +enum class ESlPositionalTrackingMode : uint8 +{ + PTM_Standard UMETA(DisplayName = "Standard"), + PTM_Quality UMETA(DisplayName = "Quality") +}; + /* * Lists available object tracking state. */ @@ -1316,6 +1329,14 @@ struct STEREOLABS_API FSlSpatialMappingParameters UPROPERTY(EditAnywhere, BlueprintReadWrite) ESlSpatialMappingRange PresetRange; + /** + \brief Control the integration rate of the current depth into the mapping process. + This parameter controls how many times a stable 3D points should be seen before it is integrated into the spatial mapping. + Default value is 0, this will define the stability counter based on the mesh resolution, the higher the resolution, the higher the stability counter. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int StabilityCounter; + /* * Set to true if you want be able to apply texture to your mesh after its creation. * This option will take more memory. @@ -1947,7 +1968,8 @@ struct STEREOLABS_API FSlPositionalTrackingParameters bEnableImuFusion(true), bSetAsStatic(false), DepthMinRange(-1), - bSetGravityAsOrigin(true) + bSetGravityAsOrigin(true), + Mode(ESlPositionalTrackingMode::PTM_Standard) { } @@ -2108,6 +2130,13 @@ struct STEREOLABS_API FSlPositionalTrackingParameters */ UPROPERTY(EditAnywhere, BlueprintReadWrite) bool bSetGravityAsOrigin; + + /** + * @brief Positional tracking mode used. Can be used to improve accuracy in some type of scene at the cost of longer runtime + * default : POSITIONAL_TRACKING_MODE::STANDARD + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite) + ESlPositionalTrackingMode Mode; }; /* @@ -3012,9 +3041,17 @@ struct STEREOLABS_API FSlBodyTrackingRuntimeParameters UPROPERTY(EditAnywhere, BlueprintReadWrite) int MinimumKeypointsThreshold; - FSlBodyTrackingRuntimeParameters(): + /** + * @brief this value controls the smoothing of the fitted fused skeleton. + * it is ranged from 0 (low smoothing) and 1 (high smoothing) + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite) + float SkeletonSmoothing; + + FSlBodyTrackingRuntimeParameters() : DetectionConfidenceThreshold(20.0f), - MinimumKeypointsThreshold(-1) + MinimumKeypointsThreshold(-1), + SkeletonSmoothing(0.0f) {} }; diff --git a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsCoreGlobals.h b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsCoreGlobals.h index cbd858c..9199af1 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsCoreGlobals.h +++ b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsCoreGlobals.h @@ -2206,6 +2206,7 @@ namespace sl struct SL_BodyTrackingRuntimeParameters BTParameters; BTParameters.detection_confidence_threshold = UnrealData.DetectionConfidenceThreshold; BTParameters.minimum_keypoints_threshold = UnrealData.MinimumKeypointsThreshold; + BTParameters.skeleton_smoothing = UnrealData.SkeletonSmoothing; return BTParameters; } @@ -2280,6 +2281,7 @@ namespace sl SpatialMappingParameters.resolution_meter = GetResolution(UnrealData.PresetResolution); SpatialMappingParameters.use_chunk_only = UnrealData.GetUseChunksOnly(); SpatialMappingParameters.reverse_vertex_order = true; + SpatialMappingParameters.stability_counter = UnrealData.StabilityCounter; return SpatialMappingParameters; } diff --git a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsMesh.h b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsMesh.h index 7838337..72388a4 100644 --- a/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsMesh.h +++ b/Plugins/Stereolabs/Source/Stereolabs/Public/Core/StereolabsMesh.h @@ -103,6 +103,8 @@ class STEREOLABS_API USlMesh : public UObject TArray Triangles; + TArray Colors; + TArray UVs; TArray Texture; diff --git a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/bin/sl_zed_c.dll b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/bin/sl_zed_c.dll index cd28f1d..6fdb6c7 100644 Binary files a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/bin/sl_zed_c.dll and b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/bin/sl_zed_c.dll differ diff --git a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/types_c.h b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/types_c.h index a94a1de..3b75a40 100644 --- a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/types_c.h +++ b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/types_c.h @@ -286,7 +286,7 @@ enum SL_UNIT { \image html CoordinateSystem.png */ enum SL_COORDINATE_SYSTEM { - SL_COORDINATE_SYSTEM_IMAGE, /**< Standard coordinates system in computer vision. Used in OpenCV : see here : http://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html */ + SL_COORDINATE_SYSTEM_IMAGE, /**< Standard coordinates system in computer vision. Used in OpenCV : see here. */ SL_COORDINATE_SYSTEM_LEFT_HANDED_Y_UP, /**< Left-Handed with Y up and Z forward. Used in Unity with DirectX. */ SL_COORDINATE_SYSTEM_RIGHT_HANDED_Y_UP, /**< Right-Handed with Y pointing up and Z backward. Used in OpenGL. */ SL_COORDINATE_SYSTEM_RIGHT_HANDED_Z_UP, /**< Right-Handed with Z pointing up and Y forward. Used in 3DSMax. */ @@ -481,6 +481,20 @@ enum SL_POSITIONAL_TRACKING_STATE { SL_POSITIONAL_TRACKING_STATE_SEARCHING_FLOOR_PLANE, /**< The camera is searching for the floor plane to locate itself related to it, the REFERENCE_FRAME::WORLD will be set afterward.*/ }; +/** + \enum POSITIONAL_TRACKING_MODE + \ingroup PositionalTracking_group + \brief Lists the mode of positional tracking that can be used. + */ +enum SL_POSITIONAL_TRACKING_MODE { + SL_POSITIONAL_TRACKING_MODE_STANDARD, /**< Default mode, best compromise in performance and accuracy */ + SL_POSITIONAL_TRACKING_MODE_QUALITY, /**< Improve accuracy in more challening scenes such as outdoor repetitive patterns like extensive field. Curently works best with ULTRA depth mode, requires more compute power */ + ///@cond SHOWHIDDEN + SL_POSITIONAL_TRACKING_MODE_LAST + ///@endcond +}; + + /** \brief Lists the different states of spatial memory area export. */ @@ -719,7 +733,7 @@ enum SL_BODY_FORMAT * \brief 70 keypoint model. * Body model, including feet and full hands models (and simplified face) */ - SL_BODY_FORMAT_BODY_70, + SL_BODY_FORMAT_BODY_70, }; enum SL_BODY_KEYPOINTS_SELECTION @@ -1390,6 +1404,12 @@ d \warning: This mode requires more resources to run, but greatly improves track * @brief This setting allows you to override 2 of the 3 rotations from initial_world_transform using the IMU gravity */ bool set_gravity_as_origin; + /** + * @brief Positional tracking mode used. Can be used to improve accuracy in some type of scene at the cost of longer runtime + * default : POSITIONAL_TRACKING_MODE::STANDARD + */ + enum SL_POSITIONAL_TRACKING_MODE mode; + }; /** @@ -1594,6 +1614,12 @@ struct SL_SpatialMappingParameters { \brief The type of spatial map to be created. This dictates the format that will be used for the mapping(e.g. mesh, point cloud). See \ref SPATIAL_MAP_TYPE */ enum SL_SPATIAL_MAP_TYPE map_type; + /** + \brief Control the integration rate of the current depth into the mapping process. + This parameter controls how many times a stable 3D points should be seen before it is integrated into the spatial mapping. + Default value is 0, this will define the stability counter based on the mesh resolution, the higher the resolution, the higher the stability counter. + */ + int stability_counter; }; @@ -1852,6 +1878,12 @@ struct SL_BodyTrackingRuntimeParameters { * it is useful for example to remove unstable fitting results when a skeleton is partially occluded. */ int minimum_keypoints_threshold; + /** + * @brief this value controls the smoothing of the fitted fused skeleton. + * it is ranged from 0 (low smoothing) and 1 (high smoothing) + * Default is 0; + */ + float skeleton_smoothing; }; /** diff --git a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/zed_interface.h b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/zed_interface.h index c7e6a2c..36d1fa5 100644 --- a/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/zed_interface.h +++ b/Plugins/Stereolabs/Source/ThirdParty/sl_zed_c/include/sl/c_api/zed_interface.h @@ -657,12 +657,13 @@ extern "C" { \param camera_id : id of the camera instance. \param vertices : Vertices of the mesh \param triangles : Triangles of the mesh. + \param colors : (b,g,r) colors of each vertex. \param max_submeshes : Maximum number of submesh that can be handled. \param uvs : uvs of the texture. \param texture_ptr : Texture of the mesh (if enabled). \return SUCCESS if the mesh is retrieved. */ - INTERFACE_API int sl_retrieve_mesh(int camera_id, float* vertices, int* triangles, float* uvs, unsigned char* texture_ptr, const int max_submeshes); + INTERFACE_API int sl_retrieve_mesh(int camera_id, float* vertices, int* triangles, unsigned char* colors, float* uvs, unsigned char* texture_ptr, const int max_submeshes); /** \brief Updates the internal version of the mesh and returns the sizes of the meshes. \param camera_id : id of the camera instance. @@ -683,11 +684,12 @@ extern "C" { \param max_submesh : Maximum number of submesh that can be handled. \param vertices : Vertices of the chunk \param triangles : Triangles of the chunk. + \param colors : b,g,r colors of the chunk \param uvs : uvs of the texture. \param texture_ptr : Texture of the mesh (if enabled). \return SUCCESS if the chunk is retrieved. */ - INTERFACE_API int sl_retrieve_chunks(int camera_id, float* vertices, int* triangles, float* uvs, unsigned char* texture_ptr, const int max_submesh); + INTERFACE_API int sl_retrieve_chunks(int camera_id, float* vertices, int* triangles, unsigned char* colors, float* uvs, unsigned char* texture_ptr, const int max_submesh); /** \brief Updates the fused point cloud (if spatial map type was FUSED_POINT_CLOUD). @@ -792,13 +794,14 @@ extern "C" { \brief Retrieves the full mesh. Call update_mesh before calling this. Vertex and triangles arrays must be at least of the sizes returned by update_mesh (nb_vertices and nbTriangles). \param camera_id : id of the camera instance. - \param vertices : Vertices of the chunk - \param triangles : Triangles of the chunk. + \param vertices : Vertices of the mesh + \param triangles : Triangles of the mesh. + \param colors : (b,g,r) colors of the mesh. \param uvs : uvs of the texture. \param texture_ptr : Texture of the mesh (if enabled). \return SUCCESS if the chunk is retrieved. */ - INTERFACE_API int sl_retrieve_whole_mesh(int camera_id, float* vertices, int* triangles, float* uvs, unsigned char* texture_ptr); + INTERFACE_API int sl_retrieve_whole_mesh(int camera_id, float* vertices, int* triangles, unsigned char* colors, float* uvs, unsigned char* texture_ptr); /** \brief Loads a saved mesh file. \param camera_id : id of the camera instance. diff --git a/Plugins/Stereolabs/Source/ZED/Private/Core/AnimNode_ZEDPose.cpp b/Plugins/Stereolabs/Source/ZED/Private/Core/AnimNode_ZEDPose.cpp index 94fe821..e3e0a3d 100644 --- a/Plugins/Stereolabs/Source/ZED/Private/Core/AnimNode_ZEDPose.cpp +++ b/Plugins/Stereolabs/Source/ZED/Private/Core/AnimNode_ZEDPose.cpp @@ -8,6 +8,46 @@ #include "Math/Quat.h" #include "Math/UnrealMathUtility.h" + +float FAnimNode_ZEDPose::ComputeRootTranslationFactor(FCompactPose& OutPose, const FSlBodyData& InBodyData) +{ + float avatarTotalTranslation = 0.f; + float SDKTotalTranslation = 0.f; + if (NbKeypoints <= 34) + { + for (int32 i = 22; i < 24; i++) + { + FVector BonePosition = InBodyData.LocalPositionPerJoint[i]; + FCompactPoseBoneIndex CPIndex = GetCPIndex(i, OutPose); + if (CPIndex != INDEX_NONE) + { + avatarTotalTranslation += OutPose[CPIndex].GetTranslation().Size(); + SDKTotalTranslation += BonePosition.Size(); + } + } + } + else + { + for (int32 i = 19; i < 23; i++) + { + FVector BonePosition = InBodyData.LocalPositionPerJoint[i]; + FCompactPoseBoneIndex CPIndex = GetCPIndex(i, OutPose); + if (CPIndex != INDEX_NONE) + { + avatarTotalTranslation += OutPose[CPIndex].GetTranslation().Size(); + SDKTotalTranslation += BonePosition.Size(); + } + } + } + + float factor = avatarTotalTranslation / SDKTotalTranslation; + float scale = 1.f; + FCompactPoseBoneIndex CPIndexRoot = GetCPIndex(0, OutPose); + if (CPIndexRoot != INDEX_NONE) + scale = OutPose[CPIndexRoot].GetScale3D().Z; + return FMath::Abs(scale * factor); +} + FCompactPoseBoneIndex FAnimNode_ZEDPose::GetCPIndex(int32 i, FCompactPose& OutPose) { FName Name = bMirrorOnZAxis ? KeypointsMirrored[i] : Keypoints[i]; @@ -109,22 +149,40 @@ void FAnimNode_ZEDPose::BuildPoseFromSlBodyData(FPoseContext& PoseContext) SkeletalMesh->GetBoneNames(TargetBoneNames); // Apply an offset to put the feet of the ground and offset "floating" avatars. - if (bStickAvatarOnFloor && BodyData.KeypointConfidence[*Keypoints.FindKey(FName("LEFT_ANKLE"))] > 90 && BodyData.KeypointConfidence[*Keypoints.FindKey(FName("RIGHT_ANKLE"))] > 90) { //if both foot are visible/detected - if (SkeletalMesh) { - + if (bStickAvatarOnFloor && BodyData.KeypointConfidence[*Keypoints.FindKey(FName("LEFT_ANKLE"))] > 0 && BodyData.KeypointConfidence[*Keypoints.FindKey(FName("RIGHT_ANKLE"))] > 0) { //if both foot are visible/detected + if (SkeletalMesh) + { FVector LeftFootPosition; FVector RightFootPosition; if (BodyData.Keypoint.Num() == 34) // body 34 { - LeftFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[21]]); - RightFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[25]]); + if (LeftAnkleToHeelOffset == 0 && RightAnkleToHeelOffset == 0) + { + LeftAnkleToHeelOffset = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[21]]).Z - SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[20]]).Z; + RightAnkleToHeelOffset = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[25]]).Z - SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[24]]).Z; + + } + + LeftFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[20]]) + LeftAnkleToHeelOffset; + RightFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[24]]) + RightAnkleToHeelOffset; + } else // body 38 or 70 { - LeftFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[24]]); - RightFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[25]]); + if (LeftAnkleToHeelOffset == 0 && RightAnkleToHeelOffset == 0) + { + LeftAnkleToHeelOffset = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[24]]).Z - SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[22]]).Z; + RightAnkleToHeelOffset = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[25]]).Z - SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[23]]).Z; + + //UE_LOG(LogTemp, Warning, TEXT("Recomputing foot position ... %f"), LeftAnkleToHeelOffset); + + } + + LeftFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[22]]) + LeftAnkleToHeelOffset; + RightFootPosition = SkeletalMesh->GetBoneLocation(RemapAsset[Keypoints[23]]) + RightAnkleToHeelOffset; } + // Shot raycast to the ground. FHitResult HitLeftFoot; bool RaycastLeftFoot = SkeletalMesh->GetWorld()->LineTraceSingleByObjectType(OUT HitLeftFoot, LeftFootPosition + FVector(0, 0, 200), LeftFootPosition - FVector(0, 0, 200), @@ -141,41 +199,33 @@ void FAnimNode_ZEDPose::BuildPoseFromSlBodyData(FPoseContext& PoseContext) // Compute the distance between one foot and the ground (the first static object found by the ray cast). if (RaycastLeftFoot) { - LeftFootFloorDistance = (LeftFootPosition + FVector(0, 0, FeetOffset) - HitLeftFoot.ImpactPoint).Z; + LeftFootFloorDistance = (LeftFootPosition + FVector(0, 0, AutomaticHeightOffset) - HitLeftFoot.ImpactPoint).Z; } if (RaycastRightFoot) { - RightFootFloorDistance = (RightFootPosition + FVector(0, 0, FeetOffset) - HitRightFoot.ImpactPoint).Z; + RightFootFloorDistance = (RightFootPosition + FVector(0, 0, AutomaticHeightOffset) - HitRightFoot.ImpactPoint).Z; } - float MinFootFloorDistance = 0; - - // If both feet are under the ground, use the max value instead of the min value. - if (RightFootFloorDistance < 0 && LeftFootFloorDistance < 0) + //UE_LOG(LogTemp, Warning, TEXT("%f"), abs(fminf(LeftFootFloorDistance, RightFootFloorDistance))); + if (abs(fminf(LeftFootFloorDistance, RightFootFloorDistance)) <= DistanceToFloorThreshold) { - MinFootFloorDistance = -1.0f * fmax(abs(RightFootFloorDistance), abs(LeftFootFloorDistance)); - - FeetOffset = FeetOffsetAlpha * MinFootFloorDistance + (1 - FeetOffsetAlpha) * FeetOffset; + // Reset counter + DurationOffsetError = 0; } - else if (RightFootFloorDistance > 0 && LeftFootFloorDistance > 0) + else { - MinFootFloorDistance = fmin(abs(RightFootFloorDistance), abs(LeftFootFloorDistance)); - - // The feet offset is added in the buffer of size "FeetOffsetBufferSize". If the buffer is already full, remove the oldest value (the first of the deque) - if (FeetOffsetBuffer.size() == FeetOffsetBufferSize) + auto NowTS_ms = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + DurationOffsetError += (NowTS_ms - PreviousTS_ms) / 1000.0f; + PreviousTS_ms = NowTS_ms; + + if (DurationOffsetError > DurationOffsetErrorThreshold) { - FeetOffsetBuffer.pop_front(); - } - FeetOffsetBuffer.push_back(MinFootFloorDistance); + AutomaticHeightOffset = fmin(LeftFootFloorDistance, RightFootFloorDistance); + DurationOffsetError = 0; - // The feet offset is the min element of this deque (of size FeetOffsetBufferSize). - FeetOffset = *std::min_element(FeetOffsetBuffer.begin(), FeetOffsetBuffer.end()); - } - else - { - MinFootFloorDistance = fmin(RightFootFloorDistance, LeftFootFloorDistance); - FeetOffset = FeetOffsetAlpha * MinFootFloorDistance + (1 - FeetOffsetAlpha) * FeetOffset; + //UE_LOG(LogTemp, Warning, TEXT("Recomputing offset ... %f"), AutomaticHeightOffset); + } } } } @@ -220,9 +270,12 @@ void FAnimNode_ZEDPose::BuildPoseFromSlBodyData(FPoseContext& PoseContext) // Only use position + rotation data for root. For all other bones, set rotation only. if (TargetBoneName == *RemapAsset.Find(GetTargetRootName())) { + float rootScaleFactor = ComputeRootTranslationFactor(OutPose, BodyData); FVector RootPosition = BodyData.Keypoint[0]; - RootPosition.Z += HeightOffset; - RootPosition.Z -= FeetOffset; + RootPosition.Z += ManualHeightOffset; + RootPosition.Z -= AutomaticHeightOffset; + RootPosition.Z *= rootScaleFactor; + Translation = FMath::Lerp( PreviousRootPosition, @@ -298,7 +351,6 @@ void FAnimNode_ZEDPose::BuildPoseFromSlBodyData(FPoseContext& PoseContext) ParentBoneScale = *ZEDBoneSize.Find(TargetParentBoneName) / *RefPoseBoneSize.Find(TargetParentBoneName); BoneScale /= ParentBoneScale; - FinalScale = BoneScaleAlpha * (*BonesScale.Find(TargetBoneName)) + (1 - BoneScaleAlpha) * FVector(BoneScale, BoneScale, BoneScale); } else @@ -334,6 +386,12 @@ void FAnimNode_ZEDPose::Initialize_AnyThread(const FAnimationInitializeContext& InputPose.Initialize(Context); BoneScaleAlpha = 0.2f; + PreviousTS_ms = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + + if (bStickAvatarOnFloor) + { + UE_LOG(LogTemp, Warning, TEXT("Automatic offset of avatar and Foot IK can not be enabled together. FootIK will be ignored")); + } } void FAnimNode_ZEDPose::PreUpdate(const UAnimInstance* InAnimInstance) diff --git a/Plugins/Stereolabs/Source/ZED/Public/Core/AnimNode_ZEDPose.h b/Plugins/Stereolabs/Source/ZED/Public/Core/AnimNode_ZEDPose.h index eae08a8..95142d1 100644 --- a/Plugins/Stereolabs/Source/ZED/Public/Core/AnimNode_ZEDPose.h +++ b/Plugins/Stereolabs/Source/ZED/Public/Core/AnimNode_ZEDPose.h @@ -33,7 +33,7 @@ struct ZED_API FAnimNode_ZEDPose : public FAnimNode_Base bool bMirrorOnZAxis; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SourceData, meta = (PinShownByDefault)) - float HeightOffset; + float ManualHeightOffset; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SourceData, meta = (PinShownByDefault)) bool bStickAvatarOnFloor; @@ -72,6 +72,7 @@ struct ZED_API FAnimNode_ZEDPose : public FAnimNode_Base private: void BuildPoseFromSlBodyData(FPoseContext& PoseContext); //void BuildPoseFromSlObjectData(FComponentSpacePoseContext& PoseContext); + float ComputeRootTranslationFactor(FCompactPose& OutPose, const FSlBodyData& InBodyData); void PropagateRestPoseRotations(int32 parentIdx, FCompactPose& OutPose, FQuat restPoseRot, bool inverse); void PutInRefPose(FCompactPose& OutPose, TArray SourceBoneNames); @@ -93,13 +94,18 @@ struct ZED_API FAnimNode_ZEDPose : public FAnimNode_Base TMap BonesScale; - // factor used to computer foot offset over time. float BoneScaleAlpha = 0.2f; - int FeetOffsetBufferSize = 120; - std::deque FeetOffsetBuffer; - float FeetOffset = 0; - float FeetOffsetAlpha = 1.0f; + float DurationOffsetErrorThreshold = 3.0f; + float DurationOffsetError = 0.0f; + long long PreviousTS_ms = 0; + + float DistanceToFloorThreshold = 0.f; + + float AutomaticHeightOffset = 0; + + float LeftAnkleToHeelOffset = 0; + float RightAnkleToHeelOffset = 0; // Used for slerping rotations to avoid stuttering TArray PreviousRotations;