Export translation and rotation to .ds3obj

This will make no need of decompose the matrix.
This commit fixed the missing confirm dialog when exporting filename exists.
master
huxingyi 2020-12-06 15:03:46 +09:30
parent 7c43ac4916
commit eacc96d13b
1 changed files with 28 additions and 13 deletions

View File

@ -1976,7 +1976,7 @@ void DocumentWindow::exportObjToFilename(const QString &filename)
void DocumentWindow::exportFbxResult()
{
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
tr("Autodesk FBX (.fbx)"));
tr("Autodesk FBX (*.fbx)"));
if (filename.isEmpty()) {
return;
}
@ -2045,7 +2045,7 @@ void DocumentWindow::exportFbxToFilename(const QString &filename)
void DocumentWindow::exportGlbResult()
{
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
tr("glTF Binary Format (.glb)"));
tr("glTF Binary Format (*.glb)"));
if (filename.isEmpty()) {
return;
}
@ -2056,7 +2056,7 @@ void DocumentWindow::exportGlbResult()
void DocumentWindow::exportDs3objResult()
{
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
tr("Dust3D Object (.ds3obj)"));
tr("Dust3D Object (*.ds3obj)"));
if (filename.isEmpty()) {
return;
}
@ -2135,6 +2135,7 @@ void DocumentWindow::exportDs3objToFilename(const QString &filename)
const auto &node = nodes[boneIndex];
writer->writeStartElement("bone");
writer->writeAttribute("index", QString::number(boneIndex));
{
QMatrix4x4 translationMatrix;
translationMatrix.translate(node.translation);
QMatrix4x4 rotationMatrix;
@ -2146,6 +2147,20 @@ void DocumentWindow::exportDs3objToFilename(const QString &filename)
matrixItemList += QString::number(floatArray[j]);
}
writer->writeAttribute("matrix", matrixItemList.join(","));
}
{
writer->writeAttribute("translation",
QString::number(node.translation.x()) + "," +
QString::number(node.translation.y()) + "," +
QString::number(node.translation.z()));
}
{
writer->writeAttribute("rotation",
QString::number(node.rotation.x()) + "," +
QString::number(node.rotation.y()) + "," +
QString::number(node.rotation.z()) + "," +
QString::number(node.rotation.scalar()));
}
writer->writeEndElement();
}
writer->writeEndElement();