VisualizationCylindroid.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ElementVisualizer.h"
4 
5 #include <RobotAPI/interface/ArViz/Elements.h>
6 
7 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
8 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationNode.h>
9 
10 #include <Inventor/nodes/SoUnits.h>
11 
12 namespace armarx::viz::coin
13 {
15  {
16  using ElementType = data::ElementCylindroid;
17 
18  bool update(ElementType const& element)
19  {
20  auto color = element.color;
21  constexpr float conv = 1.0f / 255.0f;
22  const float r = color.r * conv;
23  const float g = color.g * conv;
24  const float b = color.b * conv;
25  const float a = color.a * conv;
26 
27  VirtualRobot::VisualizationNodePtr cylindroid_node;
28  {
29  // Params.
30  SoMaterial* mat = new SoMaterial;
31  mat->diffuseColor.setValue(r, g, b);
32  mat->ambientColor.setValue(r, g, b);
33  mat->transparency.setValue(1. - a);
34 
35  SoSeparator* res = new SoSeparator();
36  res->ref();
37  SoUnits* u = new SoUnits();
38  u->units = SoUnits::MILLIMETERS;
39  res->addChild(u);
40  res->addChild(VirtualRobot::CoinVisualizationFactory::CreateCylindroid(
41  element.axisLengths.e0, element.axisLengths.e1, element.height,
42  mat));
43 
44  cylindroid_node.reset(new VirtualRobot::CoinVisualizationNode(res));
45  res->unref();
46  }
47 
48  SoNode* cylindroid = dynamic_cast<VirtualRobot::CoinVisualizationNode&>(
49  *cylindroid_node).getCoinVisualization();
50 
51  node->removeAllChildren();
52  node->addChild(cylindroid);
53 
54  return true;
55  }
56  };
57 }
armarx::viz::coin::VisualizationCylindroid::ElementType
data::ElementCylindroid ElementType
Definition: VisualizationCylindroid.h:16
ElementVisualizer.h
armarx::viz::coin::TypedElementVisualization
Definition: ElementVisualizer.h:53
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::viz::coin::VisualizationCylindroid::update
bool update(ElementType const &element)
Definition: VisualizationCylindroid.h:18
armarx::viz::coin::TypedElementVisualization< SoSeparator >::node
NodeType * node
Definition: ElementVisualizer.h:68
armarx::viz::coin
Definition: ElementVisualizer.cpp:11
armarx::viz::coin::VisualizationCylindroid
Definition: VisualizationCylindroid.h:14