FlipUVsProcess should also process AnimMeshes (if any)
parent
28fd396db4
commit
b965e7a6dc
|
@ -59,6 +59,25 @@ using namespace Assimp;
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS
|
#ifndef ASSIMP_BUILD_NO_MAKELEFTHANDED_PROCESS
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template <typename aiMeshType>
|
||||||
|
void flipUVs(aiMeshType* pMesh) {
|
||||||
|
if (pMesh == nullptr) { return; }
|
||||||
|
// mirror texture y coordinate
|
||||||
|
for (unsigned int tcIdx = 0; tcIdx < AI_MAX_NUMBER_OF_TEXTURECOORDS; tcIdx++) {
|
||||||
|
if (!pMesh->HasTextureCoords(tcIdx)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int vIdx = 0; vIdx < pMesh->mNumVertices; vIdx++) {
|
||||||
|
pMesh->mTextureCoords[tcIdx][vIdx].y = 1.0f - pMesh->mTextureCoords[tcIdx][vIdx].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
MakeLeftHandedProcess::MakeLeftHandedProcess()
|
MakeLeftHandedProcess::MakeLeftHandedProcess()
|
||||||
|
@ -282,15 +301,9 @@ void FlipUVsProcess::ProcessMaterial (aiMaterial* _mat)
|
||||||
// Converts a single mesh
|
// Converts a single mesh
|
||||||
void FlipUVsProcess::ProcessMesh( aiMesh* pMesh)
|
void FlipUVsProcess::ProcessMesh( aiMesh* pMesh)
|
||||||
{
|
{
|
||||||
// mirror texture y coordinate
|
flipUVs(pMesh);
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
for (unsigned int idx = 0; idx < pMesh->mNumAnimMeshes; idx++) {
|
||||||
if( !pMesh->HasTextureCoords( a ) ) {
|
flipUVs(pMesh->mAnimMeshes[idx]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( unsigned int b = 0; b < pMesh->mNumVertices; b++ ) {
|
|
||||||
pMesh->mTextureCoords[ a ][ b ].y = 1.0f - pMesh->mTextureCoords[ a ][ b ].y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue