00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 #ifndef VRS_MATERIAL_H
00080 #define VRS_MATERIAL_H
00081
00082 #include <vrs/color.h>
00083 #include <vrs/monoattribute.h>
00084
00085 namespace VRS {
00086
00088 class VRS_CORE_API Material : public MonoAttribute {
00089
00090 public:
00091 Material(
00092 double Ka = 0.2, double Kd = 0.5, double Ks = 0.0,
00093 double roughness = 0.1,
00094 const Color& specularColor = Color::white,
00095 const Color& emissionColor = Color::black,
00096 bool distinguishFrontAndBackFaces = 0
00097 );
00109 bool operator==(const Material& other) const;
00110
00111 void setAmbient(double Ka, int side = 0);
00112 double getAmbient(int side = 0) const;
00114
00115 void setDiffuse(double Kd, int side = 0);
00116 double getDiffuse(int side = 0) const;
00118
00119 void setSpecular(double Ks, int side = 0);
00120 double getSpecular(int side = 0) const;
00122
00123 void setRoughness(double r, int side = 0);
00124 double getRoughness(int side = 0) const;
00126
00127 void setSpecularColor(const Color& s, int side = 0);
00128 Color getSpecularColor(int side = 0) const;
00130
00131 void setEmissionColor(const Color&, int side = 0);
00132 Color getEmissionColor(int side = 0) const;
00134
00135 void setDistinguishSides(bool onOff);
00136 bool getDistinguishSides() const;
00140 VRS_TYPEINFO(Material, MonoAttribute);
00141 VRS_SERIALIZABLE(Material);
00142
00143 private:
00144 bool distinguishSides_;
00145 double ambient_[2];
00146 double diffuse_[2];
00147 double specular_[2];
00148 double roughness_[2];
00149 Color specColor_[2];
00150 Color emisColor_[2];
00151 };
00152
00153 inline double Material::getAmbient(int side) const {
00154 VRS_Assertion(side==0||side==1, "unkown side flag");
00155 return ambient_[side];
00156 }
00157
00158 inline double Material::getDiffuse(int side) const {
00159 VRS_Assertion(side==0||side==1, "unkown side flag");
00160 return diffuse_[side];
00161 }
00162 inline double Material::getSpecular(int side) const {
00163 VRS_Assertion(side==0||side==1, "unkown side flag");
00164 return specular_[side];
00165 }
00166 inline double Material::getRoughness(int side) const {
00167 VRS_Assertion(side==0||side==1, "unkown side flag");
00168 return roughness_[side];
00169 }
00170 inline Color Material::getSpecularColor(int side) const {
00171 VRS_Assertion(side==0||side==1, "unkown side flag");
00172 return specColor_[side];
00173 }
00174 inline Color Material::getEmissionColor(int side) const {
00175 VRS_Assertion(side==0||side==1, "unkown side flag");
00176 return emisColor_[side];
00177 }
00178 inline bool Material::getDistinguishSides() const {
00179 return distinguishSides_;
00180 }
00181
00182 }
00183
00184 #endif // VRS_MATERIAL_H