Easy3D 2.6.1
Loading...
Searching...
No Matches
drawable_triangles.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_RENDERER_DRAWABLE_TRIANGLES_H
28#define EASY3D_RENDERER_DRAWABLE_TRIANGLES_H
29
30#include <easy3d/renderer/drawable.h>
31
32
33namespace easy3d {
34
35
46 class TrianglesDrawable : public Drawable {
47 public:
53 explicit TrianglesDrawable(const std::string& name = "", Model* model = nullptr);
54
59 Type type() const override { return DT_TRIANGLES; }
60
65 bool smooth_shading() const { return smooth_shading_; }
70 void set_smooth_shading(bool b) { smooth_shading_ = b; }
71
79 float opacity() const { return opacity_; }
86 void set_opacity(float opacity) { opacity_ = opacity; }
87
92 void draw(const Camera* camera) const override;
93
94 private:
95 bool smooth_shading_;
96 float opacity_;
97 };
98
99}
100
101
102#endif // EASY3D_RENDERER_DRAWABLE_TRIANGLES_H
A perspective or orthographic camera.
Definition camera.h:113
Type
The type of the drawable.
Definition drawable.h:63
@ DT_TRIANGLES
Triangles drawable (GL_TRIANGLES).
Definition drawable.h:66
const std::string & name() const
Returns the name of the drawable.
Definition drawable.h:92
Model * model()
Returns the model to which the drawable is attached.
Definition drawable.h:103
Drawable(const std::string &name="unknown", Model *model=nullptr)
Constructor that initializes the drawable with a name and an optional model.
Definition drawable.cpp:46
The base class of renderable 3D models.
Definition model.h:50
bool smooth_shading() const
Returns the type of the drawable.
Definition drawable_triangles.h:65
void set_smooth_shading(bool b)
Sets whether smooth shading is enabled.
Definition drawable_triangles.h:70
float opacity() const
Query the opacity of the drawable, in the range [0.0, 1.0], with 0.0 being fully transparent and 1....
Definition drawable_triangles.h:79
void draw(const Camera *camera) const override
Draws the drawable.
Definition drawable_triangles.cpp:53
Type type() const override
Returns the type of the drawable.
Definition drawable_triangles.h:59
TrianglesDrawable(const std::string &name="", Model *model=nullptr)
Constructor that initializes the drawable with a name and an optional model.
Definition drawable_triangles.cpp:41
void set_opacity(float opacity)
Set the opacity of the drawable.
Definition drawable_triangles.h:86
Definition collider.cpp:182