Merge branch 'master' into patch-1
commit
c539dfe7a2
|
@ -235,9 +235,6 @@ void FBXExporter::WriteBinaryFooter()
|
||||||
outfile->Write(NULL_RECORD.c_str(), NULL_RECORD.size(), 1);
|
outfile->Write(NULL_RECORD.c_str(), NULL_RECORD.size(), 1);
|
||||||
|
|
||||||
outfile->Write(GENERIC_FOOTID.c_str(), GENERIC_FOOTID.size(), 1);
|
outfile->Write(GENERIC_FOOTID.c_str(), GENERIC_FOOTID.size(), 1);
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
|
||||||
outfile->Write("\x00", 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// here some padding is added for alignment to 16 bytes.
|
// here some padding is added for alignment to 16 bytes.
|
||||||
// if already aligned, the full 16 bytes is added.
|
// if already aligned, the full 16 bytes is added.
|
||||||
|
|
|
@ -54,6 +54,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "FBXProperties.h"
|
#include "FBXProperties.h"
|
||||||
#include <assimp/ByteSwapper.h>
|
#include <assimp/ByteSwapper.h>
|
||||||
|
|
||||||
|
#include <algorithm> // std::transform
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace FBX {
|
namespace FBX {
|
||||||
|
|
||||||
|
@ -82,11 +84,12 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
|
||||||
|
|
||||||
std::string templateName;
|
std::string templateName;
|
||||||
|
|
||||||
const char* const sh = shading.c_str();
|
// lower-case shading because Blender (for example) writes "Phong"
|
||||||
if(!strcmp(sh,"phong")) {
|
std::transform(shading.begin(), shading.end(), shading.begin(), ::tolower);
|
||||||
|
if(shading == "phong") {
|
||||||
templateName = "Material.FbxSurfacePhong";
|
templateName = "Material.FbxSurfacePhong";
|
||||||
}
|
}
|
||||||
else if(!strcmp(sh,"lambert")) {
|
else if(shading == "lambert") {
|
||||||
templateName = "Material.FbxSurfaceLambert";
|
templateName = "Material.FbxSurfaceLambert";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -245,28 +245,7 @@ void PLYImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSy
|
||||||
// list is containing a list of points
|
// list is containing a list of points
|
||||||
bool pointsOnly = mGeneratedMesh->mFaces == NULL ? true : false;
|
bool pointsOnly = mGeneratedMesh->mFaces == NULL ? true : false;
|
||||||
if (pointsOnly) {
|
if (pointsOnly) {
|
||||||
if (mGeneratedMesh->mNumVertices < 3) {
|
mGeneratedMesh->mPrimitiveTypes = aiPrimitiveType::aiPrimitiveType_POINT;
|
||||||
if (mGeneratedMesh != NULL) {
|
|
||||||
delete(mGeneratedMesh);
|
|
||||||
mGeneratedMesh = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
streamedBuffer.close();
|
|
||||||
throw DeadlyImportError("Invalid .ply file: Not enough "
|
|
||||||
"vertices to build a proper face list. ");
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned int iNum = (unsigned int)mGeneratedMesh->mNumVertices / 3;
|
|
||||||
mGeneratedMesh->mNumFaces = iNum;
|
|
||||||
mGeneratedMesh->mFaces = new aiFace[mGeneratedMesh->mNumFaces];
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < iNum; ++i) {
|
|
||||||
mGeneratedMesh->mFaces[i].mNumIndices = 3;
|
|
||||||
mGeneratedMesh->mFaces[i].mIndices = new unsigned int[3];
|
|
||||||
mGeneratedMesh->mFaces[i].mIndices[0] = (i * 3);
|
|
||||||
mGeneratedMesh->mFaces[i].mIndices[1] = (i * 3) + 1;
|
|
||||||
mGeneratedMesh->mFaces[i].mIndices[2] = (i * 3) + 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now load a list of all materials
|
// now load a list of all materials
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
ply
|
||||||
|
format ascii 1.0
|
||||||
|
comment Created by Blender 2.77 (sub 0) - www.blender.org, source file: ''
|
||||||
|
element vertex 24
|
||||||
|
property float x
|
||||||
|
property float y
|
||||||
|
property float z
|
||||||
|
property float nx
|
||||||
|
property float ny
|
||||||
|
property float nz
|
||||||
|
property list uchar uint vertex_indices
|
||||||
|
end_header
|
||||||
|
7.941797 1.432409 -0.927566 0.000000 0.000000 -1.000000
|
||||||
|
7.941797 -2.321273 -0.927566 0.000000 0.000000 -1.000000
|
||||||
|
4.188114 -2.321273 -0.927566 0.000000 0.000000 -1.000000
|
||||||
|
4.188115 1.432410 -0.927566 0.000000 0.000000 -1.000000
|
||||||
|
7.941798 1.432408 2.826117 0.000000 -0.000000 1.000000
|
||||||
|
4.188114 1.432409 2.826117 0.000000 -0.000000 1.000000
|
||||||
|
4.188113 -2.321273 2.826117 0.000000 -0.000000 1.000000
|
||||||
|
7.941795 -2.321275 2.826117 0.000000 -0.000000 1.000000
|
||||||
|
7.941797 1.432409 -0.927566 1.000000 -0.000000 0.000000
|
||||||
|
7.941798 1.432408 2.826117 1.000000 -0.000000 0.000000
|
||||||
|
7.941795 -2.321275 2.826117 1.000000 -0.000000 0.000000
|
||||||
|
7.941797 -2.321273 -0.927566 1.000000 -0.000000 0.000000
|
||||||
|
7.941797 -2.321273 -0.927566 -0.000000 -1.000000 -0.000000
|
||||||
|
7.941795 -2.321275 2.826117 -0.000000 -1.000000 -0.000000
|
||||||
|
4.188113 -2.321273 2.826117 -0.000000 -1.000000 -0.000000
|
||||||
|
4.188114 -2.321273 -0.927566 -0.000000 -1.000000 -0.000000
|
||||||
|
4.188114 -2.321273 -0.927566 -1.000000 0.000000 -0.000000
|
||||||
|
4.188113 -2.321273 2.826117 -1.000000 0.000000 -0.000000
|
||||||
|
4.188114 1.432409 2.826117 -1.000000 0.000000 -0.000000
|
||||||
|
4.188115 1.432410 -0.927566 -1.000000 0.000000 -0.000000
|
||||||
|
7.941798 1.432408 2.826117 0.000000 1.000000 0.000000
|
||||||
|
7.941797 1.432409 -0.927566 0.000000 1.000000 0.000000
|
||||||
|
4.188115 1.432410 -0.927566 0.000000 1.000000 0.000000
|
||||||
|
4.188114 1.432409 2.826117 0.000000 1.000000 0.000000
|
|
@ -97,6 +97,8 @@ TEST_F(utPLYImportExport, importerMultipleTest) {
|
||||||
scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
|
scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
|
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
||||||
|
EXPECT_EQ(6u, scene->mMeshes[0]->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utPLYImportExport, importPLYwithUV) {
|
TEST_F(utPLYImportExport, importPLYwithUV) {
|
||||||
|
@ -113,7 +115,7 @@ TEST_F(utPLYImportExport, importPLYwithUV) {
|
||||||
|
|
||||||
TEST_F(utPLYImportExport, importBinaryPLY) {
|
TEST_F(utPLYImportExport, importBinaryPLY) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_binary.ply", 0);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_binary.ply", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
||||||
|
@ -136,6 +138,20 @@ TEST_F( utPLYImportExport, vertexColorTest ) {
|
||||||
EXPECT_EQ(2, first_face.mIndices[2]);
|
EXPECT_EQ(2, first_face.mIndices[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Test issue #623, PLY importer should not automatically create faces
|
||||||
|
TEST_F(utPLYImportExport, pointcloudTest) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/issue623.ply", 0);
|
||||||
|
EXPECT_NE(nullptr, scene);
|
||||||
|
|
||||||
|
EXPECT_EQ(1u, scene->mNumMeshes);
|
||||||
|
EXPECT_NE(nullptr, scene->mMeshes[0]);
|
||||||
|
EXPECT_EQ(24u, scene->mMeshes[0]->mNumVertices);
|
||||||
|
EXPECT_EQ(aiPrimitiveType::aiPrimitiveType_POINT, scene->mMeshes[0]->mPrimitiveTypes);
|
||||||
|
EXPECT_EQ(0u, scene->mMeshes[0]->mNumFaces);
|
||||||
|
}
|
||||||
|
|
||||||
static const char *test_file =
|
static const char *test_file =
|
||||||
"ply\n"
|
"ply\n"
|
||||||
"format ascii 1.0\n"
|
"format ascii 1.0\n"
|
||||||
|
@ -157,6 +173,7 @@ static const char *test_file =
|
||||||
|
|
||||||
TEST_F( utPLYImportExport, parseErrorTest ) {
|
TEST_F( utPLYImportExport, parseErrorTest ) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFileFromMemory( test_file, strlen( test_file ), aiProcess_ValidateDataStructure);
|
//Could not use aiProcess_ValidateDataStructure since it's missing faces.
|
||||||
|
const aiScene *scene = importer.ReadFileFromMemory( test_file, strlen( test_file ), 0);
|
||||||
EXPECT_NE( nullptr, scene );
|
EXPECT_NE( nullptr, scene );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue