vsg  1.1.0
VulkanSceneGraph library
View.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/app/Camera.h>
16 #include <vsg/app/Window.h>
17 #include <vsg/nodes/Group.h>
18 
19 namespace vsg
20 {
21 
22  // forward declare
23  class ViewDependentState;
24 
26  enum ViewFeatures
27  {
28  INHERIT_VIEWPOINT = (1 << 0),
29  RECORD_LIGHTS = (1 << 1),
30  RECORD_SHADOW_MAPS = (1 << 2),
31  RECORD_ALL = (RECORD_LIGHTS | RECORD_SHADOW_MAPS)
32  };
33 
35  class VSG_DECLSPEC View : public Inherit<Group, View>
36  {
37  public:
38  View(ViewFeatures in_features = RECORD_ALL);
39 
40  // share the specified view's children, viewID, mask and camera ViewportState
41  View(const View& view);
42 
43  explicit View(ref_ptr<Camera> in_camera, ref_ptr<Node> in_scenegraph = {}, ViewFeatures in_features = RECORD_ALL);
44 
45  template<class N, class V>
46  static void t_accept(N& node, V& visitor)
47  {
48  if ((visitor.traversalMask & (visitor.overrideMask | node.mask)) == MASK_OFF) return;
49 
50  auto cached_traversalMask = visitor.traversalMask;
51 
52  visitor.traversalMask = visitor.traversalMask & node.mask;
53 
54  visitor.apply(node);
55 
56  visitor.traversalMask = cached_traversalMask;
57  }
58 
59  void accept(Visitor& visitor) override { t_accept(*this, visitor); }
60  void accept(ConstVisitor& visitor) const override { t_accept(*this, visitor); }
61  void accept(RecordTraversal& visitor) const override { t_accept(*this, visitor); }
62 
64  void share(const View& view);
65 
68 
70  const uint32_t viewID = 0;
71 
73  ViewFeatures features;
74 
78  Mask mask = MASK_ALL;
79 
81  std::vector<ref_ptr<Bin>> bins;
82 
85 
87  GraphicsPipelineStates overridePipelineStates;
88 
89  protected:
90  virtual ~View();
91  };
92  VSG_type_name(vsg::View);
93 
94 } // namespace vsg
Definition: ConstVisitor.h:147
Definition: Inherit.h:28
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition: RecordTraversal.h:61
View is a Group class that pairs a Camera that defines the view with a subgraph that defines the scen...
Definition: View.h:36
ref_ptr< ViewDependentState > viewDependentState
view dependent state used for positional state like lighting, texgen and clipping
Definition: View.h:84
void share(const View &view)
share the specified view's viewID, mask, camera ViewportState, with this View
GraphicsPipelineStates overridePipelineStates
override states for customization of graphics pipelines for this view
Definition: View.h:87
ViewFeatures features
Hints for how ViewDependentState features should be handled.
Definition: View.h:73
Mask mask
Definition: View.h:78
std::vector< ref_ptr< Bin > > bins
bins
Definition: View.h:81
ref_ptr< Camera > camera
camera controls the viewport state and projection and view matrices
Definition: View.h:67
Definition: Visitor.h:147
Definition: ref_ptr.h:22