Easy3D 2.5.3
State Class Reference

Class representing the rendering state of a drawable. More...

#include <easy3d/renderer/state.h>

Inheritance diagram for State:
Drawable LinesDrawable PointsDrawable TrianglesDrawable

Classes

struct  Material
 

Public Types

enum  Method { UNIFORM_COLOR , COLOR_PROPERTY , SCALAR_FIELD , TEXTURED }
 
enum  Location { VERTEX , FACE , EDGE , HALFEDGE }
 

Public Member Functions

 State (const State &s)
 
Stateoperator= (const State &rhs)
 assign rhs to *this. performs a deep copy of all member variables.
 
bool is_visible () const
 
void set_visible (bool v)
 
bool is_selected () const
 
void set_selected (bool b)
 

Coloring

void set_uniform_coloring (const vec4 &color)
 
void set_property_coloring (Location color_location, const std::string &color_name="")
 
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)
 
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)
 
void set_coloring (Method method, Location location, const std::string &name)
 
void set_coloring_method (Method method)
 
Method coloring_method () const
 
const vec4color () const
 
void set_color (const vec4 &c)
 
Location property_location () const
 
const std::string & property_name () const
 
bool lighting () const
 returns whether lighting is enabled.
 
void set_lighting (bool l)
 enables/disables lighting.
 
bool lighting_two_sides () const
 returns whether double-sided lighting is enabled.
 
void set_lighting_two_sides (bool b)
 enables/disables double-sided lighting.
 
bool distinct_back_color () const
 
void set_distinct_back_color (bool b)
 
const vec4back_color () const
 
void set_back_color (const vec4 &c)
 
const Texturetexture () const
 
void set_texture (Texture *tex)
 
float texture_repeat () const
 
void set_texture_repeat (float r)
 
float texture_fractional_repeat () const
 
void set_texture_fractional_repeat (float fr)
 
bool is_ssao_enabled () const
 
void enable_ssao (bool b)
 
void set_ssao_texture (unsigned int tex)
 
bool clamp_range () const
 
void set_clamp_range (bool b)
 
float clamp_lower () const
 
void set_clamp_lower (float v)
 
float clamp_upper () const
 
void set_clamp_upper (float v)
 
Materialmaterial ()
 
const Materialmaterial () const
 
void set_material (const Material &m)
 
bool plane_clip_discard_primitive () const
 Controls the behavior for vertex clipping. More...
 
void set_plane_clip_discard_primitive (bool b)
 
bool highlight () const
 
void set_highlight (bool b)
 
void set_highlight_range (const std::pair< int, int > &range)
 
const std::pair< int, int > & highlight_range () const
 

Detailed Description

Class representing the rendering state of a drawable.

Member Enumeration Documentation

◆ Location

enum Location

The location of a coloring property. It is denoted by the type of the geometric primitives on which the property is defined.

◆ Method

enum Method

A complete description of a color scheme contains the coloring method, and (if not uniform color) the location and name of a property. Available coloring methods:

  • UNIFORM_COLOR: uniformly colored;
  • COLOR_PROPERTY: using a color property;
  • SCALAR_FIELD: using a scalar field;
  • TEXTURED: using texture(s). Possible properties for coloring a drawable:
  • color properties defined on vertices, faces, or edges. A color property is specified by its name, e.g., "v:color", "f:color", "e:color";
  • scalar fields defined on vertices, faces, or edges. A scalar field is specified by its name, e.g., "v:curvature", "v:height", "f:segment_id";
  • texture coordinates defined on vertices or halfedges. A texture coordinates property is specified by its name, e.g., "v:texcoord", "h:texcoord".

Member Function Documentation

◆ back_color()

const vec4 & back_color ( ) const
inline

returns the backside color.

Note
effective only when two-sides lighting and distinct back color are enabled.
See also
lighting_two_sides(), distinct_back_color()

◆ clamp_lower()

float clamp_lower ( ) const
inline

Clamp the lower side of the value range of a scalar field. Value is in [0, 1] (i.e., 0% to 100%).

◆ clamp_range()

