TAMSVIZ
Visualization and annotation tool for ROS
axes.cpp
1 // TAMSVIZ
2 // (c) 2020 Philipp Ruppel
3 
4 #include "axes.h"
5 
6 #include "shapes.h"
7 
8 MeshData makeAxes(double length, double radius, size_t segments) {
9  MeshData mesh;
10  mesh += makeCylinder(segments)
11  .colorize(1, 0, 0)
12  .scale(radius, radius, length * 0.5)
13  .translate(0, 0, length * 0.5)
14  .rotate(M_PI * 0.5, Eigen::Vector3f::UnitY());
15  mesh += makeCylinder(segments)
16  .colorize(0, 1, 0)
17  .scale(radius, radius, length * 0.5)
18  .translate(0, 0, length * 0.5)
19  .rotate(M_PI * -0.5, Eigen::Vector3f::UnitX());
20  mesh += makeCylinder(segments)
21  .colorize(0, 0, 1)
22  .scale(radius, radius, length * 0.5)
23  .translate(0, 0, length * 0.5);
24  return mesh;
25 }
26 
27 void AxesDisplay::renderSync(const RenderSyncContext &context) {
28  if (_watcher.changed(length(), radius())) {
29  _mesh_renderer = node()->create<MeshRenderer>(
30  std::make_shared<Mesh>(makeAxes(length(), radius(), 32)), material());
31  _mesh_renderer->pose(Eigen::Isometry3d::Identity());
32  }
33  FrameDisplayBase::renderSync(context);
34 }
Definition: mesh.h:11