Choreonoid  1.8
SceneLights.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_UTIL_SCENE_LIGHTS_H
7 #define CNOID_UTIL_SCENE_LIGHTS_H
8 
9 #include "SceneGraph.h"
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class CNOID_EXPORT SgLight : public SgPreprocessed
15 {
16 protected:
17  SgLight(int polymorhicId);
18  SgLight(const SgLight& org);
19 
20 public:
21  bool on() const { return on_; }
22  void on(bool on) { on_ = on; }
23  const Vector3f& color() const { return color_; }
24  template<typename Derived> void setColor(const Eigen::MatrixBase<Derived>& c) {
25  color_ = c.template cast<Vector3f::Scalar>(); }
26  float intensity() const { return intensity_; }
27  void setIntensity(float intensity) { intensity_ = intensity; }
28  float ambientIntensity() const { return ambientIntensity_; }
29  void setAmbientIntensity(float intensity) { ambientIntensity_ = intensity; }
30 
31 protected:
32  virtual Referenced* doClone(CloneMap* cloneMap) const override;
33 
34 private:
35  Vector3f color_;
36  float intensity_;
37  float ambientIntensity_;
38  bool on_;
39 };
41 
42 
43 class CNOID_EXPORT SgDirectionalLight : public SgLight
44 {
45 public:
48 
49  const Vector3& direction() const { return direction_; }
50  template<typename Derived> void setDirection(const Eigen::MatrixBase<Derived>& d) {
51  direction_ = d.template cast<Vector3::Scalar>(); }
52 
53 protected:
54  SgDirectionalLight(int polymorhicId);
55  virtual Referenced* doClone(CloneMap* cloneMap) const override;
56 
57 private:
58  Vector3 direction_;
59 };
61 
62 
63 class CNOID_EXPORT SgPointLight : public SgLight
64 {
65 public:
66  SgPointLight();
67  SgPointLight(const SgPointLight& org);
68 
69  float constantAttenuation() const { return constantAttenuation_; }
70  void setConstantAttenuation(float a) { constantAttenuation_ = a; }
71 
72  float linearAttenuation() const { return linearAttenuation_; }
73  void setLinearAttenuation(float a) { linearAttenuation_ = a; }
74 
75  float quadraticAttenuation() const { return quadraticAttenuation_; }
76  void setQuadraticAttenuation(float a) { quadraticAttenuation_ = a; }
77 
78 protected:
79  SgPointLight(int polymorhicId);
80  virtual Referenced* doClone(CloneMap* cloneMap) const override;
81 
82 private:
83  float constantAttenuation_;
84  float linearAttenuation_;
85  float quadraticAttenuation_;
86 };
88 
89 
90 class CNOID_EXPORT SgSpotLight : public SgPointLight
91 {
92 public:
93  SgSpotLight();
94  SgSpotLight(const SgSpotLight& org);
95 
96  const Vector3& direction() const { return direction_; }
97  template<typename Derived> void setDirection(const Eigen::MatrixBase<Derived>& d) {
98  direction_ = d.template cast<Vector3::Scalar>(); }
99 
100  float beamWidth() const { return beamWidth_; }
101  void setBeamWidth(float w) { beamWidth_ = w; }
102  float cutOffAngle() const { return cutOffAngle_; }
103  void setCutOffAngle(float a) { cutOffAngle_ = a; }
104  float cutOffExponent() const { return cutOffExponent_; }
105  void setCutOffExponent(float e) { cutOffExponent_ = e; }
106 
107 protected:
108  SgSpotLight(int polymorhicId);
109  virtual Referenced* doClone(CloneMap* cloneMap) const override;
110 
111 private:
112  Vector3 direction_;
113  float beamWidth_;
114  float cutOffAngle_;
115  float cutOffExponent_;
116 };
118 
119 }
120 
121 #endif
cnoid::SgPointLight::quadraticAttenuation
float quadraticAttenuation() const
Definition: SceneLights.h:75
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::SgDirectionalLight::setDirection
void setDirection(const Eigen::MatrixBase< Derived > &d)
Definition: SceneLights.h:50
cnoid::SgLight::on
void on(bool on)
Definition: SceneLights.h:22
cnoid::SgDirectionalLight::direction
const Vector3 & direction() const
Definition: SceneLights.h:49
cnoid::SgPointLight::constantAttenuation
float constantAttenuation() const
Definition: SceneLights.h:69
cnoid::SgPreprocessed
Definition: SceneGraph.h:595
cnoid::SgDirectionalLightPtr
ref_ptr< SgDirectionalLight > SgDirectionalLightPtr
Definition: SceneLights.h:60
cnoid::SgSpotLight
Definition: SceneLights.h:90
cnoid::SgSpotLight::setCutOffExponent
void setCutOffExponent(float e)
Definition: SceneLights.h:105
cnoid::SgSpotLight::setDirection
void setDirection(const Eigen::MatrixBase< Derived > &d)
Definition: SceneLights.h:97
cnoid::SgLight
Definition: SceneLights.h:14
cnoid::SgLightPtr
ref_ptr< SgLight > SgLightPtr
Definition: SceneLights.h:40
cnoid::ref_ptr< SgLight >
cnoid::SgPointLight::setConstantAttenuation
void setConstantAttenuation(float a)
Definition: SceneLights.h:70
cnoid::SgLight::on
bool on() const
Definition: SceneLights.h:21
cnoid::SgSpotLight::setCutOffAngle
void setCutOffAngle(float a)
Definition: SceneLights.h:103
cnoid::SgSpotLight::beamWidth
float beamWidth() const
Definition: SceneLights.h:100
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::SgDirectionalLight
Definition: SceneLights.h:43
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::SgSpotLightPtr
ref_ptr< SgSpotLight > SgSpotLightPtr
Definition: SceneLights.h:117
cnoid::SgSpotLight::setBeamWidth
void setBeamWidth(float w)
Definition: SceneLights.h:101
cnoid::SgPointLight::setQuadraticAttenuation
void setQuadraticAttenuation(float a)
Definition: SceneLights.h:76
cnoid::SgSpotLight::cutOffAngle
float cutOffAngle() const
Definition: SceneLights.h:102
cnoid::SgLight::ambientIntensity
float ambientIntensity() const
Definition: SceneLights.h:28
cnoid::Referenced
Definition: Referenced.h:54
cnoid::SgLight::color
const Vector3f & color() const
Definition: SceneLights.h:23
SceneGraph.h
cnoid::SgPointLight::linearAttenuation
float linearAttenuation() const
Definition: SceneLights.h:72
cnoid::SgSpotLight::direction
const Vector3 & direction() const
Definition: SceneLights.h:96
cnoid::SgLight::setColor
void setColor(const Eigen::MatrixBase< Derived > &c)
Definition: SceneLights.h:24
cnoid::SgPointLightPtr
ref_ptr< SgPointLight > SgPointLightPtr
Definition: SceneLights.h:87
cnoid::SgLight::intensity
float intensity() const
Definition: SceneLights.h:26
cnoid::SgSpotLight::cutOffExponent
float cutOffExponent() const
Definition: SceneLights.h:104
cnoid::SgLight::setAmbientIntensity
void setAmbientIntensity(float intensity)
Definition: SceneLights.h:29
cnoid::SgPointLight::setLinearAttenuation
void setLinearAttenuation(float a)
Definition: SceneLights.h:73
cnoid::SgPointLight
Definition: SceneLights.h:63
cnoid::SgLight::setIntensity
void setIntensity(float intensity)
Definition: SceneLights.h:27