diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index 7aff77ad0..a5603a3ca 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -425,6 +425,12 @@ namespace glTF { vJointNames.PushBack(StringRef(b.jointNames[i]), w.mAl); } obj.AddMember("jointNames", vJointNames, w.mAl); + + if (b.bindShapeMatrix.isPresent) { + Value val; + obj.AddMember("bindShapeMatrix", MakeValue(val, b.bindShapeMatrix.value, w.mAl).Move(), w.mAl); + } + } inline void Write(Value& obj, Technique& b, AssetWriter& w) diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 3d1aa9901..86592d245 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -166,6 +166,14 @@ static void CopyValue(const aiMatrix4x4& v, glTF::mat4& o) o[12] = v.a4; o[13] = v.b4; o[14] = v.c4; o[15] = v.d4; } +static void IdentityMatrix4(glTF::mat4& o) +{ + o[ 0] = 1; o[ 1] = 0; o[ 2] = 0; o[ 3] = 0; + o[ 4] = 0; o[ 5] = 1; o[ 6] = 0; o[ 7] = 0; + o[ 8] = 0; o[ 9] = 0; o[10] = 1; o[11] = 0; + o[12] = 0; o[13] = 0; o[14] = 0; o[15] = 1; +} + inline Ref ExportData(Asset& a, std::string& meshName, Ref& buffer, unsigned int count, void* data, AttribType::Value typeIn, AttribType::Value typeOut, ComponentType compType, bool isIndices = false) { @@ -858,6 +866,12 @@ void glTFExporter::ExportSkins() std::cout << "Node->id " << nodeRef->id << "\n"; + + skinRef->bindShapeMatrix.isPresent = true; + // CopyValue(n->mTransformation, skinRef->bindShapeMatrix.value); + // aiIdentityMatrix4(skinRef->bindShapeMatrix.value); + IdentityMatrix4(skinRef->bindShapeMatrix.value); + // skinRef->bindShapeMatrix; // skinRef->inverseBindMatrices;