VisualizationArrow.h
Go to the documentation of this file.
1#pragma once
2
3#include <RobotAPI/interface/ArViz/Elements.h>
4
5#include "ElementVisualizer.h"
6#include <Inventor/nodes/SoCone.h>
7#include <Inventor/nodes/SoCylinder.h>
8#include <Inventor/nodes/SoSphere.h>
9#include <Inventor/nodes/SoTranslation.h>
10
11namespace armarx::viz::coin
12{
14 {
15 using ElementType = data::ElementArrow;
16
18 {
19 tr = new SoTranslation;
20 c = new SoCylinder();
21 transl = new SoTranslation;
22 cone = new SoCone();
23
24 node->addChild(tr);
25 node->addChild(c);
26 node->addChild(transl);
27 node->addChild(cone);
28 }
29
30 bool
31 update(ElementType const& element)
32 {
33 float coneHeight = element.width * 6.0f;
34 float coneBottomRadius = element.width * 2.5f;
35 float baseLength = element.length - coneHeight;
36 baseLength = std::max(0.0f, baseLength);
37
38 tr->translation.setValue(0, baseLength * 0.5f, 0);
39
40 c->radius = element.width;
41 c->height = baseLength;
42
43 transl->translation.setValue(0, element.length * 0.5f, 0);
44
45 cone->bottomRadius.setValue(coneBottomRadius);
46 cone->height.setValue(coneHeight);
47
48 return true;
49 }
50
51 SoTranslation* tr;
52 SoCylinder* c;
53 SoTranslation* transl;
54 SoCone* cone;
55 };
56} // namespace armarx::viz::coin
bool update(ElementType const &element)