Skip to content

Commit

Permalink
Daz To Unreal 4.1.0 (daz3d#8)
Browse files Browse the repository at this point in the history
* Improved Genesis 8.1 materials

Updated PBRSkin materials and improvements to the material system to support the updates.

* Resubmitting the PBRSkin material saved from UE4.25.

* Some improvements to the PBRSkin Material for DazToUnreal.

* Unmapped Ambient Occlusion from the PBRSkin material.

Unmapped Ambient Occlusion from the PBRSkin material.  It was causing artifacts in shadows.

* Base Subsurface Profile is created once for the character

Base Subsurface Profile is created once for the character.

* Genesis8.1 character get a PostProcess Animation Blueprint automatically

Genesis8.1 character get a PostProcess Animation Blueprint automatically
Consolidated the PostProcess animation settings into a dictionary so there doesn't need to be a special field per character type.

* Added a setting to not rename morphs to the display name on transfer.

* Added an option to remove the rotation on the character root at import.

* Removing intermediate file that was accidently submitted

* Early Pose support checked in, but disabled

Early Pose support checked in, but disabled
Also added an option for exporting a CSV of the material settings.  I use this for reference when updating materials in Unreal.

* Advanced Options are now hidden behind a checkbox

Advanced Options are now hidden behind a checkbox.  Most of these aren't needed in general and I don't want the interface to look overly complicated when first loaded.

* Set Mouth Close to override it's controllers during export if it's chosen as a morph

Set Mouth Close to override it's controllers during export if it's chosen as a morph

* Added button to the Morphs interface for selecting the Genesis8.1 morphs needed for ARKit

Added button to the Morphs interface for selecting the Genesis8.1 morphs needed for ARKit

* Updated Versions

Added Version for Next Release.
Added .gitignore

Co-authored-by: David-Vodhanel <[email protected]>
  • Loading branch information
samjay3d and David-Vodhanel authored Mar 2, 2021
1 parent e6739ae commit b6ebf63
Show file tree
Hide file tree
Showing 21 changed files with 628 additions and 819 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vs
out
CMakeSettings.json
188 changes: 188 additions & 0 deletions Common/DzRuntimePluginAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <dzbone.h>
#include <dzskeleton.h>
#include <dzpresentation.h>
#include <dzmodifier.h>
#include <dzmorph.h>

#include <QtCore/qdir.h>
#include <QtGui/qlineedit.h>
Expand All @@ -41,6 +43,7 @@ DzRuntimePluginAction::DzRuntimePluginAction(const QString& text, const QString&
ExportMorphs = false;
ExportSubdivisions = false;
ShowFbxDialog = false;
ControllersToDisconnect.append("facs_bs_MouthClose_div2");
}

DzRuntimePluginAction::~DzRuntimePluginAction()
Expand Down Expand Up @@ -116,6 +119,84 @@ void DzRuntimePluginAction::Export()
AssetType = "Environment";
ExportNode(Selection);
}
else if (AssetType == "Pose")
{
PoseList.clear();
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))
{
poseIndex++;
numericProperty->setDoubleValue(0.0f, 0.0f);
for (int frame = 0; frame < MorphMapping.count() + 1; frame++)
{
numericProperty->setDoubleValue(dzScene->getTimeStep() * double(frame), 0.0f);
}
numericProperty->setDoubleValue(dzScene->getTimeStep() * double(poseIndex),1.0f);
PoseList.append(propName);
}
}
}

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();
qDebug() << propName;
if (MorphMapping.contains(modifier->getName()))
{
poseIndex++;
numericProperty->setDoubleValue(0.0f, 0.0f);
for (int frame = 0; frame < MorphMapping.count() + 1; frame++)
{
numericProperty->setDoubleValue(dzScene->getTimeStep() * double(frame), 0.0f);
}
numericProperty->setDoubleValue(dzScene->getTimeStep() * double(poseIndex), 1.0f);
PoseList.append(modifier->getName());
}
}
}

}

}
}

dzScene->setAnimRange(DzTimeRange(0, poseIndex * dzScene->getTimeStep()));
dzScene->setPlayRange(DzTimeRange(0, poseIndex * dzScene->getTimeStep()));

ExportNode(Selection);
}
else if (AssetType == "SkeletalMesh")
{
QList<QString> DisconnectedModifiers = DisconnectOverrideControllers();
DzNode* Selection = dzScene->getPrimarySelection();
ExportNode(Selection);
ReconnectOverrideControllers(DisconnectedModifiers);
}
else
{
DzNode* Selection = dzScene->getPrimarySelection();
Expand Down Expand Up @@ -340,4 +421,111 @@ void DzRuntimePluginAction::GetScenePropList(DzNode* Node, QMap<QString, DzNode*
}
}

QList<QString> DzRuntimePluginAction::DisconnectOverrideControllers()
{
QList<QString> ModifiedList;
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 && !numericProperty->isOverridingControllers())
{
QString propName = property->getName();
if (MorphMapping.contains(propName) && ControllersToDisconnect.contains(propName))
{
numericProperty->setOverrideControllers(true);
ModifiedList.append(propName);
}
}
}

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 && !numericProperty->isOverridingControllers())
{
QString propName = property->getName();
if (MorphMapping.contains(modifier->getName()) && ControllersToDisconnect.contains(modifier->getName()))
{
numericProperty->setOverrideControllers(true);
ModifiedList.append(modifier->getName());
}
}
}

}

}
}

return ModifiedList;
}

void DzRuntimePluginAction::ReconnectOverrideControllers(QList<QString>& DisconnetedControllers)
{
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 && numericProperty->isOverridingControllers())
{
QString propName = property->getName();
if (DisconnetedControllers.contains(propName))
{
numericProperty->setOverrideControllers(false);
}
}
}

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 && numericProperty->isOverridingControllers())
{
QString propName = property->getName();
if (DisconnetedControllers.contains(modifier->getName()))
{
numericProperty->setOverrideControllers(false);
}
}
}

}

}
}
}

#include "moc_DzRuntimePluginAction.cpp"
7 changes: 7 additions & 0 deletions Common/DzRuntimePluginAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ class DzRuntimePluginAction : public DzAction {
QString MorphString;
QString FBXVersion;
QMap<QString,QString> MorphMapping;
QList<QString> PoseList;

bool ExportMorphs;
bool ExportSubdivisions;
bool ShowFbxDialog;
bool ExportMaterialPropertiesCSV;
DzNode* Selection;

virtual QString getActionGroup() const { return tr("Bridges"); }
Expand All @@ -54,4 +56,9 @@ class DzRuntimePluginAction : public DzAction {
// During Environment export props need to get disconnected as they are exported.
void DisconnectNode(DzNode* Node, QList<AttachmentInfo>& AttachmentList);
void ReconnectNodes(QList<AttachmentInfo>& AttachmentList);

// During Skeletal Mesh Export Disconnect Override Controllers
QList<QString> DisconnectOverrideControllers();
void ReconnectOverrideControllers(QList<QString>& DisconnetedControllers);
QList<QString> ControllersToDisconnect;
};
67 changes: 58 additions & 9 deletions Unreal/DazStudioPlugin/DzUnrealAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void DzUnrealAction::executeAction()
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();
Expand All @@ -103,9 +104,28 @@ void DzUnrealAction::WriteConfiguration()

if (AssetType != "Environment")
{
writer.startMemberArray("Materials", true);
WriteMaterials(Selection, writer);
writer.finishArray();
if (ExportMaterialPropertiesCSV)
{
QString filename = CharacterFolder + CharacterName + "_Maps.csv";
QFile file(filename);
file.open(QIODevice::WriteOnly);
QTextStream stream(&file);
stream << "Version, Object, Material, Type, Color, Opacity, File" << endl;

writer.startMemberArray("Materials", true);
WriteMaterials(Selection, writer, stream);
writer.finishArray();
}
else
{
QString throwaway;
QTextStream stream(&throwaway);
writer.startMemberArray("Materials", true);
WriteMaterials(Selection, writer, stream);
writer.finishArray();
}



writer.startMemberArray("Morphs", true);
if (ExportMorphs)
Expand All @@ -129,6 +149,22 @@ void DzUnrealAction::WriteConfiguration()
writer.finishArray();
}

if (AssetType == "Pose")
{
writer.startMemberArray("Poses", true);

for (QList<QString>::iterator i = PoseList.begin(); i != PoseList.end(); ++i)
{
writer.startObject(true);
writer.addMember("Name", *i);
writer.addMember("Label", MorphMapping[*i]);
writer.finishObject();
}

writer.finishArray();

}

if (AssetType == "Environment")
{
writer.startMemberArray("Instances", true);
Expand Down Expand Up @@ -157,7 +193,7 @@ void DzUnrealAction::SetExportOptions(DzFileIOSettings& ExportOptions)
}

// Write out all the surface properties
void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer, QTextStream& Stream)
{
DzObject* Object = Node->getObject();
DzShape* Shape = Object ? Object->getCurrentShape() : NULL;
Expand All @@ -183,7 +219,11 @@ void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
Writer.addMember("Data Type", QString("String"));
Writer.addMember("Texture", QString(""));
Writer.finishObject();
//Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << "Asset Type" << ", " << presentationType << ", " << "String" << ", " << "" << endl;

if (ExportMaterialPropertiesCSV)
{
Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << "Asset Type" << ", " << presentationType << ", " << "String" << ", " << "" << endl;
}
}

for (int propertyIndex = 0; propertyIndex < Material->getNumProperties(); propertyIndex++)
Expand All @@ -210,8 +250,11 @@ void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
Writer.addMember("Data Type", QString("Texture"));
Writer.addMember("Texture", TextureName);
Writer.finishObject();
if (ExportMaterialPropertiesCSV)
{
Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << Material->getDiffuseColor().name() << ", " << "Texture" << ", " << TextureName << endl;
}
continue;
//Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << Material->getDiffuseColor().name() << ", " << "Texture" << ", " << TextureName << endl;
}

DzColorProperty* ColorProperty = qobject_cast<DzColorProperty*>(Property);
Expand All @@ -235,7 +278,10 @@ void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
Writer.addMember("Data Type", QString("Color"));
Writer.addMember("Texture", TextureName);
Writer.finishObject();
//Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << ColorProperty->getColorValue().name() << ", " << "Color" << ", " << TextureName << endl;
if (ExportMaterialPropertiesCSV)
{
Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << ColorProperty->getColorValue().name() << ", " << "Color" << ", " << TextureName << endl;
}
continue;
}

Expand All @@ -260,7 +306,10 @@ void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
Writer.addMember("Data Type", QString("Double"));
Writer.addMember("Texture", TextureName);
Writer.finishObject();
//Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << NumericProperty->getDoubleValue() << ", " << "Double" << ", " << TextureName << endl;
if (ExportMaterialPropertiesCSV)
{
Stream << "2, " << Node->getLabel() << ", " << Material->getName() << ", " << Material->getMaterialName() << ", " << Name << ", " << NumericProperty->getDoubleValue() << ", " << "Double" << ", " << TextureName << endl;
}
}
}
}
Expand All @@ -271,7 +320,7 @@ void DzUnrealAction::WriteMaterials(DzNode* Node, DzJsonWriter& Writer)
while (Iterator.hasNext())
{
DzNode* Child = Iterator.next();
WriteMaterials(Child, Writer);
WriteMaterials(Child, Writer, Stream);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Unreal/DazStudioPlugin/DzUnrealAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DzUnrealAction : public DzRuntimePluginAction {
DzUnrealSubdivisionDialog* SubdivisionDialog;

void executeAction();
void WriteMaterials(DzNode* Node, DzJsonWriter& Stream);
void WriteMaterials(DzNode* Node, DzJsonWriter& Writer, QTextStream& Stream);
void WriteInstances(DzNode* Node, DzJsonWriter& Writer, QMap<QString, DzMatrix3>& WritenInstances, QList<DzGeometry*>& ExportedGeometry, QUuid ParentID = QUuid());
QUuid WriteInstance(DzNode* Node, DzJsonWriter& Writer, QUuid ParentID);
void WriteConfiguration();
Expand Down
Loading

0 comments on commit b6ebf63

Please sign in to comment.