Skip to content

Commit

Permalink
Merge pull request daz3d#18 from daz3d/unreal-develop
Browse files Browse the repository at this point in the history
Unreal 4.2.0
  • Loading branch information
samjay3d authored May 7, 2021
2 parents b6ebf63 + c5a354f commit 5c86b3d
Show file tree
Hide file tree
Showing 17 changed files with 273 additions and 106 deletions.
66 changes: 65 additions & 1 deletion Common/DzRuntimePluginAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <QtNetwork/qudpsocket.h>
#include <QtNetwork/qabstractsocket.h>
#include <QtGui/qcheckbox.h>
#include <QtGui/QMessageBox>


#include "DzRuntimePluginAction.h"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -165,7 +176,7 @@ void DzRuntimePluginAction::Export()
if (numericProperty)
{
QString propName = property->getName();
qDebug() << propName;
//qDebug() << propName;
if (MorphMapping.contains(modifier->getName()))
{
poseIndex++;
Expand Down Expand Up @@ -528,4 +539,57 @@ void DzRuntimePluginAction::ReconnectOverrideControllers(QList<QString>& 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<DzNumericProperty*>(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<DzMorph*>(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<DzNumericProperty*>(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"
3 changes: 3 additions & 0 deletions Common/DzRuntimePluginAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ class DzRuntimePluginAction : public DzAction {
QList<QString> DisconnectOverrideControllers();
void ReconnectOverrideControllers(QList<QString>& DisconnetedControllers);
QList<QString> ControllersToDisconnect;

// For Pose exports check if writing to the timeline will alter existing keys
bool CheckIfPoseExportIsDestructive();
};
2 changes: 1 addition & 1 deletion Unreal/DazStudioPlugin/DzUnrealDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
43 changes: 38 additions & 5 deletions Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);


Expand Down Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions Unreal/DazStudioPlugin/DzUnrealMorphSelectionDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public slots:
void HandleLegJCMMorphsButton();
void HandleTorsoJCMMorphsButton();
void HandleARKitGenesis81MorphsButton();
void HandleFaceFXGenesis8Button();

private:

Expand Down
2 changes: 1 addition & 1 deletion Unreal/DazStudioPlugin/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion Unreal/UnrealPlugin/DazToUnreal/DazToUnreal.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 4,
"VersionName": "4.1.0",
"VersionName": "4.2.0",
"FriendlyName": "DazToUnreal",
"Description": "",
"Category": "Importers",
Expand All @@ -11,6 +11,8 @@
"MarketplaceURL": "",
"SupportURL": "https://www.daz3d.com/help/",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": true,
"Modules": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,21 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr<FJsonObject> 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));
Expand Down Expand Up @@ -1143,7 +1152,16 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr<FJsonObject> 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))
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 5c86b3d

Please sign in to comment.