diff --git a/Common/DzRuntimePluginAction.cpp b/Common/DzRuntimePluginAction.cpp index d94b82d..e865195 100644 --- a/Common/DzRuntimePluginAction.cpp +++ b/Common/DzRuntimePluginAction.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "DzRuntimePluginAction.h" @@ -121,6 +122,16 @@ void DzRuntimePluginAction::Export() } else if (AssetType == "Pose") { + if (CheckIfPoseExportIsDestructive()) + { + if (QMessageBox::question(0, tr("Continue"), + tr("Proceeding will delete keyed values on some properties. Continue?"), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) + { + return; + } + } + PoseList.clear(); DzNode* Selection = dzScene->getPrimarySelection(); int poseIndex = 0; @@ -165,7 +176,7 @@ void DzRuntimePluginAction::Export() if (numericProperty) { QString propName = property->getName(); - qDebug() << propName; + //qDebug() << propName; if (MorphMapping.contains(modifier->getName())) { poseIndex++; @@ -528,4 +539,57 @@ void DzRuntimePluginAction::ReconnectOverrideControllers(QList& Disconn } } +bool DzRuntimePluginAction::CheckIfPoseExportIsDestructive() +{ + DzNode* Selection = dzScene->getPrimarySelection(); + int poseIndex = 0; + DzNumericProperty* previousProperty = nullptr; + for (int index = 0; index < Selection->getNumProperties(); index++) + { + DzProperty* property = Selection->getProperty(index); + DzNumericProperty* numericProperty = qobject_cast(property); + QString propName = property->getName(); + if (numericProperty) + { + QString propName = property->getName(); + if (MorphMapping.contains(propName)) + { + if (!(numericProperty->getKeyRange().getEnd() == 0.0f && numericProperty->getDoubleValue(0.0f) == 0.0f)) return true; + } + } + } + + DzObject* Object = Selection->getObject(); + if (Object) + { + for (int index = 0; index < Object->getNumModifiers(); index++) + { + DzModifier* modifier = Object->getModifier(index); + DzMorph* mod = qobject_cast(modifier); + if (mod) + { + for (int propindex = 0; propindex < modifier->getNumProperties(); propindex++) + { + DzProperty* property = modifier->getProperty(propindex); + QString propName = property->getName(); + QString propLabel = property->getLabel(); + DzNumericProperty* numericProperty = qobject_cast(property); + if (numericProperty) + { + QString propName = property->getName(); + if (MorphMapping.contains(modifier->getName())) + { + if (!(numericProperty->getKeyRange().getEnd() == 0.0f && numericProperty->getDoubleValue(0.0f) == 0.0f)) return true; + } + } + } + + } + + } + } + + return false; +} + #include "moc_DzRuntimePluginAction.cpp" diff --git a/Common/DzRuntimePluginAction.h b/Common/DzRuntimePluginAction.h index 5a6f360..8245808 100644 --- a/Common/DzRuntimePluginAction.h +++ b/Common/DzRuntimePluginAction.h @@ -61,4 +61,7 @@ class DzRuntimePluginAction : public DzAction { QList DisconnectOverrideControllers(); void ReconnectOverrideControllers(QList& DisconnetedControllers); QList ControllersToDisconnect; + + // For Pose exports check if writing to the timeline will alter existing keys + bool CheckIfPoseExportIsDestructive(); }; \ No newline at end of file diff --git a/Unreal/DazStudioPlugin/DzUnrealDialog.cpp b/Unreal/DazStudioPlugin/DzUnrealDialog.cpp index a5030fd..c397c51 100644 --- a/Unreal/DazStudioPlugin/DzUnrealDialog.cpp +++ b/Unreal/DazStudioPlugin/DzUnrealDialog.cpp @@ -89,7 +89,7 @@ DzUnrealDialog::DzUnrealDialog(QWidget *parent) : assetTypeCombo->addItem("Static Mesh"); assetTypeCombo->addItem("Animation"); assetTypeCombo->addItem("Environment"); - //assetTypeCombo->addItem("Pose"); + assetTypeCombo->addItem("Pose"); // Morphs QHBoxLayout* morphsLayout = new QHBoxLayout(this); diff --git a/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.cpp b/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.cpp index 47ff889..82bd093 100644 --- a/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.cpp +++ b/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.cpp @@ -77,7 +77,7 @@ DzUnrealMorphSelectionDialog::DzUnrealMorphSelectionDialog(QWidget *parent) : setWindowTitle(tr("Select Morphs")); // Setup folder - presetsFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + QDir::separator() + "DazToUnreal" + QDir::separator() + "Presets"; + presetsFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + QDir::separator() + "DAZ 3D"+ QDir::separator() + "Bridges" + QDir::separator() + "Daz To Unreal" + QDir::separator() + "Presets"; QVBoxLayout* mainLayout = new QVBoxLayout(this); @@ -121,23 +121,32 @@ DzUnrealMorphSelectionDialog::DzUnrealMorphSelectionDialog(QWidget *parent) : treeLayout->addWidget(morphTreeWidget); // Buttons for quickly adding certain JCMs + QGroupBox* MorphGroupBox = new QGroupBox("Morph Utilities", this); + MorphGroupBox->setLayout(new QVBoxLayout(this)); QGroupBox* JCMGroupBox = new QGroupBox("Add JCMs", this); JCMGroupBox->setLayout(new QGridLayout(this)); + QGroupBox* FaceGroupBox = new QGroupBox("Add Expressions", this); + FaceGroupBox->setLayout(new QGridLayout(this)); QPushButton* ArmsJCMButton = new QPushButton("Arms"); QPushButton* LegsJCMButton = new QPushButton("Legs"); QPushButton* TorsoJCMButton = new QPushButton("Torso"); - QPushButton* ARKit81Button = new QPushButton("ARKit(Genesis8.1)"); + QPushButton* ARKit81Button = new QPushButton("ARKit (Genesis8.1)"); + QPushButton* FaceFX8Button = new QPushButton("FaceFX (Genesis8)"); ((QGridLayout*)JCMGroupBox->layout())->addWidget(ArmsJCMButton, 0, 0); ((QGridLayout*)JCMGroupBox->layout())->addWidget(LegsJCMButton, 0, 1); ((QGridLayout*)JCMGroupBox->layout())->addWidget(TorsoJCMButton, 0, 2); - ((QGridLayout*)JCMGroupBox->layout())->addWidget(ARKit81Button, 1, 0); - + ((QGridLayout*)FaceGroupBox->layout())->addWidget(ARKit81Button, 0, 1); + ((QGridLayout*)FaceGroupBox->layout())->addWidget(FaceFX8Button, 0, 2); + MorphGroupBox->layout()->addWidget(JCMGroupBox); + MorphGroupBox->layout()->addWidget(FaceGroupBox); + connect(ArmsJCMButton, SIGNAL(released()), this, SLOT(HandleArmJCMMorphsButton())); connect(LegsJCMButton, SIGNAL(released()), this, SLOT(HandleLegJCMMorphsButton())); connect(TorsoJCMButton, SIGNAL(released()), this, SLOT(HandleTorsoJCMMorphsButton())); connect(ARKit81Button, SIGNAL(released()), this, SLOT(HandleARKitGenesis81MorphsButton())); + connect(FaceFX8Button, SIGNAL(released()), this, SLOT(HandleFaceFXGenesis8Button())); - treeLayout->addWidget(JCMGroupBox); + treeLayout->addWidget(MorphGroupBox); morphsLayout->addLayout(treeLayout); @@ -675,6 +684,30 @@ void DzUnrealMorphSelectionDialog::HandleARKitGenesis81MorphsButton() RefreshExportMorphList(); } +void DzUnrealMorphSelectionDialog::HandleFaceFXGenesis8Button() +{ + QStringList MorphsToAdd; + + MorphsToAdd.append("eCTRLvSH"); + MorphsToAdd.append("eCTRLvW"); + MorphsToAdd.append("eCTRLvM"); + MorphsToAdd.append("eCTRLvF"); + MorphsToAdd.append("eCTRLMouthOpen"); + MorphsToAdd.append("eCTRLMouthWide-Narrow"); + MorphsToAdd.append("eCTRLTongueIn-Out"); + MorphsToAdd.append("eCTRLTongueUp-Down"); + + // Add the list for export + foreach(QString MorphName, MorphsToAdd) + { + if (morphs.contains(MorphName) && !morphsToExport.contains(morphs[MorphName])) + { + morphsToExport.append(morphs[MorphName]); + } + } + RefreshExportMorphList(); +} + // Refresh the Right export list void DzUnrealMorphSelectionDialog::RefreshExportMorphList() { diff --git a/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.h b/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.h index e5a888a..11aeb1e 100644 --- a/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.h +++ b/Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.h @@ -79,6 +79,7 @@ public slots: void HandleLegJCMMorphsButton(); void HandleTorsoJCMMorphsButton(); void HandleARKitGenesis81MorphsButton(); + void HandleFaceFXGenesis8Button(); private: diff --git a/Unreal/DazStudioPlugin/version.h b/Unreal/DazStudioPlugin/version.h index 8c72d6e..87c4f3b 100644 --- a/Unreal/DazStudioPlugin/version.h +++ b/Unreal/DazStudioPlugin/version.h @@ -3,7 +3,7 @@ // Version number for DazToUnreal #define PLUGIN_MAJOR 1 -#define PLUGIN_MINOR 1 +#define PLUGIN_MINOR 2 #define PLUGIN_REV 0 #define PLUGIN_BUILD 1 diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ARKitMapping.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ARKitMapping.uasset new file mode 100644 index 0000000..e8d82a4 Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ARKitMapping.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ArkitExample.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ArkitExample.uasset new file mode 100644 index 0000000..d02bdf5 Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis81ArkitExample.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis8FaceFXExample.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis8FaceFXExample.uasset new file mode 100644 index 0000000..14ccb70 Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Animation/Genesis8FaceFXExample.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Blueprints/Genesis8Character.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Blueprints/Genesis8Character.uasset new file mode 100644 index 0000000..1d87b85 Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Blueprints/Genesis8Character.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8FootIKCtrlRig.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8FootIKCtrlRig.uasset new file mode 100644 index 0000000..8b816ec Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8FootIKCtrlRig.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8SimpleCtrlRig.uasset b/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8SimpleCtrlRig.uasset new file mode 100644 index 0000000..d269421 Binary files /dev/null and b/Unreal/UnrealPlugin/DazToUnreal/Content/Genesis8SimpleCtrlRig.uasset differ diff --git a/Unreal/UnrealPlugin/DazToUnreal/DazToUnreal.uplugin b/Unreal/UnrealPlugin/DazToUnreal/DazToUnreal.uplugin index 79e5430..fcc4d6d 100644 --- a/Unreal/UnrealPlugin/DazToUnreal/DazToUnreal.uplugin +++ b/Unreal/UnrealPlugin/DazToUnreal/DazToUnreal.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, "Version": 4, - "VersionName": "4.1.0", + "VersionName": "4.2.0", "FriendlyName": "DazToUnreal", "Description": "", "Category": "Importers", @@ -11,6 +11,8 @@ "MarketplaceURL": "", "SupportURL": "https://www.daz3d.com/help/", "CanContainContent": true, + "IsBetaVersion": false, + "IsExperimentalVersion": false, "Installed": true, "Modules": [ { diff --git a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnreal.cpp b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnreal.cpp index df7335b..ab88afc 100644 --- a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnreal.cpp +++ b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnreal.cpp @@ -456,12 +456,21 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr JsonObject) // Version 2 "Version, ObjectName, Material, Type, Color, Opacity, File" if (Version == 2) - { + { FString ObjectName = material->GetStringField(TEXT("Asset Name")); ObjectName = FDazToUnrealUtils::SanitizeName(ObjectName); IntermediateMaterials.AddUnique(ObjectName + TEXT("_BaseMat")); FString ShaderName = material->GetStringField(TEXT("Material Type")); - FString MaterialName = AssetName + TEXT("_") + material->GetStringField(TEXT("Material Name")); + FString MaterialName; + if (CachedSettings->UseOriginalMaterialName) + { + MaterialName = material->GetStringField(TEXT("Material Name")); + } + else + { + MaterialName = AssetName + TEXT("_") + material->GetStringField(TEXT("Material Name")); + } + MaterialName = FDazToUnrealUtils::SanitizeName(MaterialName); FString TexturePath = material->GetStringField(TEXT("Texture")); FString TextureName = FDazToUnrealUtils::SanitizeName(FPaths::GetBaseFilename(TexturePath)); @@ -1143,7 +1152,16 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr JsonObject) //MaterialProperties.Add(MaterialName FbxSurfaceMaterial* Material = MaterialArray[MaterialIndex]; FString OriginalMaterialName = UTF8_TO_TCHAR(Material->GetName()); - FString NewMaterialName = AssetName + TEXT("_") + OriginalMaterialName; + FString NewMaterialName; + if (CachedSettings->UseOriginalMaterialName) + { + NewMaterialName = OriginalMaterialName; + } + else + { + NewMaterialName = AssetName + TEXT("_") + OriginalMaterialName; + } + NewMaterialName = FDazToUnrealUtils::SanitizeName(NewMaterialName); Material->SetName(TCHAR_TO_UTF8(*NewMaterialName)); if (MaterialProperties.Contains(NewMaterialName)) @@ -1489,6 +1507,8 @@ UObject* FDazToUnrealModule::ImportFBXAsset(const FString& SourcePath, const FSt FbxFactory->ImportUI->bImportMaterials = false; FbxFactory->ImportUI->bImportTextures = false; FbxFactory->ImportUI->bImportAnimations = true; + FbxFactory->ImportUI->AnimSequenceImportData->bConvertScene = true; + FbxFactory->ImportUI->AnimSequenceImportData->bForceFrontXAxis = CachedSettings->ZeroRootRotationOnImport; FbxFactory->ImportUI->MeshTypeToImport = FBXIT_Animation; } //UFbxFactory::EnableShowOption(); diff --git a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealMaterials.cpp b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealMaterials.cpp index a04cd3e..ff65ce7 100644 --- a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealMaterials.cpp +++ b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealMaterials.cpp @@ -39,6 +39,15 @@ FSoftObjectPath FDazToUnrealMaterials::GetBaseMaterial(FString MaterialName, TAr FString AssetType = ""; FString ShaderName = ""; + FString Seperator; + if ( CachedSettings->UseOriginalMaterialName) + { + Seperator = ""; + } + else + { + Seperator = "_"; + } TArray Properties = MaterialProperties; for (FDUFTextureProperty Property : Properties) { @@ -59,14 +68,14 @@ FSoftObjectPath FDazToUnrealMaterials::GetBaseMaterial(FString MaterialName, TAr if (AssetType == TEXT("Follower/Hair")) { BaseMaterialAssetPath = CachedSettings->BaseHairMaterial; - if (MaterialName.EndsWith(TEXT("_scalp"))) + if (MaterialName.EndsWith(Seperator + TEXT("scalp"))) { BaseMaterialAssetPath = CachedSettings->BaseScalpMaterial; } } else if (AssetType == TEXT("Follower/Attachment/Head/Face/Eyelashes")) { - if (MaterialName.Contains(TEXT("_EyeMoisture"))) + if (MaterialName.Contains(Seperator + TEXT("EyeMoisture"))) { BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; } @@ -76,60 +85,60 @@ FSoftObjectPath FDazToUnrealMaterials::GetBaseMaterial(FString MaterialName, TAr } } else if (AssetType == TEXT("Follower/Attachment/Lower-Body/Hip/Front") && - MaterialName.Contains(TEXT("_Genitalia"))) + MaterialName.Contains(Seperator + TEXT("Genitalia"))) { BaseMaterialAssetPath = GetSkinMaterialForShader(ShaderName); } else if (AssetType == TEXT("Actor/Character")) { // Check for skin materials - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Head")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_Hips")) || - MaterialName.EndsWith(TEXT("_Feet")) || - MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Body")) || - MaterialName.EndsWith(TEXT("_Neck")) || - MaterialName.EndsWith(TEXT("_Shoulders")) || - MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_Forearms")) || - MaterialName.EndsWith(TEXT("_Hands")) || - MaterialName.EndsWith(TEXT("_EyeSocket")) || - MaterialName.EndsWith(TEXT("_Ears")) || - MaterialName.EndsWith(TEXT("_Fingernails")) || - MaterialName.EndsWith(TEXT("_Toenails")) || - MaterialName.EndsWith(TEXT("_Nipples")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Head")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("Hips")) || + MaterialName.EndsWith(Seperator + TEXT("Feet")) || + MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Body")) || + MaterialName.EndsWith(Seperator + TEXT("Neck")) || + MaterialName.EndsWith(Seperator + TEXT("Shoulders")) || + MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("Forearms")) || + MaterialName.EndsWith(Seperator + TEXT("Hands")) || + MaterialName.EndsWith(Seperator + TEXT("EyeSocket")) || + MaterialName.EndsWith(Seperator + TEXT("Ears")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails")) || + MaterialName.EndsWith(Seperator + TEXT("Toenails")) || + MaterialName.EndsWith(Seperator + TEXT("Nipples")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { BaseMaterialAssetPath = GetSkinMaterialForShader(ShaderName); } - else if (MaterialName.Contains(TEXT("_EyeMoisture"))) + else if (MaterialName.Contains(Seperator + TEXT("EyeMoisture"))) { BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; } - else if (MaterialName.Contains(TEXT("_EyeReflection"))) + else if (MaterialName.Contains(Seperator + TEXT("EyeReflection"))) { BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; } - else if (MaterialName.Contains(TEXT("_Tear"))) + else if (MaterialName.Contains(Seperator + TEXT("Tear"))) { BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; } - else if (MaterialName.EndsWith(TEXT("_EyeLashes"))) + else if (MaterialName.EndsWith(Seperator + TEXT("EyeLashes"))) { BaseMaterialAssetPath = CachedSettings->BaseAlphaMaterial; } - else if (MaterialName.EndsWith(TEXT("_Eyelashes"))) + else if (MaterialName.EndsWith(Seperator + TEXT("Eyelashes"))) { BaseMaterialAssetPath = CachedSettings->BaseAlphaMaterial; } - else if (MaterialName.EndsWith(TEXT("_Eyelash"))) + else if (MaterialName.EndsWith(Seperator + TEXT("Eyelash"))) { BaseMaterialAssetPath = CachedSettings->BaseAlphaMaterial; } - else if (MaterialName.EndsWith(TEXT("_cornea"))) + else if (MaterialName.EndsWith(Seperator + TEXT("cornea"))) { BaseMaterialAssetPath = CachedSettings->BaseCorneaMaterial; } @@ -159,7 +168,7 @@ FSoftObjectPath FDazToUnrealMaterials::GetBaseMaterial(FString MaterialName, TAr } } - else if (MaterialName.Contains(TEXT("_EyeMoisture"))) + else if (MaterialName.Contains(Seperator + TEXT("EyeMoisture"))) { BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; } @@ -180,7 +189,7 @@ FSoftObjectPath FDazToUnrealMaterials::GetBaseMaterial(FString MaterialName, TAr } } - if (MaterialName.EndsWith(TEXT("_NoDraw"))) + if (MaterialName.EndsWith(Seperator + TEXT("NoDraw"))) { BaseMaterialAssetPath = CachedSettings->NoDrawMaterial; } @@ -212,13 +221,21 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C } } } - + FString Seperator; + if ( CachedSettings->UseOriginalMaterialName) + { + Seperator = ""; + } + else + { + Seperator = "_"; + } if (AssetType == TEXT("Follower/Attachment/Head/Face/Eyelashes") || AssetType == TEXT("Follower/Attachment/Head/Face/Eyes") || AssetType == TEXT("Follower/Attachment/Head/Face/Eyes/Tear") || AssetType == TEXT("Follower/Attachment/Head/Face/Tears")) { - if (MaterialName.Contains(TEXT("_EyeMoisture")) || MaterialName.EndsWith(TEXT("_EyeReflection"))) + if (MaterialName.Contains(Seperator + TEXT("EyeMoisture")) || MaterialName.EndsWith(Seperator + TEXT("EyeReflection"))) { //BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); @@ -226,7 +243,7 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C SetMaterialProperty(MaterialName, TEXT("Diffuse Color"), TEXT("Color"), TEXT("#bababa"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Index of Refraction"), TEXT("Double"), TEXT("1.0"), MaterialProperties); } - else if (MaterialName.EndsWith(TEXT("_Tear")) || MaterialName.EndsWith(TEXT("_Tears"))) + else if (MaterialName.EndsWith(Seperator + TEXT("Tear")) || MaterialName.EndsWith(Seperator + TEXT("Tears"))) { //BaseMaterialAssetPath = CachedSettings->BaseCorneaMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); @@ -241,7 +258,7 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C } } else if (AssetType == TEXT("Follower/Attachment/Lower-Body/Hip/Front") && - MaterialName.Contains(TEXT("_Genitalia"))) + MaterialName.Contains(Seperator + TEXT("Genitalia"))) { //BaseMaterialAssetPath = CachedSettings->BaseSkinMaterial; SetMaterialProperty(MaterialName, TEXT("Subsurface Alpha Texture"), TEXT("Texture"), FDazToUnrealTextures::GetSubSurfaceAlphaTexture(CharacterType, MaterialName), MaterialProperties); @@ -249,61 +266,61 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C else if (AssetType == TEXT("Actor/Character")) { // Check for skin materials - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Head")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Body")) || - MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_EyeSocket")) || - MaterialName.EndsWith(TEXT("_Ears")) || - MaterialName.EndsWith(TEXT("_Fingernails")) || - MaterialName.EndsWith(TEXT("_Toenails")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Head")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Body")) || + MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("EyeSocket")) || + MaterialName.EndsWith(Seperator + TEXT("Ears")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails")) || + MaterialName.EndsWith(Seperator + TEXT("Toenails")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { //BaseMaterialAssetPath = CachedSettings->BaseSkinMaterial; SetMaterialProperty(MaterialName, TEXT("Diffuse Subsurface Color Weight"), TEXT("Double"), FString::SanitizeFloat(CachedSettings->DefaultSkinDiffuseSubsurfaceColorWeight), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Subsurface Alpha Texture"), TEXT("Texture"), FDazToUnrealTextures::GetSubSurfaceAlphaTexture(CharacterType, MaterialName), MaterialProperties); } - else if (MaterialName.Contains(TEXT("_EyeMoisture"))) + else if (MaterialName.Contains(Seperator + TEXT("EyeMoisture"))) { //BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Opacity Strength"), TEXT("Double"), FString::SanitizeFloat(CachedSettings->DefaultEyeMoistureOpacity), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Index of Refraction"), TEXT("Double"), TEXT("1.0"), MaterialProperties); } - else if (MaterialName.EndsWith(TEXT("_EyeReflection")) || MaterialName.EndsWith(TEXT("_Tear")) || MaterialName.EndsWith(TEXT("_Tears"))) + else if (MaterialName.EndsWith(Seperator + TEXT("EyeReflection")) || MaterialName.EndsWith(Seperator + TEXT("Tear")) || MaterialName.EndsWith(Seperator + TEXT("Tears"))) { //BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Opacity Strength"), TEXT("Double"), FString::SanitizeFloat(CachedSettings->DefaultEyeMoistureOpacity), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Index of Refraction"), TEXT("Double"), TEXT("1.0"), MaterialProperties); } - else if (MaterialName.EndsWith(TEXT("_EyeLashes")) || MaterialName.EndsWith(TEXT("_Eyelashes"))) + else if (MaterialName.EndsWith(Seperator + TEXT("EyeLashes")) || MaterialName.EndsWith(Seperator + TEXT("Eyelashes"))) { //BaseMaterialAssetPath = CachedSettings->BaseAlphaMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("0"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Glossy Layered Weight"), TEXT("Double"), TEXT("0"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Index of Refraction"), TEXT("Double"), TEXT("1.0"), MaterialProperties); } - else if (MaterialName.EndsWith(TEXT("_cornea"))) + else if (MaterialName.EndsWith(Seperator + TEXT("cornea"))) { //BaseMaterialAssetPath = CachedSettings->BaseCorneaMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Opacity Strength"), TEXT("Double"), FString::SanitizeFloat(CachedSettings->DefaultEyeMoistureOpacity), MaterialProperties); SetMaterialProperty(MaterialName, TEXT("Index of Refraction"), TEXT("Double"), TEXT("1.0"), MaterialProperties); } - else if (MaterialName.EndsWith(TEXT("_sclera"))) + else if (MaterialName.EndsWith(Seperator + TEXT("sclera"))) { //BaseMaterialAssetPath = CachedSettings->BaseMaterial; } - else if (MaterialName.EndsWith(TEXT("_irises"))) + else if (MaterialName.EndsWith(Seperator + TEXT("irises"))) { SetMaterialProperty(MaterialName, TEXT("Pixel Depth Offset"), TEXT("Double"), TEXT("0.1"), MaterialProperties); //BaseMaterialAssetPath = CachedSettings->BaseMaterial; } - else if (MaterialName.EndsWith(TEXT("_pupils"))) + else if (MaterialName.EndsWith(Seperator + TEXT("pupils"))) { SetMaterialProperty(MaterialName, TEXT("Pixel Depth Offset"), TEXT("Double"), TEXT("0.1"), MaterialProperties); //BaseMaterialAssetPath = CachedSettings->BaseMaterial; @@ -324,7 +341,7 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C } } } - else if (MaterialName.Contains(TEXT("_EyeMoisture"))) + else if (MaterialName.Contains(Seperator + TEXT("EyeMoisture"))) { //BaseMaterialAssetPath = CachedSettings->BaseEyeMoistureMaterial; SetMaterialProperty(MaterialName, TEXT("Metallic Weight"), TEXT("Double"), TEXT("1"), MaterialProperties); @@ -350,7 +367,7 @@ UMaterialInstanceConstant* FDazToUnrealMaterials::CreateMaterial(const FString C } } } - if (MaterialName.EndsWith(TEXT("_NoDraw"))) + if (MaterialName.EndsWith(Seperator + TEXT("NoDraw"))) { //BaseMaterialAssetPath = CachedSettings->NoDrawMaterial; } @@ -619,6 +636,18 @@ FString FDazToUnrealMaterials::GetMaterialProperty(const FString& PropertyName, USubsurfaceProfile* FDazToUnrealMaterials::CreateSubsurfaceBaseProfileForCharacter(const FString CharacterMaterialFolder, TMap>& MaterialProperties) { + const UDazToUnrealSettings* CachedSettings = GetDefault(); + + FString Seperator; + if ( CachedSettings->UseOriginalMaterialName) + { + Seperator = ""; + } + else + { + Seperator = "_"; + } + // Find the torso material. for (TPair> Pair : MaterialProperties) { @@ -633,7 +662,7 @@ USubsurfaceProfile* FDazToUnrealMaterials::CreateSubsurfaceBaseProfileForCharact if (AssetType == TEXT("Actor/Character")) { - if (Pair.Key.EndsWith(TEXT("_Torso")) || Pair.Key.EndsWith(TEXT("_Body"))) + if (Pair.Key.EndsWith(Seperator + TEXT("Torso")) || Pair.Key.EndsWith(Seperator + TEXT("Body"))) { return CreateSubsurfaceProfileForMaterial(Pair.Key, CharacterMaterialFolder, Pair.Value); } diff --git a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealTextures.cpp b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealTextures.cpp index b1f4553..ccd5d11 100644 --- a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealTextures.cpp +++ b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Private/DazToUnrealTextures.cpp @@ -5,26 +5,36 @@ FString FDazToUnrealTextures::GetSubSurfaceAlphaTexture(const DazCharacterType CharacterType, const FString& MaterialName) { const UDazToUnrealSettings* CachedSettings = GetDefault(); + FString Seperator; + if ( CachedSettings->UseOriginalMaterialName) + { + Seperator = ""; + } + else + { + Seperator = "_"; + } if (CharacterType == DazCharacterType::Genesis8Male) { - if (MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_Fingernails"))) + + if (MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails"))) { return CachedSettings->ArmsSubSurfaceOpacityGenesis8MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Ears"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Ears"))) { return CachedSettings->FaceSubSurfaceOpacityGenesis8MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { return CachedSettings->TorsoSubSurfaceOpacityGenesis8MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_ToeNails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("ToeNails"))) { return CachedSettings->LegsSubSurfaceOpacityGenesis8MaleTexture.ToString(); } @@ -32,24 +42,24 @@ FString FDazToUnrealTextures::GetSubSurfaceAlphaTexture(const DazCharacterType C if (CharacterType == DazCharacterType::Genesis8Female) { - if (MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_Fingernails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails"))) { return CachedSettings->ArmsSubSurfaceOpacityGenesis8FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Ears"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Ears"))) { return CachedSettings->FaceSubSurfaceOpacityGenesis8FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { return CachedSettings->TorsoSubSurfaceOpacityGenesis8FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_ToeNails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("ToeNails"))) { return CachedSettings->LegsSubSurfaceOpacityGenesis8FemaleTexture.ToString(); } @@ -57,24 +67,24 @@ FString FDazToUnrealTextures::GetSubSurfaceAlphaTexture(const DazCharacterType C if (CharacterType == DazCharacterType::Genesis3Male) { - if (MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_Fingernails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails"))) { return CachedSettings->ArmsSubSurfaceOpacityGenesis3MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Ears"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Ears"))) { return CachedSettings->FaceSubSurfaceOpacityGenesis3MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { return CachedSettings->TorsoSubSurfaceOpacityGenesis3MaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_ToeNails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("ToeNails"))) { return CachedSettings->LegsSubSurfaceOpacityGenesis3MaleTexture.ToString(); } @@ -82,24 +92,24 @@ FString FDazToUnrealTextures::GetSubSurfaceAlphaTexture(const DazCharacterType C if (CharacterType == DazCharacterType::Genesis3Female) { - if (MaterialName.EndsWith(TEXT("_Arms")) || - MaterialName.EndsWith(TEXT("_Fingernails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Arms")) || + MaterialName.EndsWith(Seperator + TEXT("Fingernails"))) { return CachedSettings->ArmsSubSurfaceOpacityGenesis3FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Face")) || - MaterialName.EndsWith(TEXT("_Lips")) || - MaterialName.EndsWith(TEXT("_Ears"))) + if (MaterialName.EndsWith(Seperator + TEXT("Face")) || + MaterialName.EndsWith(Seperator + TEXT("Lips")) || + MaterialName.EndsWith(Seperator + TEXT("Ears"))) { return CachedSettings->FaceSubSurfaceOpacityGenesis3FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Torso")) || - MaterialName.EndsWith(TEXT("_Genitalia"))) + if (MaterialName.EndsWith(Seperator + TEXT("Torso")) || + MaterialName.EndsWith(Seperator + TEXT("Genitalia"))) { return CachedSettings->TorsoSubSurfaceOpacityGenesis3FemaleTexture.ToString(); } - if (MaterialName.EndsWith(TEXT("_Legs")) || - MaterialName.EndsWith(TEXT("_ToeNails"))) + if (MaterialName.EndsWith(Seperator + TEXT("Legs")) || + MaterialName.EndsWith(Seperator + TEXT("ToeNails"))) { return CachedSettings->LegsSubSurfaceOpacityGenesis3FemaleTexture.ToString(); } diff --git a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Public/DazToUnrealSettings.h b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Public/DazToUnrealSettings.h index 7661f39..ba8a6f3 100644 --- a/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Public/DazToUnrealSettings.h +++ b/Unreal/UnrealPlugin/DazToUnreal/Source/DazToUnreal/Public/DazToUnrealSettings.h @@ -56,6 +56,7 @@ class DAZTOUNREAL_API UDazToUnrealSettings : public UDeveloperSettings BaseCorneaMaterial = FSoftObjectPath(TEXT("/DazToUnreal/BaseAlphaMaterial.BaseAlphaMaterial")); NoDrawMaterial = FSoftObjectPath(TEXT("/DazToUnreal/NoDrawMaterial.NoDrawMaterial")); + UseOriginalMaterialName = false; UseInternalMorphName = false; ArmsSubSurfaceOpacityGenesis1Texture = FSoftObjectPath(TEXT("/Engine/EngineResources/WhiteSquareTexture.WhiteSquareTexture")); @@ -89,7 +90,7 @@ class DAZTOUNREAL_API UDazToUnrealSettings : public UDeveloperSettings MaterialPropertyMapping.Add(TEXT("Specular Strength Texture Active"), TEXT("Glossy Layered Weight Texture Active")); DefaultSkinDiffuseSubsurfaceColorWeight = 0.5f; - DefaultEyeMoistureOpacity = 0.04f; + DefaultEyeMoistureOpacity = 0.01f; } virtual FName GetCategoryName() const { return FName(TEXT("Plugins")); } @@ -202,6 +203,10 @@ class DAZTOUNREAL_API UDazToUnrealSettings : public UDeveloperSettings UPROPERTY(config, EditAnywhere, Category = MaterialSettings) float DefaultEyeMoistureOpacity; + /** Use Original Name of Material */ + UPROPERTY(config, EditAnywhere, Category = MaterialSettings) + bool UseOriginalMaterialName; + /** Use the internal name rather than the display name when transfering morphs */ UPROPERTY(config, EditAnywhere, Category = MorphSettings) bool UseInternalMorphName;