28 #include <Inventor/SbVec3f.h>
29 #include <Inventor/nodes/SoCoordinate3.h>
30 #include <Inventor/nodes/SoDrawStyle.h>
31 #include <Inventor/nodes/SoMaterial.h>
32 #include <Inventor/nodes/SoMaterialBinding.h>
33 #include <Inventor/nodes/SoPointSet.h>
34 #include <Inventor/nodes/SoSphere.h>
35 #include <Inventor/nodes/SoTransform.h>
46 this->removeAllChildren();
54 this->removeAllChildren();
57 SoMaterial* materialInfo =
new SoMaterial();
58 std::vector<SbColor> colorData;
59 colorData.reserve(cloud->points.size());
61 SoCoordinate3* coordinates =
new SoCoordinate3();
62 std::vector<SbVec3f> pointData;
63 pointData.reserve(cloud->points.size());
64 for (
const PointT& p : cloud->points)
68 SbColor colorContainer;
69 if (useOriginalColors)
73 colorArray[0] = (
float)p.r / 256.0f;
74 colorArray[1] = (
float)p.g / 256.0f;
75 colorArray[2] = (
float)p.b / 256.0f;
77 colorContainer.setValue(colorArray);
81 colorContainer = this->color;
84 colorData.push_back(colorContainer);
86 SbVec3f pointContainer;
88 pointContainer[0] = p.x / 1000;
89 pointContainer[1] = p.y / 1000;
90 pointContainer[2] = p.z / 1000;
91 pointData.push_back(pointContainer);
96 materialInfo->diffuseColor.setValues(0, colorData.size(), colorData.data());
97 this->addChild(materialInfo);
100 SoMaterialBinding* binding =
new SoMaterialBinding();
101 binding->value = SoMaterialBinding::PER_PART;
102 this->addChild(binding);
104 coordinates->point.setValues(0, pointData.size(), pointData.data());
105 this->addChild(coordinates);
108 SoDrawStyle* pointSize =
new SoDrawStyle();
109 pointSize->pointSize = this->pointSize;
110 this->addChild(pointSize);
113 SoPointSet* pointSet =
new SoPointSet();
114 this->addChild(pointSet);
121 this->useOriginalColors =
false;
131 this->pointSize = size;
137 this->useOriginalColors =
true;