5 #include <RobotAPI/interface/ArViz/Elements.h>
7 #include <Inventor/nodes/SoCone.h>
8 #include <Inventor/nodes/SoCoordinate3.h>
9 #include <Inventor/nodes/SoCylinder.h>
10 #include <Inventor/nodes/SoIndexedFaceSet.h>
11 #include <Inventor/nodes/SoShapeHints.h>
12 #include <Inventor/nodes/SoSphere.h>
13 #include <Inventor/nodes/SoTranslation.h>
39 SoMaterialBinding* torusBinding =
new SoMaterialBinding;
40 torusBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
42 coords =
new SoCoordinate3;
44 SoShapeHints* torusHints =
new SoShapeHints;
46 torusHints->vertexOrdering = SoShapeHints::VertexOrdering::COUNTERCLOCKWISE;
47 torusHints->shapeType = SoShapeHints::ShapeType::UNKNOWN_SHAPE_TYPE;
50 torus =
new SoSeparator;
52 torus->addChild(torusBinding);
54 torus->addChild(torusHints);
70 int numVerticesPerRow =
SIDES + 1;
71 int numVerticesPerColumn =
RINGS + 1;
75 faces.resize(numFaces * 4);
76 matInx.resize(numFaces * 4);
81 float completion = std::min<float>(1.0f,
std::max(-1.0f, element.completion));
82 int sign = completion >= 0 ? 1 : -1;
83 float torusCompletion = completion - 1.0f /
RINGS *
sign;
84 if (torusCompletion *
sign < 0)
93 float radius = element.radius;
94 float tubeRadius = element.width;
95 float completion = torusCompletion;
97 int numVerticesPerRow =
SIDES + 1;
98 int numVerticesPerColumn =
RINGS + 1;
103 float verticalAngularStride = TWO_PI /
RINGS;
104 float horizontalAngularStride = TWO_PI /
SIDES;
106 int numVertices = numVerticesPerColumn * numVerticesPerRow;
107 for (
int verticalIt = 0; verticalIt < numVerticesPerColumn; verticalIt++)
109 theta = verticalAngularStride * verticalIt * completion;
111 for (
int horizontalIt = 0; horizontalIt < numVerticesPerRow; horizontalIt++)
113 phi = horizontalAngularStride * horizontalIt;
116 float x = std::cos(theta) * (radius + tubeRadius * std::cos(phi));
117 float y = std::sin(theta) * (radius + tubeRadius * std::cos(phi));
118 float z = tubeRadius * std::sin(phi);
120 int vertexIndex = verticalIt * numVerticesPerRow + horizontalIt;
126 for (
int verticalIt = 0; verticalIt <
RINGS; verticalIt++)
128 for (
int horizontalIt = 0; horizontalIt <
SIDES; horizontalIt++)
130 int faceIndex = (verticalIt *
SIDES + horizontalIt) * 2;
132 short lt = (short)(horizontalIt + verticalIt * (numVerticesPerRow));
133 short rt = (short)((horizontalIt + 1) + verticalIt * (numVerticesPerRow));
135 short lb = (short)(horizontalIt + (verticalIt + 1) * (numVerticesPerRow));
136 short rb = (short)((horizontalIt + 1) + (verticalIt + 1) * (numVerticesPerRow));
139 faces[faceIndex * 4 + 0] = lt;
140 faces[faceIndex * 4 + 1] = rt;
141 faces[faceIndex * 4 + 2] = lb;
142 faces[faceIndex * 4 + 3] = SO_END_FACE_INDEX;
144 matInx[faceIndex * 4 + 0] = 0;
145 matInx[faceIndex * 4 + 1] = 0;
146 matInx[faceIndex * 4 + 2] = 0;
147 matInx[faceIndex * 4 + 3] = SO_END_FACE_INDEX;
151 faces[faceIndex * 4 + 0] = rt;
152 faces[faceIndex * 4 + 1] = rb;
153 faces[faceIndex * 4 + 2] = lb;
154 faces[faceIndex * 4 + 3] = SO_END_FACE_INDEX;
156 matInx[faceIndex * 4 + 0] = 0;
157 matInx[faceIndex * 4 + 1] = 0;
158 matInx[faceIndex * 4 + 2] = 0;
159 matInx[faceIndex * 4 + 3] = SO_END_FACE_INDEX;
169 float angle0 = (
RINGS - 1.0f) /
RINGS * TWO_PI * completion;
170 float x0 = element.radius * std::cos(angle0);
171 float y0 = element.radius * std::sin(angle0);
172 float angle1 = (
RINGS - 0.5f) /
RINGS * TWO_PI * completion;
178 float coneHeight = element.width * 6.0f;
179 float coneBottomRadius = element.width * 2.5f;
181 SbVec3f axis(0.0f, 0.0f, 1.0f);
185 cone->bottomRadius.setValue(coneBottomRadius);
186 cone->height.setValue(coneHeight);