Easy3D 2.5.3
TrianglesDrawable Class Reference

The drawable for rendering a set of triangles, e.g., the surface of a triangular mesh. More...

#include <easy3d/renderer/drawable_triangles.h>

Inheritance diagram for TrianglesDrawable:
Drawable State

Public Member Functions

 TrianglesDrawable (const std::string &name="", Model *model=nullptr)
 
Type type () const override
 Returns the type of the drawable. More...
 
bool smooth_shading () const
 
void set_smooth_shading (bool b)
 
float opacity () const
 Query the opacity of the drawable, in the range [0.0, 1.0]. More...
 
void set_opacity (float opacity)
 Set the opacity of the drawable. More...
 
void draw (const Camera *camera) const override
 The draw method. More...
 
- Public Member Functions inherited from Drawable
 Drawable (const std::string &name="unknown", Model *model=nullptr)
 
virtual Type type () const =0
 Returns the type of the drawable. More...
 
const std::string & name () const
 
void set_name (const std::string &n)
 
Modelmodel ()
 the model to which the drawable is attached to (can be NULL).
 
const Modelmodel () const
 
void set_model (Model *m)
 
const Box3bounding_box () const
 
Statestate ()
 
const Statestate () const
 
void set_state (const State &s)
 
void buffer_stats (std::ostream &output) const
 print statistics (e.g., num vertices, memory usage) of the buffers to an output stream (e.g., std::cout).
 
std::size_t num_vertices () const
 
VertexArrayObjectvao ()
 Returns the vertex array object of this drawable.
 
const VertexArrayObjectvao () const
 Returns the vertex array object of this drawable.
 
unsigned int vertex_buffer () const
 
unsigned int color_buffer () const
 
unsigned int normal_buffer () const
 
unsigned int texcoord_buffer () const
 
unsigned int element_buffer () const
 
void update_vertex_buffer (const std::vector< vec3 > &vertices, bool dynamic=false)
 Creates/Updates a single buffer. More...
 
void update_color_buffer (const std::vector< vec3 > &colors, bool dynamic=false)
 
void update_normal_buffer (const std::vector< vec3 > &normals, bool dynamic=false)
 
void update_texcoord_buffer (const std::vector< vec2 > &texcoords, bool dynamic=false)
 
void update_element_buffer (const std::vector< unsigned int > &elements)
 
void update_element_buffer (const std::vector< std::vector< unsigned int > > &elements)
 Updates the element buffer. More...
 
void disable_element_buffer ()
 Disables the use of the element buffer. More...
 
void gl_draw () const
 
void update ()
 Requests an update of the OpenGL buffers. More...
 
void set_update_func (const std::function< void(Model *, Drawable *)> &func)
 Setups how a drawable updates its rendering buffers. More...
 
Manipulatormanipulator ()
 Gets the manipulator attached to this drawable. More...
 
const Manipulatormanipulator () const
 Gets the manipulator attached to this drawable. More...
 
void set_manipulator (Manipulator *manip)
 Attaches a manipulator to this model. More...
 
mat4 manipulated_matrix () const
 Returns the manipulation matrix.
 
- Public Member Functions inherited from State
 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)
 
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
 

Additional Inherited Members

- Public Types inherited from Drawable
enum  Type { DT_POINTS = 0x0000 , DT_LINES = 0x0001 , DT_TRIANGLES = 0x0004 }
 
- Public Types inherited from State
enum  Method { UNIFORM_COLOR , COLOR_PROPERTY , SCALAR_FIELD , TEXTURED }
 
enum  Location { VERTEX , FACE , EDGE , HALFEDGE }
 

Detailed Description

The drawable for rendering a set of triangles, e.g., the surface of a triangular mesh.

See also
LinesDrawable, PointsDrawable
Note
TrianglesDrawable supports triangles only. Visualizing general polygons typically requires tessellating the faces into a set of triangles (using Tessellator or any other methods). Vertex coordinates and properties (e.g., color, normal) must be provided as consecutive triplets in an array to be transferred to GPU. See Drawable::update_vertex_buffer().
Examples
Tutorial_204_Viewer_Qt, Tutorial_301_Drawables, Tutorial_311_Animation, Tutorial_501_AmbientOcclusion, and Tutorial_504_Transparency.

Member Function Documentation

◆ draw()

void draw ( const Camera camera) const
overridevirtual

The draw method.

Implements Drawable.

◆ opacity()

float opacity ( ) const
inline

Query the opacity of the drawable, in the range [0.0, 1.0].

Returns
The opacity of the drawable.

◆ set_opacity()

void set_opacity ( float  opacity)
inline

Set the opacity of the drawable.

Parameters
opacityThe new opacity value, in the range [0.0, 1.0].

◆ type()

Drawable::Type type ( ) const
overridevirtual

Returns the type of the drawable.

Implements Drawable.


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