3 #include <Inventor/nodes/SoCoordinate3.h>
4 #include <Inventor/nodes/SoIndexedFaceSet.h>
5 #include <Inventor/nodes/SoMaterial.h>
6 #include <Inventor/nodes/SoMaterialBinding.h>
7 #include <Inventor/nodes/SoNormal.h>
8 #include <Inventor/nodes/SoShapeHints.h>
15 SoMaterialBinding* myBinding =
new SoMaterialBinding;
16 myBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
19 coords =
new SoCoordinate3;
21 SoShapeHints* hints =
new SoShapeHints;
23 hints->vertexOrdering = SoShapeHints::VertexOrdering::COUNTERCLOCKWISE;
24 hints->shapeType = SoShapeHints::ShapeType::UNKNOWN_SHAPE_TYPE;
28 node->addChild(myBinding);
31 node->addChild(hints);
38 int colorSize = (int)element.colors.size();
39 bool noColorsArray = colorSize == 0;
47 const float conv = 1.0f / 255.0f;
50 auto color = element.color;
51 float r = color.r * conv;
52 float g = color.g * conv;
53 float b = color.b * conv;
54 float a = color.a * conv;
60 for (
int i = 0; i < colorSize; i++)
62 auto color = element.colors[i];
63 float r = color.r * conv;
64 float g = color.g * conv;
65 float b = color.b * conv;
66 float a = color.a * conv;
78 int vertexSize = (int)element.vertices.size();
80 for (
int i = 0; i < vertexSize; i++)
82 auto v = element.vertices[i];
89 int facesSize = (int)element.faces.size();
90 faces.resize(facesSize * 4);
91 matInx.resize(facesSize * 4);
93 for (
int i = 0; i < facesSize; i++)
95 auto& face = element.faces[i];
97 faces[i * 4 + 0] = face.v0;
98 faces[i * 4 + 1] = face.v1;
99 faces[i * 4 + 2] = face.v2;
100 faces[i * 4 + 3] = SO_END_FACE_INDEX;
102 matInx[i * 4 + 0] = face.c0;
103 matInx[i * 4 + 1] = face.c1;
104 matInx[i * 4 + 2] = face.c2;
105 matInx[i * 4 + 3] = SO_END_FACE_INDEX;