TAMSVIZ
Visualization and annotation tool for ROS
mesh.h
1 // TAMSVIZ
2 // (c) 2020 Philipp Ruppel
3 
4 #pragma once
5 
6 #include <memory>
7 
8 #include <Eigen/Dense>
9 
10 #include "../render/renderlist.h"
11 
12 #include "node.h"
13 
14 class MaterialRenderer;
15 class Mesh;
16 class RenderAsyncContext;
17 class RenderSyncContext;
18 class MeshDisplayBase;
19 class Material;
20 class MaterialOverride;
21 class RenderOptions;
22 class Interaction;
23 
24 class MeshRenderer : public SceneNode {
25 protected:
26  std::shared_ptr<MaterialRenderer> _material;
27  std::shared_ptr<Mesh> _mesh;
28  RenderOptions _render_options, _render_options_2;
29  std::function<void(const Interaction &)> _interact_callback;
30  Eigen::Affine3d _parent_pose = Eigen::Affine3d::Identity();
31 
32 public:
33  MeshRenderer(const MeshRenderer &) = delete;
34  MeshRenderer &operator=(const MeshRenderer &) = delete;
35  MeshRenderer(const std::shared_ptr<Mesh> &mesh,
36  const std::shared_ptr<MaterialRenderer> &material);
38  const std::shared_ptr<Mesh> &mesh,
39  std::shared_ptr<const Material> material,
40  std::shared_ptr<const MaterialOverride> material_override = nullptr);
41  MeshRenderer(const std::shared_ptr<Mesh> &mesh,
42  std::shared_ptr<const Material> material,
43  const Eigen::Isometry3d &pose);
45  const std::shared_ptr<Mesh> &mesh,
46  std::shared_ptr<const Material> material,
47  const std::function<void(const Interaction &)> &interact_callback);
48  ~MeshRenderer();
49  virtual bool pick(uint32_t id) const override;
50  virtual bool interact(const Interaction &interaction) override;
51  virtual void renderSync(const RenderSyncContext &context) override;
52  virtual void renderAsync(const RenderAsyncContext &context) override;
53  const std::shared_ptr<Mesh> &mesh() const;
54  const std::shared_ptr<MaterialRenderer> &materialRenderer();
55  void options(const RenderOptions &options);
56  const RenderOptions &options() const;
57  RenderOptions &options();
58 };
59 
61  std::vector<Eigen::Isometry3d, Eigen::aligned_allocator<Eigen::Isometry3d>>
62  _poses;
63 
64 public:
65  InstancedMeshRenderer(const std::shared_ptr<Mesh> &mesh,
66  std::shared_ptr<const Material> material);
67  void clearInstances();
68  void addInstance(const Eigen::Isometry3d &pose);
69  virtual void renderAsync(const RenderAsyncContext &context) override;
70 };
Definition: mesh.h:49
Definition: node.h:20