bool clamp_range ( ) const
inline

Clamp the value range of a scalar field.

◆ clamp_upper()

float clamp_upper ( ) const
inline

Clamp the upper side of the value range of a scalar field. Value is in [0, 1] (i.e., 0% to 100%).

◆ color()

const vec4 & color ( ) const
inline

The color, which is effective only when the coloring method was set to UNIFORM_COLOR. Call set_uniform_coloring() to change this color.

◆ coloring_method()

Method coloring_method ( ) const
inline

Returns the coloring method being used for rendering.

◆ distinct_back_color()

bool distinct_back_color ( ) const
inline

returns whether a different color is used for rendering the backside of a drawable.

Note
effective only when two-sides lighting is enabled

◆ highlight()

bool highlight ( ) const
inline

Highlight a subset of primitives of this drawable. Primitives with indices within the range [highlight_id_low_, highlight_id_high_] will be highlighted.

Parameters
rangeSpecifies the min and max indices of the primitives to be highlighted. Providing [-1, -1] will un-highlight any previously highlighted primitives.
Attention
For non-triangular surface meshes, all polygonal faces are internally triangulated to allow a unified rendering APIs. The range must be given on the triangulated faces! If you have face range, you should convert the face range to triangle range. For each face, its triangles are defined on SurfaceMesh::face_property<std::pair<int, int> >("f:triangle_range").

◆ plane_clip_discard_primitive()

bool plane_clip_discard_primitive ( ) const
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.

◆ property_location()

Location property_location ( ) const
inline

The location of the color property.

◆ property_name()

const std::string & property_name ( ) const
inline

The name of the color attribute.

◆ set_back_color()

void set_back_color ( const vec4 c)
inline

sets the backside color.

Note
effective only when two-sides lighting and distinct back color are enabled.
See also
set_lighting_two_sides(), set_distinct_back_color()

◆ set_coloring()

void set_coloring ( Method  method,
Location  location,
const std::string &  name 
)

Sets the coloring. A generic version of the set_[method]_coloring() method.

Parameters
methodThe coloring method.
locationThe the location of the coloring property.
nameThe name of the coloring property.
textureThe texture for the coloring.

◆ set_coloring_method()

void set_coloring_method ( Method  method)
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.

See also
set_coloring()
Parameters
methodThe coloring method.

◆ set_distinct_back_color()

void set_distinct_back_color ( bool  b)
inline

enables/disables different backside color.

Note
effective only when two-sides lighting is enabled

◆ set_property_coloring()

void set_property_coloring ( Location  color_location,
const std::string &  color_name = "" 
)

Constructs a scheme for rendering a drawable with per-element color.

Parameters
color_locationThe location of the color property.
color_nameThe name of the color property.
Examples
Tutorial_203_Viewer_wxWidgets, Tutorial_204_Viewer_Qt, and Tutorial_310_TextMesher.

◆ set_scalar_coloring()

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.

Parameters
scalar_locationThe location of the scalar field.
scalar_nameThe name of the scalar field.
textureThe pointer to the texture.
clamp_lowerThe percentage of values to be clamped at the lower side of the range. Default is 5%.
clamp_upperThe percentage of values to be clamped at the upper side of the range. Default is 5%.
Examples
Tutorial_303_ScalarField.

◆ set_texture_coloring()

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.

Parameters
texcoord_locationThe location of texture coordinate.
texcoord_nameThe name of the texture coordinate property.
textureThe pointer to the texture.
repeatThe repeat factor of the texture. Default value is 1.0.
repeat_fractionThe fractional repeat factor of the texture. Default value is 0.0.

◆ set_uniform_coloring()

◆ texture()

const Texture * texture ( ) const
inline

Memory management of textures is the user's responsibility.

◆ texture_fractional_repeat()

float texture_fractional_repeat ( ) const
inline

Controls the texture repeat at a finer level: 100 fractional repeat == 1 repeat.

◆ texture_repeat()

float texture_repeat ( ) const
inline

How many times do you want to repeat the texture?


The documentation for this class was generated from the following files: