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 #ifndef VRS_OPENGL_CARTOONSHADINGGL_H_
00040 #define VRS_OPENGL_CARTOONSHADINGGL_H_
00041
00042 #include <vrs/opengl/edgeenhancementgl.h>
00043 #include <vrs/color.h>
00044
00045 namespace VRS {
00046
00049 class VRS_CORE_API CartoonShadingGL : public EdgeEnhancementGL {
00050 public:
00051 CartoonShadingGL(bool useSpecular = true, bool useShapeMaterial = false,
00052 float ambientRange = 0.4f, float diffuseRange = 0.93f,
00053 const Color& globalAmbient = Color(0.7,0.7,0.7))
00054 : specular_(useSpecular), shapeMat_(useShapeMaterial),
00055 ambientRange_(ambientRange), diffuseRange_(diffuseRange),
00056 globalAmbient_(globalAmbient) { };
00077 bool useSpecular() const;
00078 void useSpecular(bool);
00081 bool useShapeMaterial() const;
00082 void useShapeMaterial(bool);
00085 float getAmbientRange() const;
00086 float getDiffuseRange() const;
00087 void setColorRange(float ambient, float diffuse);
00093 const Color& getGlobalAmbient() const;
00094 void setGlobalAmbient(const Color& globalAmbient);
00097 VRS_TYPEINFO(CartoonShadingGL, EdgeEnhancementGL);
00098 VRS_SERIALIZABLE(CartoonShadingGL);
00099
00100 private:
00101 bool specular_;
00102 bool shapeMat_;
00103 float ambientRange_;
00104 float diffuseRange_;
00105 Color globalAmbient_;
00106 };
00107
00108 inline bool CartoonShadingGL::useSpecular() const { return specular_; }
00109 inline void CartoonShadingGL::useSpecular(bool s) {
00110 if(s!=specular_) {
00111 specular_ = s;
00112 modified();
00113 }
00114 };
00115
00116 inline bool CartoonShadingGL::useShapeMaterial() const { return shapeMat_; }
00117 inline void CartoonShadingGL::useShapeMaterial(bool s) {
00118 if(s!=shapeMat_) {
00119 shapeMat_ = s;
00120 modified();
00121 }
00122 };
00123
00124 inline const Color& CartoonShadingGL::getGlobalAmbient() const { return globalAmbient_; }
00125 inline void CartoonShadingGL::setGlobalAmbient(const Color& c) {
00126 globalAmbient_ = c;
00127 modified();
00128 }
00129
00130 inline float CartoonShadingGL::getAmbientRange() const { return ambientRange_; }
00131 inline float CartoonShadingGL::getDiffuseRange() const { return diffuseRange_; }
00132 inline void CartoonShadingGL::setColorRange(float ambient, float diffuse) {
00133 ambientRange_ = ambient;
00134 diffuseRange_ = diffuse;
00135 modified();
00136 }
00137
00138 }
00139
00140
00141 #endif // VRS_OPENGL_CARTOONSHADINGGL_H_