From c4e24369a0cf96442ec159d20737d6acb30ecbfe Mon Sep 17 00:00:00 2001 From: Fabian Reister <fabian.reister@kit.edu> Date: Fri, 11 Jun 2021 07:24:14 +0200 Subject: [PATCH] Arviz Path visu: added points that will be drawn in corners --- .../ArViz/Coin/VisualizationPath.cpp | 40 +++++++++++++++++-- .../components/ArViz/Coin/VisualizationPath.h | 8 ++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationPath.cpp b/source/RobotAPI/components/ArViz/Coin/VisualizationPath.cpp index 3018a3af5..a0190abd7 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationPath.cpp +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationPath.cpp @@ -1,9 +1,12 @@ #include "VisualizationPath.h" +#include <algorithm> + #include <Inventor/SbVec3f.h> #include <Inventor/nodes/SoCoordinate3.h> #include <Inventor/nodes/SoDrawStyle.h> #include <Inventor/nodes/SoLineSet.h> +#include <Inventor/nodes/SoPointSet.h> namespace armarx::viz::coin { @@ -27,19 +30,36 @@ namespace armarx::viz::coin node->addChild(coordinate3); node->addChild(lineSep); + + // points (use the following, if the points should be drawn in a different color) + + // pclMat = new SoMaterial; + + // SoMaterialBinding* pclMatBind = new SoMaterialBinding; + // pclMatBind->value = SoMaterialBinding::PER_PART; + + pclCoords = new SoCoordinate3; + pclStyle = new SoDrawStyle; + + // node->addChild(pclMat); + // node->addChild(pclMatBind); + node->addChild(pclCoords); + node->addChild(pclStyle); + node->addChild(new SoPointSet); } bool VisualizationPath::update(ElementType const& element) { // set position - coordinate3->point.setValuesPointer(element.points.size(), reinterpret_cast<const float*>(element.points.data())); + coordinate3->point.setValuesPointer(element.points.size(), + reinterpret_cast<const float*>(element.points.data())); // set color - const auto lineColor = element.lineColor; + const auto lineColor = element.color; constexpr float toUnit = 1.0F / 255.0F; - const auto color = SbVec3f(lineColor.r, lineColor.g, lineColor.b) * toUnit; + const auto color = SbVec3f(lineColor.r, lineColor.g, lineColor.b) * toUnit; const float transparency = 1.0F - static_cast<float>(lineColor.a) * toUnit; lineMaterial->diffuseColor.setValue(color); @@ -58,6 +78,20 @@ namespace armarx::viz::coin const int pointSize = static_cast<int>(element.points.size()); lineSet->numVertices.set1Value(0, pointSize); + // points at each node + // const std::vector<SbVec3f> colorData(element.points.size(), color); + + // pclMat->diffuseColor.setValuesPointer(colorData.size(), + // reinterpret_cast<const float*>(colorData.data())); + // pclMat->ambientColor.setValuesPointer(colorData.size(), + // reinterpret_cast<const float*>(colorData.data())); + // pclMat->transparency = transparency; + + pclCoords->point.setValuesPointer(element.points.size(), + reinterpret_cast<const float*>(element.points.data())); + + pclStyle->pointSize = element.lineWidth + 5; + return true; } } // namespace armarx::viz::coin \ No newline at end of file diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationPath.h b/source/RobotAPI/components/ArViz/Coin/VisualizationPath.h index e1e446bbe..487ee9df5 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationPath.h +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationPath.h @@ -39,9 +39,17 @@ namespace armarx::viz::coin bool update(ElementType const& element); + /// lines SoCoordinate3* coordinate3; SoDrawStyle* lineStyle; SoLineSet* lineSet; SoMaterial* lineMaterial; + + + /// points + // SoMaterial* pclMat; + SoCoordinate3* pclCoords; + SoDrawStyle* pclStyle; + }; } // namespace armarx::viz::coin -- GitLab