26 #include <Inventor/nodes/SoMaterial.h>
27 #include <Inventor/nodes/SoMaterialBinding.h>
28 #include <Inventor/nodes/SoCoordinate3.h>
29 #include <Inventor/nodes/SoDrawStyle.h>
30 #include <Inventor/nodes/SoPointSet.h>
31 #include <Inventor/SbVec3f.h>
32 #include <Inventor/nodes/SoTransform.h>
33 #include <Inventor/nodes/SoSphere.h>
46 this->removeAllChildren();
53 this->removeAllChildren();
56 SoMaterial* materialInfo =
new SoMaterial();
57 std::vector<SbColor> colorData;
58 colorData.reserve(cloud->points.size());
60 SoCoordinate3* coordinates =
new SoCoordinate3();
61 std::vector<SbVec3f> pointData;
62 pointData.reserve(cloud->points.size());
63 for (
const PointT& p : cloud->points)
67 SbColor colorContainer;
68 if (useOriginalColors)
72 colorArray[0] = (
float) p.r / 256.0f;
73 colorArray[1] = (
float) p.g / 256.0f;
74 colorArray[2] = (
float) p.b / 256.0f;
76 colorContainer.setValue(colorArray);
80 colorContainer = this->color;
83 colorData.push_back(colorContainer);
85 SbVec3f pointContainer;
87 pointContainer[0] = p.x / 1000;
88 pointContainer[1] = p.y / 1000;
89 pointContainer[2] = p.z / 1000;
90 pointData.push_back(pointContainer);
95 materialInfo->diffuseColor.setValues(0, colorData.size(), colorData.data());
96 this->addChild(materialInfo);
99 SoMaterialBinding* binding =
new SoMaterialBinding();
100 binding->value = SoMaterialBinding::PER_PART;
101 this->addChild(binding);
103 coordinates->point.setValues(0, pointData.size(), pointData.data());
104 this->addChild(coordinates);
107 SoDrawStyle* pointSize =
new SoDrawStyle();
108 pointSize->pointSize = this->pointSize;
109 this->addChild(pointSize);
112 SoPointSet* pointSet =
new SoPointSet();
113 this->addChild(pointSet);
119 this->useOriginalColors =
false;
128 this->pointSize = size;
133 this->useOriginalColors =
true;