27 #include <VirtualRobot/XML/RobotIO.h>
28 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
31 #include <Inventor/actions/SoGetMatrixAction.h>
32 #include <Inventor/actions/SoSearchAction.h>
33 #include <Inventor/SbViewportRegion.h>
34 #include <Inventor/nodes/SoCube.h>
58 this->hasEndEffectorVisualizer = endEffector ? true :
false;
61 this->material =
new SoMaterial();
62 this->material->transparency = 0.5;
63 this->material->setOverride(
true);
64 this->addChild(material);
67 if (this->hasEndEffectorVisualizer)
71 this->addChild(endEffectorVisualization->getCoinVisualization());
75 SoCube* cube =
new SoCube();
83 this->manip.reset(
new SoTransformerManip());
89 SoSeparator* nullSep =
new SoSeparator;
92 manip->getDragger()->setPart(
"scale1", nullSep);
93 manip->getDragger()->setPart(
"scale2", nullSep);
94 manip->getDragger()->setPart(
"scale3", nullSep);
95 manip->getDragger()->setPart(
"scale4", nullSep);
96 manip->getDragger()->setPart(
"scale5", nullSep);
97 manip->getDragger()->setPart(
"scale6", nullSep);
98 manip->getDragger()->setPart(
"scale7", nullSep);
99 manip->getDragger()->setPart(
"scale8", nullSep);
102 manip->getDragger()->setPart(
"translator1", nullSep);
103 manip->getDragger()->setPart(
"translator2", nullSep);
104 manip->getDragger()->setPart(
"translator3", nullSep);
105 manip->getDragger()->setPart(
"translator4", nullSep);
106 manip->getDragger()->setPart(
"translator5", nullSep);
107 manip->getDragger()->setPart(
"translator6", nullSep);
110 manip->getDragger()->setPart(
"rotator1", nullSep);
111 manip->getDragger()->setPart(
"rotator2", nullSep);
112 manip->getDragger()->setPart(
"rotator3", nullSep);
113 manip->getDragger()->setPart(
"rotator4", nullSep);
114 manip->getDragger()->setPart(
"rotator5", nullSep);
115 manip->getDragger()->setPart(
"rotator6", nullSep);
119 if (this->hasEndEffectorVisualizer)
122 this->localTransformation = endEffector->getBase()->getTransformationTo(endEffector->getTcp());
124 globalMat = endEffector->getBase()->getGlobalPose();
129 globalMat(0, 3) /= 1000;
130 globalMat(1, 3) /= 1000;
131 globalMat(2, 3) /= 1000;
132 manip->setMatrix(VirtualRobot::CoinVisualizationFactory::getSbMatrix(globalMat));
133 this->insertChild(manip.get(), 0);
135 this->isVisualizing =
true;
142 this->removeAllChildren();
145 this->isVisualizing =
false;
146 this->hasEndEffectorVisualizer =
false;
154 this->material->ambientColor.setValue(r, g, b);
162 SoGetMatrixAction* action =
new SoGetMatrixAction(SbViewportRegion());
164 sa.setNode(manip.get());
165 sa.setSearchingAll(TRUE);
166 SoBaseKit::setSearchingChildren(TRUE);
169 action->apply(sa.getPath());
171 SbMatrix matrix = action->getMatrix();
174 mat(0, 0) = matrix[0][0];
175 mat(0, 1) = matrix[1][0];
176 mat(0, 2) = matrix[2][0];
177 mat(0, 3) = matrix[3][0] * 1000;
179 mat(1, 0) = matrix[0][1];
180 mat(1, 1) = matrix[1][1];
181 mat(1, 2) = matrix[2][1];
182 mat(1, 3) = matrix[3][1] * 1000;
184 mat(2, 0) = matrix[0][2];
185 mat(2, 1) = matrix[1][2];
186 mat(2, 2) = matrix[2][2];
187 mat(2, 3) = matrix[3][2] * 1000;
189 mat(3, 0) = matrix[0][3];
190 mat(3, 1) = matrix[1][3];
191 mat(3, 2) = matrix[2][3];
192 mat(3, 3) = matrix[3][3];
197 if (this->hasEndEffectorVisualizer)
199 mat = mat * this->localTransformation;
213 std::stringstream buffer;
222 if (this->hasEndEffectorVisualizer)
224 globalPose = globalPose * this->localTransformation.inverse();
226 globalPose(0, 3) /= 1000;
227 globalPose(1, 3) /= 1000;
228 globalPose(2, 3) /= 1000;
229 manip->setMatrix(VirtualRobot::CoinVisualizationFactory::getSbMatrix(globalPose));