Skip to content

Commit

Permalink
Merge pull request #26 from cocktailboy/master
Browse files Browse the repository at this point in the history
Daz and UE4 Plugin modifications to invoke subd skin weight
  • Loading branch information
samjay3d authored Aug 2, 2021
2 parents 68c5177 + ee6e8cf commit 84f8901
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 22 deletions.
26 changes: 23 additions & 3 deletions Common/DzRuntimePluginAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void DzRuntimePluginAction::ExportNode(DzNode* Node)
}
ExportOptions.setBoolValue("doLights", false);
ExportOptions.setBoolValue("doCameras", false);
ExportOptions.setBoolValue("doAnims", true);
ExportOptions.setBoolValue("doAnims", false);
if ((AssetType == "Animation" || AssetType == "SkeletalMesh") && ExportMorphs && MorphString != "")
{
ExportOptions.setBoolValue("doMorphs", true);
Expand Down Expand Up @@ -354,9 +354,29 @@ void DzRuntimePluginAction::ExportNode(DzNode* Node)
dir.mkpath(CharacterFolder);

SetExportOptions(ExportOptions);
Exporter->writeFile(CharacterFBX, &ExportOptions);

WriteConfiguration();
if (ExportSubdivisions)
{
if (ExportBaseMesh)
{
QString CharacterBaseFBX = CharacterFBX;
CharacterBaseFBX.replace(".fbx", "_base.fbx");
Exporter->writeFile(CharacterBaseFBX, &ExportOptions);
}
else
{
QString CharacterHDFBX = CharacterFBX;
CharacterHDFBX.replace(".fbx", "_HD.fbx");
Exporter->writeFile(CharacterHDFBX, &ExportOptions);

WriteConfiguration();
}
}
else
{
Exporter->writeFile(CharacterFBX, &ExportOptions);
WriteConfiguration();
}

// Change back material names
UndoRenameDuplicateMaterials(Parent, MaterialNames, OriginalMaterialNames);
Expand Down
1 change: 1 addition & 0 deletions Common/DzRuntimePluginAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DzRuntimePluginAction : public DzAction {

bool ExportMorphs;
bool ExportSubdivisions;
bool ExportBaseMesh;
bool ShowFbxDialog;
bool ExportMaterialPropertiesCSV;
DzNode* Selection;
Expand Down
54 changes: 36 additions & 18 deletions Unreal/DazStudioPlugin/DzUnrealAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,34 @@ void DzUnrealAction::executeAction()
// If the Accept button was pressed, start the export
if (dlg->exec() == QDialog::Accepted)
{
// Collect the values from the dialog fields
CharacterName = dlg->assetNameEdit->text();
ImportFolder = dlg->intermediateFolderEdit->text();
CharacterFolder = ImportFolder + "\\" + CharacterName + "\\";
CharacterFBX = CharacterFolder + CharacterName + ".fbx";
AssetType = dlg->assetTypeCombo->currentText().replace(" ", "");
MorphString = dlg->GetMorphString();
Port = dlg->portEdit->text().toInt();
ExportMorphs = dlg->morphsEnabledCheckBox->isChecked();
ExportSubdivisions = dlg->subdivisionEnabledCheckBox->isChecked();
MorphMapping = dlg->GetMorphMapping();
ShowFbxDialog = dlg->showFbxDialogCheckBox->isChecked();
ExportMaterialPropertiesCSV = dlg->exportMaterialPropertyCSVCheckBox->isChecked();
SubdivisionDialog = DzUnrealSubdivisionDialog::Get(dlg);
SubdivisionDialog->LockSubdivisionProperties(ExportSubdivisions);
FBXVersion = dlg->fbxVersionCombo->currentText();

Export();
// Collect the values from the dialog fields
CharacterName = dlg->assetNameEdit->text();
ImportFolder = dlg->intermediateFolderEdit->text();
CharacterFolder = ImportFolder + "\\" + CharacterName + "\\";
CharacterFBX = CharacterFolder + CharacterName + ".fbx";
AssetType = dlg->assetTypeCombo->currentText().replace(" ", "");
MorphString = dlg->GetMorphString();
Port = dlg->portEdit->text().toInt();
ExportMorphs = dlg->morphsEnabledCheckBox->isChecked();
ExportSubdivisions = dlg->subdivisionEnabledCheckBox->isChecked();
MorphMapping = dlg->GetMorphMapping();
ShowFbxDialog = dlg->showFbxDialogCheckBox->isChecked();
ExportMaterialPropertiesCSV = dlg->exportMaterialPropertyCSVCheckBox->isChecked();
SubdivisionDialog = DzUnrealSubdivisionDialog::Get(dlg);
FBXVersion = dlg->fbxVersionCombo->currentText();

if (AssetType == "SkeletalMesh" && ExportSubdivisions)
{
// export base mesh
ExportBaseMesh = true;
SubdivisionDialog->LockSubdivisionProperties(false);
Export();
}

ExportBaseMesh = false;
SubdivisionDialog->LockSubdivisionProperties(ExportSubdivisions);
Export();

}
}

Expand Down Expand Up @@ -188,6 +198,14 @@ void DzUnrealAction::WriteConfiguration()

DTUfile.close();

if (AssetType != "Environment" && ExportSubdivisions)
{
QString CMD = "ImportFBXScene " + DTUfilename;
QByteArray array = CMD.toLocal8Bit();
char* cmd = array.data();
int res = system(cmd);
}

// Send a message to Unreal telling it to start an import
QUdpSocket* sendSocket = new QUdpSocket(this);
QHostAddress* sendAddress = new QHostAddress("127.0.0.1");
Expand Down
1 change: 1 addition & 0 deletions Unreal/DazStudioPlugin/DzUnrealSubdivisionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void DzUnrealSubdivisionDialog::CreateList(DzNode* Node)
subdivisionLevelCombo->setProperty("Object", QVariant(Node->getName()));
subdivisionLevelCombo->addItem("0");
subdivisionLevelCombo->addItem("1");
subdivisionLevelCombo->addItem("2");
SubdivisionCombos.append(subdivisionLevelCombo);
subdivisionItemsGrid->addWidget(subdivisionLevelCombo, row, 1);
if (SubdivisionLevels.contains(Node->getName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ UObject* FDazToUnrealModule::ImportFromDaz(TSharedPtr<FJsonObject> JsonObject)
RootNode->AddChild(SceneNode);
}
}
#if 1
#if 0 // Do not create missing weights
if (SubdivisionLevels.Num() > 0)
{
// Create missing weights
Expand Down

0 comments on commit 84f8901

Please sign in to comment.