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);
75 namespace SceneGraph {
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
ApplyProperties
Apply which properties? Others will be ignored. Values may be OR'ed.
void disableBlending()
disable blending
const Vec4f & diffuse_color() const
get the diffuse color.
bool round_points() const
get round points enabled
bool alphaTest() const
Return state of Alpha test.
Namespace providing different geometric functions concerning angles.
void enable_backface_culling()
enable backface culling (not active by default, see applyProperties)
void disable_blending()
disable blending
void specularColor(const Vec4f &_s)
set the specular color
PickTarget
What target to use for picking.
unsigned int applyProperties() const
get properties that will be applied (OR'ed ApplyProperties)
const Vec4f & overlayColor() const
get the overlay color (This can be used to render overlays e.g. additional wireframes in a different ...
bool multiSampling()
Get state of multisampling.
void enableBackfaceCulling()
enable backface culling (not active by default, see applyProperties)
void set_random_color()
Generates a random color and sets it.
float point_size() const
get point size
bool roundPoints() const
get: round points enabled
const Vec4f & base_color() const
get the base color
void set_overlay_color(const Vec4f &_s)
set the overlay color
bool colorMaterial()
get colorMaterial state
VectorT< float, 4 > Vec4f
void disable_alpha_test()
disable alpha test
const Vec4f & specularColor() const
get the specular color
void enable_multisampling()
Enable Multisampling.
const Vec4f & ambientColor() const
get the ambient color.
virtual ~MaterialNode()
Destructor.
void enableAlphaTest(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
void set_base_color(const Vec4f &_c)
set the base color
void diffuseColor(const Vec4f &_d)
set the diffuse color.
Material(const Material &_m)
Copy constructor.
void reflectance(double _m)
set reflectance ( not used in OpenGL Rendering)
void generateRandomColor()
Creates a randomized color and sets it.
void set_color(const Vec4f &_c)
set color (base, ambient, diffuse, specular) based on _c
void roundPoints(bool _b)
set: round points enabled
double reflectance() const
get reflectance ( not used in OpenGL Rendering)
void set_material(const ACG::SceneGraph::Material &_m)
Set material object.
void set_point_size(float _sz)
set point size (default: 1.0)
ACG::SceneGraph::Material & material()
Get material object reference.
void overlayColor(const Vec4f &_s)
set the overlay color (This can be used to render overlays e.g. additional wireframes in a different ...
float pointSize() const
get point size
void lineWidth(float _sz)
set line width (default: 1.0)
float shininess() const
get shininess
void applyProperties(unsigned int _applyProperties)
set properties that will be applied (OR'ed ApplyProperties)
bool colorMaterial()
get colorMaterial state
const Vec4f & diffuseColor() const
get the diffuse color.
void lineSmooth(bool _b)
set: smooth lines enabled
void set_line_width(float _sz)
set line width (default: 1.0)
void ambientColor(const Vec4f &_a)
set the ambient color.
void enable_color_material()
Enable Color Material.
void enableBlending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
void set_specular_color(const Vec4f &_s)
set the specular color
void set_reflectance(double _m)
set reflectance
void set_round_points(bool _b)
set round points enabled
bool line_smooth() const
get: rsmooth lines enabled
bool multiSampling() const
Get state of multisampling.
float shininess() const
get shininess
const Vec4f & specular_color() const
get the specular color
void baseColor(const Vec4f &_c)
set the base color
void multisampling(bool _state)
Set state of multisampling.
float lineWidth() const
get line width
void set_multisampling(bool _state)
Set state of multisampling.
const Vec4f & overlay_color() const
get the overlay color
Material()
Default constructor.
double reflectance() const
get reflectance
bool alpha_test()
Return state of Alpha test.
ACG::SceneGraph::Material material_
Local material class that actually stores the properties.
bool lineSmooth() const
get: rsmooth lines enabled
void enable_alpha_test(float _clip)
enable alpha test (draw pixels if alpha >= _clip)
void disableColorMaterial()
Disable Color Material.
void disableBackfaceCulling()
disable backface culling (not active by default, see applyProperties)
void disable_color_material()
Disable Color Material.
void set_line_smooth(bool _b)
set: smooth lines enabled
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
void enableColorMaterial()
Enable Color Material.
void colorMaterial(const bool _cm)
Set colorMaterial.
void color(const Vec4f &_c)
Set color based on _c.
void disableMultisampling()
enable alpha test (draw pixels if alpha >= _clip)
void disable_multisampling()
enable alpha test (draw pixels if alpha >= _clip)
void colorMaterial(const bool _cm)
Set colorMaterial.
Clear all attribute bits.
float line_width() const
get line width
virtual ~Material()
Deconstructor.
ACG::SceneGraph::MaterialNode MaterialNode
Materialnode.
void disableAlphaTest()
disable alpha test
void shininess(float _s)
set shininess
void enableMultisampling()
Enable Multisampling.
void set_shininess(float _s)
set shininess
const Vec4f & baseColor() const
get the base color
int applyProperties_
OR'ed ApplyProperties.
void enable_blending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
void pointSize(float _sz)
set point size (default: 1.0)
ACG::SceneGraph::Material materialBackup_
Material Backup.
void set_ambient_color(const Vec4f &_a)
set the ambient color.
float alphaValue() const
get current alpha value for alpha_test
void disable_backface_culling()
disable backface culling (not active by default, see applyProperties)
const Vec4f & ambient_color() const
get the ambient color.