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) {};
113 baseColor_(_m.baseColor_),
114 ambientColor_(_m.ambientColor_),
115 diffuseColor_(_m.diffuseColor_),
116 specularColor_(_m.specularColor_),
117 overlayColor_(_m.overlayColor_),
118 shininess_(_m.shininess_),
119 reflectance_(_m.reflectance_),
120 indexOfRefraction_(_m.indexOfRefraction_),
121 isRefractive_(_m.isRefractive_),
122 pointSize_(_m.pointSize_),
123 lineWidth_(_m.lineWidth_),
124 roundPoints_(_m.roundPoints_),
125 linesSmooth_(_m.linesSmooth_),
126 alphaTest_(_m.alphaTest_),
127 alphaClip_(_m.alphaClip_),
128 blending_(_m.blending_),
129 blendParam1_(_m.blendParam1_),
130 blendParam2_(_m.blendParam2_),
131 colorMaterial_(_m.colorMaterial_),
132 backfaceCulling_(_m.backfaceCulling_),
133 multiSampling_(_m.multiSampling_) {};
135 static bool support_json_serialization();
136 QString serializeToJson()
const;
137 void deserializeFromJson(
const QString &json);
138 void deserializeFromVariantMap(
const QVariantMap &matMap);
148 Vec4f c(0.0,0.0,0.0,1.0);
151 c = _c * 0.2f; c[3]=_c[3]; ambientColor(c);
152 c = _c * 0.6f; c[3]=_c[3]; diffuseColor(c);
153 c = _c * 0.8f; c[3]=_c[3]; specularColor(c);
158 color(
Vec4f(0.2 +
double(rand())/
double(RAND_MAX)*0.8,
159 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
160 0.2 +
double(rand())/
double(RAND_MAX)*0.8,
245 alphaTest_ =
true; alphaClip_ = _clip;
256 multiSampling_ =
true;
261 multiSampling_ =
false;
266 return multiSampling_;
271 multiSampling_ = _state;
277 bool blending()
const {
return blending_; };
279 GLenum blendingParam1()
const {
return blendParam1_; };
280 GLenum blendingParam2()
const {
return blendParam2_; };
284 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA)
285 { blending_ =
true; blendParam1_ = _p1; blendParam2_ = _p2; }
289 bool backfaceCulling()
const {
return backfaceCulling_; };
296 bool isEmissive()
const {
return (baseColor_[0] > 0.f || baseColor_[1] > 0.f || baseColor_[2] > 0.f); }
303 Vec4f specularColor_;
308 double indexOfRefraction_;
324 bool backfaceCulling_;
375 const std::string& _name =
"<MaterialNode>",
376 unsigned int _applyProperties = (All & ~BackFaceCulling));
382 void read( std::istream & _is);
417 material_.generateRandomColor();
462 float shininess()
const {
return material_.shininess(); }
542 float alpha_value(){
return material_.alphaValue(); };
545 bool blending() {
return material_.blending(); };
547 GLenum blending_param1() {
return material_.blendingParam1(); };
548 GLenum blending_param2() {
return material_.blendingParam2(); };
552 GLenum _p2 = GL_ONE_MINUS_SRC_ALPHA) {
553 material_.enableBlending(_p1, _p2);
558 bool backface_culling() {
return material_.backfaceCulling(); };
571 applyProperties_ = _applyProperties;
597 #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) )
Material(const Material &_m)
Copy constructor.
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.
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.