iMSTK
Interactive Medical Simulation Toolkit
imstkLight.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkColor.h"
10 #include "imstkEntity.h"
11 #include "imstkMath.h"
12 
13 #include <string>
14 
15 namespace imstk
16 {
22 class Light : public Entity
23 {
24 protected:
25  Light() = default;
26 
27 public:
28  ~Light() override = default;
29 
33  void setFocalPoint(const Vec3d& p) { m_focalPoint = p; }
34  void setFocalPoint(const double x, const double y, const double z) { setFocalPoint(Vec3d(x, y, z)); }
35  const Vec3d& getFocalPoint() const { return m_focalPoint; }
37 
41  bool isOn() const { return m_switchState; }
42 
46  void switchOn() { m_switchState = true; }
47 
51  void switchOff() { m_switchState = false; }
52 
56  const Color& getColor() const { return m_color; }
57 
61  void setColor(const Color& c) { m_color = c; }
62 
66  double getIntensity() const { return m_intensity; }
67 
71  void setIntensity(const double intensity) { m_intensity = intensity; }
72 
77  void setAttenuationValues(const double a, const double b, const double c)
78  {
79  m_attenuation[0] = c;
80  m_attenuation[1] = b;
81  m_attenuation[2] = a;
82  }
83 
84  const Vec3d& getAttenuationValues() const { return m_attenuation; }
85 
86 protected:
87  // properties with defaults
88  double m_intensity = 1.0;
89  Color m_color = Color::White;
90  bool m_switchState = true;
91  Vec3d m_focalPoint = Vec3d::Zero();
92  Vec3d m_attenuation = Vec3d(1.0, 0.0, 0.0);
93 };
94 } // namespace imstk
double getIntensity() const
Get the light intensity.
Definition: imstkLight.h:66
void setColor(const Color &c)
Set the light color.
Definition: imstkLight.h:61
void setAttenuationValues(const double a, const double b, const double c)
Sets the attenuation values. Quadratic, linear, and constant c (ax^2+bx+c) (a,b,c) = {0...
Definition: imstkLight.h:77
Compound Geometry.
const Color & getColor() const
Get the light color.
Definition: imstkLight.h:56
void setIntensity(const double intensity)
Set the light intensity. This value is unbounded.
Definition: imstkLight.h:71
void switchOff()
Switch the light Off.
Definition: imstkLight.h:51
void switchOn()
Switch the light On.
Definition: imstkLight.h:46
Vec3d m_attenuation
c, b, a (ax^2+bx+c)
Definition: imstkLight.h:92
Top-level class for entities. Entities contain a collection of components which define how to be used...
Definition: imstkEntity.h:26
Color in RGB space.
Definition: imstkColor.h:24
static Color White
Various commonly used colors.
Definition: imstkColor.h:112
void setFocalPoint(const Vec3d &p)
Get/Set the light focal point.
Definition: imstkLight.h:33
bool isOn() const
Get the status (On/off) of the light.
Definition: imstkLight.h:41
Abstract base class for lights.
Definition: imstkLight.h:22