fix issue: 3482: invalid gltf2 properties
parent
8d4b816dfe
commit
793bd44cee
|
@ -571,7 +571,6 @@ namespace glTF2 {
|
||||||
|
|
||||||
inline void Write(Value& obj, Node& n, AssetWriter& w)
|
inline void Write(Value& obj, Node& n, AssetWriter& w)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (n.matrix.isPresent) {
|
if (n.matrix.isPresent) {
|
||||||
Value val;
|
Value val;
|
||||||
obj.AddMember("matrix", MakeValue(val, n.matrix.value, w.mAl).Move(), w.mAl);
|
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);
|
obj.AddMember("mesh", n.meshes[0]->index, w.mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddRefsVector(obj, "skeletons", n.skeletons, w.mAl);
|
|
||||||
|
|
||||||
if (n.skin) {
|
if (n.skin) {
|
||||||
obj.AddMember("skin", n.skin->index, w.mAl);
|
obj.AddMember("skin", n.skin->index, w.mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!n.jointName.empty()) {
|
//gltf2 spec does not support "skeletons" under node
|
||||||
obj.AddMember("jointName", n.jointName, w.mAl);
|
if(n.skeletons.size()) {
|
||||||
|
AddRefsVector(obj, "skeletons", n.skeletons, w.mAl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1095,6 +1095,7 @@ void glTF2Exporter::ExportMeshes()
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// Finish the skin
|
// Finish the skin
|
||||||
// Create the Accessor for skinRef->inverseBindMatrices
|
// Create the Accessor for skinRef->inverseBindMatrices
|
||||||
|
bool bAddCustomizedProperty = this->mProperties->HasPropertyBool("GLTF2_CUSTOMIZE_PROPERTY");
|
||||||
if (createSkin) {
|
if (createSkin) {
|
||||||
mat4* invBindMatrixData = new mat4[inverseBindMatricesData.size()];
|
mat4* invBindMatrixData = new mat4[inverseBindMatricesData.size()];
|
||||||
for ( unsigned int idx_joint = 0; idx_joint < inverseBindMatricesData.size(); ++idx_joint) {
|
for ( unsigned int idx_joint = 0; idx_joint < inverseBindMatricesData.size(); ++idx_joint) {
|
||||||
|
@ -1110,7 +1111,7 @@ void glTF2Exporter::ExportMeshes()
|
||||||
|
|
||||||
// Identity Matrix =====> skinRef->bindShapeMatrix
|
// Identity Matrix =====> skinRef->bindShapeMatrix
|
||||||
// Temporary. Hard-coded identity matrix here
|
// Temporary. Hard-coded identity matrix here
|
||||||
skinRef->bindShapeMatrix.isPresent = true;
|
skinRef->bindShapeMatrix.isPresent = bAddCustomizedProperty;
|
||||||
IdentityMatrix4(skinRef->bindShapeMatrix.value);
|
IdentityMatrix4(skinRef->bindShapeMatrix.value);
|
||||||
|
|
||||||
// Find nodes that contain a mesh with bones and add "skeletons" and "skin" attributes to those nodes.
|
// 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;
|
std::string meshID = mesh->id;
|
||||||
FindMeshNode(rootNode, meshNode, meshID);
|
FindMeshNode(rootNode, meshNode, meshID);
|
||||||
Ref<Node> rootJoint = FindSkeletonRootJoint(skinRef);
|
Ref<Node> rootJoint = FindSkeletonRootJoint(skinRef);
|
||||||
meshNode->skeletons.push_back(rootJoint);
|
if(bAddCustomizedProperty)
|
||||||
|
meshNode->skeletons.push_back(rootJoint);
|
||||||
meshNode->skin = skinRef;
|
meshNode->skin = skinRef;
|
||||||
}
|
}
|
||||||
delete[] invBindMatrixData;
|
delete[] invBindMatrixData;
|
||||||
|
|
Loading…
Reference in New Issue