vsg  1.1.0
VulkanSceneGraph library
Light.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2022 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/maths/common.h>
16 #include <vsg/nodes/Node.h>
17 
18 namespace vsg
19 {
20 
24  class VSG_DECLSPEC Light : public Inherit<Node, Light>
25  {
26  public:
27  std::string name;
28  vec3 color = vec3(1.0f, 1.0f, 1.0f);
29  float intensity = 1.0f;
30  uint32_t shadowMaps = 0;
31 
32  void read(Input& input) override;
33  void write(Output& output) const override;
34 
35  protected:
36  virtual ~Light() {}
37  };
38  VSG_type_name(vsg::Light);
39 
41  class VSG_DECLSPEC AmbientLight : public Inherit<Light, AmbientLight>
42  {
43  public:
44  void read(Input& input) override;
45  void write(Output& output) const override;
46 
47  protected:
48  virtual ~AmbientLight() {}
49  };
50  VSG_type_name(vsg::AmbientLight);
51 
53  class VSG_DECLSPEC DirectionalLight : public Inherit<Light, DirectionalLight>
54  {
55  public:
56  dvec3 direction = dvec3(0.0, 0.0, -1.0);
57 
58  void read(Input& input) override;
59  void write(Output& output) const override;
60 
61  protected:
62  virtual ~DirectionalLight() {}
63  };
64  VSG_type_name(vsg::DirectionalLight);
65 
67  class VSG_DECLSPEC PointLight : public Inherit<Light, PointLight>
68  {
69  public:
70  dvec3 position = dvec3(0.0, 0.0, 0.0);
71 
72  void read(Input& input) override;
73  void write(Output& output) const override;
74 
75  protected:
76  virtual ~PointLight() {}
77  };
78  VSG_type_name(vsg::PointLight);
79 
81  class VSG_DECLSPEC SpotLight : public Inherit<Light, SpotLight>
82  {
83  public:
84  dvec3 position = dvec3(0.0, 0.0, 0.0);
85  dvec3 direction = dvec3(0.0, 0.0, -1.0);
86  double innerAngle = radians(30.0);
87  double outerAngle = radians(45.0);
88 
89  void read(Input& input) override;
90  void write(Output& output) const override;
91 
92  protected:
93  virtual ~SpotLight() {}
94  };
95  VSG_type_name(vsg::SpotLight);
96 
98  extern VSG_DECLSPEC ref_ptr<vsg::Node> createHeadlight();
99 
100 } // namespace vsg
AmbientLight represents an ambient light source.
Definition: Light.h:42
DirectionalLight represents a directional light source - used for light sources that are treated as i...
Definition: Light.h:54
Definition: Inherit.h:28
Definition: Input.h:44
Definition: Light.h:25
Definition: Output.h:41
PointLight represents a local point light source where all light radiants event from the light positi...
Definition: Light.h:68
SpotLight represents a local point light source whose intensity varies as a spot light.
Definition: Light.h:82