59 #ifndef ACG_MATERIAL_NODE_HH 60 #define ACG_MATERIAL_NODE_HH 65 #include "BaseNode.hh" 67 #include <QVariantMap> 73 QVariantMap ACGDLLEXPORT json_to_variant_map(QString json);
92 baseColor_(
GLState::default_base_color),
93 ambientColor_(
GLState::default_ambient_color),
94 diffuseColor_(
GLState::default_diffuse_color),
95 specularColor_(
GLState::default_specular_color),
96 overlayColor_(
GLState::default_overlay_color),
97 shininess_(
GLState::default_shininess),
106 blendParam1_(GL_SRC_ALPHA),
107 blendParam2_(GL_ONE_MINUS_SRC_ALPHA),
108 colorMaterial_(true),
109 backfaceCulling_(false),
110 multiSampling_(true) {};
117 baseColor_(_m.baseColor_),
118 ambientColor_(_m.ambientColor_),
119 diffuseColor_(_m.diffuseColor_),
120 specularColor_(_m.specularColor_),
121 overlayColor_(_m.overlayColor_),
122 shininess_(_m.shininess_),
123 reflectance_(_m.reflectance_),
124 pointSize_(_m.pointSize_),
125 lineWidth_(_m.lineWidth_),
126 roundPoints_(_m.roundPoints_),
127 linesSmooth_(_m.linesSmooth_),
128 alphaTest_(_m.alphaTest_),
129 alphaClip_(_m.alphaClip_),
130 blending_(_m.blending_),
131 blendParam1_(_m.blendParam1_),
132 blendParam2_(_m.blendParam2_),
133 colorMaterial_(_m.colorMaterial_),
134 backfaceCulling_(_m.backfaceCulling_),
135 multiSampling_(_m.multiSampling_) {};
137 static bool support_json_serialization();
138 QString serializeToJson()
const;
139 void deserializeFromJson(
const QString &json);
140 void deserializeFromVariantMap(
const QVariantMap &matMap);
150 Vec4f c(0.0,0.0,0.0,1.0);
153 c = _c * 0.2f; c[3]=_c[3]; ambientColor(c);
154 c = _c * 0.6f; c[3]=_c[3]; diffuseColor(c);
155 c = _c * 0.8f; c[3]=_c[3]; specularColor(c);
160 color(
Vec4f(0.2 +
double(rand())/
double(RAND_MAX)*0.8,
161 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
162 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
232 alphaTest_ =
true; alphaClip_ = _clip;
243 multiSampling_ =
true;
248 multiSampling_ =
false;
253 return multiSampling_;
258 multiSampling_ = _state;
264 bool blending()
const {
return blending_; };
266 GLenum blendingParam1()
const {
return blendParam1_; };
267 GLenum blendingParam2()
const {
return blendParam2_; };
271 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA)
272 { blending_ =
true; blendParam1_ = _p1; blendParam2_ = _p2; }
276 bool backfaceCulling()
const {
return backfaceCulling_; };
288 Vec4f specularColor_;
307 bool backfaceCulling_;
358 const std::string& _name =
"<MaterialNode>",
359 unsigned int _applyProperties = (All & ~BackFaceCulling));
365 void read( std::istream & _is);
400 material_.generateRandomColor();
440 float shininess()
const {
return material_.shininess(); }
510 float alpha_value(){
return material_.alphaValue(); };
513 bool blending() {
return material_.blending(); };
515 GLenum blending_param1() {
return material_.blendingParam1(); };
516 GLenum blending_param2() {
return material_.blendingParam2(); };
520 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA) {
521 material_.enableBlending(_p1, _p2);
526 bool backface_culling() {
return material_.backfaceCulling(); };
539 applyProperties_ = _applyProperties;
565 #endif // ACG_MATERIAL_NODE_HH defined float lineWidth() const
get line width
const Vec4f & baseColor() const
get the base color
void disable_alpha_test()
disable alpha test
void specularColor(const Vec4f &_s)
set the specular color
const Vec4f & overlayColor() const
get the overlay color (This can be used to render overlays e.g. additional wireframes in a different ...
virtual ~MaterialNode()
Destructor.
void lineSmooth(bool _b)
set: smooth lines enabled
void disable_backface_culling()
disable backface culling (not active by default, see applyProperties)
const Vec4f & ambient_color() const
get the ambient color.
void set_reflectance(double _m)
set reflectance
void set_random_color()
Generates a random color and sets it.
void roundPoints(bool _b)
set: round points enabled
bool line_smooth() const
get: rsmooth lines enabled
void disableBackfaceCulling()
disable backface culling (not active by default, see applyProperties)
VectorT< float, 4 > Vec4f
void enableBackfaceCulling()
enable backface culling (not active by default, see applyProperties)
bool alphaTest() const
Return state of Alpha test.
void enable_color_material()
Enable Color Material.
bool round_points() const
get round points enabled
bool colorMaterial()
get colorMaterial state
void set_specular_color(const Vec4f &_s)
set the specular color
bool alpha_test()
Return state of Alpha test.
void colorMaterial(const bool _cm)
Set colorMaterial.
ACG::SceneGraph::Material & material()
Get material object reference.
float shininess() const
get shininess
void multisampling(bool _state)
Set state of multisampling.
void disable_blending()
disable blending
void set_multisampling(bool _state)
Set state of multisampling.
void disableColorMaterial()
Disable Color Material.
void set_shininess(float _s)
set shininess
ACG::SceneGraph::Material materialBackup_
Material Backup.
void set_ambient_color(const Vec4f &_a)
set the ambient color.
void enableAlphaTest(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
ACG::SceneGraph::MaterialNode MaterialNode
Materialnode.
int applyProperties_
OR'ed ApplyProperties.
void baseColor(const Vec4f &_c)
set the base color
float point_size() const
get point size
void enableBlending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
float alphaValue() const
get current alpha value for alpha_test
void overlayColor(const Vec4f &_s)
set the overlay color (This can be used to render overlays e.g. additional wireframes in a different ...
float line_width() const
get line width
PickTarget
What target to use for picking.
bool colorMaterial()
get colorMaterial state
void enable_backface_culling()
enable backface culling (not active by default, see applyProperties)
bool multiSampling()
Get state of multisampling.
void ambientColor(const Vec4f &_a)
set the ambient color.
void colorMaterial(const bool _cm)
Set colorMaterial.
bool lineSmooth() const
get: rsmooth lines enabled
void lineWidth(float _sz)
set line width (default: 1.0)
ApplyProperties
Apply which properties? Others will be ignored. Values may be OR'ed.
void enable_blending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
void disable_color_material()
Disable Color Material.
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
void enableMultisampling()
Enable Multisampling.
void disable_multisampling()
enable alpha test (draw pixels if alpha >= _clip)
Clear all attribute bits.
void diffuseColor(const Vec4f &_d)
set the diffuse color.
void reflectance(double _m)
set reflectance ( not used in OpenGL Rendering)
void set_round_points(bool _b)
set round points enabled
float shininess() const
get shininess
const Vec4f & overlay_color() const
get the overlay color
const Vec4f & diffuse_color() const
get the diffuse color.
ACG::SceneGraph::Material material_
Local material class that actually stores the properties.
void set_overlay_color(const Vec4f &_s)
set the overlay color
Namespace providing different geometric functions concerning angles.
unsigned int applyProperties() const
get properties that will be applied (OR'ed ApplyProperties)
Material(const Material &_m)
Copy constructor.
void disableBlending()
disable blending
void applyProperties(unsigned int _applyProperties)
set properties that will be applied (OR'ed ApplyProperties)
const Vec4f & specularColor() const
get the specular color
void set_line_smooth(bool _b)
set: smooth lines enabled
void set_line_width(float _sz)
set line width (default: 1.0)
void enableColorMaterial()
Enable Color Material.
const Vec4f & base_color() const
get the base color
void disableMultisampling()
enable alpha test (draw pixels if alpha >= _clip)
void generateRandomColor()
Creates a randomized color and sets it.
void enable_multisampling()
Enable Multisampling.
void shininess(float _s)
set shininess
void set_color(const Vec4f &_c)
set color (base, ambient, diffuse, specular) based on _c
const Vec4f & diffuseColor() const
get the diffuse color.
double reflectance() const
get reflectance ( not used in OpenGL Rendering)
bool roundPoints() const
get: round points enabled
void enable_alpha_test(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
void color(const Vec4f &_c)
Set color based on _c.
float pointSize() const
get point size
void pointSize(float _sz)
set point size (default: 1.0)
void set_base_color(const Vec4f &_c)
set the base color
bool multiSampling() const
Get state of multisampling.
const Vec4f & specular_color() const
get the specular color
void disableAlphaTest()
disable alpha test
Material()
Default constructor.
virtual ~Material()
Deconstructor.
void set_material(const ACG::SceneGraph::Material &_m)
Set material object.
double reflectance() const
get reflectance
void set_point_size(float _sz)
set point size (default: 1.0)
const Vec4f & ambientColor() const
get the ambient color.