opensurgsim
Light.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_LIGHT_H
17 #define SURGSIM_GRAPHICS_LIGHT_H
18 
19 #include "SurgSim/Graphics/Representation.h"
21 #include "SurgSim/Math/Vector.h"
22 
23 namespace SurgSim
24 {
25 namespace Graphics
26 {
27 
28 class Group;
29 
48 class Light : public virtual Representation
49 {
50 public:
51 
53  explicit Light(const std::string& name) : Representation(name)
54  {
55  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, SurgSim::Math::Vector4d, DiffuseColor,
57  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, SurgSim::Math::Vector4d, SpecularColor,
59  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, ConstantAttenuation,
61  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, LinearAttenuation,
63  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, QuadraticAttenuation,
65  SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, std::string, LightGroupReference,
67  }
68 
69  virtual ~Light()
70  {
71  }
72 
76  virtual bool setGroup(std::shared_ptr<SurgSim::Graphics::Group> group) = 0;
77 
80  virtual std::shared_ptr<SurgSim::Graphics::Group> getGroup() = 0;
81 
84  virtual void setDiffuseColor(const SurgSim::Math::Vector4d& color) = 0;
85 
89 
92  virtual void setSpecularColor(const SurgSim::Math::Vector4d& color) = 0;
93 
97 
100  virtual void setConstantAttenuation(double val) = 0;
101 
104  virtual double getConstantAttenuation() = 0;
105 
108  virtual void setLinearAttenuation(double val) = 0;
109 
112  virtual double getLinearAttenuation() = 0;
113 
116  virtual void setQuadraticAttenuation(double val) = 0;
117 
120  virtual double getQuadraticAttenuation() = 0;
121 
124  virtual void setLightGroupReference(const std::string& name) = 0;
125 
128  virtual std::string getLightGroupReference() = 0;
129 };
130 
131 }; // Graphics
132 }; // SurgSim
133 
134 #endif
virtual SurgSim::Math::Vector4d getDiffuseColor()=0
Gets diffuse color.
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
virtual void setQuadraticAttenuation(double val)=0
Sets quadratic attenuation.
virtual double getQuadraticAttenuation()=0
Gets quadratic attenuation.
Abstract interface for a light, a light needs to be assigned to a group to be active, only the members of this group will be considered to be lit by this light.
Definition: Light.h:48
virtual void setSpecularColor(const SurgSim::Math::Vector4d &color)=0
Sets specular color of this light.
This contains a series of functions to encode and decode Eigen data structures to and from YAML nodes...
virtual void setLinearAttenuation(double val)=0
Sets linear attenuation.
virtual void setConstantAttenuation(double val)=0
Sets constant attenuation.
virtual bool setGroup(std::shared_ptr< SurgSim::Graphics::Group > group)=0
Sets the group for this light, setting nullptr here will remove the light from its current group...
virtual SurgSim::Math::Vector4d getSpecularColor()=0
Gets specular color.
virtual double getConstantAttenuation()=0
Gets constant attenuation.
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:40
virtual void setDiffuseColor(const SurgSim::Math::Vector4d &color)=0
Sets diffuse color of this light.
Light(const std::string &name)
Constructor.
Definition: Light.h:53
Definitions of small fixed-size vector types.
virtual double getLinearAttenuation()=0
Gets linear attenuation.
virtual std::string getLightGroupReference()=0
Gets the name of the group this light should operate on.
virtual std::shared_ptr< SurgSim::Graphics::Group > getGroup()=0
Gets the group that this light has been assigned to.
virtual void setLightGroupReference(const std::string &name)=0
Sets the name of the group that this light should work on.