mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Added texture/color blending option directly in the app. Added LAZ export option.
This commit is contained in:
@@ -2926,6 +2926,10 @@ void RTABMapApp::setWireframe(bool enabled)
|
||||
{
|
||||
main_scene_.setWireframe(enabled);
|
||||
}
|
||||
void RTABMapApp::setTextureColorSeamsHidden(bool hidden)
|
||||
{
|
||||
main_scene_.setTextureColorSeamsHidden(hidden);
|
||||
}
|
||||
|
||||
void RTABMapApp::setLocalizationMode(bool enabled)
|
||||
{
|
||||
@@ -3113,7 +3117,7 @@ void RTABMapApp::setDepthConfidence(int value)
|
||||
void RTABMapApp::setExportPointCloudFormat(const std::string & format)
|
||||
{
|
||||
#if defined(RTABMAP_PDAL) || defined(RTABMAP_LIBLAS)
|
||||
if(format == "las") {
|
||||
if(format == "las" || format == "laz") {
|
||||
exportPointCloudFormat_ = format;
|
||||
}
|
||||
else
|
||||
@@ -4205,9 +4209,9 @@ bool RTABMapApp::writeExportedMesh(const std::string & directory, const std::str
|
||||
if(polygonMesh->cloud.data.size())
|
||||
{
|
||||
#if defined(RTABMAP_PDAL) || defined(RTABMAP_LIBLAS)
|
||||
if(polygonMesh->polygons.empty() && exportPointCloudFormat_ == "las") {
|
||||
if(polygonMesh->polygons.empty() && (exportPointCloudFormat_ == "las" || exportPointCloudFormat_ == "laz")) {
|
||||
// Point cloud LAS
|
||||
std::string filePath = directory + UDirectory::separator() + name + ".las";
|
||||
std::string filePath = directory + UDirectory::separator() + name + (exportPointCloudFormat_ == "las"? ".las" : ".laz");
|
||||
LOGI("Saving las (%d vertices) to %s.", (int)polygonMesh->cloud.data.size()/polygonMesh->cloud.point_step, filePath.c_str());
|
||||
pcl::PointCloud<pcl::PointXYZRGB> output;
|
||||
pcl::fromPCLPointCloud2(polygonMesh->cloud, output);
|
||||
|
||||
@@ -128,6 +128,7 @@ class RTABMapApp : public UEventsHandler {
|
||||
void setLighting(bool enabled);
|
||||
void setBackfaceCulling(bool enabled);
|
||||
void setWireframe(bool enabled);
|
||||
void setTextureColorSeamsHidden(bool hidden);
|
||||
void setLocalizationMode(bool enabled);
|
||||
void setTrajectoryMode(bool enabled);
|
||||
void setGraphOptimization(bool enabled);
|
||||
|
||||
@@ -231,12 +231,22 @@ const std::string kTextureMeshFragmentShader =
|
||||
"uniform float uGainR;\n"
|
||||
"uniform float uGainG;\n"
|
||||
"uniform float uGainB;\n"
|
||||
"uniform int uHideSeams;\n"
|
||||
"varying vec3 vColor;\n"
|
||||
"varying vec2 vTexCoord;\n"
|
||||
"varying float vLightWeighting;\n"
|
||||
""
|
||||
"void main() {\n"
|
||||
" vec4 textureColor = texture2D(uTexture, vTexCoord) * vec4(vColor.z, vColor.y, vColor.x, 1.0);\n"
|
||||
" vec4 textureColor;\n"
|
||||
" if(uHideSeams==1) {\n"
|
||||
" if(vTexCoord.x>0.99 && vTexCoord.y>0.99) {\n"
|
||||
" textureColor = vec4(vColor.z, vColor.y, vColor.x, 1.0);\n"
|
||||
" } else {\n"
|
||||
" textureColor = texture2D(uTexture, vTexCoord);\n"
|
||||
" }\n"
|
||||
" } else {\n"
|
||||
" textureColor = texture2D(uTexture, vTexCoord) * vec4(vColor.z, vColor.y, vColor.x, 1.0);\n"
|
||||
" }\n"
|
||||
" gl_FragColor = vec4(textureColor.r * uGainR * vLightWeighting, textureColor.g * uGainG * vLightWeighting, textureColor.b * uGainB * vLightWeighting, textureColor.a);\n"
|
||||
"}\n";
|
||||
const std::string kTextureMeshBlendingFragmentShader =
|
||||
@@ -1016,7 +1026,8 @@ void PointCloudDrawable::Render(
|
||||
float nearClipPlane,
|
||||
float farClipPlane,
|
||||
bool packDepthToColorChannel,
|
||||
bool wireFrame) const
|
||||
bool wireFrame,
|
||||
bool hideSeams) const
|
||||
{
|
||||
if(vertex_buffer_ && nPoints_ && visible_ && !shaderPrograms_.empty())
|
||||
{
|
||||
@@ -1135,6 +1146,12 @@ void PointCloudDrawable::Render(
|
||||
|
||||
attribute_texture = glGetAttribLocation(program, "aTexCoord");
|
||||
glEnableVertexAttribArray(attribute_texture);
|
||||
|
||||
if(depthTexture == 0)
|
||||
{
|
||||
GLuint hideSeams_handle = glGetUniformLocation(program, "uHideSeams");
|
||||
glUniform1i(hideSeams_handle, hideSeams?1:0);
|
||||
}
|
||||
}
|
||||
|
||||
attribute_color = glGetAttribLocation(program, "aColor");
|
||||
|
||||
@@ -98,7 +98,8 @@ private:
|
||||
float nearClipPlane = 0, // nonnull if depthTexture>0
|
||||
float farClipPlane = 0, // nonnull if depthTexture>0
|
||||
bool packDepthToColorChannel = false,
|
||||
bool wireFrame = false) const;
|
||||
bool wireFrame = false,
|
||||
bool hideSeams = false) const;
|
||||
|
||||
private:
|
||||
template<class PointT>
|
||||
|
||||
@@ -93,6 +93,7 @@ Scene::Scene() :
|
||||
lighting_(false),
|
||||
backfaceCulling_(true),
|
||||
wireFrame_(false),
|
||||
textureColorSeamsHidden_(false),
|
||||
r_(0.0f),
|
||||
g_(0.0f),
|
||||
b_(0.0f),
|
||||
@@ -674,7 +675,7 @@ int Scene::Render(const float * uvsTransformed, glm::mat4 arViewMatrix, glm::mat
|
||||
cloud->getPose().z() - openglCamera.z());
|
||||
float distanceToCameraSqr = cloudToCamera[0]*cloudToCamera[0] + cloudToCamera[1]*cloudToCamera[1] + cloudToCamera[2]*cloudToCamera[2];
|
||||
|
||||
cloud->Render(projectionMatrix, viewMatrix, meshRendering_, pointSize_, meshRenderingTexture_, lighting_, distanceToCameraSqr, onlineBlending?depthTexture_:0, screenWidth_, screenHeight_, gesture_camera_->getNearClipPlane(), gesture_camera_->getFarClipPlane(), false, wireFrame_);
|
||||
cloud->Render(projectionMatrix, viewMatrix, meshRendering_, pointSize_, meshRenderingTexture_, lighting_, distanceToCameraSqr, onlineBlending?depthTexture_:0, screenWidth_, screenHeight_, gesture_camera_->getNearClipPlane(), gesture_camera_->getFarClipPlane(), false, wireFrame_, textureColorSeamsHidden_);
|
||||
}
|
||||
|
||||
if(quads_.find(55556)!=quads_.end())
|
||||
|
||||
@@ -193,6 +193,7 @@ class Scene {
|
||||
void setLighting(bool enabled) {lighting_ = enabled;}
|
||||
void setBackfaceCulling(bool enabled) {backfaceCulling_ = enabled;}
|
||||
void setWireframe(bool enabled) {wireFrame_ = enabled;}
|
||||
void setTextureColorSeamsHidden(bool hidden) {textureColorSeamsHidden_ = hidden;}
|
||||
void setBackgroundColor(float r, float g, float b) {r_=r; g_=g; b_=b;} // 0.0f <> 1.0f
|
||||
void setGridColor(float r, float g, float b);
|
||||
|
||||
@@ -255,6 +256,7 @@ class Scene {
|
||||
bool lighting_;
|
||||
bool backfaceCulling_;
|
||||
bool wireFrame_;
|
||||
bool textureColorSeamsHidden_;
|
||||
float r_;
|
||||
float g_;
|
||||
float b_;
|
||||
|
||||
Reference in New Issue
Block a user