Merge branch 'master' into collada_modeller_metadata
commit
9ef2d7fb7d
|
@ -2089,6 +2089,13 @@ namespace Assimp {
|
|||
TrySetTextureProperties(out_mat, textures, "Maya|TEX_metallic_map|file", aiTextureType_METALNESS, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|TEX_roughness_map|file", aiTextureType_DIFFUSE_ROUGHNESS, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "Maya|TEX_ao_map|file", aiTextureType_AMBIENT_OCCLUSION, mesh);
|
||||
|
||||
// 3DSMax PBR
|
||||
TrySetTextureProperties(out_mat, textures, "3dsMax|Parameters|base_color_map", aiTextureType_BASE_COLOR, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "3dsMax|Parameters|bump_map", aiTextureType_NORMAL_CAMERA, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "3dsMax|Parameters|emission_map", aiTextureType_EMISSION_COLOR, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "3dsMax|Parameters|metalness_map", aiTextureType_METALNESS, mesh);
|
||||
TrySetTextureProperties(out_mat, textures, "3dsMax|Parameters|roughness_map", aiTextureType_DIFFUSE_ROUGHNESS, mesh);
|
||||
}
|
||||
|
||||
void FBXConverter::SetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures, const MeshGeometry* const mesh)
|
||||
|
|
|
@ -137,8 +137,9 @@ public:
|
|||
// -------------------------------------------------------------------
|
||||
void Execute( aiScene* pScene);
|
||||
|
||||
protected:
|
||||
void ProcessMesh( aiMesh* pMesh);
|
||||
public:
|
||||
/** Some other types of post-processing require winding order flips */
|
||||
static void ProcessMesh( aiMesh* pMesh);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -43,13 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* @brief Implementation of the aiProcess_OptimizGraph step
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS
|
||||
|
||||
#include "OptimizeGraph.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
@ -70,11 +70,11 @@ using namespace Assimp;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
OptimizeGraphProcess::OptimizeGraphProcess()
|
||||
: mScene()
|
||||
, nodes_in()
|
||||
, nodes_out()
|
||||
, count_merged() {
|
||||
OptimizeGraphProcess::OptimizeGraphProcess() :
|
||||
mScene(),
|
||||
nodes_in(),
|
||||
nodes_out(),
|
||||
count_merged() {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
|||
nodes.push_back(nd);
|
||||
|
||||
// Now check for possible optimizations in our list of child nodes. join as many as possible
|
||||
aiNode* join_master = NULL;
|
||||
aiNode *join_master = nullptr;
|
||||
aiMatrix4x4 inv;
|
||||
|
||||
const LockedSetType::const_iterator end = locked.end();
|
||||
|
@ -173,7 +173,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
|||
join_master->mName.length = ::ai_snprintf(join_master->mName.data, MAXLEN, "$MergedNode_%i", count_merged++);
|
||||
|
||||
unsigned int out_meshes = 0;
|
||||
for (std::list<aiNode*>::iterator it = join.begin(); it != join.end(); ++it) {
|
||||
for (std::list<aiNode *>::const_iterator it = join.cbegin(); it != join.cend(); ++it) {
|
||||
out_meshes += (*it)->mNumMeshes;
|
||||
}
|
||||
|
||||
|
@ -184,17 +184,26 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
|||
*tmp++ = join_master->mMeshes[n];
|
||||
}
|
||||
|
||||
for (std::list<aiNode*>::iterator it = join.begin(); it != join.end(); ++it) {
|
||||
for (unsigned int n = 0; n < (*it)->mNumMeshes; ++n) {
|
||||
for (const aiNode *join_node : join) {
|
||||
for (unsigned int n = 0; n < join_node->mNumMeshes; ++n) {
|
||||
|
||||
*tmp = (*it)->mMeshes[n];
|
||||
*tmp = join_node->mMeshes[n];
|
||||
aiMesh *mesh = mScene->mMeshes[*tmp++];
|
||||
|
||||
// Assume the transformation is affine
|
||||
// manually move the mesh into the right coordinate system
|
||||
const aiMatrix3x3 IT = aiMatrix3x3( (*it)->mTransformation ).Inverse().Transpose();
|
||||
|
||||
// Check for odd negative scale (mirror)
|
||||
if (join_node->mTransformation.Determinant() < 0) {
|
||||
// Reverse the mesh face winding order
|
||||
FlipWindingOrderProcess::ProcessMesh(mesh);
|
||||
}
|
||||
|
||||
// Update positions, normals and tangents
|
||||
const aiMatrix3x3 IT = aiMatrix3x3(join_node->mTransformation).Inverse().Transpose();
|
||||
for (unsigned int a = 0; a < mesh->mNumVertices; ++a) {
|
||||
|
||||
mesh->mVertices[a] *= (*it)->mTransformation;
|
||||
mesh->mVertices[a] *= join_node->mTransformation;
|
||||
|
||||
if (mesh->HasNormals())
|
||||
mesh->mNormals[a] *= IT;
|
||||
|
@ -205,7 +214,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
|||
}
|
||||
}
|
||||
}
|
||||
delete *it; // bye, node
|
||||
delete join_node; // bye, node
|
||||
}
|
||||
delete[] join_master->mMeshes;
|
||||
join_master->mMeshes = meshes;
|
||||
|
@ -220,8 +229,8 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list<aiNode*>& no
|
|||
|
||||
if (!child_nodes.empty()) {
|
||||
nd->mChildren = new aiNode *[child_nodes.size()];
|
||||
}
|
||||
else nd->mChildren = nullptr;
|
||||
} else
|
||||
nd->mChildren = nullptr;
|
||||
}
|
||||
|
||||
nd->mNumChildren = static_cast<unsigned int>(child_nodes.size());
|
||||
|
@ -305,7 +314,7 @@ void OptimizeGraphProcess::Execute( aiScene* pScene) {
|
|||
ai_assert(nodes.size() == 1);
|
||||
|
||||
if (dummy_root->mNumChildren == 0) {
|
||||
pScene->mRootNode = NULL;
|
||||
pScene->mRootNode = nullptr;
|
||||
throw DeadlyImportError("After optimizing the scene graph, no data remains");
|
||||
}
|
||||
|
||||
|
@ -314,17 +323,16 @@ void OptimizeGraphProcess::Execute( aiScene* pScene) {
|
|||
|
||||
// Keep the dummy node but assign the name of the old root node to it
|
||||
pScene->mRootNode->mName = prev;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// Remove the dummy root node again.
|
||||
pScene->mRootNode = dummy_root->mChildren[0];
|
||||
|
||||
dummy_root->mChildren[0] = NULL;
|
||||
dummy_root->mChildren[0] = nullptr;
|
||||
delete dummy_root;
|
||||
}
|
||||
|
||||
pScene->mRootNode->mParent = NULL;
|
||||
pScene->mRootNode->mParent = nullptr;
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
if (nodes_in != nodes_out) {
|
||||
ASSIMP_LOG_INFO_F("OptimizeGraphProcess finished; Input nodes: ", nodes_in, ", Output nodes: ", nodes_out);
|
||||
|
@ -338,8 +346,7 @@ void OptimizeGraphProcess::Execute( aiScene* pScene) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build a LUT of all instanced meshes
|
||||
void OptimizeGraphProcess::FindInstancedMeshes (aiNode* pNode)
|
||||
{
|
||||
void OptimizeGraphProcess::FindInstancedMeshes(aiNode *pNode) {
|
||||
for (unsigned int i = 0; i < pNode->mNumMeshes; ++i) {
|
||||
++meshes[pNode->mMeshes[i]];
|
||||
}
|
||||
|
|
|
@ -75,13 +75,13 @@ public:
|
|||
~OptimizeGraphProcess();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
bool IsActive( unsigned int pFlags) const;
|
||||
bool IsActive( unsigned int pFlags) const override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void Execute( aiScene* pScene);
|
||||
void Execute( aiScene* pScene) override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void SetupProperties(const Importer* pImp);
|
||||
void SetupProperties(const Importer* pImp) override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Add a list of node names to be locked and not modified.
|
||||
|
|
|
@ -45,11 +45,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* @brief Implementation of the "PretransformVertices" post processing step
|
||||
*/
|
||||
|
||||
|
||||
#include "PretransformVertices.h"
|
||||
#include "ConvertToLHProcess.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include <assimp/SceneCombiner.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/SceneCombiner.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -59,12 +59,12 @@ using namespace Assimp;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
PretransformVertices::PretransformVertices()
|
||||
: configKeepHierarchy (false)
|
||||
, configNormalize(false)
|
||||
, configTransform(false)
|
||||
, configTransformation()
|
||||
, mConfigPointCloud( false ) {
|
||||
PretransformVertices::PretransformVertices() :
|
||||
configKeepHierarchy(false),
|
||||
configNormalize(false),
|
||||
configTransform(false),
|
||||
configTransformation(),
|
||||
mConfigPointCloud(false) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -76,15 +76,13 @@ PretransformVertices::~PretransformVertices() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
bool PretransformVertices::IsActive( unsigned int pFlags) const
|
||||
{
|
||||
bool PretransformVertices::IsActive(unsigned int pFlags) const {
|
||||
return (pFlags & aiProcess_PreTransformVertices) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup import configuration
|
||||
void PretransformVertices::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
void PretransformVertices::SetupProperties(const Importer *pImp) {
|
||||
// Get the current value of AI_CONFIG_PP_PTV_KEEP_HIERARCHY, AI_CONFIG_PP_PTV_NORMALIZE,
|
||||
// AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION and AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION
|
||||
configKeepHierarchy = (0 != pImp->GetPropertyInteger(AI_CONFIG_PP_PTV_KEEP_HIERARCHY, 0));
|
||||
|
@ -98,11 +96,9 @@ void PretransformVertices::SetupProperties(const Importer* pImp)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Count the number of nodes
|
||||
unsigned int PretransformVertices::CountNodes( aiNode* pcNode )
|
||||
{
|
||||
unsigned int PretransformVertices::CountNodes(const aiNode *pcNode) const {
|
||||
unsigned int iRet = 1;
|
||||
for (unsigned int i = 0;i < pcNode->mNumChildren;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcNode->mNumChildren; ++i) {
|
||||
iRet += CountNodes(pcNode->mChildren[i]);
|
||||
}
|
||||
return iRet;
|
||||
|
@ -110,8 +106,7 @@ unsigned int PretransformVertices::CountNodes( aiNode* pcNode )
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a bitwise combination identifying the vertex format of a mesh
|
||||
unsigned int PretransformVertices::GetMeshVFormat( aiMesh* pcMesh )
|
||||
{
|
||||
unsigned int PretransformVertices::GetMeshVFormat(aiMesh *pcMesh) const {
|
||||
// the vertex format is stored in aiMesh::mBones for later retrieval.
|
||||
// there isn't a good reason to compute it a few hundred times
|
||||
// from scratch. The pointer is unused as animations are lost
|
||||
|
@ -119,7 +114,6 @@ unsigned int PretransformVertices::GetMeshVFormat( aiMesh* pcMesh )
|
|||
if (pcMesh->mBones)
|
||||
return (unsigned int)(uint64_t)pcMesh->mBones;
|
||||
|
||||
|
||||
const unsigned int iRet = GetMeshVFormatUnique(pcMesh);
|
||||
|
||||
// store the value for later use
|
||||
|
@ -130,20 +124,16 @@ unsigned int PretransformVertices::GetMeshVFormat( aiMesh* pcMesh )
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Count the number of vertices in the whole scene and a given
|
||||
// material index
|
||||
void PretransformVertices::CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNode, unsigned int iMat,
|
||||
unsigned int iVFormat, unsigned int* piFaces, unsigned int* piVertices)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcNode->mNumMeshes;++i)
|
||||
{
|
||||
void PretransformVertices::CountVerticesAndFaces(const aiScene *pcScene, const aiNode *pcNode, unsigned int iMat,
|
||||
unsigned int iVFormat, unsigned int *piFaces, unsigned int *piVertices) const {
|
||||
for (unsigned int i = 0; i < pcNode->mNumMeshes; ++i) {
|
||||
aiMesh *pcMesh = pcScene->mMeshes[pcNode->mMeshes[i]];
|
||||
if (iMat == pcMesh->mMaterialIndex && iVFormat == GetMeshVFormat(pcMesh))
|
||||
{
|
||||
if (iMat == pcMesh->mMaterialIndex && iVFormat == GetMeshVFormat(pcMesh)) {
|
||||
*piVertices += pcMesh->mNumVertices;
|
||||
*piFaces += pcMesh->mNumFaces;
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0;i < pcNode->mNumChildren;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcNode->mNumChildren; ++i) {
|
||||
CountVerticesAndFaces(pcScene, pcNode->mChildren[i], iMat,
|
||||
iVFormat, piFaces, piVertices);
|
||||
}
|
||||
|
@ -151,24 +141,20 @@ void PretransformVertices::CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNo
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Collect vertex/face data
|
||||
void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsigned int iMat,
|
||||
void PretransformVertices::CollectData(const aiScene *pcScene, const aiNode *pcNode, unsigned int iMat,
|
||||
unsigned int iVFormat, aiMesh *pcMeshOut,
|
||||
unsigned int aiCurrent[2], unsigned int* num_refs)
|
||||
{
|
||||
unsigned int aiCurrent[2], unsigned int *num_refs) const {
|
||||
// No need to multiply if there's no transformation
|
||||
const bool identity = pcNode->mTransformation.IsIdentity();
|
||||
for (unsigned int i = 0; i < pcNode->mNumMeshes;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcNode->mNumMeshes; ++i) {
|
||||
aiMesh *pcMesh = pcScene->mMeshes[pcNode->mMeshes[i]];
|
||||
if (iMat == pcMesh->mMaterialIndex && iVFormat == GetMeshVFormat(pcMesh))
|
||||
{
|
||||
if (iMat == pcMesh->mMaterialIndex && iVFormat == GetMeshVFormat(pcMesh)) {
|
||||
// Decrement mesh reference counter
|
||||
unsigned int &num_ref = num_refs[pcNode->mMeshes[i]];
|
||||
ai_assert(0 != num_ref);
|
||||
--num_ref;
|
||||
// Save the name of the last mesh
|
||||
if (num_ref==0)
|
||||
{
|
||||
if (num_ref == 0) {
|
||||
pcMeshOut->mName = pcMesh->mName;
|
||||
}
|
||||
|
||||
|
@ -184,8 +170,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
pcMesh->mNormals,
|
||||
pcMesh->mNumVertices * sizeof(aiVector3D));
|
||||
}
|
||||
if (iVFormat & 0x4)
|
||||
{
|
||||
if (iVFormat & 0x4) {
|
||||
// copy tangents without modifying them
|
||||
::memcpy(pcMeshOut->mTangents + aiCurrent[AI_PTVS_VERTEX],
|
||||
pcMesh->mTangents,
|
||||
|
@ -195,9 +180,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
pcMesh->mBitangents,
|
||||
pcMesh->mNumVertices * sizeof(aiVector3D));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// copy positions, transform them to worldspace
|
||||
for (unsigned int n = 0; n < pcMesh->mNumVertices; ++n) {
|
||||
pcMeshOut->mVertices[aiCurrent[AI_PTVS_VERTEX] + n] = pcNode->mTransformation * pcMesh->mVertices[n];
|
||||
|
@ -208,16 +191,14 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
// TODO: implement Inverse() for aiMatrix3x3
|
||||
aiMatrix3x3 m = aiMatrix3x3(mWorldIT);
|
||||
|
||||
if (iVFormat & 0x2)
|
||||
{
|
||||
if (iVFormat & 0x2) {
|
||||
// copy normals, transform them to worldspace
|
||||
for (unsigned int n = 0; n < pcMesh->mNumVertices; ++n) {
|
||||
pcMeshOut->mNormals[aiCurrent[AI_PTVS_VERTEX] + n] =
|
||||
(m * pcMesh->mNormals[n]).Normalize();
|
||||
}
|
||||
}
|
||||
if (iVFormat & 0x4)
|
||||
{
|
||||
if (iVFormat & 0x4) {
|
||||
// copy tangents and bitangents, transform them to worldspace
|
||||
for (unsigned int n = 0; n < pcMesh->mNumVertices; ++n) {
|
||||
pcMeshOut->mTangents[aiCurrent[AI_PTVS_VERTEX] + n] = (m * pcMesh->mTangents[n]).Normalize();
|
||||
|
@ -226,8 +207,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
}
|
||||
}
|
||||
unsigned int p = 0;
|
||||
while (iVFormat & (0x100 << p))
|
||||
{
|
||||
while (iVFormat & (0x100 << p)) {
|
||||
// copy texture coordinates
|
||||
memcpy(pcMeshOut->mTextureCoords[p] + aiCurrent[AI_PTVS_VERTEX],
|
||||
pcMesh->mTextureCoords[p],
|
||||
|
@ -235,8 +215,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
++p;
|
||||
}
|
||||
p = 0;
|
||||
while (iVFormat & (0x1000000 << p))
|
||||
{
|
||||
while (iVFormat & (0x1000000 << p)) {
|
||||
// copy vertex colors
|
||||
memcpy(pcMeshOut->mColors[p] + aiCurrent[AI_PTVS_VERTEX],
|
||||
pcMesh->mColors[p],
|
||||
|
@ -246,8 +225,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
// now we need to copy all faces. since we will delete the source mesh afterwards,
|
||||
// we don't need to reallocate the array of indices except if this mesh is
|
||||
// referenced multiple times.
|
||||
for (unsigned int planck = 0;planck < pcMesh->mNumFaces;++planck)
|
||||
{
|
||||
for (unsigned int planck = 0; planck < pcMesh->mNumFaces; ++planck) {
|
||||
aiFace &f_src = pcMesh->mFaces[planck];
|
||||
aiFace &f_dst = pcMeshOut->mFaces[aiCurrent[AI_PTVS_FACE] + planck];
|
||||
|
||||
|
@ -263,8 +241,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
for (unsigned int hahn = 0; hahn < num_idx; ++hahn) {
|
||||
pi[hahn] += aiCurrent[AI_PTVS_VERTEX];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pi = f_dst.mIndices = new unsigned int[num_idx];
|
||||
|
||||
// copy and offset all vertex indices
|
||||
|
@ -274,8 +251,7 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
}
|
||||
|
||||
// Update the mPrimitiveTypes member of the mesh
|
||||
switch (pcMesh->mFaces[planck].mNumIndices)
|
||||
{
|
||||
switch (pcMesh->mFaces[planck].mNumIndices) {
|
||||
case 0x1:
|
||||
pcMeshOut->mPrimitiveTypes |= aiPrimitiveType_POINT;
|
||||
break;
|
||||
|
@ -305,11 +281,9 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a list of all vertex formats that occur for a given material index
|
||||
// The output list contains duplicate elements
|
||||
void PretransformVertices::GetVFormatList( aiScene* pcScene, unsigned int iMat,
|
||||
std::list<unsigned int>& aiOut)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
void PretransformVertices::GetVFormatList(const aiScene *pcScene, unsigned int iMat,
|
||||
std::list<unsigned int> &aiOut) const {
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes; ++i) {
|
||||
aiMesh *pcMesh = pcScene->mMeshes[i];
|
||||
if (iMat == pcMesh->mMaterialIndex) {
|
||||
aiOut.push_back(GetMeshVFormat(pcMesh));
|
||||
|
@ -319,8 +293,7 @@ void PretransformVertices::GetVFormatList( aiScene* pcScene, unsigned int iMat,
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Compute the absolute transformation matrices of each node
|
||||
void PretransformVertices::ComputeAbsoluteTransform( aiNode* pcNode )
|
||||
{
|
||||
void PretransformVertices::ComputeAbsoluteTransform(aiNode *pcNode) {
|
||||
if (pcNode->mParent) {
|
||||
pcNode->mTransformation = pcNode->mParent->mTransformation * pcNode->mTransformation;
|
||||
}
|
||||
|
@ -332,22 +305,26 @@ void PretransformVertices::ComputeAbsoluteTransform( aiNode* pcNode )
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Apply the node transformation to a mesh
|
||||
void PretransformVertices::ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)
|
||||
{
|
||||
void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const {
|
||||
// Check whether we need to transform the coordinates at all
|
||||
if (!mat.IsIdentity()) {
|
||||
|
||||
// Check for odd negative scale (mirror)
|
||||
if (mesh->HasFaces() && mat.Determinant() < 0) {
|
||||
// Reverse the mesh face winding order
|
||||
FlipWindingOrderProcess::ProcessMesh(mesh);
|
||||
}
|
||||
|
||||
// Update positions
|
||||
if (mesh->HasPositions()) {
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||
mesh->mVertices[i] = mat * mesh->mVertices[i];
|
||||
}
|
||||
}
|
||||
if (mesh->HasNormals() || mesh->HasTangentsAndBitangents()) {
|
||||
aiMatrix4x4 mWorldIT = mat;
|
||||
mWorldIT.Inverse().Transpose();
|
||||
|
||||
// TODO: implement Inverse() for aiMatrix3x3
|
||||
aiMatrix3x3 m = aiMatrix3x3(mWorldIT);
|
||||
// Update normals and tangents
|
||||
if (mesh->HasNormals() || mesh->HasTangentsAndBitangents()) {
|
||||
const aiMatrix3x3 m = aiMatrix3x3(mat).Inverse().Transpose();
|
||||
|
||||
if (mesh->HasNormals()) {
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||
|
@ -367,8 +344,7 @@ void PretransformVertices::ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Simple routine to build meshes in worldspace, no further optimization
|
||||
void PretransformVertices::BuildWCSMeshes(std::vector<aiMesh *> &out, aiMesh **in,
|
||||
unsigned int numIn, aiNode* node)
|
||||
{
|
||||
unsigned int numIn, aiNode *node) const {
|
||||
// NOTE:
|
||||
// aiMesh::mNumBones store original source mesh, or UINT_MAX if not a copy
|
||||
// aiMesh::mBones store reference to abs. transform we multiplied with
|
||||
|
@ -382,8 +358,7 @@ void PretransformVertices::BuildWCSMeshes(std::vector<aiMesh*>& out, aiMesh** in
|
|||
// yes, we can.
|
||||
mesh->mBones = reinterpret_cast<aiBone **>(&node->mTransformation);
|
||||
mesh->mNumBones = UINT_MAX;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// try to find us in the list of newly created meshes
|
||||
for (unsigned int n = 0; n < out.size(); ++n) {
|
||||
|
@ -421,8 +396,7 @@ void PretransformVertices::BuildWCSMeshes(std::vector<aiMesh*>& out, aiMesh** in
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reset transformation matrices to identity
|
||||
void PretransformVertices::MakeIdentityTransform(aiNode* nd)
|
||||
{
|
||||
void PretransformVertices::MakeIdentityTransform(aiNode *nd) const {
|
||||
nd->mTransformation = aiMatrix4x4();
|
||||
|
||||
// call children
|
||||
|
@ -432,8 +406,7 @@ void PretransformVertices::MakeIdentityTransform(aiNode* nd)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build reference counters for all meshes
|
||||
void PretransformVertices::BuildMeshRefCountArray(aiNode* nd, unsigned int * refs)
|
||||
{
|
||||
void PretransformVertices::BuildMeshRefCountArray(const aiNode *nd, unsigned int *refs) const {
|
||||
for (unsigned int i = 0; i < nd->mNumMeshes; ++i)
|
||||
refs[nd->mMeshes[i]]++;
|
||||
|
||||
|
@ -444,8 +417,7 @@ void PretransformVertices::BuildMeshRefCountArray(aiNode* nd, unsigned int * ref
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void PretransformVertices::Execute( aiScene* pScene)
|
||||
{
|
||||
void PretransformVertices::Execute(aiScene *pScene) {
|
||||
ASSIMP_LOG_DEBUG("PretransformVerticesProcess begin");
|
||||
|
||||
// Return immediately if we have no meshes
|
||||
|
@ -496,7 +468,8 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
memcpy(npp + pScene->mNumMeshes, &apcOutMeshes[0], sizeof(aiMesh *) * apcOutMeshes.size());
|
||||
|
||||
pScene->mNumMeshes += static_cast<unsigned int>(apcOutMeshes.size());
|
||||
delete[] pScene->mMeshes; pScene->mMeshes = npp;
|
||||
delete[] pScene->mMeshes;
|
||||
pScene->mMeshes = npp;
|
||||
}
|
||||
|
||||
// now iterate through all meshes and transform them to worldspace
|
||||
|
@ -524,8 +497,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
unsigned int iVertices = 0;
|
||||
unsigned int iFaces = 0;
|
||||
CountVerticesAndFaces(pScene, pScene->mRootNode, i, *j, &iFaces, &iVertices);
|
||||
if (0 != iFaces && 0 != iVertices)
|
||||
{
|
||||
if (0 != iFaces && 0 != iVertices) {
|
||||
apcOutMeshes.push_back(new aiMesh());
|
||||
aiMesh *pcMesh = apcOutMeshes.back();
|
||||
pcMesh->mNumFaces = iFaces;
|
||||
|
@ -534,17 +506,17 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
pcMesh->mVertices = new aiVector3D[iVertices];
|
||||
pcMesh->mMaterialIndex = i;
|
||||
if ((*j) & 0x2) pcMesh->mNormals = new aiVector3D[iVertices];
|
||||
if ((*j) & 0x4)
|
||||
{
|
||||
if ((*j) & 0x4) {
|
||||
pcMesh->mTangents = new aiVector3D[iVertices];
|
||||
pcMesh->mBitangents = new aiVector3D[iVertices];
|
||||
}
|
||||
iFaces = 0;
|
||||
while ((*j) & (0x100 << iFaces))
|
||||
{
|
||||
while ((*j) & (0x100 << iFaces)) {
|
||||
pcMesh->mTextureCoords[iFaces] = new aiVector3D[iVertices];
|
||||
if ((*j) & (0x10000 << iFaces))pcMesh->mNumUVComponents[iFaces] = 3;
|
||||
else pcMesh->mNumUVComponents[iFaces] = 2;
|
||||
if ((*j) & (0x10000 << iFaces))
|
||||
pcMesh->mNumUVComponents[iFaces] = 3;
|
||||
else
|
||||
pcMesh->mNumUVComponents[iFaces] = 2;
|
||||
iFaces++;
|
||||
}
|
||||
iFaces = 0;
|
||||
|
@ -562,12 +534,9 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
if (apcOutMeshes.empty()) {
|
||||
|
||||
throw DeadlyImportError("No output meshes: all meshes are orphaned and are not referenced by any nodes");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// now delete all meshes in the scene and build a new mesh list
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||
aiMesh *mesh = pScene->mMeshes[i];
|
||||
mesh->mNumBones = 0;
|
||||
mesh->mBones = NULL;
|
||||
|
@ -606,8 +575,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
pScene->mNumAnimations = 0;
|
||||
|
||||
// --- we need to keep all cameras and lights
|
||||
for (unsigned int i = 0; i < pScene->mNumCameras;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumCameras; ++i) {
|
||||
aiCamera *cam = pScene->mCameras[i];
|
||||
const aiNode *nd = pScene->mRootNode->FindNode(cam->mName);
|
||||
ai_assert(NULL != nd);
|
||||
|
@ -619,8 +587,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
cam->mUp = aiMatrix3x3(nd->mTransformation) * cam->mUp;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < pScene->mNumLights;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumLights; ++i) {
|
||||
aiLight *l = pScene->mLights[i];
|
||||
const aiNode *nd = pScene->mRootNode->FindNode(l->mName);
|
||||
ai_assert(NULL != nd);
|
||||
|
@ -641,20 +608,16 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
delete pScene->mRootNode;
|
||||
pScene->mRootNode = newRoot;
|
||||
|
||||
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras)
|
||||
{
|
||||
if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras) {
|
||||
pScene->mRootNode->mNumMeshes = 1;
|
||||
pScene->mRootNode->mMeshes = new unsigned int[1];
|
||||
pScene->mRootNode->mMeshes[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pScene->mRootNode->mNumChildren = pScene->mNumMeshes + pScene->mNumLights + pScene->mNumCameras;
|
||||
aiNode **nodes = pScene->mRootNode->mChildren = new aiNode *[pScene->mRootNode->mNumChildren];
|
||||
|
||||
// generate mesh nodes
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i,++nodes)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i, ++nodes) {
|
||||
aiNode *pcNode = new aiNode();
|
||||
*nodes = pcNode;
|
||||
pcNode->mParent = pScene->mRootNode;
|
||||
|
@ -666,8 +629,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
pcNode->mMeshes[0] = i;
|
||||
}
|
||||
// generate light nodes
|
||||
for (unsigned int i = 0; i < pScene->mNumLights;++i,++nodes)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumLights; ++i, ++nodes) {
|
||||
aiNode *pcNode = new aiNode();
|
||||
*nodes = pcNode;
|
||||
pcNode->mParent = pScene->mRootNode;
|
||||
|
@ -675,8 +637,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
pScene->mLights[i]->mName = pcNode->mName;
|
||||
}
|
||||
// generate camera nodes
|
||||
for (unsigned int i = 0; i < pScene->mNumCameras;++i,++nodes)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumCameras; ++i, ++nodes) {
|
||||
aiNode *pcNode = new aiNode();
|
||||
*nodes = pcNode;
|
||||
pcNode->mParent = pScene->mRootNode;
|
||||
|
@ -684,8 +645,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
pScene->mCameras[i]->mName = pcNode->mName;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// ... and finally set the transformation matrix of all nodes to identity
|
||||
MakeIdentityTransform(pScene->mRootNode);
|
||||
}
|
||||
|
|
|
@ -73,15 +73,15 @@ public:
|
|||
|
||||
// -------------------------------------------------------------------
|
||||
// Check whether step is active
|
||||
bool IsActive( unsigned int pFlags) const;
|
||||
bool IsActive(unsigned int pFlags) const override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Execute step on a given scene
|
||||
void Execute( aiScene* pScene);
|
||||
void Execute(aiScene *pScene) override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Setup import settings
|
||||
void SetupProperties(const Importer* pImp);
|
||||
void SetupProperties(const Importer *pImp) override;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Toggle the 'keep hierarchy' option
|
||||
|
@ -102,35 +102,35 @@ public:
|
|||
private:
|
||||
// -------------------------------------------------------------------
|
||||
// Count the number of nodes
|
||||
unsigned int CountNodes( aiNode* pcNode );
|
||||
unsigned int CountNodes(const aiNode *pcNode) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get a bitwise combination identifying the vertex format of a mesh
|
||||
unsigned int GetMeshVFormat(aiMesh* pcMesh);
|
||||
unsigned int GetMeshVFormat(aiMesh *pcMesh) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Count the number of vertices in the whole scene and a given
|
||||
// material index
|
||||
void CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNode,
|
||||
void CountVerticesAndFaces(const aiScene *pcScene, const aiNode *pcNode,
|
||||
unsigned int iMat,
|
||||
unsigned int iVFormat,
|
||||
unsigned int *piFaces,
|
||||
unsigned int* piVertices);
|
||||
unsigned int *piVertices) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Collect vertex/face data
|
||||
void CollectData( aiScene* pcScene, aiNode* pcNode,
|
||||
void CollectData(const aiScene *pcScene, const aiNode *pcNode,
|
||||
unsigned int iMat,
|
||||
unsigned int iVFormat,
|
||||
aiMesh *pcMeshOut,
|
||||
unsigned int aiCurrent[2],
|
||||
unsigned int* num_refs);
|
||||
unsigned int *num_refs) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get a list of all vertex formats that occur for a given material
|
||||
// The output list contains duplicate elements
|
||||
void GetVFormatList( aiScene* pcScene, unsigned int iMat,
|
||||
std::list<unsigned int>& aiOut);
|
||||
void GetVFormatList(const aiScene *pcScene, unsigned int iMat,
|
||||
std::list<unsigned int> &aiOut) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Compute the absolute transformation matrices of each node
|
||||
|
@ -139,19 +139,19 @@ private:
|
|||
// -------------------------------------------------------------------
|
||||
// Simple routine to build meshes in worldspace, no further optimization
|
||||
void BuildWCSMeshes(std::vector<aiMesh *> &out, aiMesh **in,
|
||||
unsigned int numIn, aiNode* node);
|
||||
unsigned int numIn, aiNode *node) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Apply the node transformation to a mesh
|
||||
void ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat);
|
||||
void ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Reset transformation matrices to identity
|
||||
void MakeIdentityTransform(aiNode* nd);
|
||||
void MakeIdentityTransform(aiNode *nd) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Build reference counters for all meshes
|
||||
void BuildMeshRefCountArray(aiNode* nd, unsigned int * refs);
|
||||
void BuildMeshRefCountArray(const aiNode *nd, unsigned int *refs) const;
|
||||
|
||||
//! Configuration option: keep scene hierarchy as long as possible
|
||||
bool configKeepHierarchy;
|
||||
|
|
|
@ -202,6 +202,7 @@ inline void SetMaterialTextureProperty(std::vector<int> &embeddedTexIdxs, Asset
|
|||
}
|
||||
|
||||
mat->AddProperty(&uri, AI_MATKEY_TEXTURE(texType, texSlot));
|
||||
mat->AddProperty(&prop.texCoord, 1, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(texType, texSlot));
|
||||
|
||||
if (prop.textureTransformSupported) {
|
||||
aiUVTransform transform;
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,172 @@
|
|||
{
|
||||
"asset" : {
|
||||
"generator" : "Khronos glTF Blender I/O v1.0.5",
|
||||
"version" : "2.0"
|
||||
},
|
||||
"scene" : 0,
|
||||
"scenes" : [
|
||||
{
|
||||
"name" : "Scene",
|
||||
"nodes" : [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes" : [
|
||||
{
|
||||
"mesh" : 0,
|
||||
"name" : "Cube"
|
||||
},
|
||||
{
|
||||
"name" : "Light",
|
||||
"rotation" : [
|
||||
0.16907575726509094,
|
||||
0.7558803558349609,
|
||||
-0.27217137813568115,
|
||||
0.570947527885437
|
||||
],
|
||||
"translation" : [
|
||||
4.076245307922363,
|
||||
5.903861999511719,
|
||||
-1.0054539442062378
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "Camera",
|
||||
"rotation" : [
|
||||
0.483536034822464,
|
||||
0.33687159419059753,
|
||||
-0.20870360732078552,
|
||||
0.7804827094078064
|
||||
],
|
||||
"translation" : [
|
||||
7.358891487121582,
|
||||
4.958309173583984,
|
||||
6.925790786743164
|
||||
]
|
||||
}
|
||||
],
|
||||
"materials" : [
|
||||
{
|
||||
"doubleSided" : true,
|
||||
"name" : "Material",
|
||||
"pbrMetallicRoughness" : {
|
||||
"baseColorTexture" : {
|
||||
"index" : 0,
|
||||
"texCoord" : 0
|
||||
},
|
||||
"metallicFactor" : 0,
|
||||
"metallicRoughnessTexture" : {
|
||||
"index" : 0,
|
||||
"texCoord" : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"meshes" : [
|
||||
{
|
||||
"name" : "Cube",
|
||||
"primitives" : [
|
||||
{
|
||||
"attributes" : {
|
||||
"POSITION" : 0,
|
||||
"NORMAL" : 1,
|
||||
"TEXCOORD_0" : 2,
|
||||
"TEXCOORD_1" : 3
|
||||
},
|
||||
"indices" : 4,
|
||||
"material" : 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"textures" : [
|
||||
{
|
||||
"source" : 0
|
||||
}
|
||||
],
|
||||
"images" : [
|
||||
{
|
||||
"mimeType" : "image/png",
|
||||
"name" : "Material Base Color",
|
||||
"uri" : "texture.png"
|
||||
}
|
||||
],
|
||||
"accessors" : [
|
||||
{
|
||||
"bufferView" : 0,
|
||||
"componentType" : 5126,
|
||||
"count" : 24,
|
||||
"max" : [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"min" : [
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
],
|
||||
"type" : "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView" : 1,
|
||||
"componentType" : 5126,
|
||||
"count" : 24,
|
||||
"type" : "VEC3"
|
||||
},
|
||||
{
|
||||
"bufferView" : 2,
|
||||
"componentType" : 5126,
|
||||
"count" : 24,
|
||||
"type" : "VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView" : 3,
|
||||
"componentType" : 5126,
|
||||
"count" : 24,
|
||||
"type" : "VEC2"
|
||||
},
|
||||
{
|
||||
"bufferView" : 4,
|
||||
"componentType" : 5123,
|
||||
"count" : 36,
|
||||
"type" : "SCALAR"
|
||||
}
|
||||
],
|
||||
"bufferViews" : [
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 288,
|
||||
"byteOffset" : 0
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 288,
|
||||
"byteOffset" : 288
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 192,
|
||||
"byteOffset" : 576
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 192,
|
||||
"byteOffset" : 768
|
||||
},
|
||||
{
|
||||
"buffer" : 0,
|
||||
"byteLength" : 72,
|
||||
"byteOffset" : 960
|
||||
}
|
||||
],
|
||||
"buffers" : [
|
||||
{
|
||||
"byteLength" : 1032,
|
||||
"uri" : "boxTexcoords.bin"
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
|
@ -49,6 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <array>
|
||||
|
||||
#include <assimp/pbrmaterial.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
class utglTF2ImportExport : public AbstractImportExportBase {
|
||||
|
@ -464,3 +466,30 @@ TEST_F(utglTF2ImportExport, sceneMetadata) {
|
|||
ASSERT_EQ(strcmp(generator.C_Str(), "COLLADA2GLTF"), 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(utglTF2ImportExport, texcoords) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTexcoords-glTF/boxTexcoords.gltf",
|
||||
aiProcess_ValidateDataStructure);
|
||||
ASSERT_NE(scene, nullptr);
|
||||
|
||||
ASSERT_TRUE(scene->HasMaterials());
|
||||
const aiMaterial *material = scene->mMaterials[0];
|
||||
|
||||
aiString path;
|
||||
aiTextureMapMode modes[2];
|
||||
EXPECT_EQ(aiReturn_SUCCESS, material->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr,
|
||||
nullptr, nullptr, modes));
|
||||
EXPECT_STREQ(path.C_Str(), "texture.png");
|
||||
|
||||
int uvIndex = -1;
|
||||
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_DIFFUSE, 0), &uvIndex), aiReturn_SUCCESS);
|
||||
EXPECT_EQ(uvIndex, 0);
|
||||
|
||||
// Using manual macro expansion of AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE here.
|
||||
// The following works with some but not all compilers:
|
||||
// #define APPLY(X, Y) X(Y)
|
||||
// ..., APPLY(AI_MATKEY_GLTF_TEXTURE_TEXCOORD, AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE), ...
|
||||
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
|
||||
EXPECT_EQ(uvIndex, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue