Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
draw_node.hpp
1 // Copyright [2015] Albert Huang
2 
3 #ifndef SCENEVIEW_DRAW_NODE_HPP__
4 #define SCENEVIEW_DRAW_NODE_HPP__
5 
6 #include <memory>
7 #include <utility>
8 #include <vector>
9 
10 #include <sceneview/drawable.hpp>
11 #include <sceneview/scene_node.hpp>
12 #include <sceneview/geometry_resource.hpp>
13 #include <sceneview/material_resource.hpp>
14 
15 namespace sv {
16 
17 class Drawable;
18 class DrawGroup;
19 
26 class DrawNode : public SceneNode {
27  public:
28  virtual ~DrawNode();
29 
30  SceneNodeType NodeType() const override { return SceneNodeType::kDrawNode; }
31 
38  void Add(const Drawable::Ptr& drawable);
39 
49  void Add(const GeometryResource::Ptr& geometry,
50  const MaterialResource::Ptr& material);
51 
55  const std::vector<Drawable::Ptr>& Drawables() const;
56 
57  const AxisAlignedBox& WorldBoundingBox() override;
58 
59  protected:
60  void BoundingBoxChanged() override;
61 
62  private:
63  DrawGroup* GetDrawGroup() { return draw_group_; }
64 
65  void SetDrawGroup(DrawGroup* draw_group) {
66  draw_group_ = draw_group; }
67 
68  friend class Scene;
69 
70  friend class Drawable;
71 
72  explicit DrawNode(const QString& name);
73 
74  std::vector<Drawable::Ptr> drawables_;
75 
76  AxisAlignedBox bounding_box_;
77  bool bounding_box_dirty_;
78 
79  DrawGroup* draw_group_ = nullptr;
80 };
81 
82 } // namespace sv
83 
84 #endif // SCENEVIEW_DRAW_NODE_HPP__
Pure virtual class that all scene graph nodes inherit.
Definition: scene_node.hpp:41
void BoundingBoxChanged() override
Internal method, used to enable lazy bounding box computations.
const AxisAlignedBox & WorldBoundingBox() override
Retrieve the world-space bounding box of the node and all of its children (if applicable).
An axis-aligned box typically used for bounding box and intersection calculations.
Definition: axis_aligned_box.hpp:17
Scene node that contains a list of drawable objects.
Definition: draw_node.hpp:26
SceneNodeType NodeType() const override
Retrieve the node type.
Definition: draw_node.hpp:30
const std::vector< Drawable::Ptr > & Drawables() const
Retrieve a list of the drawables attached to the node.
Definition: draw_group.hpp:22
SceneNodeType
Specifies a scene node type.
Definition: scene_node.hpp:19
void Add(const Drawable::Ptr &drawable)
Attaches a generic drawable item to the node.