Tango: fixed sketchfab export ply error, exported objs are now rotated -90deg x-axis by default for sketchfab

This commit is contained in:
matlabbe
2017-06-16 16:24:38 -04:00
parent 8787ecceb8
commit 52a6cc5bad
4 changed files with 55 additions and 47 deletions

View File

@@ -2480,8 +2480,15 @@ bool RTABMapApp::exportMesh(
}
else if(textureMesh->tex_materials.size())
{
// With Sketchfab, the OBJ models are rotated 90 degrees on x axis, so rotate -90 to have model in right position
pcl::PointCloud<pcl::PointNormal>::Ptr cloud(new pcl::PointCloud<pcl::PointNormal>);
pcl::fromPCLPointCloud2(textureMesh->cloud, *cloud);
pcl::PCLPointCloud2 tmp = textureMesh->cloud;
cloud = rtabmap::util3d::transformPointCloud(cloud, rtabmap::Transform(1,0,0,0, 0,0,1,0, 0,-1,0,0));
pcl::toPCLPointCloud2(*cloud, textureMesh->cloud);
LOGI("Saving obj (%d vertices, %d polygons) to %s.", (int)textureMesh->cloud.data.size()/textureMesh->cloud.point_step, totalPolygons, filePath.c_str());
success = pcl::io::saveOBJFile(filePath, *textureMesh) == 0;
textureMesh->cloud = tmp;
if(success)
{
LOGI("Saved obj to %s!", filePath.c_str());