Easy3D 2.5.3
clipping_plane.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_CLIPPING_PLANE_H
28#define EASY3D_RENDERER_CLIPPING_PLANE_H
29
30#include <easy3d/core/types.h>
31
32namespace easy3d {
33
34 class Camera;
35 class ShaderProgram;
36 class Manipulator;
37
45 public:
47 virtual ~ClippingPlane();
48
51 static ClippingPlane* instance();
52
54 bool is_enabled() const { return enabled_; }
56 void set_enabled(bool b) { enabled_ = b; }
57
59 void fit_scene(const vec3 &center, float radius);
60
62 vec3 center() const;
64 vec3 normal() const;
65
67 Plane3 plane0() const;
69 Plane3 plane1() const;
70
72 bool is_visible() const { return visible_; }
74 void set_visible(bool v) { visible_ = v; }
75
77 const vec4& color() const { return color_; }
79 void set_color(const vec4& c) { color_ = c; }
80
82 bool cross_section() const { return cross_section_; }
84 void set_cross_section(bool b) { cross_section_ = b; }
85
88 float cross_section_width() const { return cross_section_width_; }
90 void set_cross_section_width(float w) { cross_section_width_ = w; }
91
94 void set_program(ShaderProgram *program) const;
100 void set_discard_primitives(ShaderProgram *program, bool plane_clipping_discard) const;
101
103 void draw(Camera* cam) const;
104
106 virtual Manipulator *manipulator() { return manipulator_; }
108 virtual const Manipulator *manipulator() const { return manipulator_; }
109
110 protected:
111 Manipulator *manipulator_;
112 bool enabled_;
113 bool visible_;
114 vec4 color_;
115 bool cross_section_;
116 float cross_section_width_;
117 float scene_radius_;
118 };
119
120}
121
122#endif // EASY3D_RENDERER_CLIPPING_PLANE_H
A perspective or orthographic camera.
Definition: camera.h:116
An implementation of a manipulable clipping plane for visualization of model interiors and cross sect...
Definition: clipping_plane.h:44
void set_discard_primitives(ShaderProgram *program, bool plane_clipping_discard) const
Definition: clipping_plane.cpp:126
void set_cross_section(bool b)
enables/disables cross section.
Definition: clipping_plane.h:84
static ClippingPlane * instance()
Definition: clipping_plane.cpp:61
vec3 center() const
the center of the clipping plane.
Definition: clipping_plane.cpp:84
virtual const Manipulator * manipulator() const
returns the manipulator attached to the clipping plane.
Definition: clipping_plane.h:108
bool is_visible() const
returns whether the clipping plane is visible.
Definition: clipping_plane.h:72
const vec4 & color() const
returns the color of the clipping plane.
Definition: clipping_plane.h:77
vec3 normal() const
the normal direction of the clipping plane.
Definition: clipping_plane.cpp:89
void set_cross_section_width(float w)
sets the thickness of the cross section.
Definition: clipping_plane.h:90
bool is_enabled() const
returns whether the clipping plane has been enabled.
Definition: clipping_plane.h:54
virtual Manipulator * manipulator()
returns the manipulator attached to the clipping plane.
Definition: clipping_plane.h:106
float cross_section_width() const
Definition: clipping_plane.h:88
Plane3 plane0() const
the clipping plane
Definition: clipping_plane.cpp:73
void draw(Camera *cam) const
draws the clipping plane itself.
Definition: clipping_plane.cpp:132
bool cross_section() const
returns whether cross section is enabled.
Definition: clipping_plane.h:82
void set_program(ShaderProgram *program) const
Definition: clipping_plane.cpp:95
void set_visible(bool v)
shows/hides the clipping plane.
Definition: clipping_plane.h:74
Plane3 plane1() const
the other clipping plane. plane0() and plane1() together define a cross section.
Definition: clipping_plane.cpp:78
void set_color(const vec4 &c)
sets the color of the clipping plane.
Definition: clipping_plane.h:79
void set_enabled(bool b)
enables/disables the clipping plane.
Definition: clipping_plane.h:56
void fit_scene(const vec3 &center, float radius)
puts the clipping plane at the center of the scene.
Definition: clipping_plane.cpp:67
A manipulator is for manipulation of an object.
Definition: manipulator.h:62
OpenGL Shader Compilation.
Definition: shader_program.h:78
Definition: collider.cpp:182