Simple Assimp import and export problem
by mostlyharmless from LinuxQuestions.org on (#6K60Q)
I'm just trying to understand some simple things about assimp. As a test program, I've got a simple program, below,(originally from https://stackoverflow.com/questions/...rows-exception) which imports a file then exports the data. For some reason, none of the exported files are readable by, e.g. meshlab. What I am missing?
Code:#include <assimp/cimport.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
int main(int argc, char** argv)
{
std::string filename = "float-color.ply";
// auto stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
// aiAttachLogStream(&stream);
Assimp::Importer Importer;
//Importer.
std::cout << "\tReading file using ASSIMP" << std::endl;
const aiScene *aiscene = Importer.ReadFile(filename.c_str(), aiProcess_ValidateDataStructure | aiProcessPreset_TargetRealtime_MaxQuality);
std::string str = Importer.GetErrorString();
if (!aiscene) {
printf("Error parsing '%s': '%s'\n", filename.c_str(), Importer.GetErrorString());
return 1;
}
Assimp::Exporter Exporter;
const aiExportFormatDesc* format = Exporter.GetExportFormatDescription(0);
int lIndex = filename.find_last_of('/');
//const string path = Filename.substr(0,lIndex+1);
std::string path = "float-color.off";
std::cout << "\tExport path: " << path << std::endl;
aiReturn ret = Exporter.Export(aiscene, format->id, path);
std::cout << Exporter.GetErrorString() << std::endl;
return 0;
}The test file comes from the unit tests in assimp, below:
Code:ply
format ascii 1.0
comment VCGLIB generated
element vertex 3
property float x
property float y
property float z
property float red
property float green
property float blue
property float alpha
element face 1
property list uchar int vertex_indices
end_header
0.0 0.0 0.0 0 0 1 1
100.0 0.0 0.0 0 0 1 1
200.0 200.0 0.0 0 0 1 1
3 0 1 2The code compiles cleanly, runs without error, generates an "off" file, but the file is unreadable by meshlab. Same with multiple other exported file formats...
Code:#include <assimp/cimport.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
int main(int argc, char** argv)
{
std::string filename = "float-color.ply";
// auto stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
// aiAttachLogStream(&stream);
Assimp::Importer Importer;
//Importer.
std::cout << "\tReading file using ASSIMP" << std::endl;
const aiScene *aiscene = Importer.ReadFile(filename.c_str(), aiProcess_ValidateDataStructure | aiProcessPreset_TargetRealtime_MaxQuality);
std::string str = Importer.GetErrorString();
if (!aiscene) {
printf("Error parsing '%s': '%s'\n", filename.c_str(), Importer.GetErrorString());
return 1;
}
Assimp::Exporter Exporter;
const aiExportFormatDesc* format = Exporter.GetExportFormatDescription(0);
int lIndex = filename.find_last_of('/');
//const string path = Filename.substr(0,lIndex+1);
std::string path = "float-color.off";
std::cout << "\tExport path: " << path << std::endl;
aiReturn ret = Exporter.Export(aiscene, format->id, path);
std::cout << Exporter.GetErrorString() << std::endl;
return 0;
}The test file comes from the unit tests in assimp, below:
Code:ply
format ascii 1.0
comment VCGLIB generated
element vertex 3
property float x
property float y
property float z
property float red
property float green
property float blue
property float alpha
element face 1
property list uchar int vertex_indices
end_header
0.0 0.0 0.0 0 0 1 1
100.0 0.0 0.0 0 0 1 1
200.0 200.0 0.0 0 0 1 1
3 0 1 2The code compiles cleanly, runs without error, generates an "off" file, but the file is unreadable by meshlab. Same with multiple other exported file formats...