45 const QColor& qcolor = color_property->
getColor();
46 std_msgs::ColorRGBA color;
47 color.r = qcolor.redF();
48 color.g = qcolor.greenF();
49 color.b = qcolor.blueF();
50 color.a = (alpha_property ==
nullptr) ? 1.0 : alpha_property->
getFloat();
55 : scene_manager_(scene_manager), scene_node_(scene_node)
75 manual_object_->begin(
"BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_STRIP);
76 for (
const nav_2d_msgs::Point2D& msg_point : polygon.points)
85 const std::string& material_name)
107 nav_2d_msgs::ComplexPolygon2D complex;
108 complex.outer = polygon;
116 if (vertices.empty())
120 unsigned int vertex_count = vertices.size();
136 for (
unsigned int i = 0; i < vertex_count; i += 3)
138 std::vector<Ogre::Vector3> corners(3);
139 for (
size_t c = 0; c < 3; c++)
141 corners[c] = Ogre::Vector3(vertices[i + c].
x, vertices[i + c].
y, z_offset);
143 Ogre::Vector3 normal = (corners[1] - corners[0]).crossProduct(corners[2] - corners[0]);
146 for (
size_t c = 0; c < 3; c++)
158 static uint32_t count = 0;
160 ss <<
"PolygonMaterial" << count++;
162 material_ = Ogre::MaterialManager::getSingleton().create(name_,
"rviz");
163 material_->setReceiveShadows(
false);
164 material_->setCullingMode(Ogre::CULL_NONE);
166 Ogre::Technique* technique = material_->getTechnique(0);
167 technique->setLightingEnabled(
false);
168 technique->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
169 technique->setDepthWriteEnabled(
false);
175 Ogre::MaterialManager::getSingleton().remove(name_);
181 "Draw the outline, the filled-in polygon, or both", parent, changed_slot);
182 property_->addOption(
"Outline", static_cast<int>(DisplayMode::OUTLINE));
183 property_->addOption(
"Filled", static_cast<int>(DisplayMode::FILLED));
184 property_->addOption(
"Filled Outline", static_cast<int>(DisplayMode::FILLED_OUTLINE));
virtual QColor getColor() const
void setPolygon(const nav_2d_msgs::Polygon2D &polygon, const Ogre::ColourValue &color, double z_offset)
Set the object to display the outline of the given polygon, in a specific color, possibly offset in z...
Ogre::SceneManager & scene_manager_
std::string material_name_
std::vector< nav_2d_msgs::Point2D > triangulate(const nav_2d_msgs::ComplexPolygon2D &polygon)
Ogre::SceneNode & scene_node_
Ogre::SceneNode & scene_node_
Ogre::SceneManager & scene_manager_
PolygonOutline(Ogre::SceneManager &scene_manager, Ogre::SceneNode &scene_node)
virtual float getFloat() const
TFSIMD_FORCE_INLINE const tfScalar & y() const
virtual ~PolygonOutline()
std_msgs::ColorRGBA getColor(rviz::ColorProperty *color_property, rviz::FloatProperty *alpha_property=nullptr)
Given a Color Property and an optional Float property, return a ROS Color message.
Ogre::ManualObject * manual_object_
Several reusable pieces for displaying polygons.
PolygonDisplayModeProperty(rviz::Property *parent, const char *changed_slot=0)
virtual ~PolygonMaterial()
TFSIMD_FORCE_INLINE const tfScalar & x() const
void setPolygon(const nav_2d_msgs::Polygon2D &polygon, const std_msgs::ColorRGBA &color, double z_offset)
Set the object to display the area of the given polygon, in a specific color, possibly offset in z...
Ogre::ManualObject * manual_object_
PolygonFill(Ogre::SceneManager &scene_manager, Ogre::SceneNode &scene_node, const std::string &material_name)
unsigned int last_vertex_count_