diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h b/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h index 640d700dc8e52bed3a08aee84317d3da77caed4c..60c75f043990181f4074d1dc2e2f82780e0dd8b3 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h @@ -56,7 +56,8 @@ namespace armarx::viz::coin pclCoords->point.setValues(0, coords.size(), coords.data()); - pclStye->pointSize = pcl.size(); + // TODO: Make configurable + pclStye->pointSize = 1.0f; return true; } diff --git a/source/RobotAPI/components/ArVizExample/ArVizExample.cpp b/source/RobotAPI/components/ArVizExample/ArVizExample.cpp index 833e5ac43affcadd2488c6a659e87cfeb9dc35b6..36ecf8132771c070190869eea8f6cc948f7741d1 100644 --- a/source/RobotAPI/components/ArVizExample/ArVizExample.cpp +++ b/source/RobotAPI/components/ArVizExample/ArVizExample.cpp @@ -301,6 +301,33 @@ namespace armarx::viz } }; + class PointCloud : public ElementOps<PointCloud, ElementPointCloud> + { + public: + using ElementOps::ElementOps; + + PointCloud& transparency(float t) + { + data_->transparency = t; + + return *this; + } + + PointCloud& points(std::vector<ColoredPoint> const& ps) + { + data_->points = ps; + + return *this; + } + + PointCloud& addPoint(ColoredPoint const& p) + { + data_->points.push_back(p); + + return *this; + } + }; + class Mesh : public ElementOps<Mesh, ElementMesh> { public: @@ -644,12 +671,40 @@ void fillPermanentLayer(viz::Layer& layer) layer.add(box); } +void fillPointsLayer(viz::Layer& layer, double timeInSeconds) +{ + viz::PointCloud pc = viz::PointCloud("points") + .position(Eigen::Vector3f(2000.0f, 0.0f, 400.0f)) + .transparency(0.0f); + + viz::ColoredPoint p; + p.color = viz::Color{255, 255, 0, 255}; + for (int x = -100; x <= 100; ++x) + { + p.x = 2.0f * x; + double phase = timeInSeconds + x / 50.0f; + double heightT = std::max(0.0, std::min(0.5 * (1.0 + std::sin(phase)), 1.0)); + for (int y = -100; y <= 100; ++y) + { + p.y = 2.0f * y; + p.z = 50.0 * heightT; + + p.color.g = 255.0 * heightT; + p.color.b = 255.0 * (1.0 - heightT); + pc.addPoint(p); + } + } + + layer.add(pc); +} + void ArVizExample::update() { viz::ArVizClient arviz(*this); viz::Layer testLayer = arviz.layer("Test"); viz::Layer exampleLayer = arviz.layer("Example"); + viz::Layer pointsLayer = arviz.layer("Points"); // This layer is not updated in the loop viz::Layer permanentLayer = arviz.layer("Permanent"); @@ -665,8 +720,10 @@ void ArVizExample::update() fillTestLayer(testLayer, timeInSeconds); exampleLayer.clear(); fillExampleLayer(exampleLayer, timeInSeconds); + pointsLayer.clear(); + fillPointsLayer(pointsLayer, timeInSeconds); - arviz.commit({testLayer, exampleLayer}); + arviz.commit({testLayer, exampleLayer, pointsLayer}); c.waitForCycleDuration(); }