VisualizationCylindroid.cpp
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author ( )
17 * @date 2024
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
23
24#include <Inventor/nodes/SoMaterial.h>
25
26bool
28{
29 auto color = element.color;
30 constexpr float conv = 1.0f / 255.0f;
31 const float r = color.r * conv;
32 const float g = color.g * conv;
33 const float b = color.b * conv;
34 const float a = color.a * conv;
35
36 VirtualRobot::VisualizationNodePtr cylindroid_node;
37 {
38 // Params.
39 SoMaterial* mat = new SoMaterial;
40 mat->diffuseColor.setValue(r, g, b);
41 mat->ambientColor.setValue(r, g, b);
42 mat->transparency.setValue(1. - a);
43
44 SoSeparator* res = new SoSeparator();
45 res->ref();
46 SoUnits* u = new SoUnits();
47 u->units = SoUnits::MILLIMETERS;
48 res->addChild(u);
49 res->addChild(VirtualRobot::CoinVisualizationFactory::CreateCylindroid(
50 element.axisLengths.e0, element.axisLengths.e1, element.height, mat));
51
52 cylindroid_node.reset(new VirtualRobot::CoinVisualizationNode(res));
53 res->unref();
54 }
55
56 SoNode* cylindroid =
57 dynamic_cast<VirtualRobot::CoinVisualizationNode&>(*cylindroid_node).getCoinVisualization();
58
59 node->removeAllChildren();
60 node->addChild(cylindroid);
61
62 return true;
63}
bool update(ElementType const &element)
This file is part of ArmarX.