Material.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 #ifndef MATERIAL_HH 00018 #define MATERIAL_HH 00019 00020 #include <string> 00021 #include <iostream> 00022 #include "common/Color.hh" 00023 00024 namespace gazebo 00025 { 00026 namespace common 00027 { 00028 00031 00033 class Material 00034 { 00035 public: enum ShadeMode{FLAT, GOURAUD, PHONG, BLINN, SHADE_COUNT}; 00036 public: static std::string ShadeModeStr[SHADE_COUNT]; 00037 00038 public: enum BlendMode{ADD, MODULATE, REPLACE, BLEND_COUNT}; 00039 public: static std::string BlendModeStr[BLEND_COUNT]; 00040 00042 public: Material(); 00043 00045 public: virtual ~Material(); 00046 00048 public: Material(const Color &clr); 00049 00051 public: std::string GetName() const; 00052 00054 public: void SetTextureImage(const std::string &tex); 00055 00057 public: void SetTextureImage(const std::string &tex, 00058 const std::string &resource_path); 00059 00061 public: std::string GetTextureImage() const; 00062 00064 public: void SetAmbient(const Color &clr); 00065 00067 public: Color GetAmbient() const; 00068 00070 public: void SetDiffuse(const Color &clr); 00071 00073 public: Color GetDiffuse() const; 00074 00076 public: void SetSpecular(const Color &clr); 00077 00079 public: Color GetSpecular() const; 00080 00082 public: void SetEmissive(const Color &clr); 00083 00085 public: Color GetEmissive() const; 00086 00088 public: void SetTransparency(float t); 00089 00091 public: float SetTransparency() const; 00092 00094 public: void SetShininess(float t); 00095 00097 public: float GetShininess() const; 00098 00100 public: float GetTransparency() const; 00101 00104 public: void SetBlendFactors(double _srcFactor, double _dstFactor); 00105 00107 public: void GetBlendFactors(double &_srcFactor, double &_dstFactor); 00108 00110 public: void SetBlendMode(BlendMode b); 00111 00113 public: BlendMode GetBlendMode() const; 00114 00116 public: void SetShadeMode(ShadeMode b); 00117 00119 public: ShadeMode GetShadeMode() const; 00120 00122 public: void SetPointSize(double size); 00123 00125 public: double GetPointSize() const; 00126 00128 public: void SetDepthWrite( bool _value ); 00129 00131 public: bool GetDepthWrite() const; 00132 00134 public: void SetLighting( bool _value ); 00135 00137 public: bool GetLighting() const; 00138 00140 public: friend std::ostream &operator<<( std::ostream &out, 00141 const gazebo::common::Material &m ) 00142 { 00143 00144 out << "Material:\n"; 00145 out << "\tName: " << m.name << "\n"; 00146 out << "\tTexture: " << m.texImage << "\n"; 00147 out << "\tAmbient: " << m.ambient << "\n"; 00148 out << "\tDiffuse: " << m.diffuse << "\n"; 00149 out << "\tSpecular: " << m.specular << "\n"; 00150 out << "\tEmissive: " << m.emissive << "\n"; 00151 out << "\tTransparency: " << m.transparency << "\n"; 00152 out << "\tShininess: " << m.shininess << "\n"; 00153 out << "\tBlendMode: " << BlendModeStr[m.blendMode] << "\n"; 00154 out << "\tShadeMode: " << ShadeModeStr[m.shadeMode] << "\n"; 00155 out << "\tDepthWrite: " << m.depthWrite << "\n"; 00156 return out; 00157 } 00158 00159 protected: std::string name; 00160 protected: std::string texImage; 00161 protected: Color ambient; 00162 protected: Color diffuse; 00163 protected: Color specular; 00164 protected: Color emissive; 00165 protected: float transparency; 00166 protected: float shininess; 00167 protected: double pointSize; 00168 00169 protected: BlendMode blendMode; 00170 protected: ShadeMode shadeMode; 00171 00172 private: static unsigned int counter; 00173 00174 private: bool depthWrite; 00175 private: bool lighting; 00176 00177 private: double srcBlendFactor, dstBlendFactor; 00178 }; 00180 } 00181 } 00182 #endif

1.7.5.1