Skip to content
Snippets Groups Projects
Commit c4e24369 authored by Fabian Reister's avatar Fabian Reister
Browse files

Arviz Path visu: added points that will be drawn in corners

parent b7407d85
No related branches found
No related tags found
No related merge requests found
#include "VisualizationPath.h" #include "VisualizationPath.h"
#include <algorithm>
#include <Inventor/SbVec3f.h> #include <Inventor/SbVec3f.h>
#include <Inventor/nodes/SoCoordinate3.h> #include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h> #include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoLineSet.h> #include <Inventor/nodes/SoLineSet.h>
#include <Inventor/nodes/SoPointSet.h>
namespace armarx::viz::coin namespace armarx::viz::coin
{ {
...@@ -27,19 +30,36 @@ namespace armarx::viz::coin ...@@ -27,19 +30,36 @@ namespace armarx::viz::coin
node->addChild(coordinate3); node->addChild(coordinate3);
node->addChild(lineSep); 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) bool VisualizationPath::update(ElementType const& element)
{ {
// set position // 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 // set color
const auto lineColor = element.lineColor; const auto lineColor = element.color;
constexpr float toUnit = 1.0F / 255.0F; 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; const float transparency = 1.0F - static_cast<float>(lineColor.a) * toUnit;
lineMaterial->diffuseColor.setValue(color); lineMaterial->diffuseColor.setValue(color);
...@@ -58,6 +78,20 @@ namespace armarx::viz::coin ...@@ -58,6 +78,20 @@ namespace armarx::viz::coin
const int pointSize = static_cast<int>(element.points.size()); const int pointSize = static_cast<int>(element.points.size());
lineSet->numVertices.set1Value(0, pointSize); 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; return true;
} }
} // namespace armarx::viz::coin } // namespace armarx::viz::coin
\ No newline at end of file
...@@ -39,9 +39,17 @@ namespace armarx::viz::coin ...@@ -39,9 +39,17 @@ namespace armarx::viz::coin
bool update(ElementType const& element); bool update(ElementType const& element);
/// lines
SoCoordinate3* coordinate3; SoCoordinate3* coordinate3;
SoDrawStyle* lineStyle; SoDrawStyle* lineStyle;
SoLineSet* lineSet; SoLineSet* lineSet;
SoMaterial* lineMaterial; SoMaterial* lineMaterial;
/// points
// SoMaterial* pclMat;
SoCoordinate3* pclCoords;
SoDrawStyle* pclStyle;
}; };
} // namespace armarx::viz::coin } // namespace armarx::viz::coin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment