##

common/Material.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* 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 GAZEBO_COMMON_MATERIAL_HH_
#define GAZEBO_COMMON_MATERIAL_HH_
#include <string>
#include <iostream>
#include <ignition/math/Color.hh>
#include "gazebo/common/Color.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class GZ_COMMON_VISIBLE Material
{
public: enum ShadeMode {FLAT, GOURAUD, PHONG, BLINN, SHADE_COUNT};
public: static std::string ShadeModeStr[SHADE_COUNT];
public: enum BlendMode {ADD, MODULATE, REPLACE, BLEND_COUNT};
public: static std::string BlendModeStr[BLEND_COUNT];
public: Material();
public: virtual ~Material();
public: explicit Material(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: explicit Material(const ignition::math::Color &_clr);
public: std::string GetName() const;
public: void SetTextureImage(const std::string &_tex);
public: void SetTextureImage(const std::string &_tex,
const std::string &_resourcePath);
public: std::string GetTextureImage() const;
public: void SetAmbient(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: void SetAmbient(const ignition::math::Color &_clr);
public: Color GetAmbient() const GAZEBO_DEPRECATED(9.0);
public: ignition::math::Color Ambient() const;
public: void SetDiffuse(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: void SetDiffuse(const ignition::math::Color &_clr);
public: Color GetDiffuse() const GAZEBO_DEPRECATED(9.0);
public: ignition::math::Color Diffuse() const;
public: void SetSpecular(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: void SetSpecular(const ignition::math::Color &_clr);
public: Color GetSpecular() const GAZEBO_DEPRECATED(9.0);
public: ignition::math::Color Specular() const;
public: void SetEmissive(const Color &_clr) GAZEBO_DEPRECATED(9.0);
public: void SetEmissive(const ignition::math::Color &_clr);
public: Color GetEmissive() const GAZEBO_DEPRECATED(9.0);
public: ignition::math::Color Emissive() const;
public: void SetTransparency(double _t);
public: double GetTransparency() const;
public: void SetShininess(double _t);
public: double GetShininess() const;
public: void SetBlendFactors(double _srcFactor, double _dstFactor);
public: void GetBlendFactors(double &_srcFactor, double &_dstFactor)
const;
public: void SetBlendMode(BlendMode _b);
public: BlendMode GetBlendMode() const;
public: void SetShadeMode(ShadeMode _b);
public: ShadeMode GetShadeMode() const;
public: void SetPointSize(double _size);
public: double GetPointSize() const;
public: void SetDepthWrite(bool _value);
public: bool GetDepthWrite() const;
public: void SetLighting(bool _value);
public: bool GetLighting() const;
public: friend std::ostream &operator<<(std::ostream &_out,
const gazebo::common::Material &_m)
{
_out << "Material:\n";
_out << " Name: " << _m.name << "\n";
_out << " Texture: " << _m.texImage << "\n";
_out << " Ambient: " << _m.ambient << "\n";
_out << " Diffuse: " << _m.diffuse << "\n";
_out << " Specular: " << _m.specular << "\n";
_out << " Emissive: " << _m.emissive << "\n";
_out << " Transparency: " << _m.transparency << "\n";
_out << " Shininess: " << _m.shininess << "\n";
_out << " BlendMode: " << BlendModeStr[_m.blendMode] << "\n";
_out << " ShadeMode: " << ShadeModeStr[_m.shadeMode] << "\n";
_out << " DepthWrite: " << _m.depthWrite << "\n";
return _out;
}
protected: std::string name;
protected: std::string texImage;
protected: ignition::math::Color ambient;
protected: ignition::math::Color diffuse;
protected: ignition::math::Color specular;
protected: ignition::math::Color emissive;
protected: double transparency = 0.0;
protected: double shininess = 0.0;
protected: double pointSize;
protected: BlendMode blendMode;
protected: ShadeMode shadeMode;
private: static unsigned int counter;
private: bool depthWrite = true;
private: bool lighting = true;
private: double srcBlendFactor;
private: double dstBlendFactor;
};
}
}
#endif
gazebo::common::Material::emissive
ignition::math::Color emissive
the emissive light color
Definition: common/Material.hh:255
gazebo::common::Material::ADD
Definition: common/Material.hh:40
gazebo::common::Material::SetTransparency
void SetTransparency(double _t)
Set the transparency percentage (0..1)
gazebo::common::Material::Specular
ignition::math::Color Specular() const
Get the specular color.
gazebo::common::Material::GetSpecular
Color GetSpecular() const GAZEBO_DEPRECATED(9.0)
Get the specular color.
ignition
Definition: Model.hh:40
gazebo::common::Material::SetShininess
void SetShininess(double _t)
Set the shininess.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Material::pointSize
double pointSize
point size
Definition: common/Material.hh:264
gazebo::common::Material::SetDiffuse
void SetDiffuse(const Color &_clr) GAZEBO_DEPRECATED(9.0)
Set the diffuse color.
gazebo::common::Material::ShadeModeStr
static std::string ShadeModeStr[SHADE_COUNT]
Definition: common/Material.hh:38
gazebo::common::Material::shininess
double shininess
shininess value (0 to 1)
Definition: common/Material.hh:261
gazebo::common::Material::GetDepthWrite
bool GetDepthWrite() const
Get depth write.
gazebo::common::Material::GetPointSize
double GetPointSize() const
Get the point size.
gazebo::common::Material::BlendMode
BlendMode
Definition: common/Material.hh:40
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::Material::SetShadeMode
void SetShadeMode(ShadeMode _b)
Set the shading mode param[in] the shading mode.
gazebo::common::Material::GetDiffuse
Color GetDiffuse() const GAZEBO_DEPRECATED(9.0)
Get the diffuse color.
system.hh
gazebo::common::Material::GetName
std::string GetName() const
Get the name of the material.
gazebo::common::Material::BLEND_COUNT
Definition: common/Material.hh:40
gazebo::common::Material::ambient
ignition::math::Color ambient
the ambient light color
Definition: common/Material.hh:246
gazebo::common::Material::GetLighting
bool GetLighting() const
Get lighting enabled.
gazebo::common::Material::SetLighting
void SetLighting(bool _value)
Set lighting enabled.
gazebo::common::Material::GetTransparency
double GetTransparency() const
Get the transparency percentage (0..1)
gazebo::common::Material::GetShadeMode
ShadeMode GetShadeMode() const
Get the shading mode.
gazebo::common::Material::SetAmbient
void SetAmbient(const Color &_clr) GAZEBO_DEPRECATED(9.0)
Set the ambient color.
gazebo::common::Material::GetEmissive
Color GetEmissive() const GAZEBO_DEPRECATED(9.0)
Get the emissive color.
gazebo::common::Material::specular
ignition::math::Color specular
the specular light color
Definition: common/Material.hh:252
gazebo::common::Material::Diffuse
ignition::math::Color Diffuse() const
Get the diffuse color.
Color.hh
gazebo::common::Material::FLAT
Definition: common/Material.hh:37
gazebo::common::Material::blendMode
BlendMode blendMode
blend mode
Definition: common/Material.hh:267
gazebo::common::Material::SetEmissive
void SetEmissive(const Color &_clr) GAZEBO_DEPRECATED(9.0)
Set the emissive color.
gazebo::common::Material::MODULATE
Definition: common/Material.hh:40
gazebo::common::Material::shadeMode
ShadeMode shadeMode
the shade mode
Definition: common/Material.hh:270
gazebo::common::Material::GetShininess
double GetShininess() const
Get the shininess.
gazebo::common::Material::transparency
double transparency
transparency value in the range 0 to 1
Definition: common/Material.hh:258
gazebo::common::Material::Material
Material()
Constructor.
gazebo::common::Material::diffuse
ignition::math::Color diffuse
the diffuse ligth color
Definition: common/Material.hh:249
gazebo::common::Material::texImage
std::string texImage
the texture image file name
Definition: common/Material.hh:243
gazebo::common::Material
Encapsulates description of a material.
Definition: common/Material.hh:35
gazebo::common::Material::GetBlendFactors
void GetBlendFactors(double &_srcFactor, double &_dstFactor) const
Get the blend factors.
gazebo::common::Material::PHONG
Definition: common/Material.hh:37
gazebo::common::Material::SetTextureImage
void SetTextureImage(const std::string &_tex)
Set a texture image.
gazebo::common::Material::Ambient
ignition::math::Color Ambient() const
Get the ambient color.
gazebo::common::Material::SetBlendMode
void SetBlendMode(BlendMode _b)
Set the blending mode.
gazebo::common::Color
Defines a color.
Definition: Color.hh:36
gazebo::common::Material::BLINN
Definition: common/Material.hh:37
gazebo::common::Material::BlendModeStr
static std::string BlendModeStr[BLEND_COUNT]
Definition: common/Material.hh:41
gazebo::common::Material::GOURAUD
Definition: common/Material.hh:37
gazebo::common::Material::REPLACE
Definition: common/Material.hh:40
GAZEBO_DEPRECATED
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
gazebo::common::Material::Emissive
ignition::math::Color Emissive() const
Get the emissive color.
gazebo::common::Material::SetPointSize
void SetPointSize(double _size)
Set the point size.
gazebo::common::Material::SetSpecular
void SetSpecular(const Color &_clr) GAZEBO_DEPRECATED(9.0)
Set the specular color.
gazebo::common::Material::SHADE_COUNT
Definition: common/Material.hh:37
gazebo::common::Material::SetDepthWrite
void SetDepthWrite(bool _value)
Set depth write.
gazebo::common::Material::GetAmbient
Color GetAmbient() const GAZEBO_DEPRECATED(9.0)
Get the ambient color.
gazebo::common::Material::ShadeMode
ShadeMode
Definition: common/Material.hh:37
gazebo::common::Material::~Material
virtual ~Material()
Destructor.
gazebo::common::Material::name
std::string name
the name of the material
Definition: common/Material.hh:240
gazebo::common::Material::GetTextureImage
std::string GetTextureImage() const
Get a texture image.
gazebo::common::Material::SetBlendFactors
void SetBlendFactors(double _srcFactor, double _dstFactor)
Set the blende factors.
gazebo::common::Material::GetBlendMode
BlendMode GetBlendMode() const
Get the blending mode.