gramods
Node.hh
1 
2 #ifndef GRAMODS_GRAPHICS_NODE
3 #define GRAMODS_GRAPHICS_NODE
4 
5 #include <gmGraphics/config.hh>
6 
7 #include <gmGraphics/Camera.hh>
8 #include <gmGraphics/IntersectionLine.hh>
9 
10 #include <gmCore/Object.hh>
11 
12 #include <Eigen/Eigen>
13 #include <vector>
14 
15 BEGIN_NAMESPACE_GMGRAPHICS;
16 
20 class Node : public gmCore::Object {
21 
22 public:
23 
24  typedef std::vector<std::shared_ptr<Node>> list;
25 
37 
38  void apply(gmCore::Object *node) override { Visitor::apply(node); }
39  void apply(Object *node, const Eigen::Affine3f &transform);
40 
41  std::vector<Eigen::Affine3f> stack {Eigen::Affine3f::Identity()};
42  };
43 
57 
58  NearFarVisitor(Camera camera) : camera(camera) {}
59 
60  void apply(gmCore::Object *node) override;
61 
66  std::optional<std::pair<float, float>> getNearFar() const;
67 
68  const Camera camera;
69  float near = std::numeric_limits<float>::max();
70  float far = std::numeric_limits<float>::min();
71  };
72 
85 
86  RenderVisitor(Camera camera)
87  : camera(camera) {}
88 
89  void apply(gmCore::Object *node) override;
90 
91  const Camera camera;
92  };
93 
98  virtual std::vector<float> getIntersections(const IntersectionLine &line) {
99  return {};
100  }
101 
106  virtual std::string getDefaultKey() override { return "node"; }
107 };
108 
109 END_NAMESPACE_GMGRAPHICS;
110 
111 #endif
Base type for objects in the Gramods package for standardized handling of construction,...
Definition: Object.hh:42
The base of graphics Camera implementations.
Definition: Camera.hh:19
The scenegraph node base.
Definition: Node.hh:20
virtual std::string getDefaultKey() override
Returns the default key, in Configuration, for the Object.
Definition: Node.hh:106
virtual std::vector< float > getIntersections(const IntersectionLine &line)
Check and return intersections between the provided line and the shape represented by this node.
Definition: Node.hh:98
The visitor of a design pattern for automatic traversal.
Definition: Object.hh:75
Line for intersection with ray or segment.
Definition: IntersectionLine.hh:15
Visitor that extracts the optimal near and far planes for a scenegraph.
Definition: Node.hh:56
Visitor that renders a scenegraph to the currently active viewport.
Definition: Node.hh:84
Base for Visitor:s that need to track the space transform through traversal.
Definition: Node.hh:36
void apply(gmCore::Object *node) override
This method is called for each visited objects.
Definition: Node.hh:38