Merge branch 'master' into issue_2182
commit
a01302dd4d
|
@ -331,7 +331,7 @@ ADD_ASSIMP_EXPORTER( ASSBIN
|
||||||
Assbin/AssbinExporter.cpp
|
Assbin/AssbinExporter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_ASSIMP_IMPORTER( ASSXML
|
ADD_ASSIMP_EXPORTER( ASSXML
|
||||||
Assxml/AssxmlExporter.h
|
Assxml/AssxmlExporter.h
|
||||||
Assxml/AssxmlExporter.cpp
|
Assxml/AssxmlExporter.cpp
|
||||||
)
|
)
|
||||||
|
|
|
@ -99,7 +99,7 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co
|
||||||
, mFile(file) {
|
, mFile(file) {
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
mOutput.imbue( std::locale("C") );
|
mOutput.imbue( std::locale("C") );
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
mScene = pScene;
|
mScene = pScene;
|
||||||
mSceneOwned = false;
|
mSceneOwned = false;
|
||||||
|
|
|
@ -323,10 +323,8 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
||||||
aiString aistr;
|
aiString aistr;
|
||||||
aistr.Set(value_char);
|
aistr.Set(value_char);
|
||||||
metadata.emplace(camel_key_str, aistr);
|
metadata.emplace(camel_key_str, aistr);
|
||||||
TestClosing(key_str.c_str());
|
|
||||||
}
|
}
|
||||||
else
|
TestClosing(key_str.c_str());
|
||||||
SkipElement();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SkipElement();
|
SkipElement();
|
||||||
|
|
|
@ -590,10 +590,12 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||||
|
|
||||||
// Find an worker class which can handle the file
|
// Find an worker class which can handle the file
|
||||||
BaseImporter* imp = NULL;
|
BaseImporter* imp = NULL;
|
||||||
|
SetPropertyInteger("importerIndex", -1);
|
||||||
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
|
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
|
||||||
|
|
||||||
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, false)) {
|
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, false)) {
|
||||||
imp = pimpl->mImporter[a];
|
imp = pimpl->mImporter[a];
|
||||||
|
SetPropertyInteger("importerIndex", a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,6 +608,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
||||||
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
|
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
|
||||||
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) {
|
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) {
|
||||||
imp = pimpl->mImporter[a];
|
imp = pimpl->mImporter[a];
|
||||||
|
SetPropertyInteger("importerIndex", a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1255,7 +1255,7 @@ namespace Assimp {
|
||||||
|
|
||||||
// mapping from output indices to DOM indexing, needed to resolve weights
|
// mapping from output indices to DOM indexing, needed to resolve weights
|
||||||
std::vector<unsigned int> reverseMapping;
|
std::vector<unsigned int> reverseMapping;
|
||||||
|
std::map<unsigned int, unsigned int> translateIndexMap;
|
||||||
if (process_weights) {
|
if (process_weights) {
|
||||||
reverseMapping.resize(count_vertices);
|
reverseMapping.resize(count_vertices);
|
||||||
}
|
}
|
||||||
|
@ -1363,6 +1363,7 @@ namespace Assimp {
|
||||||
|
|
||||||
if (reverseMapping.size()) {
|
if (reverseMapping.size()) {
|
||||||
reverseMapping[cursor] = in_cursor;
|
reverseMapping[cursor] = in_cursor;
|
||||||
|
translateIndexMap[in_cursor] = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_mesh->mVertices[cursor] = vertices[in_cursor];
|
out_mesh->mVertices[cursor] = vertices[in_cursor];
|
||||||
|
@ -1394,6 +1395,39 @@ namespace Assimp {
|
||||||
ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
|
ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<aiAnimMesh*> animMeshes;
|
||||||
|
for (const BlendShape* blendShape : mesh.GetBlendShapes()) {
|
||||||
|
for (const BlendShapeChannel* blendShapeChannel : blendShape->BlendShapeChannels()) {
|
||||||
|
const std::vector<const ShapeGeometry*>& shapeGeometries = blendShapeChannel->GetShapeGeometries();
|
||||||
|
for (size_t i = 0; i < shapeGeometries.size(); i++) {
|
||||||
|
aiAnimMesh* animMesh = aiCreateAnimMesh(out_mesh);
|
||||||
|
const ShapeGeometry* shapeGeometry = shapeGeometries.at(i);
|
||||||
|
const std::vector<aiVector3D>& vertices = shapeGeometry->GetVertices();
|
||||||
|
const std::vector<aiVector3D>& normals = shapeGeometry->GetNormals();
|
||||||
|
const std::vector<unsigned int>& indices = shapeGeometry->GetIndices();
|
||||||
|
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
|
||||||
|
for (size_t j = 0; j < indices.size(); j++) {
|
||||||
|
unsigned int index = indices.at(j);
|
||||||
|
aiVector3D vertex = vertices.at(j);
|
||||||
|
aiVector3D normal = normals.at(j);
|
||||||
|
unsigned int count = 0;
|
||||||
|
const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count);
|
||||||
|
for (unsigned int k = 0; k < count; k++) {
|
||||||
|
unsigned int index = translateIndexMap[outIndices[k]];
|
||||||
|
|
||||||
|
animMesh->mVertices[index] += vertex;
|
||||||
|
if (animMesh->mNormals != nullptr) {
|
||||||
|
animMesh->mNormals[index] += normal;
|
||||||
|
animMesh->mNormals[index].NormalizeSafe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
animMesh->mWeight = shapeGeometries.size() > 1 ? blendShapeChannel->DeformPercent() / 100.0f : 1.0f;
|
||||||
|
animMeshes.push_back(animMesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return static_cast<unsigned int>(meshes.size() - 1);
|
return static_cast<unsigned int>(meshes.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,7 +1676,7 @@ namespace Assimp {
|
||||||
out_tex->pcData = reinterpret_cast<aiTexel*>(const_cast<Video&>(video).RelinquishContent());
|
out_tex->pcData = reinterpret_cast<aiTexel*>(const_cast<Video&>(video).RelinquishContent());
|
||||||
|
|
||||||
// try to extract a hint from the file extension
|
// try to extract a hint from the file extension
|
||||||
const std::string& filename = video.FileName().empty() ? video.RelativeFilename() : video.FileName();
|
const std::string& filename = video.RelativeFilename().empty() ? video.FileName() : video.RelativeFilename();
|
||||||
std::string ext = BaseImporter::GetExtension(filename);
|
std::string ext = BaseImporter::GetExtension(filename);
|
||||||
|
|
||||||
if (ext == "jpeg") {
|
if (ext == "jpeg") {
|
||||||
|
@ -1653,7 +1687,7 @@ namespace Assimp {
|
||||||
memcpy(out_tex->achFormatHint, ext.c_str(), ext.size());
|
memcpy(out_tex->achFormatHint, ext.c_str(), ext.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
out_tex->mFilename.Set(video.FileName().c_str());
|
out_tex->mFilename.Set(filename.c_str());
|
||||||
|
|
||||||
return static_cast<unsigned int>(textures.size() - 1);
|
return static_cast<unsigned int>(textures.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1328,6 +1328,7 @@ void LWOImporter::LoadLWO2File()
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
|
|
||||||
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
|
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
|
||||||
|
unsigned int iUnnamed = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
|
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
|
||||||
|
@ -1339,7 +1340,6 @@ void LWOImporter::LoadLWO2File()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint8_t* const next = mFileBuffer+head.length;
|
uint8_t* const next = mFileBuffer+head.length;
|
||||||
unsigned int iUnnamed = 0;
|
|
||||||
|
|
||||||
if(!head.length) {
|
if(!head.length) {
|
||||||
mFileBuffer = next;
|
mFileBuffer = next;
|
||||||
|
|
|
@ -126,9 +126,9 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
const std::locale& l = std::locale("C");
|
const std::locale& l = std::locale("C");
|
||||||
mOutput.imbue(l);
|
mOutput.imbue(l);
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
mOutputMat.imbue(l);
|
mOutputMat.imbue(l);
|
||||||
mOutputMat.precision(16);
|
mOutputMat.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
WriteGeometryFile(noMtl);
|
WriteGeometryFile(noMtl);
|
||||||
if ( !noMtl ) {
|
if ( !noMtl ) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
const std::locale& l = std::locale("C");
|
const std::locale& l = std::locale("C");
|
||||||
mOutput.imbue(l);
|
mOutput.imbue(l);
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
unsigned int faces = 0u, vertices = 0u, components = 0u;
|
unsigned int faces = 0u, vertices = 0u, components = 0u;
|
||||||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
const std::locale& l = std::locale("C");
|
const std::locale& l = std::locale("C");
|
||||||
mOutput.imbue(l);
|
mOutput.imbue(l);
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
if (binary) {
|
if (binary) {
|
||||||
char buf[80] = {0} ;
|
char buf[80] = {0} ;
|
||||||
buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p';
|
buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p';
|
||||||
|
|
|
@ -151,7 +151,7 @@ StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std
|
||||||
|
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
mOutput.imbue(std::locale("C"));
|
mOutput.imbue(std::locale("C"));
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
// start writing
|
// start writing
|
||||||
WriteFile();
|
WriteFile();
|
||||||
|
@ -166,7 +166,7 @@ void StepExporter::WriteFile()
|
||||||
mOutput.setf(std::ios::fixed);
|
mOutput.setf(std::ios::fixed);
|
||||||
// precision for double
|
// precision for double
|
||||||
// see http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout
|
// see http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
// standard color
|
// standard color
|
||||||
aiColor4D fColor;
|
aiColor4D fColor;
|
||||||
|
|
|
@ -113,7 +113,7 @@ XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const s
|
||||||
{
|
{
|
||||||
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
// make sure that all formatting happens using the standard, C locale and not the user's current locale
|
||||||
mOutput.imbue( std::locale("C") );
|
mOutput.imbue( std::locale("C") );
|
||||||
mOutput.precision(16);
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
|
||||||
|
|
||||||
// start writing
|
// start writing
|
||||||
WriteFile();
|
WriteFile();
|
||||||
|
@ -134,7 +134,7 @@ void XFileExporter::WriteFile()
|
||||||
{
|
{
|
||||||
// note, that all realnumber values must be comma separated in x files
|
// note, that all realnumber values must be comma separated in x files
|
||||||
mOutput.setf(std::ios::fixed);
|
mOutput.setf(std::ios::fixed);
|
||||||
mOutput.precision(16); // precision for double
|
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION); // precision for ai_real
|
||||||
|
|
||||||
// entry of writing the file
|
// entry of writing the file
|
||||||
WriteHeader();
|
WriteHeader();
|
||||||
|
|
|
@ -142,7 +142,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
/** @brief Specifies the maximum angle that may be between two vertex tangents
|
/** @brief Specifies the maximum angle that may be between two vertex tangents
|
||||||
* that their tangents and bi-tangents are smoothed.
|
* that their tangents and bi-tangents are smoothed.
|
||||||
*
|
*
|
||||||
* This applies to the CalcTangentSpace-Step. The angle is specified
|
* This applies to the CalcTangentSpace-Step. TFvhe angle is specified
|
||||||
* in degrees. The maximum value is 175.
|
* in degrees. The maximum value is 175.
|
||||||
* Property type: float. Default value: 45 degrees
|
* Property type: float. Default value: 45 degrees
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -241,10 +241,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
typedef double ai_real;
|
typedef double ai_real;
|
||||||
typedef signed long long int ai_int;
|
typedef signed long long int ai_int;
|
||||||
typedef unsigned long long int ai_uint;
|
typedef unsigned long long int ai_uint;
|
||||||
|
#ifndef ASSIMP_AI_REAL_TEXT_PRECISION
|
||||||
|
#define ASSIMP_AI_REAL_TEXT_PRECISION 16
|
||||||
|
#endif // ASSIMP_AI_REAL_TEXT_PRECISION
|
||||||
#else // ASSIMP_DOUBLE_PRECISION
|
#else // ASSIMP_DOUBLE_PRECISION
|
||||||
typedef float ai_real;
|
typedef float ai_real;
|
||||||
typedef signed int ai_int;
|
typedef signed int ai_int;
|
||||||
typedef unsigned int ai_uint;
|
typedef unsigned int ai_uint;
|
||||||
|
#ifndef ASSIMP_AI_REAL_TEXT_PRECISION
|
||||||
|
#define ASSIMP_AI_REAL_TEXT_PRECISION 8
|
||||||
|
#endif // ASSIMP_AI_REAL_TEXT_PRECISION
|
||||||
#endif // ASSIMP_DOUBLE_PRECISION
|
#endif // ASSIMP_DOUBLE_PRECISION
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -161,6 +161,13 @@ struct aiColor3D
|
||||||
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
||||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
||||||
|
|
||||||
|
aiColor3D &operator=(const aiColor3D &o) {
|
||||||
|
r = o.r;
|
||||||
|
g = o.g;
|
||||||
|
b = o.b;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Component-wise comparison */
|
/** Component-wise comparison */
|
||||||
// TODO: add epsilon?
|
// TODO: add epsilon?
|
||||||
bool operator == (const aiColor3D& other) const
|
bool operator == (const aiColor3D& other) const
|
||||||
|
|
|
@ -274,6 +274,8 @@ def hasattr_silent(object, name):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if not object:
|
||||||
|
return False
|
||||||
return hasattr(object, name)
|
return hasattr(object, name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -241,6 +241,7 @@ TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
|
||||||
aiString path;
|
aiString path;
|
||||||
aiTextureMapMode modes[2];
|
aiTextureMapMode modes[2];
|
||||||
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
|
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
|
||||||
|
ASSERT_STREQ(path.C_Str(), "..\\..\\..\\Desktop\\uv_test.png");
|
||||||
|
|
||||||
ASSERT_EQ(1, scene->mNumTextures);
|
ASSERT_EQ(1, scene->mNumTextures);
|
||||||
ASSERT_TRUE(scene->mTextures[0]->pcData);
|
ASSERT_TRUE(scene->mTextures[0]->pcData);
|
||||||
|
|
Loading…
Reference in New Issue