set bindShapeMatrix to identity
authorAngelo Scandaliato <angelo@adtile.me>
Thu, 6 Oct 2016 01:16:32 +0000 (18:16 -0700)
committerAngelo Scandaliato <angelo@adtile.me>
Thu, 6 Oct 2016 01:16:32 +0000 (18:16 -0700)
code/glTFAssetWriter.inl
code/glTFExporter.cpp

index 7aff77a..a5603a3 100644 (file)
@@ -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)
index 3d1aa99..86592d2 100644 (file)
@@ -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<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& 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;