53 #ifndef ACG_MATERIAL_NODE_HH 54 #define ACG_MATERIAL_NODE_HH 59 #include "BaseNode.hh" 61 #include <QVariantMap> 67 QVariantMap ACGDLLEXPORT json_to_variant_map(QString json);
86 baseColor_(
GLState::default_base_color),
87 ambientColor_(
GLState::default_ambient_color),
88 diffuseColor_(
GLState::default_diffuse_color),
89 specularColor_(
GLState::default_specular_color),
90 overlayColor_(
GLState::default_overlay_color),
91 shininess_(
GLState::default_shininess),
93 indexOfRefraction_(1.0),
102 blendParam1_(GL_SRC_ALPHA),
103 blendParam2_(GL_ONE_MINUS_SRC_ALPHA),
104 colorMaterial_(true),
105 backfaceCulling_(false),
106 multiSampling_(true) {};
114 static bool support_json_serialization();
115 QString serializeToJson()
const;
116 void deserializeFromJson(
const QString &json);
117 void deserializeFromVariantMap(
const QVariantMap &matMap);
127 Vec4f c(0.0,0.0,0.0,1.0);
130 c = _c * 0.2f; c[3]=_c[3]; ambientColor(c);
131 c = _c * 0.6f; c[3]=_c[3]; diffuseColor(c);
132 c = _c * 0.8f; c[3]=_c[3]; specularColor(c);
137 color(
Vec4f(0.2 +
double(rand())/
double(RAND_MAX)*0.8,
138 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
139 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
224 alphaTest_ =
true; alphaClip_ = _clip;
235 multiSampling_ =
true;
240 multiSampling_ =
false;
245 return multiSampling_;
250 multiSampling_ = _state;
256 bool blending()
const {
return blending_; };
258 GLenum blendingParam1()
const {
return blendParam1_; };
259 GLenum blendingParam2()
const {
return blendParam2_; };
263 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA)
264 { blending_ =
true; blendParam1_ = _p1; blendParam2_ = _p2; }
268 bool backfaceCulling()
const {
return backfaceCulling_; };
275 bool isEmissive()
const {
return (baseColor_[0] > 0.f || baseColor_[1] > 0.f || baseColor_[2] > 0.f); }
282 Vec4f specularColor_;
287 double indexOfRefraction_;
303 bool backfaceCulling_;
354 const std::string& _name =
"<MaterialNode>",
355 unsigned int _applyProperties = (All & ~BackFaceCulling));
361 void read( std::istream & _is);
396 material_.generateRandomColor();
441 float shininess()
const {
return material_.shininess(); }
521 float alpha_value(){
return material_.alphaValue(); };
524 bool blending() {
return material_.blending(); };
526 GLenum blending_param1() {
return material_.blendingParam1(); };
527 GLenum blending_param2() {
return material_.blendingParam2(); };
531 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA) {
532 material_.enableBlending(_p1, _p2);
537 bool backface_culling() {
return material_.backfaceCulling(); };
550 applyProperties_ = _applyProperties;
576 #endif // ACG_MATERIAL_NODE_HH defined void enableBlending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
bool multiSampling() const
Get state of multisampling.
void set_material(const ACG::SceneGraph::Material &_m)
Set material object.
void disableMultisampling()
enable alpha test (draw pixels if alpha >= _clip)
void pointSize(float _sz)
set point size (default: 1.0)
float alphaValue() const
get current alpha value for alpha_test
void enable_color_material()
Enable Color Material.
void multisampling(bool _state)
Set state of multisampling.
void set_specular_color(const Vec4f &_s)
set the specular color
void enableAlphaTest(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
void lineSmooth(bool _b)
set: smooth lines enabled
const Vec4f & ambient_color() const
get the ambient color.
Material()
Default constructor.
Namespace providing different geometric functions concerning angles.
void set_overlay_color(const Vec4f &_s)
set the overlay color
const Vec4f & overlayColor() const
get the overlay color (This can be used to render overlays e.g. additional wireframes in a different ...
void set_refractive(bool _r)
set refractive flag
void disableBlending()
disable blending
double indexOfRefraction() const
get index of refraction
VectorT< float, 4 > Vec4f
void generateRandomColor()
Creates a randomized color and sets it.
void baseColor(const Vec4f &_c)
set the base color (Sets the baseColor which is the same as the emission(const Vec4f& _c) ) ...
virtual ~Material()
Deconstructor.
float shininess() const
get shininess
const Vec4f & specular_color() const
get the specular color
void set_ambient_color(const Vec4f &_a)
set the ambient color.
void set_line_width(float _sz)
set line width (default: 1.0)
void disableAlphaTest()
disable alpha test
float shininess() const
get shininess
void enable_multisampling()
Enable Multisampling.
void set_random_color()
Generates a random color and sets it.
void set_multisampling(bool _state)
Set state of multisampling.
void disable_blending()
disable blending
void enable_blending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
void set_shininess(float _s)
set shininess
const Vec4f & baseColor() const
get the base color ( Same as emission() )
virtual ~MaterialNode()
Destructor.
const Vec4f & diffuse_color() const
get the diffuse color.
bool isRefractive() const
get refractive flag
void enableBackfaceCulling()
enable backface culling (not active by default, see applyProperties)
const Vec4f & specularColor() const
get the specular color
void disable_alpha_test()
disable 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 ...
ApplyProperties
Apply which properties? Others will be ignored. Values may be OR'ed.
double reflectance() const
get reflectance ( not used in OpenGL Rendering)
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
bool colorMaterial()
get colorMaterial state
void lineWidth(float _sz)
set line width (default: 1.0)
void enableColorMaterial()
Enable Color Material.
float lineWidth() const
get line width
ACG::SceneGraph::Material material_
Local material class that actually stores the properties.
ACG::SceneGraph::Material materialBackup_
Material Backup.
PickTarget
What target to use for picking.
void disable_multisampling()
enable alpha test (draw pixels if alpha >= _clip)
void ambientColor(const Vec4f &_a)
set the ambient color.
bool roundPoints() const
get: round points enabled
float line_width() const
get line width
bool alpha_test()
Return state of Alpha test.
void diffuseColor(const Vec4f &_d)
set the diffuse color.
bool lineSmooth() const
get: rsmooth lines enabled
void set_emission(const Vec4f &_c)
set emission ( same as set_base_color(const Vec4f& _c) )
const Vec4f & overlay_color() const
get the overlay color
void disable_backface_culling()
disable backface culling (not active by default, see applyProperties)
bool multiSampling()
Get state of multisampling.
float pointSize() const
get point size
void disable_color_material()
Disable Color Material.
void disableBackfaceCulling()
disable backface culling (not active by default, see applyProperties)
void reflectance(double _m)
set reflectance ( not used in OpenGL Rendering)
float point_size() const
get point size
bool line_smooth() const
get: rsmooth lines enabled
const Vec4f & base_color() const
get the base color ( same as emission() )
unsigned int applyProperties() const
get properties that will be applied (OR'ed ApplyProperties)
double indexOfRefraction() const
get index of refraction ( not used in OpenGL Rendering)
void disableColorMaterial()
Disable Color Material.
void set_reflectance(double _m)
set reflectance
void set_round_points(bool _b)
set round points enabled
void applyProperties(unsigned int _applyProperties)
set properties that will be applied (OR'ed ApplyProperties)
void emissionColor(const Vec4f &_c)
set emission ( Same as baseColor( const Vec4f& _c )) )
void enable_backface_culling()
enable backface culling (not active by default, see applyProperties)
bool isRefractive() const
get refractive flag
bool round_points() const
get round points enabled
const Vec4f & ambientColor() const
get the ambient color.
const Vec4f & emissionColor() const
get emission ( Same as baseColor() )
void set_indexOfRefraction(double _m)
set index of refraction
bool colorMaterial()
get colorMaterial state
void specularColor(const Vec4f &_s)
set the specular color
void set_base_color(const Vec4f &_c)
set the base color ( Same as set_emission(const Vec4f& _c) )
bool alphaTest() const
Return state of Alpha test.
int applyProperties_
OR'ed ApplyProperties.
ACG::SceneGraph::MaterialNode MaterialNode
Materialnode.
void roundPoints(bool _b)
set: round points enabled
void setRefractive(bool _r)
set refractive flag
void enable_alpha_test(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
const Vec4f & diffuseColor() const
get the diffuse color.
void set_line_smooth(bool _b)
set: smooth lines enabled
double reflectance() const
get reflectance
void color(const Vec4f &_c)
Set color based on _c.
Clear all attribute bits.
void enableMultisampling()
Enable Multisampling.
apply material (ambient, diffuse, specular, shininess)
const Vec4f & emission() const
get emission ( same as base_color() )
void colorMaterial(const bool _cm)
Set colorMaterial.
void set_point_size(float _sz)
set point size (default: 1.0)
ACG::SceneGraph::Material & material()
Get material object reference.
void shininess(float _s)
set shininess
void indexOfRefraction(double _m)
set index of refraction
void set_color(const Vec4f &_c)
set color (base, ambient, diffuse, specular) based on _c
void colorMaterial(const bool _cm)
Set colorMaterial.