diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h b/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h index 60c75f043990181f4074d1dc2e2f82780e0dd8b3..0af38c88082785ac1173e3a24594ee342689025c 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationPointCloud.h @@ -56,8 +56,7 @@ namespace armarx::viz::coin pclCoords->point.setValues(0, coords.size(), coords.data()); - // TODO: Make configurable - pclStye->pointSize = 1.0f; + pclStye->pointSize = element.pointSizeInPixels; return true; } diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp index c71a0b4fa329d292153ec349148015ada038bc6b..075f05b3cdaa90dc13635972e7d95a9f20fea4dc 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.cpp @@ -133,7 +133,7 @@ namespace armarx::viz::coin robot.setJointValues(element.jointValues); - if (loadedDrawStyle == ModelDrawStyle_COLLISION_MODEL) + if (loadedDrawStyle & ModelDrawStyle_OVERRIDE_COLOR) { int numChildren = node->getNumChildren(); for (int i = 0; i < numChildren; i++) @@ -143,7 +143,7 @@ namespace armarx::viz::coin SoMaterial* m = dynamic_cast<SoMaterial*>(nodeSep->getChild(0)); if (!m) { - ARMARX_WARNING << "Errir at node with index: " << i; + ARMARX_WARNING << "Error at node with index: " << i; continue; } @@ -161,10 +161,10 @@ namespace armarx::viz::coin return true; } - void VisualizationRobot::recreateVisualizationNodes(ModelDrawStyle drawStyle) + void VisualizationRobot::recreateVisualizationNodes(int drawStyle) { VirtualRobot::SceneObject::VisualizationType visuType = VirtualRobot::SceneObject::Full; - if (drawStyle == ModelDrawStyle_COLLISION_MODEL) + if (drawStyle & ModelDrawStyle_COLLISION) { visuType = VirtualRobot::SceneObject::Collision; } diff --git a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h index 88f77459ebc4a2a238ff4903c2f451cc7e0234c6..15c81347abea9dc26e14de426feda46b8eaa8c07 100644 --- a/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h +++ b/source/RobotAPI/components/ArViz/Coin/VisualizationRobot.h @@ -21,10 +21,10 @@ namespace armarx::viz::coin bool update(ElementType const& element); - void recreateVisualizationNodes(ModelDrawStyle drawStyle); + void recreateVisualizationNodes(int drawStyle); LoadedRobot loaded; - ModelDrawStyle loadedDrawStyle = ModelDrawStyle_FULL_MODEL; + int loadedDrawStyle = ModelDrawStyle_ORIGINAL; }; void clearRobotCache(); diff --git a/source/RobotAPI/components/ArVizExample/ArVizExample.cpp b/source/RobotAPI/components/ArVizExample/ArVizExample.cpp index 36ecf8132771c070190869eea8f6cc948f7741d1..94e5ccc5894a32bb8f761b22cb95675530f370ac 100644 --- a/source/RobotAPI/components/ArVizExample/ArVizExample.cpp +++ b/source/RobotAPI/components/ArVizExample/ArVizExample.cpp @@ -382,9 +382,31 @@ namespace armarx::viz return *this; } - Robot& drawStyle(ModelDrawStyle style) + // Encapsulate this + Robot& useCollisionModel() { - data_->drawStyle = style; + data_->drawStyle |= ModelDrawStyle_COLLISION; + + return *this; + } + + Robot& useFullModel() + { + data_->drawStyle &= ~ModelDrawStyle_COLLISION; + + return *this; + } + + Robot& overrideColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255) + { + data_->drawStyle |= ModelDrawStyle_OVERRIDE_COLOR; + + return color(r, g, b, a); + } + + Robot& useOriginalColor() + { + data_->drawStyle &= ~ModelDrawStyle_OVERRIDE_COLOR; return *this; } @@ -649,9 +671,18 @@ void fillExampleLayer(viz::Layer& layer, double timeInSeconds) viz::Robot robot = viz::Robot("robot") .position(pos) - .file("Armar6RT", "Armar6RT/robotmodel/Armar6-SH/Armar6-SH.xml") - .drawStyle(viz::ModelDrawStyle_FULL_MODEL) - .color(128, 128, 255); + .file("Armar6RT", "Armar6RT/robotmodel/Armar6-SH/Armar6-SH.xml"); + + // Full model + if (true) + { + robot.useFullModel(); + } + else + { + robot.useCollisionModel() + .overrideColor(0, 255, 128, 128); + } float value = 0.5f * (1.0f + std::sin(timeInSeconds)); robot.joint("ArmR2_Sho1", value); diff --git a/source/RobotAPI/interface/ArViz/Elements.ice b/source/RobotAPI/interface/ArViz/Elements.ice index cdd75351e3a522ebc384336a4a9e31913e048876..6745ceb88d957e191cbd3ec0b802bb2f5cbb7be9 100644 --- a/source/RobotAPI/interface/ArViz/Elements.ice +++ b/source/RobotAPI/interface/ArViz/Elements.ice @@ -104,6 +104,7 @@ module viz { ColoredPointList points; float transparency = 0.0f; + float pointSizeInPixels = 1.0f; }; sequence<Color> ColorSeq; @@ -127,17 +128,18 @@ module viz FaceSeq faces; }; - enum ModelDrawStyle + enum ModelDrawStyleFlags { - ModelDrawStyle_FULL_MODEL, - ModelDrawStyle_COLLISION_MODEL + ModelDrawStyle_ORIGINAL = 0, + ModelDrawStyle_COLLISION = 1, + ModelDrawStyle_OVERRIDE_COLOR = 2, }; class ElementRobot extends Element { string project; string filename; - ModelDrawStyle drawStyle = ModelDrawStyle_COLLISION_MODEL; + int drawStyle = ModelDrawStyle_ORIGINAL; StringFloatDictionary jointValues; };