27#ifndef EASY3D_RENDERER_STATE_H
28#define EASY3D_RENDERER_STATE_H
32#include <easy3d/core/types.h>
65 UNIFORM_COLOR, COLOR_PROPERTY, SCALAR_FIELD, TEXTURED
73 VERTEX, FACE, EDGE, HALFEDGE
95 virtual ~State() =
default;
97 bool is_visible()
const {
return visible_; }
98 void set_visible(
bool v) { visible_ = v; }
100 bool is_selected()
const {
return selected_; }
101 void set_selected(
bool b) { selected_ = b; }
127 const Texture *
texture =
nullptr,
float repeat = 1.0f,
128 float repeat_fraction = 0.0f);
167 void set_color(
const vec4& c) { color_ = c; }
203 void set_texture(
Texture *tex) { texture_ = tex; }
207 void set_texture_repeat(
float r) { texture_repeat_ = r; };
211 void set_texture_fractional_repeat(
float fr) { texture_fractional_repeat_ = fr; };
214 bool is_ssao_enabled()
const {
return ssao_enabled_; }
215 void enable_ssao(
bool b) { ssao_enabled_ = b; }
216 void set_ssao_texture(
unsigned int tex) { ssao_texture_ = tex; }
220 void set_clamp_range(
bool b) { clamp_range_ = b; }
224 void set_clamp_lower(
float v) { clamp_lower_ = v; }
228 void set_clamp_upper(
float v) { clamp_upper_ = v; }
230 Material &material() {
return material_; }
231 const Material &material()
const {
return material_; }
232 void set_material(
const Material &m) { material_ = m; }
243 void set_plane_clip_discard_primitive(
bool b) { plane_clip_discard_primitive_ = b; };
256 void set_highlight(
bool b) { highlight_ = b; }
257 void set_highlight_range(
const std::pair<int, int> &range) { highlight_range_ = range; }
258 const std::pair<int, int> &highlight_range()
const {
return highlight_range_; }
267 std::string property_name_;
271 bool lighting_two_sides_;
272 bool distinct_back_color_;
276 const Texture *texture_;
278 float texture_repeat_;
280 float texture_fractional_repeat_;
283 unsigned int ssao_texture_;
294 bool plane_clip_discard_primitive_;
298 std::pair<int, int> highlight_range_;
Class representing the rendering state of a drawable.
Definition: state.h:45
void set_lighting(bool l)
enables/disables lighting.
Definition: state.h:178
Location property_location() const
Definition: state.h:170
Method
Definition: state.h:64
void set_scalar_coloring(Location scalar_location, const std::string &scalar_name, const Texture *texture=nullptr, float clamp_lower=0.05f, float clamp_upper=0.05f)
Definition: state.cpp:115
Method coloring_method() const
Definition: state.h:160
float clamp_lower() const
Definition: state.h:223
State & operator=(const State &rhs)
assign rhs to *this. performs a deep copy of all member variables.
Definition: state.cpp:64
const vec4 & color() const
Definition: state.h:166
float clamp_upper() const
Definition: state.h:227
bool distinct_back_color() const
Definition: state.h:187
void set_uniform_coloring(const vec4 &color)
Definition: state.cpp:89
float texture_repeat() const
Definition: state.h:206
bool highlight() const
Definition: state.h:255
void set_texture_coloring(Location texcoord_location, const std::string &texcoord_name, const Texture *texture=nullptr, float repeat=1.0f, float repeat_fraction=0.0f)
Definition: state.cpp:104
float texture_fractional_repeat() const
Definition: state.h:210
const vec4 & back_color() const
Definition: state.h:195
void set_back_color(const vec4 &c)
Definition: state.h:199
const std::string & property_name() const
Definition: state.h:173
void set_coloring(Method method, Location location, const std::string &name)
Definition: state.cpp:128
bool lighting() const
returns whether lighting is enabled.
Definition: state.h:176
bool plane_clip_discard_primitive() const
Controls the behavior for vertex clipping.
Definition: state.h:242
void set_property_coloring(Location color_location, const std::string &color_name="")
Definition: state.cpp:97
const Texture * texture() const
Definition: state.h:202
bool lighting_two_sides() const
returns whether double-sided lighting is enabled.
Definition: state.h:181
bool clamp_range() const
Definition: state.h:219
void set_distinct_back_color(bool b)
Definition: state.h:190
void set_coloring_method(Method method)
Definition: state.h:157
Location
Definition: state.h:72
void set_lighting_two_sides(bool b)
enables/disables double-sided lighting.
Definition: state.h:183
OpenGL texture.
Definition: texture.h:44
Definition: collider.cpp:182
Vec< 4, float > vec4
A 4D point/vector of float type.
Definition: types.h:47