Home:ALL Converter>How to export higher precision output files from ASSIMP?

How to export higher precision output files from ASSIMP?

Ask Time:2016-07-06T11:55:22         Author:Chris

Json Formatter

When exporting meshes with assimp through code as shown below I receive very limited precision output. Is there a way in assimp to increase export precision? (Nothing hints at this in the documentation.)

void export(aiScene* scene, const std::string & outputFile)
{
    Assimp::Exporter exporter;

    // exporter.mOutput.precision(16); ???

    exporter.Export(scene, "obj", outputFile);
}

Output in the .obj file will contain no more than 6 digits per value:

v  557760 4.07449e+06 -49.1995
v  557760 4.07449e+06 -49.095
v  557760 4.0745e+06 -49.0082
v  557760 4.0745e+06 -49.1127

When looking at the actual exporter class (ObjExporter.cpp) all data is written through a public stringstream:

public:
    std::ostringstream mOutput, mOutputMat;

[...]

mOutput << "# " << vp.size() << " vertex positions" << endl;
for(const aiVector3D& v : vp) {
    mOutput << "v  " << v.x << " " << v.y << " " << v.z << endl;
}
mOutput << endl;

Is there a way I could increase the stringstream precision (http://www.cplusplus.com/reference/ios/ios_base/precision/) without having to change the assimp source?

Author:Chris,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/38216098/how-to-export-higher-precision-output-files-from-assimp
yy