Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UE5 preview2 2 2 2 2! please #45

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
857698d
Fix for Fixed Rotations with Separate Clothing Export
David-Vodhanel Jun 14, 2021
5821de3
Merge branch 'master' of https://github.com/David-Vodhanel/DazToRuntime
David-Vodhanel Jun 22, 2021
ca3b315
Updates to the AR Kit
samjay3d Jul 5, 2021
0acc682
Merge pull request #23 from David-Vodhanel/master
samjay3d Jul 5, 2021
2c063e6
Merge pull request #2 from daz3d/unreal-develop
David-Vodhanel Jul 7, 2021
ee6e8cf
Daz and UE4 Plugin modifications to invoke subd skin weight
cocktail-boy Aug 2, 2021
9a10ef7
Merge pull request #3 from cocktailboy/master
David-Vodhanel Sep 1, 2021
fdec774
Subdivision Updates.
David-Vodhanel Sep 8, 2021
536eef8
Adding AutoJCM feature
David-Vodhanel Sep 26, 2021
6f37c70
Fixed some rotation issues with the Environment transfer method
David-Vodhanel Dec 4, 2021
e9f63c0
Updates to the AR Kit
samjay3d Jul 5, 2021
3c7010f
Daz and UE4 Plugin modifications to invoke subd skin weight
cocktail-boy Aug 2, 2021
e0976b5
Subdivision Updates.
David-Vodhanel Sep 8, 2021
9e6b1f1
Adding AutoJCM feature
David-Vodhanel Sep 26, 2021
9575054
Merge branch 'master' of https://github.com/David-Vodhanel/DazToRuntime
David-Vodhanel Dec 5, 2021
d93450a
Revert "Fixed some rotation issues with the Environment transfer method"
David-Vodhanel Dec 5, 2021
680e3a2
Compile fixed for UE4.25
David-Vodhanel Dec 5, 2021
876f500
Some rotation fixes for Environment transfer method.
David-Vodhanel Dec 5, 2021
094d655
Missed the Build.cs update, causing a compile error
David-Vodhanel Dec 5, 2021
db69a11
Missed another file update.
David-Vodhanel Dec 5, 2021
0da9213
Fix for a crash when adding JCM mappings to the blueprint.
David-Vodhanel Dec 5, 2021
facb22b
Environment Transfer Fix for some pieces not exporting
David-Vodhanel Dec 16, 2021
9a67b65
Environment rotation fixes
David-Vodhanel Dec 21, 2021
ae38652
Fix for crash when re-transferring a character
David-Vodhanel Dec 31, 2021
8cfc74d
Update DazToUnrealSubdivision.cpp
David-Vodhanel Feb 26, 2022
b1d6c61
Environment Transfer Hierarchy Fix
David-Vodhanel Mar 9, 2022
31c642d
Fix for new directories not getting created in some cases.
David-Vodhanel Mar 16, 2022
1a4dbad
Environment transfers now work with InstanceNodes.
David-Vodhanel Mar 16, 2022
570910a
Quick fix for compiling 5.0 release
David-Vodhanel Apr 6, 2022
2183daa
Another quick 5.0 fix
David-Vodhanel Apr 6, 2022
9b802f6
Proper Updates for UE5 release
David-Vodhanel Apr 8, 2022
73d3f6d
Fix for animations not transferring
David-Vodhanel Apr 9, 2022
5930797
Fix for Environment Transfer giving bad rotations when Force Front X …
David-Vodhanel Apr 9, 2022
a695857
Compile fix for Unreal 4.26 and older.
David-Vodhanel Apr 10, 2022
4288112
Compile Fix for UE4.27
David-Vodhanel Apr 10, 2022
ed25ceb
Fix for blendshape anim curves not transferring.
David-Vodhanel Apr 10, 2022
cc63bb6
Adding retargeting assets for UE5.
David-Vodhanel Apr 14, 2022
662f970
Fix for AutoJCM PostProcess AnimBlueprint breaking animation in UE5
David-Vodhanel Apr 21, 2022
aa66eba
Improved Retarget Assets for UE5
David-Vodhanel Apr 24, 2022
8aee84b
Fix for a packaging error in UE5.0 due to uninitialized variables.
David-Vodhanel Apr 25, 2022
e2a1d84
Fix a crash when AutoJCM sets the PostProcessAnimation
David-Vodhanel Apr 28, 2022
b8488c2
Added a function for checking if AutoJCM is setup in the DTU file.
David-Vodhanel Apr 28, 2022
d7e9538
Added heel values to the IK foot Control Rig
David-Vodhanel May 7, 2022
683f0ea
Adding my work in progress Control Rig for Genesis 8
David-Vodhanel May 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions Common/DzRuntimePluginAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <dzimageproperty.h>
#include <dzstringproperty.h>
#include <dznumericproperty.h>
#include <dzfloatproperty.h>
#include <dzcolorproperty.h>
#include <dzstringproperty.h>
#include <dzenumproperty.h>
Expand Down Expand Up @@ -87,6 +88,9 @@ void DzRuntimePluginAction::Export()
}
}

