5 #include <RobotAPI/interface/ArViz/Elements.h>
7 #include <Inventor/nodes/SoCoordinate3.h>
8 #include <Inventor/nodes/SoIndexedFaceSet.h>
9 #include <Inventor/nodes/SoMaterialBinding.h>
10 #include <Inventor/nodes/SoNormal.h>
11 #include <Inventor/nodes/SoShapeHints.h>
21 SoMaterialBinding* myBinding =
new SoMaterialBinding;
22 myBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
25 coords =
new SoCoordinate3;
27 SoShapeHints* hints =
new SoShapeHints;
29 hints->vertexOrdering = SoShapeHints::VertexOrdering::COUNTERCLOCKWISE;
30 hints->shapeType = SoShapeHints::ShapeType::UNKNOWN_SHAPE_TYPE;
34 node->addChild(myBinding);
37 node->addChild(hints);
43 int colorSize = (int)element.colors.size();
44 bool noColorsArray = colorSize == 0;
52 const float conv = 1.0f / 255.0f;
55 auto color = element.color;
56 float r = color.r * conv;
57 float g = color.g * conv;
58 float b = color.b * conv;
59 float a = color.a * conv;
65 for (
int i = 0; i < colorSize; i++)
67 auto color = element.colors[i];
68 float r = color.r * conv;
69 float g = color.g * conv;
70 float b = color.b * conv;
71 float a = color.a * conv;
83 int vertexSize = (int)element.vertices.size();
85 for (
int i = 0; i < vertexSize; i++)
87 auto v = element.vertices[i];
94 int facesSize = (int)element.faces.size();
95 faces.resize(facesSize * 4);
96 matInx.resize(facesSize * 4);
98 for (
int i = 0; i < facesSize; i++)
100 auto& face = element.faces[i];
102 faces[i * 4 + 0] = face.v0;
103 faces[i * 4 + 1] = face.v1;
104 faces[i * 4 + 2] = face.v2;
105 faces[i * 4 + 3] = SO_END_FACE_INDEX;
107 matInx[i * 4 + 0] = face.c0;
108 matInx[i * 4 + 1] = face.c1;
109 matInx[i * 4 + 2] = face.c2;
110 matInx[i * 4 + 3] = SO_END_FACE_INDEX;