mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 09:17:29 +02:00
wip
This commit is contained in:
parent
af205c7f1e
commit
911fd27fc5
1 changed files with 2 additions and 16 deletions
|
@ -1472,8 +1472,6 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
|
|
||||||
// Build weights (adapted from FBXSerializer.cpp)
|
// Build weights (adapted from FBXSerializer.cpp)
|
||||||
if (hfmModel.hasSkeletonJoints) {
|
if (hfmModel.hasSkeletonJoints) {
|
||||||
int prevMeshClusterIndexCount = mesh.clusterIndices.count();
|
|
||||||
int prevMeshClusterWeightCount = mesh.clusterWeights.count();
|
|
||||||
const int WEIGHTS_PER_VERTEX = 4;
|
const int WEIGHTS_PER_VERTEX = 4;
|
||||||
const float ALMOST_HALF = 0.499f;
|
const float ALMOST_HALF = 0.499f;
|
||||||
int numVertices = mesh.vertices.size() - prevMeshVerticesCount;
|
int numVertices = mesh.vertices.size() - prevMeshVerticesCount;
|
||||||
|
@ -1485,6 +1483,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
int prevMeshClusterIndexCount = mesh.clusterIndices.count();
|
||||||
for (int c = 0; c < clusterJoints.size(); ++c) {
|
for (int c = 0; c < clusterJoints.size(); ++c) {
|
||||||
mesh.clusterIndices[prevMeshClusterIndexCount + c] =
|
mesh.clusterIndices[prevMeshClusterIndexCount + c] =
|
||||||
originalToNewNodeIndexMap[_file.skins[node.skin].joints[clusterJoints[c]]];
|
originalToNewNodeIndexMap[_file.skins[node.skin].joints[clusterJoints[c]]];
|
||||||
|
@ -1492,6 +1491,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// normalize and compress to 16-bits
|
// normalize and compress to 16-bits
|
||||||
|
int prevMeshClusterWeightCount = mesh.clusterWeights.count();
|
||||||
for (int i = 0; i < numVertices; ++i) {
|
for (int i = 0; i < numVertices; ++i) {
|
||||||
int j = i * WEIGHTS_PER_VERTEX;
|
int j = i * WEIGHTS_PER_VERTEX;
|
||||||
|
|
||||||
|
@ -1507,20 +1507,6 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
|
||||||
} else {
|
} else {
|
||||||
mesh.clusterWeights[prevMeshClusterWeightCount + j] = (uint16_t)((float)(UINT16_MAX) + ALMOST_HALF);
|
mesh.clusterWeights[prevMeshClusterWeightCount + j] = (uint16_t)((float)(UINT16_MAX) + ALMOST_HALF);
|
||||||
}
|
}
|
||||||
for (int clusterIndex = 0; clusterIndex < mesh.clusters.size() - 1; ++clusterIndex) {
|
|
||||||
ShapeVertices& points = hfmModel.shapeVertices.at(clusterIndex);
|
|
||||||
glm::vec3 globalMeshScale = extractScale(globalTransforms[nodeIndex]);
|
|
||||||
const glm::mat4 meshToJoint = glm::scale(glm::mat4(), globalMeshScale) * jointInverseBindTransforms[clusterIndex];
|
|
||||||
|
|
||||||
const float EXPANSION_WEIGHT_THRESHOLD = 0.25f;
|
|
||||||
if (mesh.clusterWeights[j] >= EXPANSION_WEIGHT_THRESHOLD) {
|
|
||||||
// TODO: fix transformed vertices being pushed back
|
|
||||||
auto& vertex = mesh.vertices[i];
|
|
||||||
const glm::mat4 vertexTransform = meshToJoint * (glm::translate(glm::mat4(), vertex));
|
|
||||||
glm::vec3 transformedVertex = hfmModel.joints[clusterIndex].translation * (extractTranslation(vertexTransform));
|
|
||||||
points.push_back(transformedVertex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue