forked from daz3d/DazToRuntime
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to help Genesis 8.1 support
Improvements to help Genesis 8.1 support PBRSkin Material for Genesis 8.1 Includes some code for the new Pose transfer feature.
- Loading branch information
1 parent
a51b779
commit bb6f6fc
Showing
11 changed files
with
187 additions
and
38 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file modified
BIN
-5.91 KB
(85%)
Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8BaseSkeleton.uasset
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealPoses.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "DazToUnrealPoses.h" | ||
#include "DazToUnrealSettings.h" | ||
#include "DazToUnrealTextures.h" | ||
#include "DazToUnrealUtils.h" | ||
|
||
#include "Animation/Skeleton.h" | ||
#include "Animation/AnimSequence.h" | ||
#include "Animation/PoseAsset.h" | ||
|
||
#include "Factories/PoseAssetFactory.h" | ||
#include "IContentBrowserSingleton.h" | ||
#include "ContentBrowserModule.h" | ||
#include "AssetRegistryModule.h" | ||
#include "PackageTools.h" | ||
|
||
// Partially taken from UPoseAssetFactory::FactoryCreateNew | ||
void FDazToUnrealPoses::CreatePoseAsset(UAnimSequence* SourceAnimation, TArray<FString> PoseNames) | ||
{ | ||
if (SourceAnimation) | ||
{ | ||
const UDazToUnrealSettings* CachedSettings = GetDefault<UDazToUnrealSettings>(); | ||
|
||
// Make sure the path exists | ||
FString ContentDirectory = FPaths::ProjectContentDir(); | ||
FString DAZPoseImportFolder = CachedSettings->PoseImportDirectory.Path.Replace(TEXT("/Game/"), *ContentDirectory); | ||
if (!FDazToUnrealUtils::MakeDirectoryAndCheck(DAZPoseImportFolder)) | ||
{ | ||
//log error | ||
} | ||
|
||
USkeleton* TargetSkeleton = SourceAnimation->GetSkeleton(); | ||
|
||
TArray<FSmartName> InputPoseNames; | ||
if (PoseNames.Num() > 0) | ||
{ | ||
for (int32 Index = 0; Index < PoseNames.Num(); ++Index) | ||
{ | ||
FName PoseName = FName(*PoseNames[Index]); | ||
FSmartName NewName; | ||
if (TargetSkeleton->GetSmartNameByName(USkeleton::AnimCurveMappingName, PoseName, NewName) == false) | ||
{ | ||
// if failed, add it | ||
TargetSkeleton->AddSmartNameAndModify(USkeleton::AnimCurveMappingName, PoseName, NewName); | ||
} | ||
|
||
// we want same names in multiple places | ||
InputPoseNames.AddUnique(NewName); | ||
} | ||
} | ||
|
||
FString PackageName = UPackageTools::SanitizePackageName(*(CachedSettings->PoseImportDirectory.Path / FString(SourceAnimation->GetName()))); | ||
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION < 26 | ||
UPackage* Pkg = CreatePackage(nullptr, *PackageName); | ||
#else | ||
UPackage* Pkg = CreatePackage(*PackageName); | ||
#endif | ||
EObjectFlags Flags = RF_Public | RF_Standalone | RF_Transactional; | ||
|
||
UPoseAsset* PoseAsset = NewObject<UPoseAsset>(Pkg, FName(*SourceAnimation->GetName()), Flags); | ||
//PoseAsset->bAdditivePose = true; | ||
//PoseAsset->BasePoseIndex = 0; | ||
PoseAsset->CreatePoseFromAnimation(SourceAnimation, &InputPoseNames); | ||
PoseAsset->SetSkeleton(TargetSkeleton); | ||
PoseAsset->ConvertSpace(true, 0); | ||
} | ||
//return NewPose; | ||
|
||
//UPoseAssetFactory* Factory = NewObject<UPoseAssetFactory>(); | ||
//Factory->TargetSkeleton = Skeleton; | ||
//Factory->PreviewSkeletalMesh = SkeletalMesh; | ||
|
||
//FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser"); | ||
//ContentBrowserModule.Get().CreateNewAsset(Name, FPackageName::GetLongPackagePath(PackageName), T::StaticClass(), Factory); | ||
|
||
/*UPoseAsset* PoseAsset = NewObject<UPoseAsset>(InParent, Class, Name, Flags); | ||
PoseAsset->CreatePoseFromAnimation(SourceAnimation, &InputPoseNames); | ||
PoseAsset->SetSkeleton(TargetSkeleton);*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ enum DazAssetType | |
SkeletalMesh, | ||
StaticMesh, | ||
Animation, | ||
Environment | ||
Environment, | ||
Pose | ||
}; | ||
|
||
|
||
|
11 changes: 11 additions & 0 deletions
11
Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Public/DazToUnrealPoses.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "CoreMinimal.h" | ||
#include "DazToUnrealEnums.h" | ||
|
||
|
||
class FDazToUnrealPoses | ||
{ | ||
public: | ||
static void CreatePoseAsset(UAnimSequence* SourceAnimation, TArray<FString> PoseNames); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters