Easy3D 2.6.1
|
Class representing the rendering state of a drawable. More...
#include <easy3d/renderer/state.h>
Classes | |
struct | Material |
Public Types | |
enum | Method { UNIFORM_COLOR , COLOR_PROPERTY , SCALAR_FIELD , TEXTURED } |
Available coloring methods. More... | |
enum | Location { VERTEX , FACE , EDGE , HALFEDGE } |
The location of a coloring property. More... | |
Public Member Functions | |
State () | |
Default constructor. | |
State (const State &s) | |
Copy constructor. | |
State & | operator= (const State &rhs) |
Assignment operator. | |
virtual | ~State ()=default |
Virtual destructor. | |
bool | is_visible () const |
Checks if the drawable is visible. | |
void | set_visible (bool v) |
Sets the visibility of the drawable. | |
bool | is_selected () const |
Checks if the drawable is selected. | |
void | set_selected (bool b) |
Sets the selection state of the drawable. | |
Coloring | |
void | set_uniform_coloring (const vec4 &color) |
Constructs a uniform coloring scheme. | |
void | set_property_coloring (Location color_location, const std::string &color_name="") |
Constructs a scheme for rendering a drawable with per-element color. | |
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) |
Constructs a scheme for textured rendering. | |
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) |
Constructs a scheme for rendering scalar fields. | |
void | set_coloring (Method method, Location location, const std::string &name) |
Sets the coloring. | |
void | set_coloring_method (Method method) |
Sets the coloring method. | |
Method | coloring_method () const |
Returns the coloring method being used for rendering. | |
const vec4 & | color () const |
Returns the color, which is effective only when the coloring method was set to UNIFORM_COLOR. | |
void | set_color (const vec4 &c) |
Sets the color. | |
Location | property_location () const |
Returns the location of the color property. | |
const std::string & | property_name () const |
Returns the name of the color attribute. | |
bool | lighting () const |
Checks if lighting is enabled. | |
void | set_lighting (bool l) |
Enables or disables lighting. | |
bool | lighting_two_sides () const |
Checks if double-sided lighting is enabled. | |
void | set_lighting_two_sides (bool b) |
Enables or disables double-sided lighting. | |
bool | distinct_back_color () const |
Checks if a different color is used for rendering the backside of a drawable. | |
void | set_distinct_back_color (bool b) |
Enables or disables different backside color. | |
const vec4 & | back_color () const |
Returns the backside color. | |
void | set_back_color (const vec4 &c) |
Sets the backside color. | |
const Texture * | texture () const |
Returns the texture. | |
void | set_texture (const Texture *tex) |
Sets the texture. | |
float | texture_repeat () const |
Returns the repeat factor of the texture. | |
void | set_texture_repeat (float r) |
Sets the repeat factor of the texture. | |
float | texture_fractional_repeat () const |
Returns the fractional repeat factor of the texture. | |
void | set_texture_fractional_repeat (float fr) |
Sets the fractional repeat factor of the texture. | |
bool | is_ssao_enabled () const |
Checks if SSAO is enabled. | |
void | enable_ssao (bool b) |
Enables or disables SSAO. | |
void | set_ssao_texture (unsigned int tex) |
Sets the SSAO texture. | |
bool | clamp_range () const |
Checks if the value range of a scalar field is clamped. | |
void | set_clamp_range (bool b) |
Sets the clamping of the value range of a scalar field. | |
float | clamp_lower () const |
Returns the percentage of values clamped at the lower side of the range. | |
void | set_clamp_lower (float v) |
Sets the percentage of values clamped at the lower side of the range. | |
float | clamp_upper () const |
Returns the percentage of values clamped at the upper side of the range. | |
void | set_clamp_upper (float v) |
Sets the percentage of values clamped at the upper side of the range. | |
Material & | material () |
Returns the material. | |
const Material & | material () const |
Returns the material (const version). | |
void | set_material (const Material &m) |
Sets the material. | |
bool | plane_clip_discard_primitive () const |
Controls the behavior for vertex clipping. | |
void | set_plane_clip_discard_primitive (bool b) |
Sets the behavior for vertex clipping. | |
bool | highlight () const |
Checks if a subset of primitives of this drawable is highlighted. | |
void | set_highlight (bool b) |
Sets the highlight state of a subset of primitives of this drawable. | |
void | set_highlight_range (const std::pair< int, int > &range) |
Sets the range of primitives to be highlighted. | |
const std::pair< int, int > & | highlight_range () const |
Returns the range of primitives to be highlighted. | |
Class representing the rendering state of a drawable.
enum Location |
enum Method |
Available coloring methods.
A complete description of a color scheme contains the coloring method, and (if not uniform color) the location and name of a property. Possible properties for coloring a drawable:
Enumerator | |
---|---|
UNIFORM_COLOR | Uniformly colored. |
COLOR_PROPERTY | Using a color property. |
SCALAR_FIELD | Using a scalar field. |
TEXTURED | Using texture(s) |
|
inline |
Returns the backside color.
Effective only when two-sides lighting and distinct back color are enabled.
|
inline |
Returns the percentage of values clamped at the lower side of the range.
Value is in [0, 1] (i.e., 0% to 100%).
|
inline |
Checks if the value range of a scalar field is clamped.
true
if the value range is clamped, false
otherwise.
|
inline |
Returns the percentage of values clamped at the upper side of the range.
Value is in [0, 1] (i.e., 0% to 100%).
|
inline |
Returns the color, which is effective only when the coloring method was set to UNIFORM_COLOR.
|
inline |
Returns the coloring method being used for rendering.
|
inline |
Checks if a different color is used for rendering the backside of a drawable.
Effective only when two-sides lighting is enabled.
true
if a different backside color is used, false
otherwise.
|
inline |
Enables or disables SSAO.
b | true to enable SSAO, false to disable. |
|
inline |
Checks if a subset of primitives of this drawable is highlighted.
true
if highlighted, false
otherwise.
|
inline |
Returns the range of primitives to be highlighted.
Primitives with indices within the range will be highlighted.
|
inline |
Checks if the drawable is selected.
true
if selected, false
otherwise.
|
inline |
Checks if SSAO is enabled.
true
if SSAO is enabled, false
otherwise.
|
inline |
Checks if the drawable is visible.
true
if visible, false
otherwise.
|
inline |
Checks if lighting is enabled.
true
if lighting is enabled, false
otherwise.
|
inline |
Checks if double-sided lighting is enabled.
true
if double-sided lighting is enabled, false
otherwise.
|
inline |
Returns the material.
|
inline |
Returns the material (const version).
|
inline |
Controls the behavior for vertex clipping.
If plane_clip_discard_primitive() is false
(default value, standard plane clip), the clip distances will be linearly interpolated across the primitive (e.g., line, triangle) and the portion of the primitive with interpolated distances less than 0.0 will be clipped. If plane_clip_discard_primitive() is true
, a primitive will be completely discarded if one of its vertices has a negative clip distance.
true
if the primitive is discarded, false
otherwise.
|
inline |
Returns the location of the color property.
|
inline |
Returns the name of the color attribute.
|
inline |
Sets the backside color.
Effective only when two-sides lighting and distinct back color are enabled.
c | The backside color. |
|
inline |
Sets the percentage of values clamped at the lower side of the range.
Value is in [0, 1] (i.e., 0% to 100%).
v | The percentage of values clamped at the lower side. |
|
inline |
Sets the clamping of the value range of a scalar field.
b | true to clamp the value range, false to disable clamping. |
|
inline |
Sets the percentage of values clamped at the upper side of the range.
Value is in [0, 1] (i.e., 0% to 100%).
v | The percentage of values clamped at the upper side. |
|
inline |
Sets the color.
c | The color. |
Sets the coloring.
A generic version of the set_[method]_coloring() method.
method | The coloring method. |
location | The location of the coloring property. |
name | The name of the coloring property. |
|
inline |
Sets the coloring method.
It has the same effect as if set_coloring() is called without changing the location (2nd argument) and name (3rd argument) of the coloring property.
method | The coloring method. |
|
inline |
Enables or disables different backside color.
Effective only when two-sides lighting is enabled.
b | true to enable different backside color, false to disable. |
|
inline |
Sets the highlight state of a subset of primitives of this drawable.
b | true to highlight, false to un-highlight. |
|
inline |
Sets the range of primitives to be highlighted.
Primitives with indices within the range will be highlighted.
range | Specifies the min and max indices of the primitives to be highlighted. Providing [-1, -1] will un-highlight any previously highlighted primitives. |
|
inline |
Enables or disables lighting.
l | true to enable lighting, false to disable. |
|
inline |
Enables or disables double-sided lighting.
b | true to enable double-sided lighting, false to disable. |
|
inline |
Sets the material.
m | The material. |
|
inline |
Sets the behavior for vertex clipping.
If plane_clip_discard_primitive() is false
(default value, standard plane clip), the clip distances will be linearly interpolated across the primitive (e.g., line, triangle) and the portion of the primitive with interpolated distances less than 0.0 will be clipped. If plane_clip_discard_primitive() is true
, a primitive will be completely discarded if one of its vertices has a negative clip distance.
b | true to discard the primitive, false otherwise. |
void set_property_coloring | ( | Location | color_location, |
const std::string & | color_name = "" ) |
Constructs a scheme for rendering a drawable with per-element color.
color_location | The location of the color property. |
color_name | The name of the color property. |
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 ) |
Constructs a scheme for rendering scalar fields.
scalar_location | The location of the scalar field. |
scalar_name | The name of the scalar field. |
texture | The pointer to the texture. Default is nullptr , a scalar default texture will be created from "/colormaps/default.png". Client code can provide a more suitable texture at a later stage. |
clamp_lower | The percentage of values to be clamped at the lower side of the range. Default is 5%. |
clamp_upper | The percentage of values to be clamped at the upper side of the range. Default is 5%. |
|
inline |
Sets the selection state of the drawable.
b | true to select, false to deselect. |
|
inline |
Sets the SSAO texture.
tex | The SSAO texture. |
|
inline |
Sets the texture.
tex | The texture. |
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 ) |
Constructs a scheme for textured rendering.
texcoord_location | The location of texture coordinate. |
texcoord_name | The name of the texture coordinate property. |
texture | The pointer to the texture. If nullptr , a default texture will be created from "textures/checkerboard.png". Client code is expected to provide a meaningful texture at a later stage. |
repeat | The repeat factor of the texture. Default value is 1.0. |
repeat_fraction | The fractional repeat factor of the texture. Default value is 0.0. |
|
inline |
Sets the fractional repeat factor of the texture.
Controls the texture repeat at a finer level: 100 fractional repeat == 1 repeat.
fr | The fractional repeat factor. |
|
inline |
Sets the repeat factor of the texture.
r | The repeat factor. |
void set_uniform_coloring | ( | const vec4 & | color | ) |
Constructs a uniform coloring scheme.
color | The color. |
|
inline |
Sets the visibility of the drawable.
v | true to make visible, false to hide. |
|
inline |
Returns the texture.
Memory management of textures is the user's responsibility.
|
inline |
Returns the fractional repeat factor of the texture.
Controls the texture repeat at a finer level: 100 fractional repeat == 1 repeat.
|
inline |
Returns the repeat factor of the texture.