Sceneview
 All Classes Functions Variables Enumerations Enumerator Groups Pages
light_node.hpp
1 // Copyright [2015] Albert Huang
2 
3 #ifndef SCENEVIEW_LIGHT_NODE_HPP__
4 #define SCENEVIEW_LIGHT_NODE_HPP__
5 
6 #include <memory>
7 #include <vector>
8 
9 #include <sceneview/scene_node.hpp>
10 
11 namespace sv {
12 
18 enum class LightType {
19  kPoint,
20  kDirectional,
21  kSpot
22 };
23 
32 class LightNode : public SceneNode {
33  public:
34  virtual ~LightNode() {}
35 
36  SceneNodeType NodeType() const override {
37  return SceneNodeType::kLightNode; }
38 
42  void SetLightType(LightType light_type) { light_type_ = light_type; }
43 
44  LightType GetLightType() const { return light_type_; }
45 
46  void SetDirection(const QVector3D& dir) { direction_ = dir; }
47 
53  const QVector3D& Direction() const { return direction_; }
54 
55  float Ambient() const { return ambient_; }
56 
60  void SetAmbient(const float ambient) { ambient_ = ambient; }
61 
62  float Specular() const { return specular_; }
63 
67  void SetSpecular(const float specular) { specular_ = specular;}
68 
69  const QVector3D& Color() const { return color_; }
70 
71  void SetColor(const QVector3D& color) { color_ = color; }
72 
78  void SetAttenuation(const float val) { attenuation_ = val; }
79 
80  float Attenuation() const { return attenuation_; }
81 
87  void SetConeAngle(float cone_angle_deg) {
88  cone_angle_deg_ = cone_angle_deg;
89  }
90 
94  float ConeAngle() const { return cone_angle_deg_; }
95 
99  void SetScale(const QVector3D& vec) override;
100 
101  const AxisAlignedBox& WorldBoundingBox() override;
102 
103  private:
104  friend class Scene;
105 
106  explicit LightNode(const QString& name);
107 
108  static const AxisAlignedBox kBoundingBox;
109 
110  LightType light_type_;
111  QVector3D direction_;
112  QVector3D color_;
113  float ambient_;
114  float specular_;
115  float attenuation_;
116  float cone_angle_deg_;
117 };
118 
119 } // namespace sv
120 
121 #endif // SCENEVIEW_LIGHT_NODE_HPP__
Pure virtual class that all scene graph nodes inherit.
Definition: scene_node.hpp:41
void SetConeAngle(float cone_angle_deg)
Sets the light cone angle (in degrees).
Definition: light_node.hpp:87
void SetAmbient(const float ambient)
Sets the ambient coefficient for this light.
Definition: light_node.hpp:60
void SetAttenuation(const float val)
Sets the attenuation factor.
Definition: light_node.hpp:78
An axis-aligned box typically used for bounding box and intersection calculations.
Definition: axis_aligned_box.hpp:17
void SetScale(const QVector3D &vec) override
Disabled for this class.
LightType
Specifies a light type.
Definition: light_node.hpp:18
float ConeAngle() const
Retrieve the cone angle, in degrees.
Definition: light_node.hpp:94
A scene graph.
Definition: scene.hpp:36
const AxisAlignedBox & WorldBoundingBox() override
Retrieve the world-space bounding box of the node and all of its children (if applicable).
const QVector3D & Direction() const
Sets the light direction.
Definition: light_node.hpp:53
void SetSpecular(const float specular)
Sets the specular coefficient for this light.
Definition: light_node.hpp:67
A light in a scene graph used by some shaders to calculate lighting effects.
Definition: light_node.hpp:32
void SetLightType(LightType light_type)
Sets the light type.
Definition: light_node.hpp:42
SceneNodeType
Specifies a scene node type.
Definition: scene_node.hpp:19
SceneNodeType NodeType() const override
Retrieve the node type.
Definition: light_node.hpp:36