diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl index 65fddaec5..ab30e418a 100644 --- a/code/AssetLib/glTF2/glTF2AssetWriter.inl +++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl @@ -571,7 +571,6 @@ namespace glTF2 { inline void Write(Value& obj, Node& n, AssetWriter& w) { - if (n.matrix.isPresent) { Value val; obj.AddMember("matrix", MakeValue(val, n.matrix.value, w.mAl).Move(), w.mAl); @@ -597,14 +596,13 @@ namespace glTF2 { obj.AddMember("mesh", n.meshes[0]->index, w.mAl); } - AddRefsVector(obj, "skeletons", n.skeletons, w.mAl); - if (n.skin) { obj.AddMember("skin", n.skin->index, w.mAl); } - - if (!n.jointName.empty()) { - obj.AddMember("jointName", n.jointName, w.mAl); + + //gltf2 spec does not support "skeletons" under node + if(n.skeletons.size()) { + AddRefsVector(obj, "skeletons", n.skeletons, w.mAl); } } diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index 9bc670cb2..10525e028 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -1095,6 +1095,7 @@ void glTF2Exporter::ExportMeshes() //---------------------------------------- // Finish the skin // Create the Accessor for skinRef->inverseBindMatrices + bool bAddCustomizedProperty = this->mProperties->HasPropertyBool("GLTF2_CUSTOMIZE_PROPERTY"); if (createSkin) { mat4* invBindMatrixData = new mat4[inverseBindMatricesData.size()]; for ( unsigned int idx_joint = 0; idx_joint < inverseBindMatricesData.size(); ++idx_joint) { @@ -1110,7 +1111,7 @@ void glTF2Exporter::ExportMeshes() // Identity Matrix =====> skinRef->bindShapeMatrix // Temporary. Hard-coded identity matrix here - skinRef->bindShapeMatrix.isPresent = true; + skinRef->bindShapeMatrix.isPresent = bAddCustomizedProperty; IdentityMatrix4(skinRef->bindShapeMatrix.value); // Find nodes that contain a mesh with bones and add "skeletons" and "skin" attributes to those nodes. @@ -1131,7 +1132,8 @@ void glTF2Exporter::ExportMeshes() std::string meshID = mesh->id; FindMeshNode(rootNode, meshNode, meshID); Ref rootJoint = FindSkeletonRootJoint(skinRef); - meshNode->skeletons.push_back(rootJoint); + if(bAddCustomizedProperty) + meshNode->skeletons.push_back(rootJoint); meshNode->skin = skinRef; } delete[] invBindMatrixData;