Light.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_LIGHT_H
#define SURGSIM_GRAPHICS_LIGHT_H
#include "SurgSim/Graphics/Representation.h"
#include "SurgSim/Math/MathConvert.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Graphics
{
class Group;
class Light : public virtual Representation
{
public:
explicit Light(const std::string& name) : Representation(name)
{
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, SurgSim::Math::Vector4d, DiffuseColor,
getDiffuseColor, setDiffuseColor);
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, SurgSim::Math::Vector4d, SpecularColor,
getSpecularColor, setSpecularColor);
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, ConstantAttenuation,
getConstantAttenuation, setConstantAttenuation);
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, LinearAttenuation,
getLinearAttenuation, setLinearAttenuation);
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, double, QuadraticAttenuation,
getQuadraticAttenuation, setQuadraticAttenuation);
SURGSIM_ADD_SERIALIZABLE_PROPERTY(Light, std::string, LightGroupReference,
getLightGroupReference, setLightGroupReference);
}
virtual ~Light()
{
}
virtual bool setGroup(std::shared_ptr<SurgSim::Graphics::Group> group) = 0;
virtual std::shared_ptr<SurgSim::Graphics::Group> getGroup() = 0;
virtual void setDiffuseColor(const SurgSim::Math::Vector4d& color) = 0;
virtual SurgSim::Math::Vector4d getDiffuseColor() = 0;
virtual void setSpecularColor(const SurgSim::Math::Vector4d& color) = 0;
virtual SurgSim::Math::Vector4d getSpecularColor() = 0;
virtual void setConstantAttenuation(double val) = 0;
virtual double getConstantAttenuation() = 0;
virtual void setLinearAttenuation(double val) = 0;
virtual double getLinearAttenuation() = 0;
virtual void setQuadraticAttenuation(double val) = 0;
virtual double getQuadraticAttenuation() = 0;
virtual void setLightGroupReference(const std::string& name) = 0;
virtual std::string getLightGroupReference() = 0;
};
}; // Graphics
}; // SurgSim
#endif
SurgSim::Graphics::Light::getDiffuseColor
virtual SurgSim::Math::Vector4d getDiffuseColor()=0
Gets diffuse color.
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::Light::setQuadraticAttenuation
virtual void setQuadraticAttenuation(double val)=0
Sets quadratic attenuation.
SurgSim::Graphics::Light::getQuadraticAttenuation
virtual double getQuadraticAttenuation()=0
Gets quadratic attenuation.
SurgSim::Graphics::Light::~Light
virtual ~Light()
Definition: Light.h:69
SurgSim::Graphics::Light
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
SurgSim::Graphics::Light::setSpecularColor
virtual void setSpecularColor(const SurgSim::Math::Vector4d &color)=0
Sets specular color of this light.
MathConvert.h
This contains a series of functions to encode and decode Eigen data structures to and from YAML nodes...
SurgSim::Graphics::Light::setLinearAttenuation
virtual void setLinearAttenuation(double val)=0
Sets linear attenuation.
SurgSim::Graphics::Light::setConstantAttenuation
virtual void setConstantAttenuation(double val)=0
Sets constant attenuation.
Representation.h
SurgSim::Graphics::Light::setGroup
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...
SURGSIM_ADD_SERIALIZABLE_PROPERTY
#define SURGSIM_ADD_SERIALIZABLE_PROPERTY(class, type, property, getter, setter)
A macro to register a serializable property, this needs to support reading, writing and all the conve...
Definition: Accessible.h:225
SurgSim::Graphics::Light::getSpecularColor
virtual SurgSim::Math::Vector4d getSpecularColor()=0
Gets specular color.
SurgSim::Graphics::Light::getConstantAttenuation
virtual double getConstantAttenuation()=0
Gets constant attenuation.
SurgSim::Graphics::Representation
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
SurgSim::Graphics::Light::setDiffuseColor
virtual void setDiffuseColor(const SurgSim::Math::Vector4d &color)=0
Sets diffuse color of this light.
SurgSim::Graphics::Light::Light
Light(const std::string &name)
Constructor.
Definition: Light.h:53
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Graphics::Light::getLinearAttenuation
virtual double getLinearAttenuation()=0
Gets linear attenuation.
SurgSim::Graphics::Light::getLightGroupReference
virtual std::string getLightGroupReference()=0
Gets the name of the group this light should operate on.
SurgSim::Math::Vector4d
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
SurgSim::Graphics::Light::getGroup
virtual std::shared_ptr< SurgSim::Graphics::Group > getGroup()=0
Gets the group that this light has been assigned to.
SurgSim::Graphics::Light::setLightGroupReference
virtual void setLightGroupReference(const std::string &name)=0
Sets the name of the group that this light should work on.