//Unlock the transform controls so the node can be moved to root
UnlockTranform(Node);

// Disconnect the asset being sent from everything else
QList<AttachmentInfo> AttachmentList;
DisconnectNode(Node, AttachmentList);
Expand Down Expand Up @@ -297,7 +301,11 @@ void DzRuntimePluginAction::ExportNode(DzNode* Node)
}
ExportOptions.setBoolValue("doLights", false);
ExportOptions.setBoolValue("doCameras", false);
ExportOptions.setBoolValue("doAnims", true);
ExportOptions.setBoolValue("doAnims", false);
if (AssetType == "Animation")
{
ExportOptions.setBoolValue("doAnims", true);
}
if ((AssetType == "Animation" || AssetType == "SkeletalMesh") && ExportMorphs && MorphString != "")
{
ExportOptions.setBoolValue("doMorphs", true);
Expand Down Expand Up @@ -341,9 +349,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 Expand Up @@ -406,7 +434,8 @@ void DzRuntimePluginAction::GetScenePropList(DzNode* Node, QMap<QString, DzNode*
QString FileName = File.fileName();
QStringList Items = FileName.split("/");
QStringList Parts = Items[Items.count() - 1].split(".");
QString Name = Parts[0].remove(QRegExp("[^A-Za-z0-9_]"));
QString AssetID = Node->getAssetUri().getId();
QString Name = AssetID.remove(QRegExp("[^A-Za-z0-9_]"));

if (Figure)
{
Expand Down Expand Up @@ -592,4 +621,29 @@ bool DzRuntimePluginAction::CheckIfPoseExportIsDestructive()
return false;
}

void DzRuntimePluginAction::UnlockTranform(DzNode* NodeToUnlock)
{
DzFloatProperty* Property = nullptr;
Property = NodeToUnlock->getXPosControl();
Property->lock(false);
Property = NodeToUnlock->getYPosControl();
Property->lock(false);
Property = NodeToUnlock->getZPosControl();
Property->lock(false);

Property = NodeToUnlock->getXRotControl();
Property->lock(false);
Property = NodeToUnlock->getYRotControl();
Property->lock(false);
Property = NodeToUnlock->getZRotControl();
Property->lock(false);

Property = NodeToUnlock->getXScaleControl();
Property->lock(false);
Property = NodeToUnlock->getYScaleControl();
Property->lock(false);
Property = NodeToUnlock->getZScaleControl();
Property->lock(false);
}

#include "moc_DzRuntimePluginAction.cpp"
6 changes: 6 additions & 0 deletions Common/DzRuntimePluginAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class DzRuntimePluginAction : public DzAction {
QString ImportFolder;
QString CharacterFolder;
QString CharacterFBX;
QString CharacterBaseFBX;
QString CharacterHDFBX;
QString AssetType;
QString MorphString;
QString FBXVersion;
Expand All @@ -33,6 +35,7 @@ class DzRuntimePluginAction : public DzAction {

bool ExportMorphs;
bool ExportSubdivisions;
bool ExportBaseMesh;
bool ShowFbxDialog;
bool ExportMaterialPropertiesCSV;
DzNode* Selection;
Expand Down Expand Up @@ -64,4 +67,7 @@ class DzRuntimePluginAction : public DzAction {

// For Pose exports check if writing to the timeline will alter existing keys
bool CheckIfPoseExportIsDestructive();

// Need to be able to move asset instances to origin during environment export
void UnlockTranform(DzNode* NodeToUnlock);
};
131 changes: 107 additions & 24 deletions Unreal/DazStudioPlugin/DzUnrealAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
#include <dzfigure.h>
#include <dzfacetmesh.h>
#include <dzbone.h>
#include <dzgroupnode.h>
#include <dzinstancenode.h>
//#include <dznodeinstance.h>
#include "idzsceneasset.h"
#include "dzuri.h"

#include "DzUnrealDialog.h"
#include "DzUnrealAction.h"
#include "DzUnrealMorphSelectionDialog.h"

DzUnrealAction::DzUnrealAction() :
DzRuntimePluginAction(tr("&Daz to Unreal"), tr("Send the selected node to Unreal."))
Expand Down Expand Up @@ -69,24 +72,36 @@ 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";
CharacterBaseFBX = CharacterFolder + CharacterName + "_base.fbx";
CharacterHDFBX = CharacterFolder + CharacterName + "_HD.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 All @@ -100,6 +115,8 @@ void DzUnrealAction::WriteConfiguration()
writer.addMember("Asset Name", CharacterName);
writer.addMember("Asset Type", AssetType);
writer.addMember("FBX File", CharacterFBX);
writer.addMember("Base FBX File", CharacterBaseFBX);
writer.addMember("HD FBX File", CharacterHDFBX);
writer.addMember("Import Folder", CharacterFolder);

if (AssetType != "Environment")
Expand Down Expand Up @@ -138,10 +155,42 @@ void DzUnrealAction::WriteConfiguration()
writer.finishObject();
}
}

writer.finishArray();


if (ExportMorphs)
{
DzMainWindow* mw = dzApp->getInterface();
DzUnrealMorphSelectionDialog* morphDialog = DzUnrealMorphSelectionDialog::Get(mw);
if (morphDialog->IsAutoJCMEnabled())
{
writer.startMemberArray("JointLinks", true);
QList<JointLinkInfo> JointLinks = morphDialog->GetActiveJointControlledMorphs(Selection);
foreach(JointLinkInfo linkInfo, JointLinks)
{
writer.startObject(true);
writer.addMember("Bone", linkInfo.Bone);
writer.addMember("Axis", linkInfo.Axis);
writer.addMember("Morph", linkInfo.Morph);
writer.addMember("Scalar", linkInfo.Scalar);
writer.addMember("Alpha", linkInfo.Alpha);
if (linkInfo.Keys.count() > 0)
{
writer.startMemberArray("Keys", true);
foreach(JointLinkKey key, linkInfo.Keys)
{
writer.startObject(true);
writer.addMember("Angle", key.Angle);
writer.addMember("Value", key.Value);
writer.finishObject();
}
writer.finishArray();
}
writer.finishObject();
}
writer.finishArray();
}
}

writer.startMemberArray("Subdivisions", true);
if (ExportSubdivisions)
SubdivisionDialog->WriteSubdivisions(writer);
Expand Down Expand Up @@ -178,6 +227,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 Expand Up @@ -330,13 +387,25 @@ void DzUnrealAction::WriteInstances(DzNode* Node, DzJsonWriter& Writer, QMap<QSt
DzShape* Shape = Object ? Object->getCurrentShape() : NULL;
DzGeometry* Geometry = Shape ? Shape->getGeometry() : NULL;
DzBone* Bone = qobject_cast<DzBone*>(Node);
DzGroupNode* GroupNode = qobject_cast<DzGroupNode*>(Node);
DzInstanceNode* InstanceNode = qobject_cast<DzInstanceNode*>(Node);

if (Bone == nullptr && Geometry)
{
ExportedGeometry.append(Geometry);
ParentID = WriteInstance(Node, Writer, ParentID);
}

if (GroupNode)
{
ParentID = WriteInstance(Node, Writer, ParentID);
}

if (InstanceNode)
{
ParentID = WriteInstance(Node, Writer, ParentID);
}

for (int ChildIndex = 0; ChildIndex < Node->getNumNodeChildren(); ChildIndex++)
{
DzNode* ChildNode = Node->getNodeChild(ChildIndex);
Expand All @@ -348,12 +417,26 @@ QUuid DzUnrealAction::WriteInstance(DzNode* Node, DzJsonWriter& Writer, QUuid Pa
{
QString Path = Node->getAssetFileInfo().getUri().getFilePath();
QFile File(Path);
QString FileName = File.fileName();
QStringList Items = FileName.split("/");
QStringList Parts = Items[Items.count() - 1].split(".");
QString Name = Parts[0].remove(QRegExp("[^A-Za-z0-9_]"));
QString AssetID = Node->getAssetUri().getId();
QString Name = AssetID.remove(QRegExp("[^A-Za-z0-9_]"));
QUuid Uid = QUuid::createUuid();

// Group Node needs an empty InstanceAsset
DzGroupNode* GroupNode = qobject_cast<DzGroupNode*>(Node);
if (GroupNode)
{
Name = "";
}

// Group Node needs an empty InstanceAsset
DzInstanceNode* InstanceNode = qobject_cast<DzInstanceNode*>(Node);
if (InstanceNode)
{
AssetID = InstanceNode->getTarget()->getAssetUri().getId();
Name = AssetID.remove(QRegExp("[^A-Za-z0-9_]"));
}


Writer.startObject(true);
Writer.addMember("Version", 1);
Writer.addMember("InstanceLabel", Node->getLabel());
Expand Down
Loading