53 manager_(manager), outer_radius_(outer_radius),
54 inner_radius_(inner_radius), name_(name), polygon_type_(CIRCLE)
56 manual_ = manager->createManualObject();
85 Ogre::RenderOperation::OT_TRIANGLE_STRIP);
92 double theta = 2.0 * M_PI / resolution * i;
93 double next_theta = 2.0 * M_PI / resolution * (i + 1);
98 manual_->textureCoord((1 + radius_ratio *
cos(theta)) / 2.0,
99 (1.0 - radius_ratio *
sin(theta)) / 2.0);
105 (1.0 -
sin(theta)) / 2.0);
110 manual_->textureCoord((1 + radius_ratio *
cos(next_theta)) / 2.0,
111 (1.0 - radius_ratio *
sin(next_theta)) / 2.0);
116 manual_->textureCoord((1 +
cos(next_theta)) / 2.0,
117 (1.0 -
sin(next_theta)) / 2.0);
160 const std::string name):
161 width_(width), height_(height),
name_(name)
163 texture_ = Ogre::TextureManager::getSingleton().createManual(
165 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
172 material_ = Ogre::MaterialManager::getSingleton().create(
174 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
176 material_->getTechnique(0)->getPass(0)->createTextureUnitState(
179 material_->getTechnique(0)->setLightingEnabled(
true);
180 material_->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE);
181 material_->getTechnique(0)->getPass(0)->setLightingEnabled(
false);
182 material_->getTechnique(0)->getPass(0)->setDepthWriteEnabled(
false);
183 material_->getTechnique(0)->getPass(0)->setDepthCheckEnabled(
true);
185 material_->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre::TVC_DIFFUSE);
186 material_->getTechnique(0)->getPass(0)->createTextureUnitState(
texture_->getName());
187 material_->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
190 ->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
199 Ogre::MaterialManager::getSingleton().remove(
material_->getName());
209 return name_ +
"Material";
213 Ogre::SceneNode* parent,
215 scene_manager_(manager), size_(size), enable_(true), text_(
"")
217 node_ = parent->createChildSceneNode();
222 node_->detachAllObjects();
228 node_->setPosition(pos);
235 Ogre::Camera* camera = panel->
getCamera();
236 Ogre::Quaternion
q = camera->getDerivedOrientation();
242 node_->setOrientation(rot);
271 color_.r = color.red() / 255.0;
272 color_.g = color.green() / 255.0;
273 color_.b = color.blue() / 255.0;
284 Ogre::SceneManager* manager,
285 Ogre::SceneNode* parent,
299 msg_->setVisible(
false);
302 target_text_node_->attachObject(
msg_);
323 Ogre::MaterialManager::getSingleton().remove(
upper_material_->getName());
324 Ogre::MaterialManager::getSingleton().remove(
lower_material_->getName());
325 Ogre::MaterialManager::getSingleton().remove(
left_material_->getName());
326 Ogre::MaterialManager::getSingleton().remove(
right_material_->getName());
344 msg_->setVisible(
false);
349 const double size_factor = 0.15;
354 Ogre::RenderOperation::OT_TRIANGLE_LIST);
360 size_ * size_factor * 2,
364 size_ * size_factor * 2,
372 Ogre::RenderOperation::OT_TRIANGLE_LIST);
376 -
size_ * size_factor,
380 -
size_ * size_factor * 2,
384 -
size_ * size_factor * 2,
391 Ogre::RenderOperation::OT_TRIANGLE_LIST);
403 -
size_ * size_factor,
411 Ogre::RenderOperation::OT_TRIANGLE_LIST);
423 -
size_ * size_factor,
429 upper_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
432 lower_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
435 left_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
438 right_material_->getTechnique(0)->setSceneBlending( Ogre::SBT_TRANSPARENT_ALPHA );
446 static uint32_t
count = 0;
448 ss <<
"TargetVisualizerDisplayTriangle" << count++;
460 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
463 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
466 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
469 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
471 upper_material_->setReceiveShadows(
false);
472 upper_material_->getTechnique(0)->setLightingEnabled(
true);
473 upper_material_->setCullingMode(Ogre::CULL_NONE);
511 for (
size_t i = 0; i < resolution + 1; i++) {
512 double x =
size_ *
cos(i * 2 * M_PI / resolution);
513 double y =
size_ *
sin(i * 2 * M_PI / resolution);
526 Ogre::Vector3 text_position(
size_ *
cos(45.0 / 180.0 * M_PI)
532 Ogre::Vector3 msg_size =
msg_->
GetAABB().getSize();
539 Ogre::Vector3
A(
size_ *
cos(45.0 / 180.0 * M_PI),
542 Ogre::Vector3 B(text_position + Ogre::Vector3(-
size_ / 4.0, 0, 0));
543 Ogre::Vector3 C(text_position + Ogre::Vector3(msg_size[0], 0, 0));
560 msg_->setVisible(enable);
587 Ogre::SceneNode* parent,
592 static int count = 0;
593 ss <<
"FacingVisualizer" << count++;
609 Ogre::SceneNode* parent,
623 QColor transparent(0, 0, 0, 0);
625 QColor white(255, 255, 255,
color_.a * 255);
626 QImage Hud = buffer.
getQImage(128, 128, transparent);
628 double inner_line_width = 10;
637 double mouse_cy_offset = 5;
639 QPainter painter( &Hud );
640 painter.setRenderHint(QPainter::Antialiasing,
true);
641 painter.setPen(QPen(foreground, line_width, Qt::SolidLine));
642 painter.setBrush(white);
643 painter.drawEllipse(line_width / 2.0, line_width / 2.0,
644 l - line_width, l - line_width);
645 double offset_rate = fmod(now.
toSec(), 10) / 10.0;
646 double theta_offset = offset_rate * M_PI * 2.0;
647 for (
size_t ci = 0; ci < text.length(); ci++) {
648 double theta = M_PI * 2.0 / text.length() * ci + theta_offset;
650 QFont
font(
"DejaVu Sans Mono");
651 font.setPointSize(8);
653 painter.setFont(font);
654 painter.translate(cx + r *
cos(theta),
655 cy + r *
sin(theta));
656 painter.rotate(theta / M_PI * 180 + 90);
657 painter.drawText(0, 0, text.substr(ci, 1).c_str());
660 painter.setPen(QPen(foreground, inner_line_width, Qt::SolidLine));
661 painter.setBrush(transparent);
662 painter.drawEllipse(cx - inner_r, cy - inner_r,
663 inner_r * 2, inner_r * 2);
664 double mouse_c_x = cx;
665 double mouse_c_y = cy - mouse_cy_offset;
666 double start_angle = -25 * M_PI / 180;
667 double end_angle = -125 * M_PI / 180;
668 painter.setPen(QPen(foreground, line_width, Qt::SolidLine));
669 painter.drawChord(mouse_c_x - mouse_r, mouse_c_y - mouse_r,
670 2.0 * mouse_r, 2.0 * mouse_r,
671 start_angle * 180 / M_PI * 16,
672 end_angle * 180 / M_PI * 16);
virtual void setSize(double size)
std::string upper_material_name_
Ogre::TexturePtr texture_
virtual std::string getMaterialName()
virtual ScopedPixelBuffer getBuffer()
virtual void setPosition(Ogre::Vector3 &pos)
Ogre::ManualObject * right_arrow_
virtual void rebuildPolygon()
void addPoint(const Ogre::Vector3 &point)
virtual QImage getQImage(unsigned int width, unsigned int height)
virtual void updateColor()=0
virtual void setText(std::string text)
TextureObject(const int width, const int height, const std::string name)
virtual void update(float wall_dt, float ros_dt)
PolygonType polygon_type_
TextureObject::Ptr texture_object_
virtual ViewManager * getViewManager() const =0
virtual void updateLine()
Ogre::MaterialPtr material_
FacingObject(Ogre::SceneManager *manager, Ogre::SceneNode *parent, double size)
virtual void updateText()
std::string lower_material_name_
virtual void setAlpha(double alpha)
SquareObject::Ptr square_object_
const double minimum_font_size
void setCharacterHeight(Ogre::Real height)
rviz::BillboardLine * text_under_line_
FacingTexturedObject(Ogre::SceneManager *manager, Ogre::SceneNode *parent, double size)
virtual void updateText()=0
Ogre::MaterialPtr left_material_
virtual void setOrientation(rviz::DisplayContext *context)
Ogre::SceneNode * getSceneNode()
Ogre::SceneNode * lower_arrow_node_
virtual void setColor(float r, float g, float b, float a)
Ogre::ManualObject * left_arrow_
virtual void createArrows(rviz::DisplayContext *context)
virtual Ogre::ManualObject * getManualObject()
virtual void setText(std::string text)
virtual void setEnable(bool enable)
Ogre::SceneNode * target_text_node_
virtual void setSize(double size)
Ogre::ManualObject * manual_
virtual void updateColor()
Ogre::SceneNode * right_arrow_node_
virtual void setAnonymous(bool anonymous)
std::string right_material_name_
QColor ogreToQt(const Ogre::ColourValue &c)
const float arrow_animation_duration
void setCaption(const Ogre::String &caption)
virtual void setPolygonType(PolygonType type)
virtual void setOuterRadius(double outer_radius)
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
virtual void setColor(QColor color)
void setNumLines(uint32_t num)
void setMaxPointsPerLine(uint32_t max)
virtual void updateArrowsObjects(Ogre::ColourValue color)
virtual void setSize(double size)
virtual ~SimpleCircleFacingVisualizer()
virtual Ogre::SceneManager * getSceneManager() const =0
SquareObject(Ogre::SceneManager *manager, double outer_radius, double inner_radius, std::string name)
Ogre::MaterialPtr lower_material_
void setColor(const Ogre::ColourValue &color)
virtual void setSize(double size)
std::string left_material_name_
Ogre::AxisAlignedBox GetAABB(void)
Ogre::Camera * getCamera() const
rviz::BillboardLine * line_
Ogre::SceneManager * scene_manager_
Ogre::SceneNode * left_arrow_node_
Ogre::SceneManager * manager_
Ogre::MaterialPtr right_material_
virtual void setEnable(bool enable)
SimpleCircleFacingVisualizer(Ogre::SceneManager *manager, Ogre::SceneNode *parent, rviz::DisplayContext *context, double size, std::string text="")
virtual void updateTextUnderLine()
RenderPanel * getRenderPanel() const
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
virtual void update(float wall_dt, float ros_dt)
Ogre::SceneNode * upper_arrow_node_
Ogre::ManualObject * lower_arrow_
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
Ogre::ManualObject * upper_arrow_
void setLineWidth(float width)
Ogre::MaterialPtr upper_material_
virtual void setInnerRadius(double inner_radius)
GISCircleVisualizer(Ogre::SceneManager *manager, Ogre::SceneNode *parent, double size, std::string text="")