Added flag to flip vertex position y coordinates
This commit is contained in:
parent
5df36d7b19
commit
7b46e71f33
1 changed files with 8 additions and 2 deletions
|
|
@ -541,7 +541,8 @@ namespace vkglTF
|
||||||
typedef enum FileLoadingFlags {
|
typedef enum FileLoadingFlags {
|
||||||
None = 0,
|
None = 0,
|
||||||
PreTransformVertices = 1,
|
PreTransformVertices = 1,
|
||||||
PreMultiplyVertexColors = 2
|
PreMultiplyVertexColors = 2,
|
||||||
|
FlipY = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1042,9 +1043,10 @@ namespace vkglTF
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-Calculations for requested features
|
// Pre-Calculations for requested features
|
||||||
if ((fileLoadingFlags & FileLoadingFlags::PreTransformVertices) || (fileLoadingFlags & FileLoadingFlags::PreMultiplyVertexColors)) {
|
if ((fileLoadingFlags & FileLoadingFlags::PreTransformVertices) || (fileLoadingFlags & FileLoadingFlags::PreMultiplyVertexColors) || (fileLoadingFlags & FileLoadingFlags::FlipY)) {
|
||||||
const bool preTransform = fileLoadingFlags & FileLoadingFlags::PreTransformVertices;
|
const bool preTransform = fileLoadingFlags & FileLoadingFlags::PreTransformVertices;
|
||||||
const bool preMultiplyColor = fileLoadingFlags & FileLoadingFlags::PreMultiplyVertexColors;
|
const bool preMultiplyColor = fileLoadingFlags & FileLoadingFlags::PreMultiplyVertexColors;
|
||||||
|
const bool flipY = fileLoadingFlags & FileLoadingFlags::FlipY;
|
||||||
for (Node* node : linearNodes) {
|
for (Node* node : linearNodes) {
|
||||||
if (node->mesh) {
|
if (node->mesh) {
|
||||||
const glm::mat4 localMatrix = node->getMatrix();
|
const glm::mat4 localMatrix = node->getMatrix();
|
||||||
|
|
@ -1055,6 +1057,10 @@ namespace vkglTF
|
||||||
if (preTransform) {
|
if (preTransform) {
|
||||||
vertex.pos = glm::vec3(localMatrix * glm::vec4(vertex.pos, 1.0f));
|
vertex.pos = glm::vec3(localMatrix * glm::vec4(vertex.pos, 1.0f));
|
||||||
}
|
}
|
||||||
|
// Flip Y-Axis of vertex positions
|
||||||
|
if (preTransform) {
|
||||||
|
vertex.pos.y *= -1.0f;
|
||||||
|
}
|
||||||
// Pre-Multiply vertex colors with material base color
|
// Pre-Multiply vertex colors with material base color
|
||||||
if (preMultiplyColor) {
|
if (preMultiplyColor) {
|
||||||
vertex.color = primitive->material.baseColorFactor * vertex.color;
|
vertex.color = primitive->material.baseColorFactor * vertex.color;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue